Mercurial > hg > Members > innparusu > Gears
changeset 117:c9ab10847fc3
Define dependency Task create function
author | Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 19 Jul 2016 02:18:31 +0900 |
parents | 69fbd905d750 |
children | 4df53a60e59a |
files | src/parallel_execution/context.h src/parallel_execution/dependency.c src/parallel_execution/main.c |
diffstat | 3 files changed, 36 insertions(+), 33 deletions(-) [+] |
line wrap: on
line diff
--- a/src/parallel_execution/context.h Tue Jul 12 16:26:05 2016 +0900 +++ b/src/parallel_execution/context.h Tue Jul 19 02:18:31 2016 +0900 @@ -132,7 +132,9 @@ #endif struct Task { enum Code code; - int key; + int iKeys[2]; + int oKeys[2]; + int idsCount; } task; struct Queue { struct Element* first;
--- a/src/parallel_execution/dependency.c Tue Jul 12 16:26:05 2016 +0900 +++ b/src/parallel_execution/dependency.c Tue Jul 19 02:18:31 2016 +0900 @@ -7,7 +7,7 @@ goto (context->code[next])(context); } -__code waitFor1(struct Context* context, struct Task* master, struct Task* slave, struct Element* element) { +__code waitFor1(struct Context* context, struct Task* master, struct Task* slave, struct Element* element, struct Node* node) { element->data = (union Data *)slave; // enqueue waitMe //goto meta_waitFor(context, master->waitMe, PutQueue1); @@ -36,10 +36,7 @@ } __code spawnTask(struct Context* context, struct Task* task, struct Element* element, struct Queue* activeQueue, struct Queue* waitQueue) { - element->data = (union Data *)task; - goto meta_spawnTask(context, activeQueue, PutQueue1); - /* - if (task->waitI->count == task->idsCount) { + if (task->idsCount == 0) { //printf("put ActiveQueue\n"); // enqueue activeQueue goto meta_spawnTask(context, activeQueue, PutQueue1); @@ -48,7 +45,6 @@ // enqueue waitQueue goto meta_spawnTask(context, waitQueue, PutQueue1); } - */ } __code spawnTask_stub(struct Context* context) { @@ -59,20 +55,10 @@ &context->data[WaitQueue]->queue); } -__code taskA(struct Context* context, struct Integer* input1, struct Integer* input2) { - allocator(context); - goto meta(context, calcPlus); -} - __code add(struct Context* context, struct Integer* input1, struct Integer* input2, struct Integer* output) { output->value = input1->value + input2->value; } -__code taskB(struct Context* context) { - allocator(context); - goto meta(context, context->next); -} - __code mult(struct Context* context, struct Integer* input1, struct Integer* input2, struct Integer* output) { output->value = input1->value * input2->value; }
--- a/src/parallel_execution/main.c Tue Jul 12 16:26:05 2016 +0900 +++ b/src/parallel_execution/main.c Tue Jul 19 02:18:31 2016 +0900 @@ -119,7 +119,6 @@ goto meta(context, CreateData2); } - loopCounter->i = 0; goto meta(context, CreateTask1); } @@ -184,13 +183,15 @@ __code createTask2(struct Context* context, struct LoopCounter* loopCounter, struct Task* task, struct Element* element, struct Queue* activeQueue) { int i = loopCounter->i; - task->code = TaskB; - task->key = i; + task->code = Mult; + task->iKeys[0] = i-1; + task->iKeys[1] = i-2; + task->idsCount = 1; + loopCounter->i -= 2; element->data = (union Data *)task; - context->next = CreateData1; - loopCounter->i++; + context->next = CreateTask3; goto meta(context, SpawnTask); } @@ -202,23 +203,37 @@ &context->data[Element]->element); } -__code createTask3(struct Context* context, struct LoopCounter* loopCounter, struct Task* task, struct Task* slave, struct Element* element) { - int i = loopCounter->i; - - task->code = TaskA; - task->key = i; - element->data = (union Data *)task; - - context->next = CreateData1; - loopCounter->i++; - - goto meta(context, WaitFor1); +__code createTask3(struct Context* context, struct Allocate* allocate) { + allocate->size = sizeof(struct Task); + allocator(context); + goto meta(context, CreateTask2); } __code createTask3_stub(struct Context* context) { + goto createTask1(context, &context->data[Allocate]->allocate); +} + + +__code createTask4(struct Context* context, struct LoopCounter* loopCounter, struct Task* task, struct Element* element, struct Node* node) { + int i = loopCounter->i; + + task->code = Add; + task->oKeys[0] = i; + task->iKeys[0] = i-1; + task->iKeys[1] = i-2; + loopCounter->i -= 2; + element->data = (union Data *)task; + context->next = WaitFor1; + + node->key = okeys[0]; + goto meta(context, Get); +} + +__code createTask4_stub(struct Context* context) { goto createTask3(context, &context->data[LoopCounter]->loopCounter, &context->data[context->dataNum]->task, + &context->data[Node]->node, &context->data[Element]->element); }