annotate src/parallel_execution/examples/calc/calc.cbc @ 381:b81492c74d2b

Create examples directory
author Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
date Mon, 24 Jul 2017 16:52:09 +0900
parents src/parallel_execution/examples/calc.cbc@9049c19036fd
children bba401f93dcd
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
326
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 #include <stdio.h>
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2 #include <string.h>
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
3 #include <stdlib.h>
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
4 #include <unistd.h>
330
a258505bf9fd Add assert calc examples
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 328
diff changeset
5 #include <assert.h>
326
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
6
381
b81492c74d2b Create examples directory
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 378
diff changeset
7 #include "../../../context.h"
326
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
8
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
9 int cpu_num = 1;
328
48c2b5bcab79 Fix calc example
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 327
diff changeset
10 int length = 100;
326
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
11 int gpu_num = 0;
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
12 int CPU_ANY = -1;
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
13 int CPU_CUDA = -1;
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
14
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
15 void print_queue(struct Element* element) {
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
16 while (element) {
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
17 printf("%p\n", ((struct Task *)(element->data)));
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
18 element = element->next;
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
19 }
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
20 }
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
21
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
22 void print_tree(struct Node* node) {
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
23 if (node != 0) {
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
24 printf("%d\n", node->value->Array.index);
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
25 print_tree(node->left);
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
26 print_tree(node->right);
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
27 }
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
28 }
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
29
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
30 void *start_taskManager(struct Context *context) {
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
31 goto initDataGears(context, Gearef(context, LoopCounter), Gearef(context, TaskManager));
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
32 return 0;
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
33 }
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
34
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
35 #ifdef USE_CUDAWorker
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
36 #ifdef USE_CUDA_MAIN_THREAD
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
37 extern volatile int cuda_initialized;
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
38 #endif
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
39 #endif
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
40
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
41 __code initDataGears(struct LoopCounter* loopCounter, struct TaskManager* taskManager) {
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
42 // loopCounter->tree = createRedBlackTree(context);
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
43 loopCounter->i = 0;
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
44 taskManager->taskManager = (union Data*)createTaskManagerImpl(context, cpu_num, gpu_num, 0);
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
45 #ifdef USE_CUDAWorker
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
46 #ifdef USE_CUDA_MAIN_THREAD
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
47 while(! cuda_initialized) {};
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
48 #endif
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
49 #endif
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
50 goto meta(context, C_createTask1);
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
51 }
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
52
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
53 __code initDataGears_stub(struct Context* context) {
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
54 struct TaskManager* taskManager = Gearef(context, TaskManager);
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
55 taskManager->taskManager = 0;
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
56 #if (! defined(USE_CUDAWorker) || ! defined(USE_CUDA_MAIN_THREAD))
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
57 struct LoopCounter* loopCounter = Gearef(context, LoopCounter);
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
58 goto initDataGears(context, loopCounter, taskManager);
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
59 #else
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
60 cuda_initialized = 0;
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
61 pthread_t thread;
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
62 pthread_create(&thread, NULL, (void*)&start_taskManager, context);
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
63 while (taskManager->taskManager == 0);
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
64 TaskManager *t = (TaskManager*)taskManager->taskManager;
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
65 TaskManagerImpl *im = (TaskManagerImpl*)t->taskManager;
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
66 struct Queue *q = (Queue *)im->workers[0];
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
67 createCUDAWorker(context,0,q, im);
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
68 pthread_join(thread,0);
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
69 exit(0);
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
70 #endif
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
71 }
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
72
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
73 __code code1(struct Time* time) {
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
74 printf("cpus:\t\t%d\n", cpu_num);
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
75 printf("gpus:\t\t%d\n", gpu_num);
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
76 printf("length:\t\t%d\n", length);
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
77 /* puts("queue"); */
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
78 /* print_queue(context->data[ActiveQueue]->queue.first); */
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
79 /* puts("tree"); */
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
80 /* print_tree(context->data[Tree]->tree.root); */
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
81 /* puts("result"); */
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
82
328
48c2b5bcab79 Fix calc example
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 327
diff changeset
83 //time->next = C_code2;
48c2b5bcab79 Fix calc example
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 327
diff changeset
84 goto meta(context, C_exit_code);
326
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
85 //goto meta(context, C_start_time);
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
86 }
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
87
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
88 __code code1_stub(struct Context* context) {
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
89 goto code1(context, Gearef(context, Time));
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
90 }
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
91
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
92
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
93 __code createTask1(struct LoopCounter* loopCounter, struct TaskManager* taskManager) {
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
94 int i = loopCounter->i;
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
95
328
48c2b5bcab79 Fix calc example
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 327
diff changeset
96 if (i < length) {
327
534601ed8c50 Running dependency example for single thread and single task
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 326
diff changeset
97 loopCounter->i++;
346
9f8a87389b68 Add Mult.cbc
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 345
diff changeset
98 goto meta(context, C_createTask2);
326
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
99 }
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
100
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
101 loopCounter->i = 0;
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
102 taskManager->next = C_code1;
353
b07078bd1f2c Add spawn Tasks to TaskManagerImpl
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 352
diff changeset
103 sleep(5);
326
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
104 goto meta(context, taskManager->taskManager->TaskManager.shutdown);
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
105 }
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
106
352
3e01e963eb2d Fix compile error for calc example but not work
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 349
diff changeset
107 __code createTask2(struct LoopCounter* loopCounter, struct TaskManager* taskManager) {
353
b07078bd1f2c Add spawn Tasks to TaskManagerImpl
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 352
diff changeset
108 struct Context** tasks = (struct Context**)ALLOC_ARRAY(context, Context, 3);
352
3e01e963eb2d Fix compile error for calc example but not work
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 349
diff changeset
109
3e01e963eb2d Fix compile error for calc example but not work
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 349
diff changeset
110 Integer* integer1 = &ALLOCATE_DATA_GEAR(context, Integer)->Integer;
3e01e963eb2d Fix compile error for calc example but not work
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 349
diff changeset
111 Integer* integer2 = &ALLOCATE_DATA_GEAR(context, Integer)->Integer;
3e01e963eb2d Fix compile error for calc example but not work
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 349
diff changeset
112 Integer* integer3 = &ALLOCATE_DATA_GEAR(context, Integer)->Integer;
3e01e963eb2d Fix compile error for calc example but not work
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 349
diff changeset
113 // par goto mult(integer1, integer2, integer3, __exit);
348
c03159481cb6 Par goto exchange inline expansion
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 346
diff changeset
114 struct Context* task = NEW(struct Context);
c03159481cb6 Par goto exchange inline expansion
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 346
diff changeset
115 initContext(task);
c03159481cb6 Par goto exchange inline expansion
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 346
diff changeset
116 task->next = C_mult;
c03159481cb6 Par goto exchange inline expansion
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 346
diff changeset
117 task->idgCount = 2;
349
01e0fa598ce3 Fix compile error but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 348
diff changeset
118 task->idg = task->dataNum;
348
c03159481cb6 Par goto exchange inline expansion
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 346
diff changeset
119 task->data[task->idg] = (union Data*)integer1;
c03159481cb6 Par goto exchange inline expansion
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 346
diff changeset
120 task->data[task->idg+1] = (union Data*)integer2;
c03159481cb6 Par goto exchange inline expansion
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 346
diff changeset
121 task->maxIdg = task->idg + 2;
c03159481cb6 Par goto exchange inline expansion
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 346
diff changeset
122 task->odg = task->maxIdg;
c03159481cb6 Par goto exchange inline expansion
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 346
diff changeset
123 task->data[task->odg] = (union Data*)integer3;
c03159481cb6 Par goto exchange inline expansion
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 346
diff changeset
124 task->maxOdg = task->odg + 1;
352
3e01e963eb2d Fix compile error for calc example but not work
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 349
diff changeset
125 tasks[0] = task;
326
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
126
352
3e01e963eb2d Fix compile error for calc example but not work
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 349
diff changeset
127 Integer* integer4 = &ALLOCATE_DATA_GEAR(context, Integer)->Integer;
3e01e963eb2d Fix compile error for calc example but not work
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 349
diff changeset
128 Integer* integer5 = &ALLOCATE_DATA_GEAR(context, Integer)->Integer;
355
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 353
diff changeset
129 // par goto add(integer4, integer5, integer1, __exit);
352
3e01e963eb2d Fix compile error for calc example but not work
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 349
diff changeset
130 task = NEW(struct Context);
348
c03159481cb6 Par goto exchange inline expansion
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 346
diff changeset
131 initContext(task);
c03159481cb6 Par goto exchange inline expansion
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 346
diff changeset
132 task->next = C_add;
c03159481cb6 Par goto exchange inline expansion
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 346
diff changeset
133 task->idgCount = 2;
349
01e0fa598ce3 Fix compile error but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 348
diff changeset
134 task->idg = task->dataNum;
352
3e01e963eb2d Fix compile error for calc example but not work
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 349
diff changeset
135 task->data[task->idg] = (union Data*)integer4;
3e01e963eb2d Fix compile error for calc example but not work
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 349
diff changeset
136 task->data[task->idg+1] = (union Data*)integer5;
348
c03159481cb6 Par goto exchange inline expansion
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 346
diff changeset
137 task->maxIdg = task->idg + 2;
c03159481cb6 Par goto exchange inline expansion
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 346
diff changeset
138 task->odg = task->maxIdg;
352
3e01e963eb2d Fix compile error for calc example but not work
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 349
diff changeset
139 task->data[task->odg] = (union Data*)integer1;
348
c03159481cb6 Par goto exchange inline expansion
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 346
diff changeset
140 task->maxOdg = task->odg + 1;
352
3e01e963eb2d Fix compile error for calc example but not work
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 349
diff changeset
141 tasks[1] = task;
326
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
142
353
b07078bd1f2c Add spawn Tasks to TaskManagerImpl
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 352
diff changeset
143 // par goto initIntegerDataGears(integer2, integer4, integer5, __exit);
b07078bd1f2c Add spawn Tasks to TaskManagerImpl
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 352
diff changeset
144 task = NEW(struct Context);
b07078bd1f2c Add spawn Tasks to TaskManagerImpl
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 352
diff changeset
145 initContext(task);
b07078bd1f2c Add spawn Tasks to TaskManagerImpl
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 352
diff changeset
146 task->next = C_initIntegerDataGears;
b07078bd1f2c Add spawn Tasks to TaskManagerImpl
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 352
diff changeset
147 task->idgCount = 0;
b07078bd1f2c Add spawn Tasks to TaskManagerImpl
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 352
diff changeset
148 task->idg = task->dataNum;
b07078bd1f2c Add spawn Tasks to TaskManagerImpl
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 352
diff changeset
149 task->maxIdg = task->idg;
b07078bd1f2c Add spawn Tasks to TaskManagerImpl
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 352
diff changeset
150 task->odg = task->maxIdg;
b07078bd1f2c Add spawn Tasks to TaskManagerImpl
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 352
diff changeset
151 task->data[task->odg] = (union Data*)integer2;
b07078bd1f2c Add spawn Tasks to TaskManagerImpl
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 352
diff changeset
152 task->data[task->odg+1] = (union Data*)integer4;
b07078bd1f2c Add spawn Tasks to TaskManagerImpl
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 352
diff changeset
153 task->data[task->odg+2] = (union Data*)integer5;
b07078bd1f2c Add spawn Tasks to TaskManagerImpl
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 352
diff changeset
154 task->maxOdg = task->odg + 3;
b07078bd1f2c Add spawn Tasks to TaskManagerImpl
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 352
diff changeset
155 tasks[2] = task;
b07078bd1f2c Add spawn Tasks to TaskManagerImpl
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 352
diff changeset
156
352
3e01e963eb2d Fix compile error for calc example but not work
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 349
diff changeset
157 taskManager->contexts = tasks;
3e01e963eb2d Fix compile error for calc example but not work
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 349
diff changeset
158 // goto crateTask1();
355
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 353
diff changeset
159 taskManager->next1 = C_createTask1;
353
b07078bd1f2c Add spawn Tasks to TaskManagerImpl
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 352
diff changeset
160 goto meta(context, taskManager->taskManager->TaskManager.spawnTasks);
326
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
161 }
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
162
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
163 void init(int argc, char** argv) {
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
164 for (int i = 1; argv[i]; ++i) {
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
165 if (strcmp(argv[i], "-cpu") == 0)
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
166 cpu_num = (int)atoi(argv[i+1]);
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
167 else if (strcmp(argv[i], "-l") == 0)
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
168 length = (int)atoi(argv[i+1]);
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
169 else if (strcmp(argv[i], "-cuda") == 0) {
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
170 gpu_num = 1;
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
171 CPU_CUDA = 0;
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
172 }
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
173 }
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
174 }
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
175
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
176 int main(int argc, char** argv) {
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
177 init(argc, argv);
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
178 struct Context* main_context = NEW(struct Context);
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
179 initContext(main_context);
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
180 main_context->next = C_initDataGears;
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
181
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
182 goto start_code(main_context);
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
183 }