Mercurial > hg > Members > Moririn
changeset 457:2b36a1878c6f
Refactor TaskManagerImpl
author | Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Thu, 14 Dec 2017 07:44:21 +0900 |
parents | 95f58f2b2c0e |
children | 3025d00eb87d |
files | src/parallel_execution/TaskManagerImpl.cbc src/parallel_execution/examples/bitonicSort/bitonicSort.cbc src/parallel_execution/generate_stub.pl src/parallel_execution/test/multiDimIterator_test.cbc |
diffstat | 4 files changed, 21 insertions(+), 41 deletions(-) [+] |
line wrap: on
line diff
--- a/src/parallel_execution/TaskManagerImpl.cbc Mon Dec 11 16:26:55 2017 +0900 +++ b/src/parallel_execution/TaskManagerImpl.cbc Thu Dec 14 07:44:21 2017 +0900 @@ -53,33 +53,26 @@ } } -__code spawnTasksTaskManagerImpl(struct TaskManagerImpl* taskManager, struct Queue* tasks, __code next1(...), struct Queue* queue) { - queue->queue = (union Data*)tasks; - queue->next = C_spawnTasksTaskManagerImpl1; - queue->whenEmpty = C_spawnTasksTaskManagerImpl3; - goto meta(context, tasks->isEmpty); +__code spawnTasksTaskManagerImpl(struct TaskManagerImpl* taskManager, struct Queue* tasks, __code next1(...)) { + goto tasks->isEmpty(spawnTasksTaskManagerImpl1, spawnTasksTaskManagerImpl3); } __code spawnTasksTaskManagerImpl_stub(struct Context* context) { TaskManagerImpl* taskManager = (TaskManagerImpl*)GearImpl(context, TaskManager, taskManager); Queue* tasks = Gearef(context, TaskManager)->tasks; enum Code next1 = Gearef(context, TaskManager)->next1; - Queue* queue = Gearef(context, Queue); - goto spawnTasksTaskManagerImpl(context, taskManager, tasks, next1, queue); + goto spawnTasksTaskManagerImpl(context, taskManager, tasks, next1); } -__code spawnTasksTaskManagerImpl1(struct TaskManagerImpl* taskManager, struct Queue* tasks, __code next1(...), struct Queue* queue) { - queue->queue = (union Data*)tasks; - queue->next = C_spawnTasksTaskManagerImpl2; - goto meta(context, tasks->take); +__code spawnTasksTaskManagerImpl1(struct TaskManagerImpl* taskManager, struct Queue* tasks, __code next1(...)) { + goto tasks->take(spawnTasksTaskManagerImpl2); } __code spawnTasksTaskManagerImpl1_stub(struct Context* context) { TaskManagerImpl* taskManager = (TaskManagerImpl*)GearImpl(context, TaskManager, taskManager); Queue* tasks = Gearef(context, TaskManager)->tasks; enum Code next1 = Gearef(context, TaskManager)->next1; - Queue* queue = Gearef(context, Queue); - goto spawnTasksTaskManagerImpl1(context, taskManager, tasks, next1, queue); + goto spawnTasksTaskManagerImpl1(context, taskManager, tasks, next1); } __code spawnTasksTaskManagerImpl2(struct TaskManagerImpl* taskManagerImpl, struct Context* task, struct TaskManager* taskManager) { @@ -96,17 +89,14 @@ goto spawnTasksTaskManagerImpl2(context, taskManagerImpl, task, taskManager); } -__code spawnTasksTaskManagerImpl3(struct TaskManagerImpl* taskManager, __code next1(...), struct Queue* queue) { - queue->queue = (union Data*)taskManager->taskQueue; - queue->next = C_spawnTasksTaskManagerImpl4; - queue->whenEmpty = next1; - goto meta(context, taskManager->taskQueue->isEmpty); +__code spawnTasksTaskManagerImpl3(struct TaskManagerImpl* taskManager, __code next1(...)) { + struct Queue* queue = taskManager->taskQueue; + goto queue->isEmpty(spawnTasksTaskManagerImpl4, next1(...)); } -__code spawnTasksTaskManagerImpl4(struct TaskManagerImpl* taskManager, __code next1(...), struct Queue* queue) { - queue->queue = (union Data*)taskManager->taskQueue; - queue->next = C_spawnTasksTaskManagerImpl5; - goto meta(context, taskManager->taskQueue->take); +__code spawnTasksTaskManagerImpl4(struct TaskManagerImpl* taskManager, __code next1(...)) { + struct Queue* queue = taskManager->taskQueue; + goto queue->take(spawnTasksTaskManagerImpl5); } __code spawnTasksTaskManagerImpl5(struct TaskManagerImpl* taskManagerImpl, struct Context* task, struct TaskManager* taskManager) { @@ -122,20 +112,16 @@ goto spawnTasksTaskManagerImpl5(context, taskManagerImpl, task, taskManager); } -__code setWaitTaskTaskManagerImpl(struct TaskManagerImpl* taskManager, struct Context* task, __code next(...), struct Queue* queue) { +__code setWaitTaskTaskManagerImpl(struct TaskManagerImpl* taskManager, struct Context* task, __code next(...)) { int i = taskManager->loopCounter->i; if(task->idg+i < task->maxIdg) { - queue->queue = (Data *)GET_WAIT_LIST(task->data[task->idg + i]); - queue->data = (Data *)task; - queue->next = C_setWaitTaskTaskManagerImpl; + struct Queue* queue = GET_WAIT_LIST(task->data[task->idg + i]); taskManager->loopCounter->i++; - goto meta(context, queue->queue->Queue.put); + goto queue->put(task, setWaitTaskTaskManagerImpl); } taskManager->loopCounter->i = 0; - queue->queue = (Data *)taskManager->taskQueue; - queue->data = (Data *)task; - queue->next = C_incrementTaskCountTaskManagerImpl; - goto meta(context, taskManager->taskQueue->put); + struct Queue* queue = taskManager->taskQueue; + goto queue->put(task, incrementTaskCountTaskManagerImpl); } __code setWaitTaskTaskManagerImpl_stub(struct Context* context) { @@ -144,8 +130,7 @@ goto setWaitTaskTaskManagerImpl(context, taskManager, task, - Gearef(context, TaskManager)->next, - Gearef(context, Queue)); + Gearef(context, TaskManager)->next); } __code incrementTaskCountTaskManagerImpl(struct TaskManagerImpl* taskManager, __code next(...)) {
--- a/src/parallel_execution/examples/bitonicSort/bitonicSort.cbc Mon Dec 11 16:26:55 2017 +0900 +++ b/src/parallel_execution/examples/bitonicSort/bitonicSort.cbc Thu Dec 14 07:44:21 2017 +0900 @@ -51,7 +51,7 @@ struct SortArray* inputSortArray = outputSortArray; struct Time* time = createTimeImpl(context); - par goto makeArray(outputSortArray, time, _exit); + par goto makeArray(outputSortArray, time, __exit); for (int i=2; i <= length; i=2*i) { int first = 1; @@ -60,7 +60,7 @@ inputSortArray->prefix = length/2/split; inputSortArray->block = j; inputSortArray->first = first; - par goto bitonicSwap(inputSortArray, outputSortArray, iterate(split), _exit); + par goto bitonicSwap(inputSortArray, outputSortArray, iterate(split), __exit); first = 0; inputSortArray = outputSortArray; }
--- a/src/parallel_execution/generate_stub.pl Mon Dec 11 16:26:55 2017 +0900 +++ b/src/parallel_execution/generate_stub.pl Thu Dec 14 07:44:21 2017 +0900 @@ -407,7 +407,7 @@ my $pType; my $pName; my $p = @$prot[$i]; - next if ( $p eq $arg); + next if ($p eq $arg); $p =~ s/^(.*)\s(\w+)//; $pType = $1; $pName = $2;
--- a/src/parallel_execution/test/multiDimIterator_test.cbc Mon Dec 11 16:26:55 2017 +0900 +++ b/src/parallel_execution/test/multiDimIterator_test.cbc Thu Dec 14 07:44:21 2017 +0900 @@ -11,11 +11,6 @@ int CPU_ANY = -1; int CPU_CUDA = -1; -void *start_taskManager(struct Context *context) { - goto initDataGears(context, Gearef(context, LoopCounter), Gearef(context, TaskManager)); - return 0; -} - __code initDataGears(struct LoopCounter* loopCounter, struct TaskManager* taskManager) { // loopCounter->tree = createRedBlackTree(context); loopCounter->i = 0;