comparison src/parallel_execution/main.c @ 112:e3cba827d489

Add spawnTask CS
author Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
date Tue, 03 May 2016 17:29:21 +0900
parents 556e203de999
children f57e9ffa7960 d05b9937aa95
comparison
equal deleted inserted replaced
111:556e203de999 112:e3cba827d489
109 } 109 }
110 110
111 __code createTask1(struct Context* context, struct Allocate* allocate) { 111 __code createTask1(struct Context* context, struct Allocate* allocate) {
112 allocate->size = sizeof(struct Task); 112 allocate->size = sizeof(struct Task);
113 allocator(context); 113 allocator(context);
114
115 goto meta(context, CreateTask2); 114 goto meta(context, CreateTask2);
116 } 115 }
117 116
118 __code createTask1_stub(struct Context* context) { 117 __code createTask1_stub(struct Context* context) {
119 goto createTask1(context, &context->data[Allocate]->allocate); 118 goto createTask1(context, &context->data[Allocate]->allocate);
120 } 119 }
121 120
122 __code meta_createTask2(struct Context* context, struct Queue* activeQueue, enum Code next) { 121 __code createTask2(struct Context* context, struct Allocate* allocate) {
122 allocate->size = sizeof(struct Queue);
123 allocator(context);
124 goto meta(context, CreateTask3);
125 }
126
127 __code createTask2_stub(struct Context* context) {
128 goto createTask2(context, &context->data[Allocate]->allocate);
129 }
130
131 __code createTask3(struct Context* context, struct Allocate* allocate) {
132 allocate->size = sizeof(struct OdsQueue);
133 allocator(context);
134 goto meta(context, CreateTask4);
135 }
136
137 __code createTask3_stub(struct Context* context) {
138 goto createTask3(context, &context->data[Allocate]->allocate);
139 }
140
141 __code meta_createTask4(struct Context* context, struct Queue* activeQueue, enum Code next) {
123 context->data[Queue] = (union Data *)activeQueue; 142 context->data[Queue] = (union Data *)activeQueue;
124 goto (context->code[next])(context); 143 goto (context->code[next])(context);
125 } 144 }
126 145
127 __code createTask2(struct Context* context, struct LoopCounter* loopCounter, struct Task* task, struct Element* element, struct Queue* activeQueue) { 146 __code createTask4(struct Context* context, struct LoopCounter* loopCounter, struct Task* task, struct Queue* waitMe, struct OdsQueue* waitI, struct Element* element, struct Queue* activeQueue) {
128 int i = loopCounter->i; 147 int i = loopCounter->i;
148
149 waitMe->first = 0;
150 waitMe->last = 0;
151 waitMe->count = 0;
152
153 waitI->first = 0;
154 waitI->last = 0;
155 waitI->count = 0;
129 156
130 task->code = Twice; 157 task->code = Twice;
131 task->key = i; 158 task->key = i;
159 task->waitMe = waitMe;
160 task->waitI = waitI;
161 task->idsCount = 0;
132 162
133 element->task = task; 163 element->task = task;
134 164
135 context->next = CreateData1; 165 context->next = CreateData1;
136 loopCounter->i++; 166 loopCounter->i++;
137 167
138 goto meta_createTask2(context, activeQueue, PutQueue1); 168 goto meta(context, SpawnTask);
139 } 169 }
140 170
141 __code createTask2_stub(struct Context* context) { 171 __code createTask4_stub(struct Context* context) {
142 goto createTask2(context, 172 goto createTask4(context,
143 &context->data[LoopCounter]->loopCounter, 173 &context->data[LoopCounter]->loopCounter,
144 &context->data[context->dataNum]->task, 174 &context->data[context->dataNum-2]->task,
175 &context->data[context->dataNum-1]->queue,
176 &context->data[context->dataNum]->odsQueue,
145 &context->data[Element]->element, 177 &context->data[Element]->element,
146 &context->data[ActiveQueue]->queue); 178 &context->data[ActiveQueue]->queue);
147 } 179 }
148 180
149 181
150 //__code createTask2(struct Context* context, struct LoopCounter* loopCounter, struct Task* task, struct Element* element) { 182 //__code createTask4(struct Context* context, struct LoopCounter* loopCounter, struct Task* task, struct Queue* waitMe, struct OdsQueue* waitI, struct Element* element, struct Queue* activeQueue) {
151 // int i = loopCounter->i; 183 // int i = loopCounter->i;
152 // 184 //
153 // task->code = TaskC; 185 // task->code = TaskC;
154 // task->key = i; 186 // task->key = i;
155 // 187 // task->waitMe = waitMe;
188 // task->waitI = waitI;
189 // task->idsCount = 1;
190 //
156 // element->task = task; 191 // element->task = task;
157 // 192 //
158 // context->next = CreateData1; 193 // context->next = CreateData1;
159 // loopCounter->i++; 194 // loopCounter->i++;
160 // 195 //
161 // goto meta(context, PutQueue1); 196 // goto meta_createTask2(context, activeQueue, PutQueue1);
162 //} 197 //}
163 // 198 //
164 //__code createTask2_stub(struct Context* context) { 199 //__code createTask4_stub(struct Context* context) {
165 // goto createTask2(context, 200 // goto createTask2(context,
166 // &context->data[LoopCounter]->loopCounter, 201 // &context->data[LoopCounter]->loopCounter,
167 // &context->data[context->dataNum]->task, 202 // &context->data[context->dataNum]->task,
168 // &context->data[Element]->element); 203 // &context->data[context->dataNum-1]->queue,
204 // &context->data[context->dataNum-2]->odsQueue,
205 // &context->data[Element]->element,
206 // &context->data[ActiveQueue]->queue);
169 //} 207 //}
170 // 208 //
171 //__code createTask3(struct Context* context, struct LoopCounter* loopCounter, struct Task* task, struct Task* slave, struct Element* element) { 209 //__code createTask5(struct Context* context, struct LoopCounter* loopCounter, struct Task* task, struct Task* slave, struct Element* element) {
172 // int i = loopCounter->i; 210 // int i = loopCounter->i;
173 // 211 //
174 // task->code = TaskB; 212 // task->code = TaskB;
175 // task->key = i; 213 // task->key = i;
176 // element->task = task; 214 // element->task = task;
177 // 215 //
178 // context->next = CreateData1; 216 // context->next = CreateData1;
179 // loopCounter->i++; 217 // loopCounter->i++;
180 // 218 //
181 // goto meta(context, WaitFor1); 219 // goto meta(context, WaitFor1);
182 //} 220 //}
183 // 221 //
184 //__code createTask3_stub(struct Context* context) { 222 //__code createTask5_stub(struct Context* context) {
185 // goto createTask2(context, 223 // goto createTask2(context,
186 // &context->data[context->dataNum]->task, 224 // &context->data[context->dataNum]->task,
187 // &context->data[Element]->element); 225 // &context->data[Element]->element);
188 //} 226 //}
189 227
190 __code putQueue1(struct Context* context, struct Allocate* allocate) { 228 __code putQueue1(struct Context* context, struct Allocate* allocate) {
191 allocate->size = sizeof(struct Element); 229 allocate->size = sizeof(struct Element);
192 allocator(context); 230 allocator(context);