# HG changeset patch # User Tatsuki IHA # Date 1485243070 -32400 # Node ID 864bb372f37f59de28dff9768066457925be12bd # Parent e450bd33b33be323af9212f3a42a8e32d4ecddd4 Add spawnTask1 diff -r e450bd33b33b -r 864bb372f37f src/parallel_execution/taskManager.c --- a/src/parallel_execution/taskManager.c Tue Jan 24 09:21:47 2017 +0900 +++ b/src/parallel_execution/taskManager.c Tue Jan 24 16:31:10 2017 +0900 @@ -31,18 +31,18 @@ int i = 0; TaskManagerImpl* taskManagerImpl = (TaskManagerImpl*)GearImpl(context,TaskManager,taskManager); taskManagerImpl->workers = (Worker*)ALLOC_ARRAY(context,Worker,taskManager->maxCPU); - for (;i>taskManager->gpu;i++) { + for (;igpu;i++) { Queue* queue = &createSynchronizedQueue(context)->Queue; taskManagerImpl->workers[i] = (Worker*)createCPUWorker(context,i,queue); } - for (;i>taskManager->cpu;i++) { + for (;icpu;i++) { #ifdef USE_CUDA #else Queue* queue = &createSynchronizedQueue(context)->Queue; taskManagerImpl->workers[i] = (Worker*)createCPUWorker(context,i,queue); #endif } - for (;i>taskManager->maxCPU;i++) { + for (;imaxCPU;i++) { Queue* queue = &createSynchronizedQueue(context)->Queue; taskManagerImpl->workers[i] = (Worker*)createCPUWorker(context,i,queue); } @@ -67,8 +67,7 @@ queue->queue = (union Data*)taskManager->taskQueue; } queue->data = (union Data*)task; - queue->next = next; - pthread_mutex_unlock(taskManagerImpl->mutex); + queue->next = C_spawnTaskManager1; goto meta(context, queue->queue->Queue.put); } @@ -78,15 +77,27 @@ (struct TaskManager*)GearImpl(context, TaskManager, taskManager), Gearef(context, Queue), Gearef(context, TaskManager)->context, - Gearef(context, TaskManager)->next - ); + Gearef(context, TaskManager)->next); +} + + +__code spawnTaskManager1(struct Context* context, struct TaskManagerImpl* taskManager, enum Code next) { + pthread_mutex_unlock(taskManagerImpl->mutex); + goto meta(context, next); +} + +__code spawnTaskManager1_stub(struct Context* context) { + goto spawnTaskManager(context, + (struct TaskManager*)GearImpl(context, TaskManager, taskManager), + Gearef(context, TaskManager)->next); } __code taskSend(struct Context* context) { if(loopCounter->i < taskManager->numWorker) { - taskManager->workers[i]->taskSend; + queue->queue = taskManager->workers[i]->tasks; + queue->next = C_taskSend; loopCounter->i++; - goto meta(context, C_taskSend); + goto meta(context, queue->queue->Queue.put); } goto meta(context, TaskManager->next); } @@ -111,7 +122,7 @@ } __code createWorker1_stub(struct Context* context) { - goto createWorker1(context, &context->data[D_LoopCounter]->LoopCounter, &context->data[D_Worker]->Worker); + goto createWorker1(context, &context->data[D_LoopCounter]->LoopCounter, &context->data[D_Worker]->Worker); } __code shutdownTaskManager(struct Context* context, struct LoopCounter* loopCounter, struct Worker* worker, struct TaskManager* taskManager) { diff -r e450bd33b33b -r 864bb372f37f src/parallel_execution/worker.c --- a/src/parallel_execution/worker.c Tue Jan 24 09:21:47 2017 +0900 +++ b/src/parallel_execution/worker.c Tue Jan 24 16:31:10 2017 +0900 @@ -36,7 +36,7 @@ } __code getTask1(struct Context* context, Worker* worker, struct Context* task) { - if (! task) + if (!task) return; // end thread task->worker = worker; goto meta(task, task->next);