diff src/parallel_execution/examples/twice/main.cbc @ 438:7679093bdd72

Work CUDAtwice
author Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
date Mon, 06 Nov 2017 00:11:43 +0900
parents 497b154141de
children ff2764cb5edb
line wrap: on
line diff
--- a/src/parallel_execution/examples/twice/main.cbc	Sat Nov 04 08:30:25 2017 +0900
+++ b/src/parallel_execution/examples/twice/main.cbc	Mon Nov 06 00:11:43 2017 +0900
@@ -66,39 +66,23 @@
     /* puts("tree"); */
     /* print_tree(context->data[Tree]->tree.root); */
     /* puts("result"); */
-    time->time = (union Data*)createTimeImpl(context);
-    time->next = C_createTask1;
-    goto meta(context, time->time->Time.start);
-}
-
-__code code2(struct Time* time, struct TaskManager* taskManager) {
-    time->next = C_code3;
-    taskManager->next = time->time->Time.end;
-    goto meta(context, taskManager->taskManager->TaskManager.shutdown);
+    goto meta(context, C_createTask1);
 }
 
-__code code3(struct LoopCounter* loopCounter) {
-    int i = loopCounter->i;
 
-    if (i < length) {
-        //printf("%d\n", array_ptr[i]);
-        if (array_ptr[i] == (i*2)) {
-            loopCounter->i++;
-            goto meta(context, C_code3);
-        } else
-            puts("wrong result");
-    }
+__code createTask1(struct LoopCounter* loopCounter, struct TaskManager* taskManager) {
+    Array* array1 = &ALLOCATE_DATA_GEAR(context, Array)->Array;
+    Array* array2 = &ALLOCATE_DATA_GEAR(context, Array)->Array;
+    Time* time = createTimeImpl(context);
 
-    goto meta(context, C_exit_code);
+    par goto createArray(array1, time, __exit);
+    par goto twice(array1, array2, iterate(split), __exit);
+    par goto printArray(array2, time, __exit);
+    goto code2();
 }
 
-__code createTask1(struct LoopCounter* loopCounter, struct TaskManager* taskManager) {
-    Array* array = &ALLOCATE_DATA_GEAR(context, Array)->Array;
-
-    par goto createArray(array, __exit);
-
-    par goto twice(array, iterate(split), __exit);
-    goto code2();
+__code code2(struct LoopCounter* loopCounter, struct TaskManager* taskManager) {
+    goto taskManager->shutdown(exit_code);
 }
 
 void init(int argc, char** argv) {
@@ -119,12 +103,6 @@
 
 int main(int argc, char** argv) {
     init(argc, argv);
-
-    array_ptr = NEWN(length, int);
-
-    for(int i=0; i<length; i++)
-        array_ptr[i]=i;
-
     struct Context* main_context = NEW(struct Context);
     initContext(main_context);
     main_context->next = C_initDataGears;