comparison src/parallel_execution/generate_stub.pl @ 403:83c9aeb1fe3e

Generate MultiDimIterator by perl script
author Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
date Fri, 01 Sep 2017 06:41:02 +0900
parents e958a409943c
children c5cd9888bf2a
comparison
equal deleted inserted replaced
402:e958a409943c 403:83c9aeb1fe3e
418 my $codeGearName = $2; 418 my $codeGearName = $2;
419 my $inputCount = $codeGear{$codeGearName}->{'input'}; 419 my $inputCount = $codeGear{$codeGearName}->{'input'};
420 my $outputCount = $codeGear{$codeGearName}->{'output'}; 420 my $outputCount = $codeGear{$codeGearName}->{'output'};
421 my @dataGears = split(/,\s*/, $3); 421 my @dataGears = split(/,\s*/, $3);
422 my $nextCodeGear = pop(@dataGears); 422 my $nextCodeGear = pop(@dataGears);
423 my $iterateCounts; 423 my @iterateCounts;
424 # parse examples 'par goto(.., iterate(10), exit);' 424 # parse examples 'par goto(.., iterate(10), exit);'
425 if ($3 =~ /iterate\((.*)?\)/) { 425 if ($3 =~ /iterate\((.*)?\)/) {
426 $iterateCounts = $1; 426 @iterateCounts = split(/,/,$1);;
427 $inputCount--; 427 $inputCount--;
428 # pop iterate statement 428 # pop iterate statement
429 pop(@dataGears); 429 pop(@dataGears);
430 } 430 }
431 if (! $inParGoto) { 431 if (! $inParGoto) {
443 ${prev}task->maxIdg = task->idg + $inputCount; 443 ${prev}task->maxIdg = task->idg + $inputCount;
444 ${prev}task->odg = task->maxIdg; 444 ${prev}task->odg = task->maxIdg;
445 ${prev}task->maxOdg = task->odg + $outputCount; 445 ${prev}task->maxOdg = task->odg + $outputCount;
446 EOFEOF 446 EOFEOF
447 print $fd $initTask; 447 print $fd $initTask;
448 if (defined $iterateCounts) { 448 if (@iterateCounts) {
449 print $fd "${prev}task->iterate = 0;\n"; 449 print $fd "${prev}task->iterate = 0;\n";
450 print $fd "${prev}task->iterator = createMultiDimIterator(context, $iterateCounts);\n"; 450 my $len = @iterateCounts;
451 if ($len == 1) {
452 print $fd "${prev}task->iterator = createMultiDimIterator(context, $iterateCounts[0], 1, 1);\n";
453 } elsif ($len == 2) {
454 print $fd "${prev}task->iterator = createMultiDimIterator(context, $iterateCounts[0], $iterateCounts[1], 1);\n";
455 } elsif ($len == 3) {
456 print $fd "${prev}task->iterator = createMultiDimIterator(context, $iterateCounts[0], $iterateCounts[1], $iterateCounts[2]);\n";
457 }
451 } 458 }
452 for my $i (0..$inputCount-1) { 459 for my $i (0..$inputCount-1) {
453 print $fd "${prev}task->data[task->idg+$i] = (union Data*)@dataGears[$i];\n"; 460 print $fd "${prev}task->data[task->idg+$i] = (union Data*)@dataGears[$i];\n";
454 } 461 }
455 462