# HG changeset patch # User Tatsuki IHA # Date 1513371872 -32400 # Node ID 57c715bd6283ec01b9775977059c754f76e09a41 # Parent 3025d00eb87d0bfe2cb753cc3b0a3974fce7d954 Change taskManager parameter from context to task diff -r 3025d00eb87d -r 57c715bd6283 src/parallel_execution/CPUWorker.cbc --- a/src/parallel_execution/CPUWorker.cbc Thu Dec 14 07:44:58 2017 +0900 +++ b/src/parallel_execution/CPUWorker.cbc Sat Dec 16 06:04:32 2017 +0900 @@ -116,7 +116,7 @@ __code odgCommit3(struct TaskManager* taskManager, struct Context* task) { if (__sync_fetch_and_sub(&task->idgCount, 1) == 1) { // atomic decrement idg counter(__sync_fetch_and_sub function return initial value of task->idgCount point) taskManager->taskManager = (union Data*)task->taskManager; - taskManager->context = task; + taskManager->task = task; taskManager->next = C_odgCommit1; goto meta(context, task->taskManager->spawn); } diff -r 3025d00eb87d -r 57c715bd6283 src/parallel_execution/CUDAWorker.cbc --- a/src/parallel_execution/CUDAWorker.cbc Thu Dec 14 07:44:58 2017 +0900 +++ b/src/parallel_execution/CUDAWorker.cbc Sat Dec 16 06:04:32 2017 +0900 @@ -119,7 +119,7 @@ __code odgCommitCUDA3(struct TaskManager* taskManager, struct Context* task) { if (__sync_fetch_and_sub(&task->idgCount, 1) == 1) { // atomic decrement idg counter(__sync_fetch_and_sub function return initial value of task->idgCount point) taskManager->taskManager = (union Data*)task->taskManager; - taskManager->context = task; + taskManager->task = task; taskManager->next = C_odgCommitCUDA1; goto meta(context, task->taskManager->spawn); } diff -r 3025d00eb87d -r 57c715bd6283 src/parallel_execution/MultiDimIterator.cbc --- a/src/parallel_execution/MultiDimIterator.cbc Thu Dec 14 07:44:58 2017 +0900 +++ b/src/parallel_execution/MultiDimIterator.cbc Sat Dec 16 06:04:32 2017 +0900 @@ -60,7 +60,7 @@ task->iterate = 1; task->gpu = 1; taskManager->taskManager = (union Data*)task->taskManager; - taskManager->context = task; + taskManager->task = task; taskManager->next = next; goto meta(context, task->taskManager->spawn); } @@ -80,7 +80,7 @@ int z = iterator->counterZ; struct Context* iterateTask = createMultiDimIterateTask(task, x, y, z); taskManager->taskManager = (union Data*)task->taskManager; - taskManager->context = iterateTask; + taskManager->task = iterateTask; taskManager->next = C_execMultiDimIterator2; goto meta(context, task->taskManager->spawn); } diff -r 3025d00eb87d -r 57c715bd6283 src/parallel_execution/TaskManager.cbc --- a/src/parallel_execution/TaskManager.cbc Thu Dec 14 07:44:58 2017 +0900 +++ b/src/parallel_execution/TaskManager.cbc Sat Dec 16 06:04:32 2017 +0900 @@ -1,9 +1,10 @@ typedef struct TaskManager{ union Data* taskManager; - struct Context* context; + struct Context* task; struct Context** tasks; __code spawn(Impl* taskManager, struct Queue* queue, struct Context* task, __code next(...)); __code spawnTasks(Impl* taskManagerImpl, struct Context** tasks, __code next1(...), struct TaskManager* taskManager); + __code setWaitTask(Impl* taskManagerImpl, struct Context* task, __code next(...)); __code shutdown(Impl* taskManagerImpl, __code next(...), struct TaskManager* taskManager, struct Queue* queue); __code incrementTaskCount(Impl* taskManagerImpl, __code next(...)); __code decrementTaskCount(Impl* taskManagerImpl, __code next(...)); diff -r 3025d00eb87d -r 57c715bd6283 src/parallel_execution/TaskManagerImpl.cbc --- a/src/parallel_execution/TaskManagerImpl.cbc Thu Dec 14 07:44:58 2017 +0900 +++ b/src/parallel_execution/TaskManagerImpl.cbc Sat Dec 16 06:04:32 2017 +0900 @@ -19,6 +19,7 @@ taskManager->shutdown = C_shutdownTaskManagerImpl; taskManager->incrementTaskCount = C_incrementTaskCountTaskManagerImpl; taskManager->decrementTaskCount = C_decrementTaskCountTaskManagerImpl; + taskManager->setWaitTask = C_setWaitTaskTaskManagerImpl; struct TaskManagerImpl* taskManagerImpl = new TaskManagerImpl(); taskManagerImpl->taskQueue = createSingleLinkedQueue(context); taskManagerImpl->numWorker = taskManager->maxCPU; @@ -62,7 +63,7 @@ Queue* tasks = Gearef(context, TaskManager)->tasks; enum Code next1 = Gearef(context, TaskManager)->next1; goto spawnTasksTaskManagerImpl(context, taskManager, tasks, next1); -} +} __code spawnTasksTaskManagerImpl1(struct TaskManagerImpl* taskManager, struct Queue* tasks, __code next1(...)) { goto tasks->take(spawnTasksTaskManagerImpl2); @@ -77,7 +78,7 @@ __code spawnTasksTaskManagerImpl2(struct TaskManagerImpl* taskManagerImpl, struct Context* task, struct TaskManager* taskManager) { task->taskManager = &taskManager->taskManager->TaskManager; - taskManager->context = task; + taskManager->task = task; taskManager->next = C_spawnTasksTaskManagerImpl; goto meta(context, C_setWaitTaskTaskManagerImpl); } @@ -87,7 +88,7 @@ Context* task = (struct Context*)Gearef(context, Queue)->data; TaskManager* taskManager = Gearef(context, TaskManager); goto spawnTasksTaskManagerImpl2(context, taskManagerImpl, task, taskManager); -} +} __code spawnTasksTaskManagerImpl3(struct TaskManagerImpl* taskManager, __code next1(...)) { struct Queue* queue = taskManager->taskQueue; @@ -100,7 +101,7 @@ } __code spawnTasksTaskManagerImpl5(struct TaskManagerImpl* taskManagerImpl, struct Context* task, struct TaskManager* taskManager) { - taskManager->context = task; + taskManager->task = task; taskManager->next = C_spawnTasksTaskManagerImpl3; goto meta(context, C_spawnTaskManagerImpl); } @@ -126,7 +127,7 @@ __code setWaitTaskTaskManagerImpl_stub(struct Context* context) { TaskManagerImpl* taskManager = (TaskManagerImpl*)GearImpl(context, TaskManager, taskManager); - struct Context* task = Gearef(context, TaskManager)->context; + struct Context* task = Gearef(context, TaskManager)->task; goto setWaitTaskTaskManagerImpl(context, taskManager, task, @@ -166,7 +167,7 @@ taskManager, Gearef(context, Iterator), &Gearef(context, TaskManager)->taskManager->TaskManager, - Gearef(context, TaskManager)->context, + Gearef(context, TaskManager)->task, Gearef(context, TaskManager)->next); } @@ -197,7 +198,7 @@ taskManager, Gearef(context, Queue), &Gearef(context, TaskManager)->taskManager->TaskManager, - Gearef(context, TaskManager)->context, + Gearef(context, TaskManager)->task, Gearef(context, TaskManager)->next); } diff -r 3025d00eb87d -r 57c715bd6283 src/parallel_execution/context.h --- a/src/parallel_execution/context.h Thu Dec 14 07:44:58 2017 +0900 +++ b/src/parallel_execution/context.h Sat Dec 16 06:04:32 2017 +0900 @@ -151,8 +151,8 @@ enum Code decrementTaskCount; enum Code next; enum Code next1; - enum Code task; - struct Context* context; + enum Code setWaitTask; + struct Context* task; struct Queue* tasks; union Data* data; int worker; diff -r 3025d00eb87d -r 57c715bd6283 src/parallel_execution/examples/twice/main.cbc --- a/src/parallel_execution/examples/twice/main.cbc Thu Dec 14 07:44:58 2017 +0900 +++ b/src/parallel_execution/examples/twice/main.cbc Sat Dec 16 06:04:32 2017 +0900 @@ -80,7 +80,6 @@ } } - int main(int argc, char** argv) { init(argc, argv); struct Context* main_context = NEW(struct Context);