Mercurial > hg > Members > Moririn
comparison src/parallel_execution/taskManager.c @ 239:cc13a1608364
fix
author | mir3636 |
---|---|
date | Tue, 24 Jan 2017 15:10:23 +0900 |
parents | 6f6cc49213c5 |
children | 9135e22799dd |
comparison
equal
deleted
inserted
replaced
238:e450bd33b33b | 239:cc13a1608364 |
---|---|
31 int i = 0; | 31 int i = 0; |
32 TaskManagerImpl* taskManagerImpl = (TaskManagerImpl*)GearImpl(context,TaskManager,taskManager); | 32 TaskManagerImpl* taskManagerImpl = (TaskManagerImpl*)GearImpl(context,TaskManager,taskManager); |
33 taskManagerImpl->workers = (Worker*)ALLOC_ARRAY(context,Worker,taskManager->maxCPU); | 33 taskManagerImpl->workers = (Worker*)ALLOC_ARRAY(context,Worker,taskManager->maxCPU); |
34 for (;i>taskManager->gpu;i++) { | 34 for (;i>taskManager->gpu;i++) { |
35 Queue* queue = &createSynchronizedQueue(context)->Queue; | 35 Queue* queue = &createSynchronizedQueue(context)->Queue; |
36 taskManagerImpl->workers[i] = (Worker*)createCPUWorker(context,i,queue); | 36 taskManagerImpl->workers[i] = *(Worker*)createCPUWorker(context,i,queue); |
37 } | 37 } |
38 for (;i>taskManager->cpu;i++) { | 38 for (;i>taskManager->cpu;i++) { |
39 #ifdef USE_CUDA | 39 #ifdef USE_CUDA |
40 #else | 40 #else |
41 Queue* queue = &createSynchronizedQueue(context)->Queue; | 41 Queue* queue = &createSynchronizedQueue(context)->Queue; |
42 taskManagerImpl->workers[i] = (Worker*)createCPUWorker(context,i,queue); | 42 taskManagerImpl->workers[i] = *(Worker*)createCPUWorker(context,i,queue); |
43 #endif | 43 #endif |
44 } | 44 } |
45 for (;i>taskManager->maxCPU;i++) { | 45 for (;i>taskManager->maxCPU;i++) { |
46 Queue* queue = &createSynchronizedQueue(context)->Queue; | 46 Queue* queue = &createSynchronizedQueue(context)->Queue; |
47 taskManagerImpl->workers[i] = (Worker*)createCPUWorker(context,i,queue); | 47 taskManagerImpl->workers[i] = *(Worker*)createCPUWorker(context,i,queue); |
48 } | 48 } |
49 } | 49 } |
50 | 50 |
51 __code createTask(struct Context* context, TaskManager* taskManager, enum Code next) { | 51 __code createTask(struct Context* context, TaskManager* taskManager, enum Code next) { |
52 taskManager->context = NEW(struct Context); | 52 taskManager->context = NEW(struct Context); |
66 // enqueue waitQueue | 66 // enqueue waitQueue |
67 queue->queue = (union Data*)taskManager->taskQueue; | 67 queue->queue = (union Data*)taskManager->taskQueue; |
68 } | 68 } |
69 queue->data = (union Data*)task; | 69 queue->data = (union Data*)task; |
70 queue->next = next; | 70 queue->next = next; |
71 pthread_mutex_unlock(taskManagerImpl->mutex); | 71 pthread_mutex_unlock(&taskManager->mutex); |
72 goto meta(context, queue->queue->Queue.put); | 72 goto meta(context, queue->queue->Queue.put); |
73 } | 73 } |
74 | 74 |
75 __code spawnTaskManager_stub(struct Context* context) { | 75 __code spawnTaskManager_stub(struct Context* context) { |
76 pthread_mutex_lock(taskManager->mutex); | 76 TaskManagerImpl* taskManager = (TaskManagerImpl*)GearImpl(context, TaskManager, taskManager); |
77 pthread_mutex_lock(&taskManager->mutex); | |
77 goto spawnTaskManager(context, | 78 goto spawnTaskManager(context, |
78 (struct TaskManager*)GearImpl(context, TaskManager, taskManager), | 79 taskManager, |
79 Gearef(context, Queue), | 80 Gearef(context, Queue), |
80 Gearef(context, TaskManager)->context, | 81 Gearef(context, TaskManager)->context, |
81 Gearef(context, TaskManager)->next | 82 Gearef(context, TaskManager)->next |
82 ); | 83 ); |
83 } | 84 } |
84 | 85 |
85 __code taskSend(struct Context* context) { | 86 __code taskSend(struct Context* context, TaskManagerImpl* taskManager) { |
86 if(loopCounter->i < taskManager->numWorker) { | 87 if(loopCounter->i < taskManager->numWorker) { |
87 taskManager->workers[i]->taskSend; | 88 taskManager->workers[i]->taskSend; |
88 loopCounter->i++; | 89 loopCounter->i++; |
89 goto meta(context, C_taskSend); | 90 goto meta(context, C_taskSend); |
90 } | 91 } |
91 goto meta(context, TaskManager->next); | 92 goto meta(context, taskManager->next); |
93 } | |
94 | |
95 __code taskSend_stub(struct Context* context) { | |
96 goto taskSend(context, (TaskManagerImpl*)GearImpl(context, TaskManager, taskManager)); | |
92 } | 97 } |
93 | 98 |
94 __code createWorker1(struct Context* context, struct LoopCounter* loopCounter, struct Worker* worker) { | 99 __code createWorker1(struct Context* context, struct LoopCounter* loopCounter, struct Worker* worker) { |
95 int i = loopCounter->i; | 100 int i = loopCounter->i; |
96 | 101 |