Mercurial > hg > Members > Moririn
changeset 378:9049c19036fd
Add iterator index
author | Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Wed, 19 Jul 2017 23:02:25 +0900 |
parents | b4677965afa7 |
children | 2744cb933ebc |
files | src/parallel_execution/Iterator.cbc src/parallel_execution/OneDimIterator.cbc src/parallel_execution/examples/calc.cbc src/parallel_execution/examples/twice.cbc src/parallel_execution/test/oneDimIterator_test.cbc |
diffstat | 5 files changed, 36 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/src/parallel_execution/Iterator.cbc Tue Jul 18 17:52:22 2017 +0900 +++ b/src/parallel_execution/Iterator.cbc Wed Jul 19 23:02:25 2017 +0900 @@ -6,4 +6,3 @@ __code whenWait(...); __code next(...); } Iterator; -
--- a/src/parallel_execution/OneDimIterator.cbc Tue Jul 18 17:52:22 2017 +0900 +++ b/src/parallel_execution/OneDimIterator.cbc Wed Jul 19 23:02:25 2017 +0900 @@ -14,17 +14,44 @@ return iterator; } +struct Context* createOneDimIterateTask(struct Context* task, int x) { + struct Context* task1 = NEW(struct Context); + initContext(task1); + task1->taskManager = task->taskManager; + task1->next = task->next; + task1->iterate = 1; + task1->iterator = task->iterator; + task1->idgCount = task->idgCount; + task1->idg = task->idg; + task1->maxIdg = task->maxIdg; + for(int i = task1->idg; i < task1->maxIdg; i++) { + task1->data[i] = task->data[i]; + } + + // create index data gear and register input data to iterate task + struct Integer* dataX = &ALLOCATE_DATA_GEAR(task1, Integer)->Integer; + dataX->value = x; + task1->data[task1->maxIdg++] = (union Data*)dataX; + + task1->odg = task->odg + 1; + task1->maxOdg = task->maxOdg + 1; + for (int i = task1->odg; i < task1->maxOdg; i++) { + task1->data[i] = task->data[i-1]; + } + + return task1; +} + __code execOneDimIterator(struct OneDimIterator* iterator, struct TaskManager* taskManager, struct Context* task, __code next(...)) { - if (iterator->loopCounter->i == iterator->x) { + int i = iterator->loopCounter->i; + if (i == iterator->x) { iterator->loopCounter->i = 0; goto next(...); } - struct Context* iterate_task = NEW(struct Context); - *iterate_task = *task; - iterate_task->iterate = 1; + struct Context* iterateTask = createOneDimIterateTask(task, i); iterator->loopCounter->i++; taskManager->taskManager = (union Data*)task->taskManager; - taskManager->context = iterate_task; + taskManager->context = iterateTask; taskManager->next = C_execOneDimIterator; goto meta(context, task->taskManager->spawn); }
--- a/src/parallel_execution/examples/calc.cbc Tue Jul 18 17:52:22 2017 +0900 +++ b/src/parallel_execution/examples/calc.cbc Wed Jul 19 23:02:25 2017 +0900 @@ -143,7 +143,6 @@ // par goto initIntegerDataGears(integer2, integer4, integer5, __exit); task = NEW(struct Context); initContext(task); - task->taskManager = &taskManager->taskManager->TaskManager; task->next = C_initIntegerDataGears; task->idgCount = 0; task->idg = task->dataNum;
--- a/src/parallel_execution/examples/twice.cbc Tue Jul 18 17:52:22 2017 +0900 +++ b/src/parallel_execution/examples/twice.cbc Wed Jul 19 23:02:25 2017 +0900 @@ -134,7 +134,6 @@ // par goto twice(loopCounter2, array, __exit); struct Context* task = NEW(struct Context); initContext(task); - task->taskManager = &taskManager->taskManager->TaskManager; task->idgCount = 0; if (gpu_num) { #ifdef USE_CUDAWorker
--- a/src/parallel_execution/test/oneDimIterator_test.cbc Tue Jul 18 17:52:22 2017 +0900 +++ b/src/parallel_execution/test/oneDimIterator_test.cbc Wed Jul 19 23:02:25 2017 +0900 @@ -88,8 +88,8 @@ initContext(task); task->iterate = 0; task->iterator = createOneDimIterator(context, 10); + task->idgCount = 0; task->next = C_printIterator; - task->idgCount = 0; task->idg = task->dataNum; task->maxIdg = task->idg; task->odg = task->maxIdg; @@ -118,16 +118,16 @@ struct Context* main_context = NEW(struct Context); initContext(main_context); main_context->next = C_initDataGears; - goto start_code(main_context); } -__code printIterator(__code next(...)) { - printf("test\n"); +__code printIterator(struct Integer* x, __code next(...)) { + printf("%d\n", x->value); goto meta(context, next); } __code printIterator_stub(struct Context* context) { goto printIterator(context, + &context->data[context->idg]->Integer, context->next); }