changeset 548:4fdeb0afc187

tweak GearsExamples, generate_stubs
author anatofuz
date Fri, 11 Oct 2019 17:37:56 +0900
parents 8814524d29ae
children 05fd14d8edbe
files src/parallel_execution/CMakeLists.txt src/parallel_execution/RedBlackTree.cbc src/parallel_execution/SingleLinkedStack.cbc src/parallel_execution/context.h src/parallel_execution/examples/bitonicSort/SortArray.cbc src/parallel_execution/examples/bitonicSort/SortArray.h src/parallel_execution/examples/bitonicSort/makeArray.cbc src/parallel_execution/examples/twice/createArray.cbc src/parallel_execution/generate_stub.pl
diffstat 9 files changed, 50 insertions(+), 43 deletions(-) [+]
line wrap: on
line diff
--- a/src/parallel_execution/CMakeLists.txt	Tue Jun 26 20:16:03 2018 +0900
+++ b/src/parallel_execution/CMakeLists.txt	Fri Oct 11 17:37:56 2019 +0900
@@ -86,7 +86,7 @@
       TARGET
           CUDAtwice
       SOURCES 
-          examples/twice/main.cbc examples/twice/twice.cbc examples/twice/CUDAtwice.cu examples/twice/createArray.cbc examples/twice/printArray.cbc CPUWorker.cbc TimerImpl.cbc examples/twice/twice.cbc TaskManagerImpl.cbc SingleLinkedQueue.cbc SynchronizedQueue.cbc CUDAWorker.cbc cuda.c MultiDimIterator.cbc CUDAExecutor.cbc AtomicReference.cbc
+          examples/twice/main.cbc examples/twice/twice.cbc examples/twice/CUDAtwice.cu examples/twice/createArray.cbc examples/twice/printArray.cbc CPUWorker.cbc TimerImpl.cbc examples/twice/twice.cbc TaskManagerImpl.cbc SingleLinkedQueue.cbc SynchronizedQueue.cbc CUDAWorker.cbc cuda.c MultiDimIterator.cbc CUDAExecutor.cbc AtomicReference.cbc 
     )
     set_target_properties(CUDAtwice PROPERTIES COMPILE_FLAGS "-Wall -g -DUSE_CUDAWorker=1")
 
@@ -120,23 +120,23 @@
       test/multiDimIterator_test.cbc test/printIterator.cbc CPUWorker.cbc TaskManagerImpl.cbc SingleLinkedQueue.cbc SynchronizedQueue.cbc MultiDimIterator.cbc AtomicReference.cbc
 )
 
-GearsCommand(
-  TARGET
-      sort
-  SOURCES
-      examples/bitonicSort/sort.cbc
-)
+#GearsCommand(
+#  TARGET
+#      sort
+#  SOURCES
+#      examples/bitonicSort/sort.cbc
+#)
 
 GearsCommand(
   TARGET
       rbtree
   SOURCES
-      SingleLinkedQueue.cbc test/rbTree_test.cbc RedBlackTree.cbc SingleLinkedStack.cbc
+      SingleLinkedQueue.cbc test/rbTree_test.cbc RedBlackTree.cbc SingleLinkedStack.cbc compare.c
 )
 
-GearsCommand(
-  TARGET
-      boundedBuffer
-  SOURCES
-  examples/boundedBuffer/main.cbc examples/boundedBuffer/initBuffer.cbc examples/boundedBuffer/SemaphoreImpl.cbc examples/boundedBuffer/BoundedBuffer.cbc examples/boundedBuffer/consumer.cbc examples/boundedBuffer/producer.cbc SpinLock.cbc CPUWorker.cbc TaskManagerImpl.cbc SingleLinkedQueue.cbc SynchronizedQueue.cbc MultiDimIterator.cbc AtomicReference.cbc
-)
+#GearsCommand(
+#  TARGET
+#      boundedBuffer
+#  SOURCES
+#  examples/boundedBuffer/main.cbc examples/boundedBuffer/initBuffer.cbc examples/boundedBuffer/SemaphoreImpl.cbc examples/boundedBuffer/BoundedBuffer.cbc examples/boundedBuffer/consumer.cbc examples/boundedBuffer/producer.cbc SpinLock.cbc CPUWorker.cbc TaskManagerImpl.cbc SingleLinkedQueue.cbc SynchronizedQueue.cbc MultiDimIterator.cbc AtomicReference.cbc
+#)
--- a/src/parallel_execution/RedBlackTree.cbc	Tue Jun 26 20:16:03 2018 +0900
+++ b/src/parallel_execution/RedBlackTree.cbc	Fri Oct 11 17:37:56 2019 +0900
@@ -3,7 +3,6 @@
 #include "../context.h"
 #interface "Tree.h"
 #interface "Stack.h"
-#include "compare.c"
 
 extern enum Relational compare(struct Node* node1, struct Node* node2);
 
@@ -126,10 +125,11 @@
     struct Stack* nodeStack = tree->nodeStack;
     struct Node* uncle;
 
-    if (tree->grandparent->left == tree->parent)
+    if (tree->grandparent->left == tree->parent) {
         uncle = tree->grandparent->right;
-    else
+    } else {
         uncle = tree->grandparent->left;
+    }
 
     if (uncle && (uncle->color == Red)) {
         // do insertcase1 on grandparent, stack must be pop by two
@@ -184,10 +184,11 @@
     rotateTree->traverse = tree;
     rotateTree->next = C_stackClear;
 
-    if ((current == parent->left) && (parent == grandparent->left))
+    if ((current == parent->left) && (parent == grandparent->left)){
         goto rotateRight();
-    else
+    } else {
         goto rotateLeft();
+    }
 }
 
 __code insertCase51_stub(struct Context* context) {
@@ -308,8 +309,9 @@
         tree->current = tree->current->left;
     }
         
-    if (tree->current)
+    if (tree->current) {
         goto meta(context, C_search);
+    }
 
     goto next(...);
 }
@@ -360,8 +362,9 @@
     }
 
 
-    if (tree->parent == NULL && tmp)
+    if (tree->parent == NULL && tmp) {
         tmp->color = Black;
+    }
 
     current == tree->parent->left ? (tree->parent->left = NULL) : (tree->parent->right = NULL);
 
@@ -393,8 +396,9 @@
 __code findMax1(struct RedBlackTree* tree, struct Node* oldNode, struct Node* newNode) {
     *newNode = *oldNode;
 
-    if (newNode->right)
+    if (newNode->right) {
         goto findMax2(tree, oldNode, newNode);
+    }
     
     tree->current = newNode;
 
@@ -423,8 +427,9 @@
     
 
 __code deleteCase1(struct RedBlackTree* tree, struct Node* current) {
-    if (tree->parent)
+    if (tree->parent) {
         goto deleteCase2(tree,current);
+    }
 
     goto delete3(tree, current);
 }
--- a/src/parallel_execution/SingleLinkedStack.cbc	Tue Jun 26 20:16:03 2018 +0900
+++ b/src/parallel_execution/SingleLinkedStack.cbc	Fri Oct 11 17:37:56 2019 +0900
@@ -77,10 +77,11 @@
 
 
 __code getSingleLinkedStack(struct SingleLinkedStack* stack, __code next(union Data* data, ...)) {
-    if (stack->top)
+    if (stack->top) {
         data = stack->top->data;
-    else
+    } else {
         data = NULL;
+    }
     goto next(data, ...);
 }
 
--- a/src/parallel_execution/context.h	Tue Jun 26 20:16:03 2018 +0900
+++ b/src/parallel_execution/context.h	Fri Oct 11 17:37:56 2019 +0900
@@ -337,6 +337,7 @@
         int value;
     } Integer;
     struct SortArray {
+        union Data* sortArray;
         struct Integer *array; //Array arrayじゃできない?
         int loopCounter;
         int block;
--- a/src/parallel_execution/examples/bitonicSort/SortArray.cbc	Tue Jun 26 20:16:03 2018 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,14 +0,0 @@
-typedef struct SortArray<Impl>{
-    SortArray *sortArray;
-    Integer **array;
-    int loop_counter;
-    int loop_counter2;
-    int loop_counter3;
-    int sort_finish;
-    __code print(struct SortArray* sortArray, __code next(...));
-    __code make_array(struct SortArray* sortArray, __code next(...));
-    __code bitonic_sort(struct SortArray* sortArray, __code next(...));
-    __code kernel(struct SortArray* sortArray, __code next(...));
-    __code kernel2(struct SortArray* sortArray, __code next(...));
-    __code swap(struct SortArray* sortArray, __code next(...));
-} SortArray;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/parallel_execution/examples/bitonicSort/SortArray.h	Fri Oct 11 17:37:56 2019 +0900
@@ -0,0 +1,14 @@
+typedef struct SortArray<Impl>{
+    SortArray *sortArray;
+    Integer **array;
+    int loop_counter;
+    int loop_counter2;
+    int loop_counter3;
+    int sort_finish;
+    __code print(struct SortArray* sortArray, __code next(...));
+    __code make_array(struct SortArray* sortArray, __code next(...));
+    __code bitonic_sort(struct SortArray* sortArray, __code next(...));
+    __code kernel(struct SortArray* sortArray, __code next(...));
+    __code kernel2(struct SortArray* sortArray, __code next(...));
+    __code swap(struct SortArray* sortArray, __code next(...));
+} SortArray;
--- a/src/parallel_execution/examples/bitonicSort/makeArray.cbc	Tue Jun 26 20:16:03 2018 +0900
+++ b/src/parallel_execution/examples/bitonicSort/makeArray.cbc	Fri Oct 11 17:37:56 2019 +0900
@@ -11,7 +11,7 @@
     if (output->loopCounter == GET_LEN(output->array)){
         printf("created Array\n");
         output->loopCounter = 0;
-        goto output1->start(next(output1, ...));
+        goto output1->start(next(...));
     }
     output->array[output->loopCounter].value = rand() % 1000;
     //printf("%d\n", output->array[output->loopCounter]->value);
--- a/src/parallel_execution/examples/twice/createArray.cbc	Tue Jun 26 20:16:03 2018 +0900
+++ b/src/parallel_execution/examples/twice/createArray.cbc	Fri Oct 11 17:37:56 2019 +0900
@@ -14,7 +14,7 @@
     if (i == GET_LEN(output->array)){
         printf("created Array\n");
         loopCounter->i = 0;
-        goto output1->start(next(output, output1, ...));
+        goto output1->start(next(...));
     }
     output->array[i] = i;
     loopCounter->i++;
--- a/src/parallel_execution/generate_stub.pl	Tue Jun 26 20:16:03 2018 +0900
+++ b/src/parallel_execution/generate_stub.pl	Fri Oct 11 17:37:56 2019 +0900
@@ -248,7 +248,7 @@
                 if ($typeName eq $var{$interface}->{$ivar}) {
                     if ($output) {
                         $dataGearName{$codeGearName} .= "\t$typeName$ptrType* O_$varName = &Gearef(context, $interface)->$varName;\n";
-                        $outputVar{$codeGearName} .= "\t$typeName$ptrType $varName = *O_$varName;\n";
+                        $outputVar{$codeGearName} .= "\t$typeName$ptrType $varName  __attribute__((unused)) = *O_$varName;\n";
                         return 1;
                     }
                     $dataGearName{$codeGearName} .= "\t$typeName$ptrType $varName = Gearef(context, $interface)->$varName;\n";
@@ -447,7 +447,7 @@
                 my $next = $2;
                 my $method = $3;
                 my $tmpArgs = $4;
-                $tmpArgs =~ s/\(.*\)/\(\)/;
+                #$tmpArgs =~ s/\(.*\)/\(\)/;
                 my @args = split(/,/,$tmpArgs);
                 my @types = @{$dataGearVarType{$codeGearName}};
                 my $ntype;