Mercurial > hg > Members > Moririn
changeset 382:f1d111e293c4
Enable Timer for bitonicSort
author | Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 24 Jul 2017 20:05:08 +0900 |
parents | b81492c74d2b |
children | 300c18700ca5 |
files | src/parallel_execution/OneDimIterator.cbc src/parallel_execution/TimeImpl.cbc src/parallel_execution/examples/bitonicSort/bitonicSort.cbc |
diffstat | 3 files changed, 47 insertions(+), 22 deletions(-) [+] |
line wrap: on
line diff
--- a/src/parallel_execution/OneDimIterator.cbc Mon Jul 24 16:52:09 2017 +0900 +++ b/src/parallel_execution/OneDimIterator.cbc Mon Jul 24 20:05:08 2017 +0900 @@ -77,5 +77,4 @@ enum Code next = Gearef(context, Iterator)->next; enum Code whenWait = Gearef(context, Iterator)->whenWait; goto barrierOneDimIterator(context, iterator, task, next, whenWait); -} - +}
--- a/src/parallel_execution/TimeImpl.cbc Mon Jul 24 16:52:09 2017 +0900 +++ b/src/parallel_execution/TimeImpl.cbc Mon Jul 24 20:05:08 2017 +0900 @@ -4,7 +4,7 @@ #include "../context.h" Time* createTimeImpl(struct Context* context) { - struct Time* time = new Time(); + struct Time* time = &ALLOCATE_DATA_GEAR(context, Time)->Time; struct TimeImpl* timeImpl = new TimeImpl(); time->time = (union Data*)timeImpl; time->start = C_startTime;
--- a/src/parallel_execution/examples/bitonicSort/bitonicSort.cbc Mon Jul 24 16:52:09 2017 +0900 +++ b/src/parallel_execution/examples/bitonicSort/bitonicSort.cbc Mon Jul 24 20:05:08 2017 +0900 @@ -65,9 +65,7 @@ /* print_tree(context->data[Tree]->tree.root); */ /* puts("result"); */ - time->time = (union Data*)createTimeImpl(context); - time->next = C_createTask1; - goto meta(context, time->time->Time.start); + goto meta(context, C_createTask1); } __code createTask1(struct LoopCounter* loopCounter, struct TaskManager* taskManager) { @@ -77,8 +75,10 @@ struct SortArray* outputSortArray = &ALLOCATE_DATA_GEAR(context, SortArray)->SortArray; struct SortArray* inputSortArray = outputSortArray; + struct Time* time = createTimeImpl(context); - // par goto makeArray(outputSortArray, _exit); + // par goto makeArray(outputSortArray, time, _exit); + // par goto makeArray(outputSortArray, time, time->start); ? struct Context* task = NEW(struct Context); initContext(task); task->next = C_makeArray; @@ -87,7 +87,8 @@ task->maxIdg = task->idg; task->odg = task->maxIdg; task->data[task->odg] = (union Data*)outputSortArray; - task->maxOdg = task->odg + 1; + task->data[task->odg+1] = (union Data*)time; + task->maxOdg = task->odg + 2; tasks[taskCount] = task; taskCount++; @@ -120,14 +121,16 @@ } } - // par goto printArray(inputSortArray, __exit) + // par goto printArray(inputSortArray, time, __exit) + // par goto printArray(inputSortArray, time, time->exit)? task = NEW(struct Context); initContext(task); task->next = C_printArray; - task->idgCount = 1; + task->idgCount = 2; task->idg = task->dataNum; task->data[task->idg] = (union Data*)inputSortArray; - task->maxIdg = task->idg + 1; + task->data[task->idg+1] = (union Data*)time; + task->maxIdg = task->idg + 2; task->odg = task->maxIdg; task->maxOdg = task->odg; tasks[taskCount] = task; @@ -140,7 +143,7 @@ } __code code2(struct LoopCounter* loopCounter, struct TaskManager* taskManager, struct Time* time) { - sleep(2); + sleep(30); taskManager->next = C_exit_code; goto meta(context, taskManager->taskManager->TaskManager.shutdown); } @@ -167,8 +170,9 @@ goto start_code(main_context); } -__code makeArray(__code next(struct SortArray* output, ...)){ +__code makeArray(struct Time* timeInterface, __code next(struct SortArray* output, struct Time* output1, ...)){ struct SortArray* output = *O_output; + struct Time* output1 = *O_output1; if (output->loopCounter == 0){ output->array = (Integer**)ALLOC_ARRAY(context, Integer, length); srand((unsigned) time(NULL)); @@ -176,36 +180,58 @@ if (output->loopCounter == GET_SIZE(output->array)){ printf("created Array\n"); output->loopCounter = 0; - goto meta(context, next); + timeInterface->time = (union Data*)output1; + timeInterface->next = context->next; + *O_output = output; + *O_output1 = output1; + goto meta(context, output1->start); } struct Integer* integer = new Integer(); integer->value = rand() % 1000; output->array[output->loopCounter] = integer; - printf("%d\n", output->array[output->loopCounter]->value); + //printf("%d\n", output->array[output->loopCounter]->value); output->loopCounter++; *O_output = output; + *O_output1 = output1; goto meta(context, C_makeArray); } __code makeArray_stub(struct Context* context) { - SortArray** O_output = (struct SortArray **)&context->data[context->odg]; + SortArray** O_output = (struct SortArray**)&context->data[context->odg]; + Time** O_output1 = (struct Time**)&context->data[context->odg+1]; goto makeArray(context, + Gearef(context, Time), context->next, - O_output); + O_output, + O_output1); } -__code printArray(struct SortArray* inputArray, __code next(...)){ +__code printArray(struct Time* timeInterface, struct SortArray* inputArray, struct Time* inputTime, __code next(...)){ + timeInterface->time = (union Data*)inputTime; + timeInterface->next = C_printArray1; + goto meta(context, inputTime->end); +} + +__code printArray_stub(struct Context* context) { + goto printArray(context, + Gearef(context, Time), + &context->data[context->idg]->SortArray, + &context->data[context->idg+1]->Time, + context->next); +} + +__code printArray1(struct SortArray* inputArray, __code next(...)){ if (inputArray->loopCounter == GET_SIZE(inputArray->array)){ inputArray->loopCounter = 0; goto meta(context, next); } - printf("%d\n", inputArray->array[inputArray->loopCounter]->value); + //printf("%d\n", inputArray->array[inputArray->loopCounter]->value); inputArray->loopCounter++; - goto meta(context, C_printArray); + goto meta(context, C_printArray1); } -__code printArray_stub(struct Context* context) { - goto printArray(context, +__code printArray1_stub(struct Context* context) { + goto printArray1(context, &context->data[context->idg]->SortArray, context->next); }