Mercurial > hg > GearsTemplate
changeset 237:6f6cc49213c5
fix
author | mir3636 |
---|---|
date | Tue, 24 Jan 2017 09:19:58 +0900 |
parents | 865179a0a56d |
children | e450bd33b33b |
files | src/parallel_execution/context.h src/parallel_execution/taskManager.c src/parallel_execution/worker.c |
diffstat | 3 files changed, 19 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/src/parallel_execution/context.h Mon Jan 23 20:00:46 2017 +0900 +++ b/src/parallel_execution/context.h Tue Jan 24 09:19:58 2017 +0900 @@ -36,13 +36,13 @@ #define ALLOC(context, t) (&ALLOCATE(context, t)->t) -#define ALLOC_ARRY(context, dseg, size) ({\ +#define ALLOC_ARRAY(context, dseg, len) ({\ struct Meta* meta = (struct Meta*)context->heap;\ context->heap += sizeof(struct Meta);\ union Data* data = context->heap; \ - context->heap += sizeof(struct t)*size; \ + context->heap += sizeof(struct dseg)*len; \ meta->type = D_##dseg; \ - meta->size = size; \ + meta->size = len; \ data; }) #define GET_TYPE(dseg) ({ \ @@ -107,6 +107,7 @@ int cpu; int gpu; int io; + int maxCPU; } TaskManager; struct TaskManagerImpl { int numWorker;
--- a/src/parallel_execution/taskManager.c Mon Jan 23 20:00:46 2017 +0900 +++ b/src/parallel_execution/taskManager.c Tue Jan 24 09:19:58 2017 +0900 @@ -1,9 +1,12 @@ #include "context.h" #include "stack.h" #include "queue.h" +#include "worker.h" #include "origin_cs.h" #include <stdio.h> +void createWorkers(Context* context, TaskManager * taskManeger); + union Data* createTaskManager(struct Context* context, int numCPU, int numGPU, int numIO) { struct TaskManager* taskManager = &ALLOCATE(context, TaskManager)->TaskManager; struct TaskManagerImpl* taskManagerImpl = &ALLOCATE(context, TaskManagerImpl)->TaskManagerImpl; @@ -20,32 +23,32 @@ taskManager->createTask = C_createTask; taskManager->spawn = C_spawnTaskManager; taskManager->shutdown = C_shutdownTaskManager; - createWorkers(taskManager); + createWorkers(context, taskManager); return (union Data*)(taskManager); } -void createWorker(Context* context, TaskManeger * taskManeger) { +void createWorkers(Context* context, TaskManager* taskManager) { int i = 0; - TaskManagerImpl *taskManagerImpl = GearImpl(context,TaskManagerImpl,taskManager); - taskManagerImpl->workers = ALLOC_ARRAY(context,Worker,taskManager->maxCPU); - for (;i>taskManeger->gpu;i++) { + TaskManagerImpl* taskManagerImpl = (TaskManagerImpl*)GearImpl(context,TaskManager,taskManager); + 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>taskManeger->cpu;i++) { + 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>taskManeger->maxCPU;i++) { + 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); } } -__code createTask(struct Context* context, TaskManeger* taskManager, enum Code next) { +__code createTask(struct Context* context, TaskManager* taskManager, enum Code next) { taskManager->context = NEW(struct Context); initContext(taskManager->context); goto meta(context, next); @@ -72,7 +75,7 @@ __code spawnTaskManager_stub(struct Context* context) { pthread_mutex_lock(taskManager->mutex); goto spawnTaskManager(context, - GearImpl(context, TaskManagerImpl, taskManager), + (struct TaskManager*)GearImpl(context, TaskManager, taskManager), Gearef(context, Queue), Gearef(context, TaskManager)->context, Gearef(context, TaskManager)->next
--- a/src/parallel_execution/worker.c Mon Jan 23 20:00:46 2017 +0900 +++ b/src/parallel_execution/worker.c Tue Jan 24 09:19:58 2017 +0900 @@ -58,7 +58,6 @@ #endif __code shutdownWorker(struct Context* context, CPUWorker* worker) { - worker->runFlag = 0; } __code shutdownWorker_stub(struct Context* context) {