Mercurial > hg > GearsTemplate
diff src/parallel_execution/main.c @ 247:ce262b2c1daf
Fix createTask for main
author | Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp> |
---|---|
date | Wed, 25 Jan 2017 04:14:50 +0900 |
parents | 421ea91dd76c |
children | 1ede5390cda2 |
line wrap: on
line diff
--- a/src/parallel_execution/main.c Wed Jan 25 03:07:59 2017 +0900 +++ b/src/parallel_execution/main.c Wed Jan 25 04:14:50 2017 +0900 @@ -6,7 +6,7 @@ #include "origin_cs.h" extern union Data* createRedBlackTree(struct Context* context); -extern union Data* createTaskManager(struct Context* context); +extern union Data* createTaskManager(struct Context* context, int numCPU, int numGPU, int numIO); extern void allocator(struct Context* context); int cpu_num = 1; @@ -32,7 +32,7 @@ __code initDataGears(struct Context* context, struct LoopCounter* loopCounter, struct TaskManager* taskManager) { loopCounter->tree = &createRedBlackTree(context)->Tree; loopCounter->i = 0; - taskManager->taskManager = (union Data*)&createTaskManager(context)->TaskManager; + taskManager->taskManager = (union Data*)&createTaskManager(context, cpu_num, 0, 0)->TaskManager; goto meta(context, C_createData1); } @@ -120,23 +120,51 @@ Gearef(context, Tree)); } -__code createTask1(struct Context* context, struct LoopCounter* loopCounter, struct TaskManager* taskManager, struct Task* task) { - task->code = C_twice; - task->idsCount = 0; +__code createTask1(struct Context* context, struct LoopCounter* loopCounter, struct TaskManager* taskManager) { + int i = loopCounter->i; -// taskManager->task = task; - taskManager->next = C_createData1; - loopCounter->i++; + if ((length/split*i) < length) { + taskManager->next = C_createTask2; + goto meta(context, taskManager->taskManager->TaskManager.createTask); + } - goto meta(context, taskManager->taskManager->TaskManager.spawn); + loopCounter->i = 0; + goto meta(context, C_code1); } __code createTask1_stub(struct Context* context) { - Task* task = &ALLOCATE(context, Task)->Task; goto createTask1(context, Gearef(context, LoopCounter), + Gearef(context, TaskManager)); +} + +__code createTask2(Context* context, LoopCounter* loopCounter, TaskManager* taskManager, Context* task, Array* array) { + int i = loopCounter->i; + + if ((length/split*i) < length) { + array->index = i; + array->prefix = length/split; + array->array = array_ptr; + task->idgCount = 0; + task->next = C_twice; + // task->data[task->idg] = (union Data*)array; + taskManager->next = C_createTask1; + loopCounter->i++; + + goto meta(context, taskManager->taskManager->TaskManager.spawn); + } + + loopCounter->i = 0; + goto meta(context, C_code1); +} + +__code createTask2_stub(struct Context* context) { + Array* array = &ALLOCATE(context, Array)->Array; + goto createTask2(context, + Gearef(context, LoopCounter), Gearef(context, TaskManager), - task); + Gearef(context, TaskManager)->context, + array); } __code taskManager(struct Context* context, struct LoopCounter* loopCounter, struct Worker* worker) { @@ -175,11 +203,6 @@ initContext(main_context); main_context->next = C_initDataGears; - struct Context* worker_contexts = NEWN(cpu_num, struct Context); - - for (int i = 0;i<cpu_num;i++) - initContext(&worker_contexts[i]); - goto start_code(main_context); }