Mercurial > hg > GearsTemplate
diff src/parallel_execution/MultiDimIterator.cbc @ 410:85b0ddbf458e
Fix CudaWorker
author | Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Thu, 14 Sep 2017 02:35:20 +0900 |
parents | e958a409943c |
children | 0eba9a04633f |
line wrap: on
line diff
--- a/src/parallel_execution/MultiDimIterator.cbc Wed Sep 06 22:01:27 2017 +0900 +++ b/src/parallel_execution/MultiDimIterator.cbc Thu Sep 14 02:35:20 2017 +0900 @@ -53,14 +53,16 @@ return task1; } -__code execMultiDimIterator(struct MultiDimIterator* iterator, struct TaskManager* taskManager, struct Context* task, __code next(...)) { - int x = iterator->counterX; - int y = iterator->counterY; - int z = iterator->counterZ; - struct Context* iterateTask = createMultiDimIterateTask(task, x, y, z); +__code execMultiDimIterator(struct MultiDimIterator* iterator, struct TaskManager* taskManager, struct Context* task, int numGPU, __code next(...)) { + // No GPU device + if (numGPU == 0) { + goto meta(context, C_execMultiDimIterator1); + } + task->iterate = 1; + task->gpu = 1; taskManager->taskManager = (union Data*)task->taskManager; - taskManager->context = iterateTask; - taskManager->next = C_execMultiDimIterator1; + taskManager->context = task; + taskManager->next = next; goto meta(context, task->taskManager->spawn); } @@ -68,11 +70,31 @@ MultiDimIterator* iterator = (MultiDimIterator*)GearImpl(context, Iterator, iterator); TaskManager* taskManager = Gearef(context, TaskManager); Context* task = Gearef(context, Iterator)->task; + int numGPU = Gearef(context, Iterator)->numGPU; enum Code next = Gearef(context, Iterator)->next; - goto execMultiDimIterator(context, iterator, taskManager, task, next); + goto execMultiDimIterator(context, iterator, taskManager, task, numGPU, next); } -__code execMultiDimIterator1(struct MultiDimIterator* iterator, struct Context* task, __code next(...)) { +__code execMultiDimIterator1(struct MultiDimIterator* iterator, struct TaskManager* taskManager, struct Context* task, __code next(...)) { + int x = iterator->counterX; + int y = iterator->counterY; + int z = iterator->counterZ; + struct Context* iterateTask = createMultiDimIterateTask(task, x, y, z); + taskManager->taskManager = (union Data*)task->taskManager; + taskManager->context = iterateTask; + taskManager->next = C_execMultiDimIterator2; + goto meta(context, task->taskManager->spawn); +} + +__code execMultiDimIterator1_stub(struct Context* context) { + MultiDimIterator* iterator = (MultiDimIterator*)GearImpl(context, Iterator, iterator); + TaskManager* taskManager = Gearef(context, TaskManager); + Context* task = Gearef(context, Iterator)->task; + enum Code next = Gearef(context, Iterator)->next; + goto execMultiDimIterator1(context, iterator, taskManager, task, next); +} + +__code execMultiDimIterator2(struct MultiDimIterator* iterator, struct Context* task, __code next(...)) { if (++iterator->counterX >= iterator->x) { iterator->counterX = 0; if (++iterator->counterY >= iterator->y) { @@ -83,7 +105,7 @@ } } } - goto meta(context, C_execMultiDimIterator); + goto meta(context, C_execMultiDimIterator1); } __code barrierMultiDimIterator(struct MultiDimIterator* iterator, struct Context* task, __code next(...), __code whenWait(...)) {