Mercurial > hg > GearsTemplate
changeset 260:6b5444bbea8a
generated stub no comiple errors
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Sat, 28 Jan 2017 15:46:33 +0900 |
parents | 195518ab62fc |
children | 0cd43e22aee1 |
files | src/parallel_execution/SingleLinkedStack.cbc src/parallel_execution/generate_stub.pl src/parallel_execution/worker.c |
diffstat | 3 files changed, 50 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/src/parallel_execution/SingleLinkedStack.cbc Sat Jan 28 12:37:22 2017 +0900 +++ b/src/parallel_execution/SingleLinkedStack.cbc Sat Jan 28 15:46:33 2017 +0900 @@ -94,7 +94,7 @@ } } else { data = NULL; - data1 = NUll; + data1 = NULL; } goto next(data, data1, ...); }
--- a/src/parallel_execution/generate_stub.pl Sat Jan 28 12:37:22 2017 +0900 +++ b/src/parallel_execution/generate_stub.pl Sat Jan 28 15:46:33 2017 +0900 @@ -34,6 +34,8 @@ my %var; my %code; my %dataGearVar; +my %outputVar; # output var initializer +my %outputArgs; # continuation's output variables my %dataGear; my %dataGearName; my $implementation; @@ -85,24 +87,39 @@ } sub generateStubArgs { - my($codeGearName, $varName, $typeName, $typeField, $interface) = @_; - push @{$dataGearVar{$codeGearName}},$varName; - if ($typeField ne $varName) { + my($codeGearName, $varName, $typeName, $typeField, $interface,$output) = @_; + my $varname1 = $output?"O_$varName":$varName; + for my $n ( @{$dataGearVar{$codeGearName}} ) { + # we already have it + return 0 if ( $n eq $varname1); + } + push @{$dataGearVar{$codeGearName}}, $varname1; + if ($typeName eq $implementation) { + # get implementation $dataGearName{$codeGearName} .= "\t$typeName* $varName = ($typeName*)GearImpl(context, $interface, $varName);\n"; } else { for my $ivar (keys %{$var{$interface}}) { + # input data gear field if ($varName eq $ivar) { + if ($output) { + $dataGearName{$codeGearName} .= "\t$typeName** O_$varName = &Gearef(context, $interface)->$varName;\n"; + $outputVar{$codeGearName} .= "\t$typeName* $varName;\n"; + return 1; + } $dataGearName{$codeGearName} .= "\t$typeName* $varName = Gearef(context, $interface)->$varName;\n"; - return; + return 1; } } for my $cName (keys %{$code{$interface}}) { if ($varName eq $cName) { + # continuation field $dataGearName{$codeGearName} .= "\tenum Code $varName = Gearef(context, $interface)->$varName;\n"; - return; + return 1; } } + # global variable case $dataGearName{$codeGearName} .= "\t$typeName* $varName = Gearef(context, $typeName)->$typeField;\n"; + return 1; } } @@ -158,33 +175,40 @@ } $prevCodeGearName = $codeGearName; $dataGearVar{$codeGearName} = []; + $outputVar{$codeGearName} = ""; + $outputArgs{$codeGearName} = {}; my $newArgs = "struct Context *context,"; while($args) { if ($args =~ s/(^\s*,\s*)//) { $newArgs .= $1; } # replace __code next - if ($args =~ s/^\_\_code\s(\w+)\([^)]*\)//) { + if ($args =~ s/^\_\_code\s+(\w+)\(([^)]*)\)//) { my $next = $1; my @args = split(/,/,$2); - $newArgs .= "enum Code $next"; + if ( &generateStubArgs($codeGearName, $next, "Code", $next, $interface,0) ) { + $newArgs .= "enum Code $next"; + } for my $arg (@args) { $arg =~ s/^\s*//; + last if ($arg =~ /\.\.\./); $arg =~ s/^(struct|union) (\w+)(\*)+\s(\w+)//; my $structType = $1; my $typeName = $2; my $varName = $4; my $typeField = lcfirst($typeName); - &generateStubArgs($codeGearName, $varName, $typeName, $typeField, $interface); + push(@{$outputArgs{$codeGearName}->{$next}}, $varName); + if (&generateStubArgs($codeGearName, $varName, $typeName, $typeField, $interface,1)) { + $newArgs .= ",$structType $typeName **O_$varName"; + } } - &generateStubArgs($codeGearName, $next, "Code", $next, $interface); } elsif ($args =~ s/^(struct|union) (\w+)(\*)+\s(\w+)//) { my $structType = $1; my $typeName = $2; my $varName = $4; my $typeField = lcfirst($typeName); - $newArgs .= $&; - &generateStubArgs($codeGearName, $varName, $typeName, $typeField, $interface); + $newArgs .= $&; # assuming no duplicate + &generateStubArgs($codeGearName, $varName, $typeName, $typeField, $interface,0); } elsif ($args =~ s/(.*,)//) { $newArgs .= $1; } else { @@ -198,11 +222,21 @@ } $dataGearName{$codeGearName} .= ");"; print $fd "__code $codeGearName($newArgs)$tail\n"; + if ($outputVar{$codeGearName} ne "") { + print $fd $outputVar{$codeGearName}; + } next; - } elsif (/^(.*)goto next\(\.\.\.(.*)\);/) { + } elsif (/^(.*)goto (\w+)\((.*)\);/) { my $prev = $1; - my $args = $2; - print $fd "${prev}goto meta(context, next);\n"; + my $next = $2; + my @args = split(/,/,$3); + # write continuation's arguments + # we may need a commit for a shared DataGear + for my $arg ( @{$outputArgs{$codeGearName}->{$next}} ) { + my $v = shift(@args); + print $fd "\t*O_$arg = $v;\n"; + } + print $fd "${prev}goto meta(context, $next);\n"; next; } else { s/new\s+(\w+)\(\)/\&ALLOCATE(context, \1)->\1/g; # replacing new
--- a/src/parallel_execution/worker.c Sat Jan 28 12:37:22 2017 +0900 +++ b/src/parallel_execution/worker.c Sat Jan 28 15:46:33 2017 +0900 @@ -47,7 +47,7 @@ __code getTask_stub(struct Context* context) { Worker* worker = &Gearef(context,Worker)->worker->Worker; - struct Context* task = &Gearef(context, Queue)->data->context; + struct Context* task = &Gearef(context, Queue)->data->Context; goto getTask(context, worker, task); }