comparison 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
comparison
equal deleted inserted replaced
437:2c1b1d56bf1e 438:7679093bdd72
64 /* puts("queue"); */ 64 /* puts("queue"); */
65 /* print_queue(context->data[ActiveQueue]->queue.first); */ 65 /* print_queue(context->data[ActiveQueue]->queue.first); */
66 /* puts("tree"); */ 66 /* puts("tree"); */
67 /* print_tree(context->data[Tree]->tree.root); */ 67 /* print_tree(context->data[Tree]->tree.root); */
68 /* puts("result"); */ 68 /* puts("result"); */
69 time->time = (union Data*)createTimeImpl(context); 69 goto meta(context, C_createTask1);
70 time->next = C_createTask1;
71 goto meta(context, time->time->Time.start);
72 } 70 }
73 71
74 __code code2(struct Time* time, struct TaskManager* taskManager) { 72
75 time->next = C_code3; 73 __code createTask1(struct LoopCounter* loopCounter, struct TaskManager* taskManager) {
76 taskManager->next = time->time->Time.end; 74 Array* array1 = &ALLOCATE_DATA_GEAR(context, Array)->Array;
77 goto meta(context, taskManager->taskManager->TaskManager.shutdown); 75 Array* array2 = &ALLOCATE_DATA_GEAR(context, Array)->Array;
76 Time* time = createTimeImpl(context);
77
78 par goto createArray(array1, time, __exit);
79 par goto twice(array1, array2, iterate(split), __exit);
80 par goto printArray(array2, time, __exit);
81 goto code2();
78 } 82 }
79 83
80 __code code3(struct LoopCounter* loopCounter) { 84 __code code2(struct LoopCounter* loopCounter, struct TaskManager* taskManager) {
81 int i = loopCounter->i; 85 goto taskManager->shutdown(exit_code);
82
83 if (i < length) {
84 //printf("%d\n", array_ptr[i]);
85 if (array_ptr[i] == (i*2)) {
86 loopCounter->i++;
87 goto meta(context, C_code3);
88 } else
89 puts("wrong result");
90 }
91
92 goto meta(context, C_exit_code);
93 }
94
95 __code createTask1(struct LoopCounter* loopCounter, struct TaskManager* taskManager) {
96 Array* array = &ALLOCATE_DATA_GEAR(context, Array)->Array;
97
98 par goto createArray(array, __exit);
99
100 par goto twice(array, iterate(split), __exit);
101 goto code2();
102 } 86 }
103 87
104 void init(int argc, char** argv) { 88 void init(int argc, char** argv) {
105 for (int i = 1; argv[i]; ++i) { 89 for (int i = 1; argv[i]; ++i) {
106 if (strcmp(argv[i], "-cpu") == 0) 90 if (strcmp(argv[i], "-cpu") == 0)
117 } 101 }
118 102
119 103
120 int main(int argc, char** argv) { 104 int main(int argc, char** argv) {
121 init(argc, argv); 105 init(argc, argv);
122
123 array_ptr = NEWN(length, int);
124
125 for(int i=0; i<length; i++)
126 array_ptr[i]=i;
127
128 struct Context* main_context = NEW(struct Context); 106 struct Context* main_context = NEW(struct Context);
129 initContext(main_context); 107 initContext(main_context);
130 main_context->next = C_initDataGears; 108 main_context->next = C_initDataGears;
131 109
132 goto start_code(main_context); 110 goto start_code(main_context);