Mercurial > hg > Gears > Gears
changeset 953:a5b36ecbb86e
...
author | anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 15 Feb 2021 14:14:37 +0900 |
parents | a86e0a2b7a30 |
children | e7cff9d88e5f |
files | src/parallel_execution/CMakeLists.txt src/parallel_execution/SingleLinkedStack.cbc src/parallel_execution/examples/DPPMC/main.cbc src/parallel_execution/examples/boundedBuffer/SemaphoreImpl.cbc src/parallel_execution/generate_context.pl |
diffstat | 5 files changed, 57 insertions(+), 23 deletions(-) [+] |
line wrap: on
line diff
--- a/src/parallel_execution/CMakeLists.txt Mon Feb 08 12:43:06 2021 +0900 +++ b/src/parallel_execution/CMakeLists.txt Mon Feb 15 14:14:37 2021 +0900 @@ -2,7 +2,7 @@ set(USE_CUDA,0) # -DUSE_CUDA -# add_definitions("-Wall -g -O") +#add_definitions("-Wall -g -O") set(CMAKE_C_COMPILER $ENV{CBC_COMPILER}) add_definitions("-Wall -g") @@ -153,8 +153,8 @@ TARGET DPPMC SOURCES - CPUWorker.cbc SynchronizedQueue.cbc examples/DPPMC/AtomicTImpl.cbc SingleLinkedStack.cbc examples/DPPMC/PhilsImpl.cbc - examples/DPPMC/main.cbc examples/DPPMC/ForkImpl.cbc ModelChecking/crc32.c ModelChecking/memory.c + CPUWorker.cbc SynchronizedQueue.cbc examples/DPPMC/AtomicTImpl.cbc SingleLinkedStack.cbc examples/DPPMC/PhilsImpl.cbc + examples/DPPMC/main.cbc examples/DPPMC/ForkImpl.cbc ModelChecking/crc32.c ModelChecking/memory.c ModelChecking/state_db.c AtomicReference.cbc ModelChecking/MCWorker.cbc MCTaskManagerImpl.cbc SingleLinkedQueue.cbc ModelChecking/TaskIterator.c examples/DPPMC/McDPP.cbc )
--- a/src/parallel_execution/SingleLinkedStack.cbc Mon Feb 08 12:43:06 2021 +0900 +++ b/src/parallel_execution/SingleLinkedStack.cbc Mon Feb 15 14:14:37 2021 +0900 @@ -3,6 +3,7 @@ #impl "Stack.h" as "SingleLinkedStack.h" #data "Node.h" +#data "Element.h" void printStack1(union Data* data) {
--- a/src/parallel_execution/examples/DPPMC/main.cbc Mon Feb 08 12:43:06 2021 +0900 +++ b/src/parallel_execution/examples/DPPMC/main.cbc Mon Feb 15 14:14:37 2021 +0900 @@ -40,13 +40,13 @@ AtomicT_int* fork4 = createAtomicT_intImpl_int(context,-1); // fork4 struct MCTaskManagerImpl *mcti = (struct MCTaskManagerImpl *)context->taskManager->taskManager; - add_memory_range(&((struct AtomicT_intImpl_int*)fork0->atomicT_int)->atomic, sizeof(int), &mcti->mem); - add_memory_range(&((struct AtomicT_intImpl_int*)fork1->atomicT_int)->atomic, sizeof(int), &mcti->mem); - add_memory_range(&((struct AtomicT_intImpl_int*)fork2->atomicT_int)->atomic, sizeof(int), &mcti->mem); - add_memory_range(&((struct AtomicT_intImpl_int*)fork3->atomicT_int)->atomic, sizeof(int), &mcti->mem); - add_memory_range(&((struct AtomicT_intImpl_int*)fork4->atomicT_int)->atomic, sizeof(int), &mcti->mem); + add_memory_range(&((struct AtomicT_intImpl_int*)fork0->atomicT_int)->atomic, sizeof(int), &mcti->mem); + add_memory_range(&((struct AtomicT_intImpl_int*)fork1->atomicT_int)->atomic, sizeof(int), &mcti->mem); + add_memory_range(&((struct AtomicT_intImpl_int*)fork2->atomicT_int)->atomic, sizeof(int), &mcti->mem); + add_memory_range(&((struct AtomicT_intImpl_int*)fork3->atomicT_int)->atomic, sizeof(int), &mcti->mem); + add_memory_range(&((struct AtomicT_intImpl_int*)fork4->atomicT_int)->atomic, sizeof(int), &mcti->mem); mcti->statefunc = mcDPP; -#if 1 +#if 1 Phils* phils0 = createPhilsImpl(context,0,fork0,fork1); // phils0 Phils* phils1 = createPhilsImpl(context,1,fork1,fork2); // phils1 Phils* phils2 = createPhilsImpl(context,2,fork2,fork3); // phils2
--- a/src/parallel_execution/examples/boundedBuffer/SemaphoreImpl.cbc Mon Feb 08 12:43:06 2021 +0900 +++ b/src/parallel_execution/examples/boundedBuffer/SemaphoreImpl.cbc Mon Feb 15 14:14:37 2021 +0900 @@ -38,7 +38,7 @@ } __code pOperationSemaphoreImpl3(struct SemaphoreImpl* semaphore, struct Worker* worker, __code next(...)) { - goto worker->taskReceive(); // goto shceduler + goto worker->taskReceive(worker->tasks); // goto shceduler } __code pOperationSemaphoreImpl3_stub(struct Context* context) {
--- a/src/parallel_execution/generate_context.pl Mon Feb 08 12:43:06 2021 +0900 +++ b/src/parallel_execution/generate_context.pl Mon Feb 15 14:14:37 2021 +0900 @@ -5,6 +5,7 @@ use warnings; use FindBin; use File::Spec; +use Storable qw/dclone/; use lib "$FindBin::Bin/lib"; use Gears::Context; @@ -377,9 +378,39 @@ } keys %$tree; + if ($modify_list) { + my @repInterfaces = grep { exists $tree->{$_} } keys %{$modify_list->{replace}}; + replaceFromInterface($tree, $modify_list, @repInterfaces); + @repInterfaces = grep { exists $tree->{$_} } keys %{$modify_list->{replace}}; + replaceFromInterface($tree, $modify_list, @repInterfaces); + } + + #p $tree; + # $gears->tree2create_context_h($tree); } +sub replaceFromInterface { + my ($tree, $modify_list, @repInterfaces) = @_; + for my $repInterface (@repInterfaces) { + my $replaceTree = dclone($tree); + my $elements = delete $replaceTree->{$repInterface}; + for my $mpair (@{$modify_list->{replace}->{$repInterface}}) { + for my $replaceInterfaceName (@{$mpair->{after}}) { + my $typeV = $mpair->{typev}; + my $defType = $mpair->{defType}; + for my $elem (@{$elements->{elem}->{content}}) { + $elem =~ s/$typeV(\*?)/$defType$1/; + } + $replaceTree->{$replaceInterfaceName} = $elements; + } + + delete $modify_list->{replace}->{$repInterface}; + } + $tree = $replaceTree; + } +} + sub find_generics_each_item { my ($name, $entry, $generics, $typed_variables, $interface_name, $file_path) = @_; if (defined $entry->{generics}) { #define type @@ -576,19 +607,19 @@ if ($file =~ /\.h$/) { print STDERR "[info] $file is header\n"; unless (grep { $_ eq $replaceType } map { $_->{before} } @{$modifyList->{header}->{$file}}) { - push(@{$modifyList->{header}->{$file}}, { before => [$type], after => [$replaceType]}); + push(@{$modifyList->{header}->{$file}}, { before => [$type], after => [$replaceType], typev => $type_v, defType => $defType}); my $implName = $file_each_instances->{$file}->[0]->{impl}; unless ($implName) { print STDERR "[error] not implemented thsi case\n"; } - push(@{$modifyList->{replace}->{$implName}}, { before => [$type], after => [$replaceType]}); + push(@{$modifyList->{replace}->{$type}}, { before => [$type], after => [$replaceType], typev => $type_v, defType => $defType}); } next; } if ($impl) { if ($impl eq $replaceImpls) { #not impl - push(@{$modifyList->{cbc}->{$file}},{before => [$type], after => [$replaceType]}); + push(@{$modifyList->{cbc}->{$file}},{before => [$type], after => [$replaceType], typev => $type_v, defType => $defType}); } else { #impl #push(@{$modifyList->{cbc}->{$file}},{before => [$type, $impl], after => [$replaceType, $replaceImpls]}); push(@{$modifyList->{cbc}->{$file}}, @@ -597,8 +628,11 @@ before_impl => [$impl], after_impl => [$replaceImpls] } ); - push(@{$modifyList->{replace}->{$type}}, { before => [$type], after => [$replaceType]}); - push(@{$modifyList->{replace}->{$impl}}, { before => [$impl], after => [$replaceImpls]}); + push(@{$modifyList->{replace}->{$type}}, { + before => [$type], after => [$replaceType], + typev => $type_v, defType => $defType, + impl => [{ before => [$impl], after => [$replaceImpls], typev => $type_v, defType => $defType}] + }); } } @@ -633,14 +667,13 @@ } } - for my $file (keys %$file2cont) { - open my $fh, '>', $file; - for my $cont (@{$file2cont->{$file}}) { - print $fh $_ for @$cont; - } - close $fh; - } - #p $modifyList; + #for my $file (keys %$file2cont) { + # open my $fh, '>', $file; + # for my $cont (@{$file2cont->{$file}}) { + # print $fh $_ for @$cont; + # } + # close $fh; + #} return $modifyList; }