Mercurial > hg > GearsTemplate
changeset 342:de1e315379c6
Add CodeGear.cbc
author | Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp> |
---|---|
date | Thu, 25 May 2017 22:49:40 +0900 |
parents | 2dd9711cd347 |
children | 5065d1e4adbb |
files | src/parallel_execution/CodeGear.cbc src/parallel_execution/Semaphore.cbc src/parallel_execution/context.h src/parallel_execution/examples/calc.cbc |
diffstat | 4 files changed, 31 insertions(+), 32 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/parallel_execution/CodeGear.cbc Thu May 25 22:49:40 2017 +0900 @@ -0,0 +1,9 @@ +typedef struct CodeGear<Impl>{ + union Data* codeGear; + enum Code code; + __code run(struct Integer* input1, struct Integer* input2, __code next(struct Integer* output, ...)); + struct Integer* input1; + struct Integer* input2; + struct Integer* output; + __code next(...); +} CodeGear;
--- a/src/parallel_execution/Semaphore.cbc Tue May 09 02:19:43 2017 +0900 +++ b/src/parallel_execution/Semaphore.cbc Thu May 25 22:49:40 2017 +0900 @@ -4,4 +4,3 @@ __code v(Impl* semaphore, __code next(...)); __code next(...); } Semaphore; -
--- a/src/parallel_execution/context.h Tue May 09 02:19:43 2017 +0900 +++ b/src/parallel_execution/context.h Thu May 25 22:49:40 2017 +0900 @@ -109,6 +109,13 @@ struct LoopCounter { int i; } LoopCounter; + struct Task { + union Data* task; + enum Code code; + int idgCount; + int odgCount; + enum Code setTaskInfo; + } Task; struct TaskManager { #ifdef USE_CUDA_MAIN_THREAD volatile @@ -174,11 +181,6 @@ enum Code next; struct Queue* args; } Main; - struct Task { - enum Code code; - struct Queue* dataGears; - int idsCount; - } Task; // Queue Interface struct Queue { union Data* queue;
--- a/src/parallel_execution/examples/calc.cbc Tue May 09 02:19:43 2017 +0900 +++ b/src/parallel_execution/examples/calc.cbc Thu May 25 22:49:40 2017 +0900 @@ -101,25 +101,14 @@ loopCounter->i = 0; taskManager->next = C_code1; - sleep(3); goto meta(context, taskManager->taskManager->TaskManager.shutdown); } __code createTask2(LoopCounter* loopCounter, TaskManager* taskManager, struct Context *task, Integer *integer1, Integer *integer2, Integer *integer3) { int i = loopCounter->i; - task->idgCount = 1; - task->next = C_mult; integer2->value = i; - 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; - taskManager->data = (union Data*)integer1; - goto meta(context, taskManager->taskManager->TaskManager.setWaitTask); + par goto mult(integer1, integer2, integer3, _exit); + goto createTask3; } __code createTask2_stub(struct Context* context) { @@ -147,10 +136,10 @@ __code createTask5(LoopCounter* loopCounter, TaskManager* taskManager, struct Context* task, Integer *integer1, Integer *integer2, Integer *integer3) { int i = loopCounter->i; + integer1->value = i; + integer2->value = i+1; task->next = C_add; task->idgCount = 0; - integer1->value = i; - integer2->value = i+1; task->data[task->idg] = (union Data*)integer1; task->data[task->idg+1] = (union Data*)integer2; task->maxIdg = task->idg + 2; @@ -198,29 +187,29 @@ goto start_code(main_context); } -__code add(struct Integer* input1, struct Integer* input2, struct Integer* output) { - output->value = input1->value + input2->value; - printf("%d + %d = %d\n", input1->value, input2->value, output->value); - goto meta(context, context->next); +__code add(struct Integer* input1, struct Integer* input2, __code next(struct Integer* output, ...)) { + output->value = input1->value + input2->value; + printf("%d + %d = %d\n", input1->value, input2->value, output->value); + goto meta(context, context->next); } -__code add_stub(struct Context* context) { - goto add(context, +__code add_stub(struct Context* context) { + goto add(context, &context->data[context->idg]->Integer, &context->data[context->idg + 1]->Integer, &context->data[context->odg]->Integer); } -__code mult(struct Integer* input1, struct Integer* input2, struct Integer* output) { - output->value = input1->value * input2->value; - printf("%d * %d = %d\n", input1->value, input2->value, output->value); +__code mult(struct Integer* input1, struct Integer* input2, __code next(struct Integer* output, ...)) { + output->value = input1->value * input2->value; + printf("%d * %d = %d\n", input1->value, input2->value, output->value); assert(output->value == 2 * (input2->value * input2->value) + input2->value); goto meta(context, context->next); } -__code mult_stub(struct Context* context) { - goto mult(context, +__code mult_stub(struct Context* context) { + goto mult(context, &context->data[context->idg]->Integer, &context->data[context->idg + 1]->Integer, &context->data[context->odg]->Integer);