Mercurial > hg > Gears > GearsAgda
changeset 348:c03159481cb6
Par goto exchange inline expansion
author | Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 06 Jun 2017 17:08:55 +0900 |
parents | 9578c38c10d1 |
children | 01e0fa598ce3 |
files | src/parallel_execution/TaskManagerImpl.cbc src/parallel_execution/examples/calc.cbc |
diffstat | 2 files changed, 48 insertions(+), 28 deletions(-) [+] |
line wrap: on
line diff
--- a/src/parallel_execution/TaskManagerImpl.cbc Tue May 30 18:21:19 2017 +0900 +++ b/src/parallel_execution/TaskManagerImpl.cbc Tue Jun 06 17:08:55 2017 +0900 @@ -73,15 +73,22 @@ goto setWorker(context, taskManager, Gearef(context, TaskManager)->context, Gearef(context, TaskManager)->next); } -__code setWaitTask(struct Queue* queue, struct Context* task, Data* data, __code next(...)) { - queue->queue = (Data *)GET_WAIT_LIST(data); - queue->next = next; - queue->data = (Data *)task; - goto meta(context, queue->queue->Queue.put); +__code setWaitTask(struct TaskManager* taskManager, struct Queue* queue, struct Context* task, struct LoopCounter* loopCounter, __code next(...)) { + int i = loopCounter->i; + if(task->idg + i < task->maxidg) { + loopCounter->i++; + queue->queue = (Data *)GET_WAIT_LIST(task->data[task->idg + i]); + queue->next = C_setWaitTask; + queue->data = (Data *)task; + goto meta(context, queue->queue->Queue.put); + } + goto meta(context, taskManager->taskManager->spawn); } __code setWaitTask_stub(struct Context* context) { - goto setWaitTask(context, Gearef(context, Queue), Gearef(context, TaskManager)->context, Gearef(context, TaskManager)->data, Gearef(context, TaskManager)->next); + TaskManager* taskManager = Gearef(context, TaskManager); + struct Context* task = Gearef(context, TaskManager)->context; + goto setWaitTask(context, taskManager, Gearef(context, Queue), task, Gearef(task, LoopCounter), taskGearef(context, TaskManager)->next); } __code spawnTaskManager(struct TaskManagerImpl* taskManager, struct Queue* queue, struct Context* task, __code next(...)) { @@ -97,10 +104,10 @@ TaskManagerImpl* taskManager = (TaskManagerImpl*)GearImpl(context, TaskManager, taskManager); pthread_mutex_lock(&taskManager->mutex); goto spawnTaskManager(context, - taskManager, - Gearef(context, Queue), - Gearef(context, TaskManager)->context, - Gearef(context, TaskManager)->next); + taskManager, + Gearef(context, Queue), + Gearef(context, TaskManager)->context, + Gearef(context, TaskManager)->next); } __code taskSend(struct TaskManagerImpl* taskManager, struct Queue* queue, struct Context* task, __code next(...)) {
--- a/src/parallel_execution/examples/calc.cbc Tue May 30 18:21:19 2017 +0900 +++ b/src/parallel_execution/examples/calc.cbc Tue Jun 06 17:08:55 2017 +0900 @@ -107,13 +107,20 @@ int i = loopCounter->i; integer1->value = i; integer2->value = i+1; - - codeGear->codeGear= createMultCodeGear(context); - codeGear->codeGear[0] = (union Data*)integer1; - codeGear->codeGear[1] = (union Data*)integer2; - codeGear->codeGear[2] = (union Data*)integer3; - codeGear->next = C_createTask1; - goto meta(context, codeGear->codeGear->CodeGear.setInfo); + struct Context* task = NEW(struct Context); + initContext(task); + task->next = C_mult; + task->idgCount = 2; + task->idg = task->datanum; + task->data[task->idg] = (union Data*)integer1; + task->data[task->idg+1] = (union Data*)integer2; + task->maxIdg = task->idg + 2; + task->odg = task->maxIdg; + task->data[task->odg] = (union Data*)integer3; + task->maxOdg = task->odg + 1; + taskManager->context = task; + taskManager->next = C_createTask3; + goto meta(context, taskManager->taskManager->TaskManager.setWaitTask); } __code createTask2_stub(struct Context* context) { @@ -123,7 +130,6 @@ goto createTask2(context, Gearef(context, LoopCounter), Gearef(context, TaskManager), - Gearef(context, TaskManager)->context, integer1, integer2, integer3); @@ -133,27 +139,34 @@ int i = loopCounter->i; integer1->value = i; integer2->value = i+1; - - codeGear->codeGear= createAddCodeGear(context); - codeGear->codeGear[0] = (union Data*)integer1; - codeGear->codeGear[1] = (union Data*)integer2; - codeGear->codeGear[2] = (union Data*)integer3; - codeGear->next = C_createTask1; - goto meta(context, codeGear->codeGear->CodeGear.setInfo); + struct Context* task = NEW(struct Context); + initContext(task); + task->next = C_add; + task->idgCount = 2; + task->idg = task->datanum; + task->data[task->idg] = (union Data*)integer1; + task->data[task->idg+1] = (union Data*)integer2; + task->maxIdg = task->idg + 2; + task->odg = task->maxIdg; + task->data[task->odg] = (union Data*)integer3; + task->maxOdg = task->odg + 1; + taskManager->context = task; + taskManager->next = C_createTask3; + goto meta(context, taskManager->taskManager->TaskManager.setWaitTask); } __code createTask3_stub(struct Context* context) { Integer* integer1 = &ALLOCATE_DATA_GEAR(context, Integer)->Integer; Integer* integer2 = &ALLOCATE_DATA_GEAR(context, Integer)->Integer; - goto createTask5(context, + Integer* integer3 = &ALLOCATE_DATA_GEAR(context, Integer)->Integer; + goto createTask3(context, Gearef(context, LoopCounter), Gearef(context, TaskManager), integer1, integer2, - &Gearef(context, TaskManager)->data->Integer); + integer3); } - void init(int argc, char** argv) { for (int i = 1; argv[i]; ++i) { if (strcmp(argv[i], "-cpu") == 0)