# HG changeset patch # User mir3636 # Date 1485238223 -32400 # Node ID cc13a16083644336926b858f54a7d19a5b4ac673 # Parent e450bd33b33be323af9212f3a42a8e32d4ecddd4 fix diff -r e450bd33b33b -r cc13a1608364 src/parallel_execution/context.h --- a/src/parallel_execution/context.h Tue Jan 24 09:21:47 2017 +0900 +++ b/src/parallel_execution/context.h Tue Jan 24 15:10:23 2017 +0900 @@ -111,6 +111,7 @@ } TaskManager; struct TaskManagerImpl { int numWorker; + pthread_mutex_t mutex; struct Queue* activeQueue; struct Queue* taskQueue; struct Worker* workers; diff -r e450bd33b33b -r cc13a1608364 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 15:10:23 2017 +0900 @@ -33,18 +33,18 @@ taskManagerImpl->workers = (Worker*)ALLOC_ARRAY(context,Worker,taskManager->maxCPU); for (;i>taskManager->gpu;i++) { Queue* queue = &createSynchronizedQueue(context)->Queue; - taskManagerImpl->workers[i] = (Worker*)createCPUWorker(context,i,queue); + taskManagerImpl->workers[i] = *(Worker*)createCPUWorker(context,i,queue); } for (;i>taskManager->cpu;i++) { #ifdef USE_CUDA #else Queue* queue = &createSynchronizedQueue(context)->Queue; - taskManagerImpl->workers[i] = (Worker*)createCPUWorker(context,i,queue); + taskManagerImpl->workers[i] = *(Worker*)createCPUWorker(context,i,queue); #endif } for (;i>taskManager->maxCPU;i++) { Queue* queue = &createSynchronizedQueue(context)->Queue; - taskManagerImpl->workers[i] = (Worker*)createCPUWorker(context,i,queue); + taskManagerImpl->workers[i] = *(Worker*)createCPUWorker(context,i,queue); } } @@ -68,27 +68,32 @@ } queue->data = (union Data*)task; queue->next = next; - pthread_mutex_unlock(taskManagerImpl->mutex); + pthread_mutex_unlock(&taskManager->mutex); goto meta(context, queue->queue->Queue.put); } __code spawnTaskManager_stub(struct Context* context) { - pthread_mutex_lock(taskManager->mutex); + TaskManagerImpl* taskManager = (TaskManagerImpl*)GearImpl(context, TaskManager, taskManager); + pthread_mutex_lock(&taskManager->mutex); goto spawnTaskManager(context, - (struct TaskManager*)GearImpl(context, TaskManager, taskManager), + taskManager, Gearef(context, Queue), Gearef(context, TaskManager)->context, Gearef(context, TaskManager)->next ); } -__code taskSend(struct Context* context) { +__code taskSend(struct Context* context, TaskManagerImpl* taskManager) { if(loopCounter->i < taskManager->numWorker) { taskManager->workers[i]->taskSend; loopCounter->i++; goto meta(context, C_taskSend); } - goto meta(context, TaskManager->next); + goto meta(context, taskManager->next); +} + +__code taskSend_stub(struct Context* context) { + goto taskSend(context, (TaskManagerImpl*)GearImpl(context, TaskManager, taskManager)); } __code createWorker1(struct Context* context, struct LoopCounter* loopCounter, struct Worker* worker) {