Mercurial > hg > GearsTemplate
changeset 464:7d67c9cf09ee
Rename from Time interface to Timer interface
author | Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Thu, 21 Dec 2017 00:07:27 +0900 |
parents | b3a2246e3218 |
children | b6437feb04ee |
files | src/parallel_execution/CMakeLists.txt src/parallel_execution/CUDAExecutor.cbc src/parallel_execution/Time.h src/parallel_execution/TimeImpl.cbc src/parallel_execution/Timer.h src/parallel_execution/TimerImpl.cbc src/parallel_execution/context.h src/parallel_execution/examples/bitonicSort/bitonicSort.cbc src/parallel_execution/examples/bitonicSort/makeArray.cbc src/parallel_execution/examples/bitonicSort/printArray.cbc src/parallel_execution/examples/twice/createArray.cbc src/parallel_execution/examples/twice/main.cbc src/parallel_execution/examples/twice/printArray.cbc src/parallel_execution/generate_stub.pl src/parallel_execution/test/multiDimIterator_test.cbc |
diffstat | 15 files changed, 82 insertions(+), 87 deletions(-) [+] |
line wrap: on
line diff
--- a/src/parallel_execution/CMakeLists.txt Wed Dec 20 22:09:17 2017 +0900 +++ b/src/parallel_execution/CMakeLists.txt Thu Dec 21 00:07:27 2017 +0900 @@ -61,7 +61,7 @@ TARGET twice SOURCES - examples/twice/main.cbc examples/twice/createArray.cbc examples/twice/twice.cbc examples/twice/printArray.cbc CPUWorker.cbc TaskManagerImpl.cbc SingleLinkedQueue.cbc SynchronizedQueue.cbc TimeImpl.cbc MultiDimIterator.cbc AtomicReference.cbc + examples/twice/main.cbc examples/twice/createArray.cbc examples/twice/twice.cbc examples/twice/printArray.cbc CPUWorker.cbc TaskManagerImpl.cbc SingleLinkedQueue.cbc SynchronizedQueue.cbc TimerImpl.cbc MultiDimIterator.cbc AtomicReference.cbc ) GearsCommand( @@ -75,7 +75,7 @@ TARGET bitonicSort SOURCES - examples/bitonicSort/bitonicSort.cbc examples/bitonicSort/bitonicSwap.cbc examples/bitonicSort/makeArray.cbc examples/bitonicSort/printArray.cbc CPUWorker.cbc TaskManagerImpl.cbc SingleLinkedQueue.cbc SynchronizedQueue.cbc MultiDimIterator.cbc TimeImpl.cbc AtomicReference.cbc + examples/bitonicSort/bitonicSort.cbc examples/bitonicSort/bitonicSwap.cbc examples/bitonicSort/makeArray.cbc examples/bitonicSort/printArray.cbc CPUWorker.cbc TaskManagerImpl.cbc SingleLinkedQueue.cbc SynchronizedQueue.cbc MultiDimIterator.cbc TimerImpl.cbc AtomicReference.cbc ) if (${USE_CUDA}) @@ -83,7 +83,7 @@ TARGET CUDAtwice SOURCES - examples/twice/main.cbc examples/twice/twice.cbc examples/twice/CUDAtwice.cu examples/twice/createArray.cbc examples/twice/printArray.cbc CPUWorker.cbc TimeImpl.cbc examples/twice/twice.cbc TaskManagerImpl.cbc SingleLinkedQueue.cbc SynchronizedQueue.cbc CUDAWorker.cbc cuda.c MultiDimIterator.cbc CUDAExecutor.cbc AtomicReference.cbc + examples/twice/main.cbc examples/twice/twice.cbc examples/twice/CUDAtwice.cu examples/twice/createArray.cbc examples/twice/printArray.cbc CPUWorker.cbc TimerImpl.cbc examples/twice/twice.cbc TaskManagerImpl.cbc SingleLinkedQueue.cbc SynchronizedQueue.cbc CUDAWorker.cbc cuda.c MultiDimIterator.cbc CUDAExecutor.cbc AtomicReference.cbc ) set_target_properties(CUDAtwice PROPERTIES COMPILE_FLAGS "-Wall -g -DUSE_CUDAWorker=1") @@ -91,7 +91,7 @@ TARGET CUDAbitonicSort SOURCES - examples/bitonicSort/bitonicSort.cbc examples/bitonicSort/bitonicSwap.cbc examples/bitonicSort/CUDAbitonicSwap.cu examples/bitonicSort/makeArray.cbc examples/bitonicSort/printArray.cbc CPUWorker.cbc CUDAWorker.cbc TaskManagerImpl.cbc SingleLinkedQueue.cbc SynchronizedQueue.cbc cuda.c MultiDimIterator.cbc TimeImpl.cbc CUDAExecutor.cbc AtomicReference.cbc + examples/bitonicSort/bitonicSort.cbc examples/bitonicSort/bitonicSwap.cbc examples/bitonicSort/CUDAbitonicSwap.cu examples/bitonicSort/makeArray.cbc examples/bitonicSort/printArray.cbc CPUWorker.cbc CUDAWorker.cbc TaskManagerImpl.cbc SingleLinkedQueue.cbc SynchronizedQueue.cbc cuda.c MultiDimIterator.cbc TimerImpl.cbc CUDAExecutor.cbc AtomicReference.cbc ) set_target_properties(CUDAbitonicSort PROPERTIES COMPILE_FLAGS "-Wall -g -DUSE_CUDAWorker=1") endif() @@ -114,7 +114,7 @@ TARGET multiDimIterator_test SOURCES - test/multiDimIterator_test.cbc test/printIterator.cbc CPUWorker.cbc TaskManagerImpl.cbc SingleLinkedQueue.cbc SynchronizedQueue.cbc MultiDimIterator.cbc TimeImpl.cbc AtomicReference.cbc + test/multiDimIterator_test.cbc test/printIterator.cbc CPUWorker.cbc TaskManagerImpl.cbc SingleLinkedQueue.cbc SynchronizedQueue.cbc MultiDimIterator.cbc AtomicReference.cbc ) GearsCommand(
--- a/src/parallel_execution/CUDAExecutor.cbc Wed Dec 20 22:09:17 2017 +0900 +++ b/src/parallel_execution/CUDAExecutor.cbc Thu Dec 21 00:07:27 2017 +0900 @@ -1,4 +1,5 @@ #include "../context.h" +#include "Executor.h" #include <stdio.h> Executor* createCUDAExecutor(struct Context* context, CUdevice device) {
--- a/src/parallel_execution/Time.h Wed Dec 20 22:09:17 2017 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,7 +0,0 @@ -typedef struct Time<Impl>{ - union Data* time; - __code start(Impl* time, __code next(...)); - __code end(Impl* time, __code next(...)); - __code next(...); -} Queue; -
--- a/src/parallel_execution/TimeImpl.cbc Wed Dec 20 22:09:17 2017 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,32 +0,0 @@ -#include <stdio.h> -#include <sys/time.h> - -#include "../context.h" -#include "Time.h" - -Time* createTimeImpl(struct Context* context) { - struct Time* time = new Time(); - struct TimeImpl* timeImpl = new TimeImpl(); - time->time = (union Data*)timeImpl; - time->start = C_startTime; - time->end = C_endTime; - return time; -} - -__code startTime(struct TimeImpl* time, __code next(...)) { - struct timeval tv; - gettimeofday(&tv, NULL); - - time->time = tv.tv_sec + (double)tv.tv_usec*1e-6; - - goto next(...); -} - -__code endTime(struct TimeImpl* time, __code next(...)) { - struct timeval tv; - gettimeofday(&tv, NULL); - - printf("%0.6f\n", (tv.tv_sec+(double)tv.tv_usec*1e-6) - time->time); - - goto next(...); -}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/parallel_execution/Timer.h Thu Dec 21 00:07:27 2017 +0900 @@ -0,0 +1,7 @@ +typedef struct Timer<Impl>{ + union Data* timer; + __code start(Impl* timer, __code next(...)); + __code end(Impl* timer, __code next(...)); + __code next(...); +} Queue; +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/parallel_execution/TimerImpl.cbc Thu Dec 21 00:07:27 2017 +0900 @@ -0,0 +1,32 @@ +#include <stdio.h> +#include <sys/time.h> + +#include "../context.h" +#include "Timer.h" + +Timer* createTimerImpl(struct Context* context) { + struct Timer* timer = new Timer(); + struct TimerImpl* timerImpl = new TimerImpl(); + timer->timer = (union Data*)timerImpl; + timer->start = C_startTimer; + timer->end = C_endTimer; + return timer; +} + +__code startTimer(struct TimerImpl* timer, __code next(...)) { + struct timeval tv; + gettimeofday(&tv, NULL); + + timer->time = tv.tv_sec + (double)tv.tv_usec*1e-6; + + goto next(...); +} + +__code endTimer(struct TimerImpl* timer, __code next(...)) { + struct timeval tv; + gettimeofday(&tv, NULL); + + printf("%0.6f\n", (tv.tv_sec+(double)tv.tv_usec*1e-6) - timer->time); + + goto next(...); +}
--- a/src/parallel_execution/context.h Wed Dec 20 22:09:17 2017 +0900 +++ b/src/parallel_execution/context.h Thu Dec 21 00:07:27 2017 +0900 @@ -133,15 +133,15 @@ struct Queue* wait; // tasks waiting this dataGear } Meta; struct Context Context; - struct Time { - union Data* time; + struct Timer { + union Data* timer; enum Code start; enum Code end; enum Code next; - } Time; - struct TimeImpl { + } Timer; + struct TimerImpl { double time; - } TimeImpl; + } TimerImpl; struct LoopCounter { int i; } LoopCounter;
--- a/src/parallel_execution/examples/bitonicSort/bitonicSort.cbc Wed Dec 20 22:09:17 2017 +0900 +++ b/src/parallel_execution/examples/bitonicSort/bitonicSort.cbc Thu Dec 21 00:07:27 2017 +0900 @@ -33,7 +33,7 @@ goto initDataGears(context, loopCounter, taskManager); } -__code code1(struct Time* time) { +__code code1(struct LoopCounter* loopCounter) { printf("cpus:\t\t%d\n", cpu_num); printf("gpus:\t\t%d\n", gpu_num); printf("length:\t\t%d\n", length); @@ -44,15 +44,15 @@ /* print_tree(context->data[Tree]->tree.root); */ /* puts("result"); */ - goto meta(context, C_createTask1); + goto createTask1(); } __code createTask1(struct LoopCounter* loopCounter, struct TaskManager* taskManager) { struct SortArray* outputSortArray = new SortArray(); struct SortArray* inputSortArray = outputSortArray; - struct Time* time = createTimeImpl(context); + struct Timer* timer = createTimerImpl(context); - par goto makeArray(outputSortArray, time, __exit); + par goto makeArray(outputSortArray, timer, __exit); for (int i=2; i <= length; i=2*i) { int first = 1; @@ -67,7 +67,7 @@ } } - par goto printArray(inputSortArray, time, __exit); + par goto printArray(inputSortArray, timer, __exit); goto code2(); }
--- a/src/parallel_execution/examples/bitonicSort/makeArray.cbc Wed Dec 20 22:09:17 2017 +0900 +++ b/src/parallel_execution/examples/bitonicSort/makeArray.cbc Thu Dec 21 00:07:27 2017 +0900 @@ -1,9 +1,11 @@ #include "../../../context.h" #include <stdio.h> +#include "Timer.h" + extern int length; -__code makeArray(__code next(struct SortArray* output, struct Time* output1, ...)){ +__code makeArray(__code next(struct SortArray* output, struct Timer* output1, ...)){ struct SortArray* output = *O_output; - struct Time* output1 = *O_output1; + struct Timer* output1 = *O_output1; if (output->loopCounter == 0){ output->array = (Integer*)ALLOCATE_ARRAY(context, Integer, length); srand((unsigned) time(NULL)); @@ -11,11 +13,9 @@ if (output->loopCounter == GET_LEN(output->array)){ printf("created Array\n"); output->loopCounter = 0; - Gearef(context, Time)->time = (union Data*)output1; - Gearef(context, Time)->next = context->next; *O_output = output; *O_output1 = output1; - goto meta(context, output1->start); + goto output1->start(next(...)); } output->array[output->loopCounter].value = rand() % 1000; //printf("%d\n", output->array[output->loopCounter]->value); @@ -27,7 +27,7 @@ __code makeArray_stub(struct Context* context) { SortArray** O_output = (struct SortArray**)&context->data[context->odg]; - Time** O_output1 = (struct Time**)&context->data[context->odg+1]; + Timer** O_output1 = (struct Timer**)&context->data[context->odg+1]; goto makeArray(context, context->next, O_output,
--- a/src/parallel_execution/examples/bitonicSort/printArray.cbc Wed Dec 20 22:09:17 2017 +0900 +++ b/src/parallel_execution/examples/bitonicSort/printArray.cbc Thu Dec 21 00:07:27 2017 +0900 @@ -1,16 +1,15 @@ #include "../../../context.h" +#include "Timer.h" #include <stdio.h> -__code printArray(struct SortArray* inputArray, struct Time* inputTime, __code next(...)){ - Gearef(context, Time)->time = (union Data*)inputTime; - Gearef(context, Time)->next = C_printArray1; - goto meta(context, inputTime->end); +__code printArray(struct SortArray* inputArray, struct Timer* inputTimer, __code next(...)){ + goto inputTimer->end(printArray1); } __code printArray_stub(struct Context* context) { goto printArray(context, &context->data[context->idg]->SortArray, - &context->data[context->idg+1]->Time, + &context->data[context->idg+1]->Timer, context->next); }
--- a/src/parallel_execution/examples/twice/createArray.cbc Wed Dec 20 22:09:17 2017 +0900 +++ b/src/parallel_execution/examples/twice/createArray.cbc Thu Dec 21 00:07:27 2017 +0900 @@ -1,12 +1,13 @@ #include <stdio.h> #include "../../../context.h" +#include "Timer.h" extern int length; extern int split; -__code createArray(__code next(struct Array* output, struct Time* output1, ...), struct LoopCounter* loopCounter) { +__code createArray(__code next(struct Array* output, struct Timer* output1, ...), struct LoopCounter* loopCounter) { struct Array* output = *O_output; - struct Time* output1 = *O_output1; + struct Timer* output1 = *O_output1; int i = loopCounter->i; if (i == 0){ output->array = (Int*)ALLOCATE_ARRAY(context, Int, length); @@ -15,11 +16,9 @@ if (i == GET_LEN(output->array)){ printf("created Array\n"); loopCounter->i = 0; - Gearef(context, Time)->time = (union Data*)output1; - Gearef(context, Time)->next = context->next; *O_output = output; *O_output1 = output1; - goto meta(context, output1->start); + goto output1->start(next(...)); } output->array[i] = i; loopCounter->i++; @@ -30,7 +29,7 @@ __code createArray_stub(struct Context* context) { Array** O_output = (struct Array **)&context->data[context->odg]; - Time** O_output1 = (struct Time**)&context->data[context->odg+1]; + Timer** O_output1 = (struct Timer**)&context->data[context->odg+1]; goto createArray(context, context->next, O_output,
--- a/src/parallel_execution/examples/twice/main.cbc Wed Dec 20 22:09:17 2017 +0900 +++ b/src/parallel_execution/examples/twice/main.cbc Thu Dec 21 00:07:27 2017 +0900 @@ -33,7 +33,7 @@ goto initDataGears(context, loopCounter, taskManager); } -__code code1(struct Time* time) { +__code code1(struct LoopCounter* loopCounter) { printf("cpus:\t\t%d\n", cpu_num); printf("gpus:\t\t%d\n", gpu_num); printf("length:\t\t%d\n", length); @@ -43,18 +43,18 @@ /* puts("tree"); */ /* print_tree(context->data[Tree]->tree.root); */ /* puts("result"); */ - goto meta(context, C_createTask1); + goto createTask1(); } __code createTask1(struct LoopCounter* loopCounter, struct TaskManager* taskManager) { Array* array1 = new Array(); Array* array2 = new Array(); - Time* time = createTimeImpl(context); + Timer* timer = createTimerImpl(context); - par goto createArray(array1, time, __exit); + par goto createArray(array1, timer, __exit); par goto twice(array1, array2, iterate(split), __exit); - par goto printArray(array2, time, __exit); + par goto printArray(array2, timer, __exit); goto code2(); }
--- a/src/parallel_execution/examples/twice/printArray.cbc Wed Dec 20 22:09:17 2017 +0900 +++ b/src/parallel_execution/examples/twice/printArray.cbc Thu Dec 21 00:07:27 2017 +0900 @@ -1,16 +1,15 @@ #include "../../../context.h" +#include "Timer.h" #include <stdio.h> -__code printArray(struct Array* array, struct Time* inputTime, __code next(...)){ - Gearef(context, Time)->time = (union Data*)inputTime; - Gearef(context, Time)->next = C_printArray1; - goto meta(context, inputTime->end); +__code printArray(struct Array* array, struct Timer* inputTimer, __code next(...)){ + goto inputTimer->end(printArray1); } __code printArray_stub(struct Context* context) { goto printArray(context, &context->data[context->idg]->Array, - &context->data[context->idg+1]->Time, + &context->data[context->idg+1]->Timer, context->next); }
--- a/src/parallel_execution/generate_stub.pl Wed Dec 20 22:09:17 2017 +0900 +++ b/src/parallel_execution/generate_stub.pl Thu Dec 21 00:07:27 2017 +0900 @@ -486,7 +486,6 @@ for my $i (0..$inputCount-1) { print $fd "${prev}context->task->data[context->task->idg+$i] = (union Data*)@dataGears[$i];\n"; } - for my $i (0..$outputCount-1) { print $fd "${prev}context->task->data[context->task->odg+$i] = (union Data*)@dataGears[$inputCount+$i];\n"; }
--- a/src/parallel_execution/test/multiDimIterator_test.cbc Wed Dec 20 22:09:17 2017 +0900 +++ b/src/parallel_execution/test/multiDimIterator_test.cbc Thu Dec 21 00:07:27 2017 +0900 @@ -25,7 +25,7 @@ goto initDataGears(context, loopCounter, taskManager); } -__code code1(struct Time* time) { +__code code1() { printf("cpus:\t\t%d\n", cpu_num); printf("gpus:\t\t%d\n", gpu_num); printf("length:\t\t%d\n", length); @@ -35,12 +35,10 @@ /* 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 createTask1(); } -__code createTask1(struct LoopCounter* loopCounter, struct TaskManager* taskManager, struct Time* time) { +__code createTask1(struct LoopCounter* loopCounter, struct TaskManager* taskManager) { int i = loopCounter->i; if (i < length) {