Mercurial > hg > Gears > Gears
changeset 946:c84684fdeaf5
generics
author | anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 05 Feb 2021 23:22:25 +0900 |
parents | 3c0f1139e464 |
children | 6044521fdf2a |
files | src/parallel_execution/examples/DPP/PhilsImpl.cbc src/parallel_execution/generate_context.pl |
diffstat | 2 files changed, 23 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/src/parallel_execution/examples/DPP/PhilsImpl.cbc Fri Feb 05 17:42:29 2021 +0900 +++ b/src/parallel_execution/examples/DPP/PhilsImpl.cbc Fri Feb 05 23:22:25 2021 +0900 @@ -15,19 +15,19 @@ // } PhilsImpl; // ---- -Phils* createPhilsImpl(struct Context *context, int id, AtomicT<int> right, AtomicT<int> left) { +Phils* createPhilsImpl(struct Context *context, int id, AtomicT<int>* right, AtomicT<int>* left) { struct Phils* phils = new Phils(); struct PhilsImpl* phils_impl = new PhilsImpl(); phils->phils = (union Data *)phils_impl; phils_impl->Leftfork = left; phils_impl->Rightfork = right; phils_impl->self = id; - phils->putdown_lfork = C_putdown_lfork_PhilsImpl; - phils->putdown_rfork = C_putdown_rfork_PhilsImpl; - phils->eating = C_eating_PhilsImpl; - phils->pickup_rfork = C_pickup_rfork_PhilsImpl; - phils->pickup_lfork = C_pickup_lfork_PhilsImpl; - phils->thinking = C_thinking_PhilsImpl; + phils->putdown_lfork = C_putdown_lforkPhilsImpl; + phils->putdown_rfork = C_putdown_rforkPhilsImpl; + phils->eating = C_eatingPhilsImpl; + phils->pickup_rfork = C_pickup_rforkPhilsImpl; + phils->pickup_lfork = C_pickup_lforkPhilsImpl; + phils->thinking = C_thinkingPhilsImpl; return phils; } @@ -48,7 +48,7 @@ __code pickup_rfork(struct PhilsImpl* phils, __code next(...)) { struct AtomicT<int>* right_fork = phils->Rightfork; - goto right_fork->checkAndSet(-1, phils->self, pickup_lfork, pickup_rfork) + goto right_fork->checkAndSet(-1, phils->self, pickup_lfork, pickup_rfork); } __code pickup_lfork(struct PhilsImpl* phils, __code next(...)) {
--- a/src/parallel_execution/generate_context.pl Fri Feb 05 17:42:29 2021 +0900 +++ b/src/parallel_execution/generate_context.pl Fri Feb 05 23:22:25 2021 +0900 @@ -535,7 +535,6 @@ my @types = keys %{{ map { $_->{in_type_name} => 1 } @{$file_each_instances->{$file}} }}; my @impls = keys %{{ map { $_->{impl} => 1 } grep { exists $_->{impl} } @{$file_each_instances->{$file}} }}; - if ( (scalar(@types) != 1) && (scalar(@types) != scalar(@impls))) { print STDERR "[INFO] TODO! this cae not implemention \n"; exit 0; @@ -604,6 +603,7 @@ } my @cbc_cont; + my $instance = lcfirst($type); open my $fh, '<', $file; while (my $line = <$fh> ){ @@ -611,7 +611,12 @@ if ($repimpl) { $line =~ s/${targetImpl}(<.*?>)?/$replaceImpls/g; } - $line =~ s/${type_v}([\s\*])/$defType$1/; + if ($line =~ /^\s*${type_v}([\s\*])/) { + $line =~ s/${type_v}([\s\*])/$defType$1/; + } + if ($line =~ /$instance/) { + $line =~ s/$instance/lcfirst($replaceType)/e; + } push(@cbc_cont, $line); } close $fh; @@ -628,14 +633,14 @@ } } - #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; + } + #p $modifyList; return $modifyList; }