comparison src/parallel_execution/examples/calc.cbc @ 353:b07078bd1f2c

Add spawn Tasks to TaskManagerImpl
author Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
date Tue, 20 Jun 2017 03:02:29 +0900
parents 3e01e963eb2d
children 45afe5d70956
comparison
equal deleted inserted replaced
352:3e01e963eb2d 353:b07078bd1f2c
98 goto meta(context, C_createTask2); 98 goto meta(context, C_createTask2);
99 } 99 }
100 100
101 loopCounter->i = 0; 101 loopCounter->i = 0;
102 taskManager->next = C_code1; 102 taskManager->next = C_code1;
103 sleep(5);
103 goto meta(context, taskManager->taskManager->TaskManager.shutdown); 104 goto meta(context, taskManager->taskManager->TaskManager.shutdown);
104 } 105 }
105 106
106 __code createTask2(struct LoopCounter* loopCounter, struct TaskManager* taskManager) { 107 __code createTask2(struct LoopCounter* loopCounter, struct TaskManager* taskManager) {
107 struct Context** tasks = (struct Context**)ALLOC_ARRAY(context, Context, 2); 108 struct Context** tasks = (struct Context**)ALLOC_ARRAY(context, Context, 3);
108 109
109 Integer* integer1 = &ALLOCATE_DATA_GEAR(context, Integer)->Integer; 110 Integer* integer1 = &ALLOCATE_DATA_GEAR(context, Integer)->Integer;
110 Integer* integer2 = &ALLOCATE_DATA_GEAR(context, Integer)->Integer; 111 Integer* integer2 = &ALLOCATE_DATA_GEAR(context, Integer)->Integer;
111 Integer* integer3 = &ALLOCATE_DATA_GEAR(context, Integer)->Integer; 112 Integer* integer3 = &ALLOCATE_DATA_GEAR(context, Integer)->Integer;
112 // par goto mult(integer1, integer2, integer3, __exit); 113 // par goto mult(integer1, integer2, integer3, __exit);
139 task->odg = task->maxIdg; 140 task->odg = task->maxIdg;
140 task->data[task->odg] = (union Data*)integer1; 141 task->data[task->odg] = (union Data*)integer1;
141 task->maxOdg = task->odg + 1; 142 task->maxOdg = task->odg + 1;
142 tasks[1] = task; 143 tasks[1] = task;
143 144
145 // par goto initIntegerDataGears(integer2, integer4, integer5, __exit);
146 task = NEW(struct Context);
147 initContext(task);
148 task->taskManager = &taskManager->taskManager->TaskManager;
149 task->next = C_initIntegerDataGears;
150 task->idgCount = 0;
151 task->idg = task->dataNum;
152 task->maxIdg = task->idg;
153 task->odg = task->maxIdg;
154 task->data[task->odg] = (union Data*)integer2;
155 task->data[task->odg+1] = (union Data*)integer4;
156 task->data[task->odg+2] = (union Data*)integer5;
157 task->maxOdg = task->odg + 3;
158 tasks[2] = task;
159
144 //goto taskManager->setWaitTask(createTask1); 160 //goto taskManager->setWaitTask(createTask1);
145 taskManager->contexts = tasks; 161 taskManager->contexts = tasks;
146 // goto crateTask1(); 162 // goto crateTask1();
147 taskManager->next = C_createTask1; 163 taskManager->next = C_createTask1;
148 goto meta(context, taskManager->taskManager->TaskManager.setWaitTask); 164 goto meta(context, taskManager->taskManager->TaskManager.spawnTasks);
149 } 165 }
150 166
151 void init(int argc, char** argv) { 167 void init(int argc, char** argv) {
152 for (int i = 1; argv[i]; ++i) { 168 for (int i = 1; argv[i]; ++i) {
153 if (strcmp(argv[i], "-cpu") == 0) 169 if (strcmp(argv[i], "-cpu") == 0)