changeset 439:eab6f8cd2820

Add printArray
author Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
date Mon, 06 Nov 2017 18:36:38 +0900
parents 7679093bdd72
children 55db2a339958
files src/parallel_execution/CUDAExecutor.cbc src/parallel_execution/examples/twice/printArray.cbc
diffstat 2 files changed, 39 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/parallel_execution/CUDAExecutor.cbc	Mon Nov 06 00:11:43 2017 +0900
+++ b/src/parallel_execution/CUDAExecutor.cbc	Mon Nov 06 18:36:38 2017 +0900
@@ -41,8 +41,8 @@
     if (task->iterate) {
         struct MultiDimIterator* iterator = &task->iterator->iterator->MultiDimIterator;
         checkCudaErrors(cuLaunchKernel(task->function,
-                    iterator->x/1024, iterator->y, iterator->z,
-                    1024, 1, 1,
+                    iterator->x, iterator->y, iterator->z,
+                    1, 1, 1,
                     0, NULL, (void**)executor->kernelParams, NULL));
     } else {
         checkCudaErrors(cuLaunchKernel(task->function,
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/parallel_execution/examples/twice/printArray.cbc	Mon Nov 06 18:36:38 2017 +0900
@@ -0,0 +1,37 @@
+#include "../../../context.h"
+#include <stdio.h>
+
+__code printArray(struct Array* array, struct Time* inputTime, __code next(...)){
+    Gearef(context, Time)->time = (union Data*)inputTime;
+    Gearef(context, Time)->next = C_printArray1;
+    goto meta(context, inputTime->end);
+}
+
+__code printArray_stub(struct Context* context) {
+    goto printArray(context,
+                   &context->data[context->idg]->Array,
+                   &context->data[context->idg+1]->Time,
+                   context->next);
+}
+
+__code printArray1(struct Array* array, __code next(...), struct LoopCounter* loopCounter){
+    int i = loopCounter->i;
+    //printf("%d\n", array->array[i]);
+    if(i < GET_LEN(array->array)) {
+        if (array->array[i] == i*2) {
+            loopCounter->i++;
+            goto meta(context, C_printArray1);
+        } else {
+            printf("wrong result\n");
+        }
+    }
+   loopCounter->i = 0;
+    goto meta(context, next);
+}
+
+__code printArray1_stub(struct Context* context) {
+    goto printArray1(context,
+            &context->data[context->idg]->Array,
+            context->next,
+            Gearef(context, LoopCounter));
+}