Mercurial > hg > GearsTemplate
view src/parallel_execution/examples/boundedBuffer/main.cbc @ 532:3881b91f5820
Generate multiDimIterator_test stub
author | Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Sat, 27 Jan 2018 23:23:38 +0900 |
parents | bc1616e1e172 |
children | 62166b0e0c7e |
line wrap: on
line source
#include <stdio.h> #include <string.h> #include <stdlib.h> #include <unistd.h> #include <assert.h> #include "../../../context.h" #interface "TaskManager.h" int cpu_num = 1; int length = 100; int buffer_size = 10; int gpu_num = 0; int CPU_ANY = -1; int CPU_CUDA = -1; __code initDataGears(struct LoopCounter* loopCounter, struct TaskManager* taskManager) { // loopCounter->tree = createRedBlackTree(context); loopCounter->i = 0; taskManager->taskManager = (union Data*)createTaskManagerImpl(context, cpu_num, gpu_num, 0); goto code1(); } __code code1(struct Timer* timer) { printf("cpus:\t\t%d\n", cpu_num); printf("gpus:\t\t%d\n", gpu_num); printf("length:\t\t%d\n", length); goto createTask1(); } __code code2(struct TaskManager* taskManager) { goto taskManager->shutdown(exit_code); } __code code2_stub(struct Context* context) { goto code2(context, &Gearef(context, TaskManager)->taskManager->TaskManager); } __code createTask1(struct TaskManager* taskManager) { struct Buffer* buffer = createBoundedBuffer(context, buffer_size); Int* len = new Int(); *len = length; par goto producer(buffer, len, __exit); par goto producer(buffer, len, __exit); par goto producer(buffer, len, __exit); par goto consumer(buffer, len, __exit); par goto consumer(buffer, len, __exit); par goto consumer(buffer, len, __exit); par goto initBuffer(buffer, len, __exit); goto code2(); } void init(int argc, char** argv) { for (int i = 1; argv[i]; ++i) { if (strcmp(argv[i], "-cpu") == 0) cpu_num = (int)atoi(argv[i+1]); else if (strcmp(argv[i], "-l") == 0) length = (int)atoi(argv[i+1]); else if (strcmp(argv[i], "-bufferSize") == 0) buffer_size = (int)atoi(argv[i+1]); else if (strcmp(argv[i], "-cuda") == 0) { gpu_num = 1; CPU_CUDA = 0; } } } int main(int argc, char** argv) { init(argc, argv); goto initDataGears(); }