Mercurial > hg > Members > Moririn
changeset 406:9b35e6581b5c
Use task member of context by par goto meta
Use task member of context for par goto meta
ate_stub.pl
author | Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Wed, 06 Sep 2017 15:11:27 +0900 |
parents | 8915fce522b3 |
children | 00d9b0664bdb |
files | src/parallel_execution/context.h src/parallel_execution/examples/twice/twice.cbc src/parallel_execution/generate_context.pl src/parallel_execution/generate_stub.pl |
diffstat | 4 files changed, 43 insertions(+), 49 deletions(-) [+] |
line wrap: on
line diff
--- a/src/parallel_execution/context.h Tue Sep 05 16:46:31 2017 +0900 +++ b/src/parallel_execution/context.h Wed Sep 06 15:11:27 2017 +0900 @@ -97,6 +97,7 @@ int odg; int maxOdg; int workerId; + struct Context* task; struct Queue* tasks; #ifdef USE_CUDAWorker int num_exec;
--- a/src/parallel_execution/examples/twice/twice.cbc Tue Sep 05 16:46:31 2017 +0900 +++ b/src/parallel_execution/examples/twice/twice.cbc Wed Sep 06 15:11:27 2017 +0900 @@ -2,7 +2,7 @@ #include "../context.h" -__code twice(struct Array* array, __code next(...), struct LoopCounter loopCounter) { +__code twice(struct Array* array, struct Dim* dim, __code next(...), struct LoopCounter loopCounter) { int i = loopCounter->i; if (i < prefix) { array[i+index*prefix] = array[i+index*prefix]*2; @@ -17,10 +17,7 @@ __code twice_stub(struct Context* context) { struct LoopCounter* loopCounter = &context->data[context->dataNum]->LoopCounter; - struct Array* array = &context->data[context->dataNum+1]->Array; goto twice(context, - loopCounter, - array->index, - array->prefix, - array->array); + &context->data[context->idgCount]->Array, + loopCounter); }
--- a/src/parallel_execution/generate_context.pl Tue Sep 05 16:46:31 2017 +0900 +++ b/src/parallel_execution/generate_context.pl Wed Sep 06 15:11:27 2017 +0900 @@ -164,16 +164,13 @@ print $fd $context_c; my $meta_call = <<"EOFEOF"; -__code par_meta(struct Context* context, enum Code spawns, enum Code next) { - Gearef(context, Queue)->queue = (union Data*)context->tasks; - Gearef(context, Queue)->whenEmpty = next; - Gearef(context, Queue)->next = spawns; - goto (context->code[context->tasks->isEmpty])(context); -} - __code meta(struct Context* context, enum Code next) { // printf("meta %d\\n",next); - goto (context->code[next])(context); + if (context->task == NULL) { + goto (context->code[next])(context); + } + context->task = NULL; + goto (context->code[Gearef(context, TaskManager)->taskManager->TaskManager.spawnTasks])(context); } __code start_code(struct Context* context) { @@ -198,25 +195,25 @@ // end context_c EOFEOF - print $fd $meta_call; +print $fd $meta_call; + +open my $fd,">","$ddir/enumData.h" or die("can't open $ddir/enumData.h $!"); +print $fd "enum DataType {\n"; +print $fd " D_Code,\n"; +for my $data ( sort keys %dataGear ) { + print $fd " D_${data},\n"; +} +print $fd "};\n\n"; - open my $fd,">","$ddir/enumData.h" or die("can't open $ddir/enumData.h $!"); - print $fd "enum DataType {\n"; - print $fd " D_Code,\n"; - for my $data ( sort keys %dataGear ) { - print $fd " D_${data},\n"; - } - print $fd "};\n\n"; - - open my $fd,">","$ddir/typedefData.h" or die("can't open $ddir/typedefData.h $!"); - for my $data ( sort keys %dataGear ) { - print $fd "typedef struct ${data} ${data};\n"; - } +open my $fd,">","$ddir/typedefData.h" or die("can't open $ddir/typedefData.h $!"); +for my $data ( sort keys %dataGear ) { + print $fd "typedef struct ${data} ${data};\n"; +} - open my $fd,">","$ddir/dataGearInit.c" or die("can't open $ddir/dataGearInit.c $!"); - for my $data ( sort keys %dataGear ) { - print $fd " ALLOC_DATA(context, ${data});\n"; - } +open my $fd,">","$ddir/dataGearInit.c" or die("can't open $ddir/dataGearInit.c $!"); +for my $data ( sort keys %dataGear ) { + print $fd " ALLOC_DATA(context, ${data});\n"; +} } # end
--- a/src/parallel_execution/generate_stub.pl Tue Sep 05 16:46:31 2017 +0900 +++ b/src/parallel_execution/generate_stub.pl Wed Sep 06 15:11:27 2017 +0900 @@ -431,41 +431,40 @@ $inParGoto = 1; print $fd "${prev}struct SingleLinkedQueue* queue = &context->tasks->queue->SingleLinkedQueue;\n"; print $fd "${prev}struct Element* element;\n"; - print $fd "${prev}struct Context* task;\n"; } my $initTask = << "EOFEOF"; - ${prev}task = NEW(struct Context); - ${prev}initContext(task); - ${prev}task->next = C_$codeGearName; - ${prev}task->idgCount = $inputCount; - ${prev}task->idg = task->dataNum; - ${prev}task->maxIdg = task->idg + $inputCount; - ${prev}task->odg = task->maxIdg; - ${prev}task->maxOdg = task->odg + $outputCount; + ${prev}context->task = NEW(struct Context); + ${prev}initContext(context->task); + ${prev}context->task->next = C_$codeGearName; + ${prev}context->task->idgCount = $inputCount; + ${prev}context->task->idg = context->task->dataNum; + ${prev}context->task->maxIdg = context->task->idg + $inputCount; + ${prev}context->task->odg = context->task->maxIdg; + ${prev}context->task->maxOdg = context->task->odg + $outputCount; EOFEOF print $fd $initTask; if (@iterateCounts) { - print $fd "${prev}task->iterate = 0;\n"; + print $fd "${prev}context->task->iterate = 0;\n"; my $len = @iterateCounts; if ($len == 1) { - print $fd "${prev}task->iterator = createMultiDimIterator(context, $iterateCounts[0], 1, 1);\n"; + print $fd "${prev}context->task->iterator = createMultiDimIterator(context, $iterateCounts[0], 1, 1);\n"; } elsif ($len == 2) { - print $fd "${prev}task->iterator = createMultiDimIterator(context, $iterateCounts[0], $iterateCounts[1], 1);\n"; + print $fd "${prev}context->task->iterator = createMultiDimIterator(context, $iterateCounts[0], $iterateCounts[1], 1);\n"; } elsif ($len == 3) { - print $fd "${prev}task->iterator = createMultiDimIterator(context, $iterateCounts[0], $iterateCounts[1], $iterateCounts[2]);\n"; + print $fd "${prev}context->task->iterator = createMultiDimIterator(context, $iterateCounts[0], $iterateCounts[1], $iterateCounts[2]);\n"; } } for my $i (0..$inputCount-1) { - print $fd "${prev}task->data[task->idg+$i] = (union Data*)@dataGears[$i];\n"; + print $fd "${prev}context->task->data[context->task->idg+$i] = (union Data*)@dataGears[$i];\n"; } for my $i (0..$outputCount-1) { - print $fd "${prev}task->data[task->odg+$i] = (union Data*)@dataGears[$inputCount+$i];\n"; + print $fd "${prev}context->task->data[context->task->odg+$i] = (union Data*)@dataGears[$inputCount+$i];\n"; } my $putTask = << "EOFEOF"; ${prev}element = &ALLOCATE(context, Element)->Element; ${prev}element->next = NULL; - ${prev}element->data = (union Data*)task; + ${prev}element->data = (union Data*)context->task; ${prev}queue->last->next = element; ${prev}queue->last = element; EOFEOF @@ -492,7 +491,7 @@ if ($inParGoto) { print $fd "${prev}taskManager->tasks = context->tasks;\n"; print $fd "${prev}taskManager->next1 = C_$next;\n"; - print $fd "${prev}goto par_meta(context, Gearef(context, TaskManager)->taskManager->TaskManager.spawnTasks, C_$next);\n"; + print $fd "${prev}goto meta(context, C_$next);\n"; } else { print $fd "${prev}goto meta(context, $next);\n"; } @@ -501,7 +500,7 @@ if ($inParGoto) { print $fd "${prev}taskManager->tasks = context->tasks;\n"; print $fd "${prev}taskManager->next1 = C_$next;\n"; - print $fd "${prev}goto par_meta(context, Gearef(context, TaskManager)->taskManager->TaskManager.spawnTasks, C_$next);\n"; + print $fd "${prev}goto meta(context, C_$next);\n"; next; } } elsif(/^}/) {