Mercurial > hg > GearsTemplate
changeset 395:864cd4e346e9
Fix taskManager
author | Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 01 Aug 2017 20:09:33 +0900 |
parents | 0c113f8e5a3f |
children | bba401f93dcd |
files | src/parallel_execution/TaskManagerImpl.cbc |
diffstat | 1 files changed, 27 insertions(+), 26 deletions(-) [+] |
line wrap: on
line diff
--- a/src/parallel_execution/TaskManagerImpl.cbc Tue Aug 01 19:42:08 2017 +0900 +++ b/src/parallel_execution/TaskManagerImpl.cbc Tue Aug 01 20:09:33 2017 +0900 @@ -14,8 +14,8 @@ taskManager->cpu = numIO+numGPU; taskManager->maxCPU = numIO+numGPU+numCPU; taskManager->spawnTasks = C_spawnTasksTaskManagerImpl; - taskManager->spawn = C_spawnTaskManager; - taskManager->shutdown = C_shutdownTaskManager; + taskManager->spawn = C_spawnTaskManagerImpl; + taskManager->shutdown = C_shutdownTaskManagerImpl; struct TaskManagerImpl* taskManagerImpl = new TaskManagerImpl(); taskManagerImpl -> activeQueue = createSingleLinkedQueue(context); taskManagerImpl -> taskQueue = createSingleLinkedQueue(context); @@ -53,48 +53,49 @@ } } -__code spawnTasksTaskManagerImpl(struct TaskManagerImpl* taskManagerImpl, struct Context** tasks, __code next1(...)) { +__code spawnTasksTaskManagerImpl(struct TaskManagerImpl* taskManagerImpl, struct Context** tasks, __code next1(...), struct TaskManager* taskManager) { int i = taskManagerImpl->loopCounter->i; if(i < GET_SIZE(tasks)) { struct Context* task = tasks[i]; taskManagerImpl->loopCounter->i++; task->taskManager = &taskManager->taskManager->TaskManager; taskManager->context = task; - taskManager->next = C_spawnTasksTaskManager; + taskManager->next = C_spawnTasksTaskManagerImpl; goto meta(context, C_setWaitTask); } taskManagerImpl->loopCounter->i = 0; - goto meta(context, C_spawnTasksTaskManager1); + goto meta(context, C_spawnTasksTaskManagerImpl1); } -__code spawnTasksTaskManager_stub(struct Context* context) { +__code spawnTasksTaskManagerImpl_stub(struct Context* context) { TaskManagerImpl* taskManager = (TaskManagerImpl*)GearImpl(context, TaskManager, taskManager); - goto spawnTasksTaskManager(context, + goto spawnTasksTaskManagerImpl(context, taskManager, Gearef(context, TaskManager)->tasks, - Gearef(context, TaskManager)->next1); + Gearef(context, TaskManager)->next1, + Gearef(context, TaskManager)); } -__code spawnTasksTaskManager1(struct TaskManager* taskManager, struct TaskManagerImpl* taskManagerImpl, struct Context** tasks, __code next1(...)) { +__code spawnTasksTaskManagerImpl1(struct TaskManagerImpl* taskManagerImpl, struct Context** tasks, __code next1(...), struct TaskManager* taskManager) { int i = taskManagerImpl->loopCounter->i; if(i < GET_SIZE(tasks)) { struct Context* task = tasks[i]; taskManagerImpl->loopCounter->i++; taskManager->context = task; - taskManager->next = C_spawnTasksTaskManager1; - goto meta(context, C_spawnTaskManager); + taskManager->next = C_spawnTasksTaskManagerImpl1; + goto meta(context, C_spawnTaskManagerImpl); } taskManagerImpl->loopCounter->i = 0; goto meta(context, next1); } -__code spawnTasksTaskManager1_stub(struct Context* context) { +__code spawnTasksTaskManagerImpl1_stub(struct Context* context) { TaskManagerImpl* taskManager = (TaskManagerImpl*)GearImpl(context, TaskManager, taskManager); - goto spawnTasksTaskManager1(context, - Gearef(context, TaskManager), + goto spawnTasksTaskManagerImpl1(context, taskManager, Gearef(context, TaskManager)->tasks, - Gearef(context, TaskManager)->next1); + Gearef(context, TaskManager)->next1, + Gearef(context, TaskManager)); } __code setWaitTask(struct Queue* queue, struct LoopCounter* loopCounter, struct Context* task, __code next(...)) { @@ -119,7 +120,7 @@ Gearef(context, TaskManager)->next); } -__code spawnTaskManager(struct TaskManagerImpl* taskManager, struct Iterator* iterator, struct Context* task, __code next(...)) { +__code spawnTaskManagerImpl(struct TaskManagerImpl* taskManager, struct Iterator* iterator, struct Context* task, __code next(...)) { if (task->idgCount == 0) { if(task->iterator != NULL && task->iterate == 0) { iterator->iterator = (union Data*)task->iterator; @@ -134,10 +135,10 @@ goto next(...); } -__code spawnTaskManager_stub(struct Context* context) { +__code spawnTaskManagerImpl_stub(struct Context* context) { TaskManagerImpl* taskManager = (TaskManagerImpl*)GearImpl(context, TaskManager, taskManager); pthread_mutex_lock(&taskManager->mutex); - goto spawnTaskManager(context, + goto spawnTaskManagerImpl(context, taskManager, Gearef(context, Iterator), Gearef(context, TaskManager)->context, @@ -166,13 +167,13 @@ Gearef(context, TaskManager)->next); } -__code shutdownTaskManager(struct LoopCounter* loopCounter, struct TaskManager* taskManager, struct TaskManagerImpl* taskManagerImpl, struct Queue* queue, __code next(...)) { +__code shutdownTaskManagerImpl(struct LoopCounter* loopCounter, struct TaskManager* taskManager, struct TaskManagerImpl* taskManagerImpl, struct Queue* queue, __code next(...)) { int i = loopCounter->i; if (taskManager->cpu <= i && i < taskManager->maxCPU) { struct Queue* tasks = taskManagerImpl->workers[i]->tasks; queue->queue = (union Data*)tasks; queue->data = NULL; - queue->next = C_shutdownTaskManager1; + queue->next = C_shutdownTaskManagerImpl1; goto meta(context, tasks->put); } @@ -180,19 +181,19 @@ goto meta(context, next); } -__code shutdownTaskManager_stub(struct Context* context) { +__code shutdownTaskManagerImpl_stub(struct Context* context) { TaskManagerImpl* taskManagerImpl = (TaskManagerImpl*)GearImpl(context, TaskManager, taskManager); - goto shutdownTaskManager(context, Gearef(context, LoopCounter), &Gearef(context, TaskManager)->taskManager->TaskManager, taskManagerImpl, Gearef(context, Queue), Gearef(context, TaskManager)->next); + goto shutdownTaskManagerImpl(context, Gearef(context, LoopCounter), &Gearef(context, TaskManager)->taskManager->TaskManager, taskManagerImpl, Gearef(context, Queue), Gearef(context, TaskManager)->next); } -__code shutdownTaskManager1(struct LoopCounter* loopCounter, TaskManagerImpl* taskManagerImpl) { +__code shutdownTaskManagerImpl1(struct LoopCounter* loopCounter, TaskManagerImpl* taskManagerImpl) { int i = loopCounter->i; pthread_join(taskManagerImpl->workers[i]->worker->CPUWorker.thread, NULL); loopCounter->i++; - goto meta(context, C_shutdownTaskManager); + goto meta(context, C_shutdownTaskManagerImpl); } -__code shutdownTaskManager1_stub(struct Context* context) { +__code shutdownTaskManagerImpl1_stub(struct Context* context) { TaskManagerImpl* taskManagerImpl = (TaskManagerImpl*)GearImpl(context, TaskManager, taskManager); - goto shutdownTaskManager1(context, Gearef(context, LoopCounter), taskManagerImpl); + goto shutdownTaskManagerImpl1(context, Gearef(context, LoopCounter), taskManagerImpl); }