Mercurial > hg > GearsTemplate
changeset 580:39b5adbcd83f
fix twice example
author | anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Wed, 27 Nov 2019 18:03:12 +0900 |
parents | fe8c04001929 |
children | 62166b0e0c7e |
files | src/parallel_execution/Executor.h src/parallel_execution/examples/twice/CUDAtwice.cu src/parallel_execution/examples/twice/createArray.cbc src/parallel_execution/examples/twice/printArray.cbc src/parallel_execution/examples/twice/twice.cbc src/parallel_execution/generate_context.pl src/parallel_execution/lib/Gears/Context.pm src/parallel_execution/lib/Gears/Util.pm src/parallel_execution/plautogen/interface/Array.h |
diffstat | 9 files changed, 20 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/src/parallel_execution/Executor.h Wed Nov 27 13:13:15 2019 +0900 +++ b/src/parallel_execution/Executor.h Wed Nov 27 18:03:12 2019 +0900 @@ -5,4 +5,4 @@ __code read(Impl* executor, struct Context* task, __code next(...)); __code exec(Impl* executor, struct Context* task, __code next(...)); __code write(Impl* executor, struct Context* task, __code next(...)); -} +} Executor;
--- a/src/parallel_execution/examples/twice/CUDAtwice.cu Wed Nov 27 13:13:15 2019 +0900 +++ b/src/parallel_execution/examples/twice/CUDAtwice.cu Wed Nov 27 18:03:12 2019 +0900 @@ -9,7 +9,7 @@ int prefix = inputArray->prefix; C_twice: if (i < prefix) { - array[i+(blockIdx.x*blockDim.x+threadIdx.x)*prefix] = array[i+(blockIdx.x*blockDim.x+threadIdx.x)*prefix]*2; + array[i+(blockIdx.x*blockDim.x+threadIdx.x)*prefix]->value = array[i+(blockIdx.x*blockDim.x+threadIdx.x)*prefix]->value*2; i++; goto C_twice; }
--- a/src/parallel_execution/examples/twice/createArray.cbc Wed Nov 27 13:13:15 2019 +0900 +++ b/src/parallel_execution/examples/twice/createArray.cbc Wed Nov 27 18:03:12 2019 +0900 @@ -8,7 +8,7 @@ __code createArray(__code next(struct Array* output, struct Timer* output1, ...), struct LoopCounter* loopCounter) { int i = loopCounter->i; if (i == 0){ - output->array = (Int*)ALLOCATE_ARRAY(context, Int, length); + output->array = (Integer*)ALLOCATE_ARRAY(context, Integer, length); output->prefix = length/split; } if (i == GET_LEN(output->array)){ @@ -16,7 +16,7 @@ loopCounter->i = 0; goto output1->start(next(...)); } - output->array[i] = i; + output->array[i].value = i; loopCounter->i++; goto createArray(); }
--- a/src/parallel_execution/examples/twice/printArray.cbc Wed Nov 27 13:13:15 2019 +0900 +++ b/src/parallel_execution/examples/twice/printArray.cbc Wed Nov 27 18:03:12 2019 +0900 @@ -10,7 +10,7 @@ int i = loopCounter->i; //printf("%d\n", array->array[i]); if (i < GET_LEN(array->array)) { - if (array->array[i] == i*2) { + if (array->array[i].value == i*2) { loopCounter->i++; goto printArray1(); } else {
--- a/src/parallel_execution/examples/twice/twice.cbc Wed Nov 27 13:13:15 2019 +0900 +++ b/src/parallel_execution/examples/twice/twice.cbc Wed Nov 27 18:03:12 2019 +0900 @@ -10,7 +10,7 @@ int i = loopCounter->i; int index = multiDim->x; if (i < array->prefix) { - array->array[i+index*array->prefix] = array->array[i+index*array->prefix]*2; + array->array[i+index*array->prefix].value = array->array[i+index*array->prefix].value*2; loopCounter->i++; goto meta(context, C_twice);
--- a/src/parallel_execution/generate_context.pl Wed Nov 27 13:13:15 2019 +0900 +++ b/src/parallel_execution/generate_context.pl Wed Nov 27 18:03:12 2019 +0900 @@ -82,8 +82,8 @@ my $data_gears = $gears->extraction_dg_compile_sources(); my $g = $gears->set_data_gear_header_path(); + #use DDP {deparse =>1}; my $dg2path = $gears->update_dg_each_header_path($data_gears,$g); - my $tree = $gears->createImplTree_from_header($dg2path); $gears->tree2create_context_h($tree); }
--- a/src/parallel_execution/lib/Gears/Context.pm Wed Nov 27 13:13:15 2019 +0900 +++ b/src/parallel_execution/lib/Gears/Context.pm Wed Nov 27 18:03:12 2019 +0900 @@ -53,6 +53,12 @@ next; } + if ($line =~ /ALLOCATE_(?:PTR_)?ARRAY\(context,\s*(\w+),[\s\w]+\)/) { + my $implementation = $1; + $counter{impl}->{$implementation}++; + $self->{data_gears_with_count}->{$implementation}->{caller}->{$cbc_file}++; + next; + } #TaskManagerImpl* taskManager = (TaskManagerImpl*)GearImpl(context, TaskManager, taskManager); if ($line =~ /\((\w+)\*\)GearImpl\(context,\s*(\w+),\s*(\w+)\)/) {
--- a/src/parallel_execution/lib/Gears/Util.pm Wed Nov 27 13:13:15 2019 +0900 +++ b/src/parallel_execution/lib/Gears/Util.pm Wed Nov 27 18:03:12 2019 +0900 @@ -128,10 +128,12 @@ $context = "${space}struct $h2context->{name} {\n"; my $content_space; - my @chars = split //, $h2context->{content}->[0]; - for my $w (@chars) { - last if ($w !~ /\s/); - $content_space .= $w; + if (exists $h2context->{content}){ + my @chars = split //, $h2context->{content}->[0]; + for my $w (@chars) { + last if ($w !~ /\s/); + $content_space .= $w; + } } for my $c (@{$h2context->{content}}) {