diff src/parallel_execution/generate_stub.pl @ 401:408b4aab7610

Supported par goto iterate statement for perl script
author Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
date Tue, 29 Aug 2017 21:50:57 +0900
parents 2d375c583064
children e958a409943c
line wrap: on
line diff
--- a/src/parallel_execution/generate_stub.pl	Tue Aug 29 04:29:50 2017 +0900
+++ b/src/parallel_execution/generate_stub.pl	Tue Aug 29 21:50:57 2017 +0900
@@ -416,10 +416,18 @@
                 # convert it to the parallel
                 my $prev = $1;
                 my $codeGearName = $2;
+                my $inputCount = $codeGear{$codeGearName}->{'input'};
+                my $outputCount = $codeGear{$codeGearName}->{'output'};
                 my @dataGears = split(/,\s*/, $3);
                 my $nextCodeGear = pop(@dataGears);
-                my $inputCount = $codeGear{$codeGearName}->{'input'};
-                my $outputCount = $codeGear{$codeGearName}->{'output'};
+                my $iterateCount;
+                # parse examples 'par goto(.., iterate(10), exit);'
+                if ($3 =~ /iterate\((\d*)\)/) {
+                    $iterateCount = $1;
+                    $inputCount--;
+                    # pop iterate statement
+                    pop(@dataGears);
+                }
                 if (! $inParGoto) {
                     $inParGoto = 1;
                     print $fd "${prev}struct SingleLinkedQueue* queue = &context->tasks->queue->SingleLinkedQueue;\n";
@@ -437,6 +445,10 @@
 ${prev}task->maxOdg = task->odg + $outputCount;
 EOFEOF
                 print $fd $initTask;
+                if (defined $iterateCount) {
+                    print $fd "${prev}task->iterate = 0;\n";
+                    print $fd "${prev}task->iterator = createOneDimIterator(context, $iterateCount);\n";
+                }
                 for my $i (0..$inputCount-1) {
                     print $fd "${prev}task->data[task->idg+$i] = (union Data*)@dataGears[$i];\n";
                 }