diff src/parallel_execution/generate_stub.pl @ 404:c5cd9888bf2a

Fix bitonicSort
author Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
date Sun, 03 Sep 2017 00:21:16 +0900
parents 83c9aeb1fe3e
children 9b35e6581b5c
line wrap: on
line diff
--- a/src/parallel_execution/generate_stub.pl	Fri Sep 01 06:41:02 2017 +0900
+++ b/src/parallel_execution/generate_stub.pl	Sun Sep 03 00:21:16 2017 +0900
@@ -178,15 +178,14 @@
             while($args) {
                 if ($args =~ s/(^\s*,\s*)//) {
                 }
-                if ($args =~ s/^(\s)*\_\_code\s+(\w+)\(//) {
+                if ($args =~ s/^(\s)*\_\_code\s+(\w+)\((.*?)\)//) {
                     $inputIncFlag = 0;
+                    $outputCount = split(/,/,$3);
+                    $outputCount--;
                 } elsif ($args =~ s/^(struct|union) (\w+)(\*)+\s(\w+)//) {
                     if($inputIncFlag) {
                         $inputCount++;
                     }
-                    else {
-                        $outputCount++;
-                    }
                 } elsif ($args =~ s/(.*,)//) {
                 } else {
                     last;
@@ -435,25 +434,25 @@
                     print $fd "${prev}struct Context* task;\n";
                 }
                 my $initTask = << "EOFEOF";
-${prev}task = NEW(struct Context);
-${prev}initContext(task);
-${prev}task->next = C_$codeGearName;
-${prev}task->idgCount = $inputCount;
-${prev}task->idg = task->dataNum;
-${prev}task->maxIdg = task->idg + $inputCount;
-${prev}task->odg = task->maxIdg;
-${prev}task->maxOdg = task->odg + $outputCount;
+                ${prev}task = NEW(struct Context);
+                ${prev}initContext(task);
+                ${prev}task->next = C_$codeGearName;
+                ${prev}task->idgCount = $inputCount;
+                ${prev}task->idg = task->dataNum;
+                ${prev}task->maxIdg = task->idg + $inputCount;
+                ${prev}task->odg = task->maxIdg;
+                ${prev}task->maxOdg = task->odg + $outputCount;
 EOFEOF
                 print $fd $initTask;
                 if (@iterateCounts) {
                     print $fd "${prev}task->iterate = 0;\n";
                     my $len = @iterateCounts;
                     if ($len == 1) {
-                      print $fd "${prev}task->iterator = createMultiDimIterator(context, $iterateCounts[0], 1, 1);\n";
+                        print $fd "${prev}task->iterator = createMultiDimIterator(context, $iterateCounts[0], 1, 1);\n";
                     } elsif ($len == 2) {
-                      print $fd "${prev}task->iterator = createMultiDimIterator(context, $iterateCounts[0], $iterateCounts[1], 1);\n";
+                        print $fd "${prev}task->iterator = createMultiDimIterator(context, $iterateCounts[0], $iterateCounts[1], 1);\n";
                     } elsif ($len == 3) {
-                      print $fd "${prev}task->iterator = createMultiDimIterator(context, $iterateCounts[0], $iterateCounts[1], $iterateCounts[2]);\n";
+                        print $fd "${prev}task->iterator = createMultiDimIterator(context, $iterateCounts[0], $iterateCounts[1], $iterateCounts[2]);\n";
                     }
                 }
                 for my $i (0..$inputCount-1) {
@@ -464,11 +463,11 @@
                     print $fd "${prev}task->data[task->odg+$i] = (union Data*)@dataGears[$inputCount+$i];\n";
                 }
                 my $putTask = << "EOFEOF";
-${prev}element = &ALLOCATE(context, Element)->Element;
-${prev}element->next = NULL;
-${prev}element->data = (union Data*)task;
-${prev}queue->last->next  = element;
-${prev}queue->last = element;
+                ${prev}element = &ALLOCATE(context, Element)->Element;
+                ${prev}element->next = NULL;
+                ${prev}element->data = (union Data*)task;
+                ${prev}queue->last->next  = element;
+                ${prev}queue->last = element;
 EOFEOF
                 print $fd $putTask;
                 next;