Mercurial > hg > Gears > GearsAgda
changeset 328:48c2b5bcab79 examples_directory
Fix calc example
author | Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 18 Apr 2017 06:00:45 +0900 |
parents | 534601ed8c50 |
children | 8592a1d161b7 |
files | src/parallel_execution/examples/calc.cbc |
diffstat | 1 files changed, 5 insertions(+), 32 deletions(-) [+] |
line wrap: on
line diff
--- a/src/parallel_execution/examples/calc.cbc Tue Apr 18 05:53:37 2017 +0900 +++ b/src/parallel_execution/examples/calc.cbc Tue Apr 18 06:00:45 2017 +0900 @@ -6,9 +6,7 @@ #include "../../context.h" int cpu_num = 1; -int length = 102400; -int split = 8; -int* array_ptr; +int length = 100; int gpu_num = 0; int CPU_ANY = -1; int CPU_CUDA = -1; @@ -75,16 +73,14 @@ printf("cpus:\t\t%d\n", cpu_num); printf("gpus:\t\t%d\n", gpu_num); printf("length:\t\t%d\n", length); - printf("length/task:\t%d\n", length/split); /* puts("queue"); */ /* print_queue(context->data[ActiveQueue]->queue.first); */ /* puts("tree"); */ /* print_tree(context->data[Tree]->tree.root); */ /* puts("result"); */ - time->next = C_code2; - goto meta(context, C_code2); - //goto meta(context, C_exit_code); + //time->next = C_code2; + goto meta(context, C_exit_code); //goto meta(context, C_start_time); } @@ -92,26 +88,11 @@ goto code1(context, Gearef(context, Time)); } -__code code2(struct LoopCounter* loopCounter) { - int i = loopCounter->i; - - if (i < length) { - //printf("%d\n", array_ptr[i]); - if (array_ptr[i] == (i*2)) { - loopCounter->i++; - goto meta(context, C_code2); - } else - puts("wrong result"); - - } - - goto meta(context, C_exit_code); -} __code createTask1(struct LoopCounter* loopCounter, struct TaskManager* taskManager) { int i = loopCounter->i; - if (i < 1) { + if (i < length) { loopCounter->i++; taskManager->next = C_createTask2; goto meta(context, taskManager->taskManager->TaskManager.createTask); @@ -127,7 +108,7 @@ int i = loopCounter->i; task->idgCount = 1; task->next = C_mult; - integer2->value = i+1; + integer2->value = i; task->data[task->idg] = (union Data*)integer1; task->data[task->idg+1] = (union Data*)integer2; task->maxIdg = task->idg + 2; @@ -197,8 +178,6 @@ cpu_num = (int)atoi(argv[i+1]); else if (strcmp(argv[i], "-l") == 0) length = (int)atoi(argv[i+1]); - else if (strcmp(argv[i], "-s") == 0) - split = (int)atoi(argv[i+1]); else if (strcmp(argv[i], "-cuda") == 0) { gpu_num = 1; CPU_CUDA = 0; @@ -209,12 +188,6 @@ int main(int argc, char** argv) { init(argc, argv); - - array_ptr = NEWN(length, int); - - for(int i=0; i<length; i++) - array_ptr[i]=i; - struct Context* main_context = NEW(struct Context); initContext(main_context); main_context->next = C_initDataGears;