Mercurial > hg > Members > Moririn
comparison src/parallel_execution/main.c @ 114:d05b9937aa95
Change element data from Task to Data
author | Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 07 Jun 2016 18:43:21 +0900 |
parents | e3cba827d489 |
children | 0f0459653d77 |
comparison
equal
deleted
inserted
replaced
112:e3cba827d489 | 114:d05b9937aa95 |
---|---|
12 int split; | 12 int split; |
13 int* array_ptr; | 13 int* array_ptr; |
14 | 14 |
15 void print_queue(struct Element* element) { | 15 void print_queue(struct Element* element) { |
16 while (element) { | 16 while (element) { |
17 printf("%d\n", element->task->key); | 17 printf("%d\n", ((struct Task *)(element->data))->key); |
18 element = element->next; | 18 element = element->next; |
19 } | 19 } |
20 } | 20 } |
21 | 21 |
22 void print_tree(struct Node* node) { | 22 void print_tree(struct Node* node) { |
50 | 50 |
51 __code code2(struct Context* context, struct Array* array, struct LoopCounter* loopCounter) { | 51 __code code2(struct Context* context, struct Array* array, struct LoopCounter* loopCounter) { |
52 int i = loopCounter->i; | 52 int i = loopCounter->i; |
53 | 53 |
54 if (i < length) { | 54 if (i < length) { |
55 // printf("%d\n", array->array[i]); | 55 printf("%d\n", array->array[i]); |
56 if (array->array[i] == (i*2)) { | 56 if (array->array[i] == (i*2)) { |
57 loopCounter->i++; | 57 loopCounter->i++; |
58 goto meta(context, Code2); | 58 goto meta(context, Code2); |
59 } else | 59 } else |
60 puts("wrong result"); | 60 puts("wrong result"); |
127 __code createTask2_stub(struct Context* context) { | 127 __code createTask2_stub(struct Context* context) { |
128 goto createTask2(context, &context->data[Allocate]->allocate); | 128 goto createTask2(context, &context->data[Allocate]->allocate); |
129 } | 129 } |
130 | 130 |
131 __code createTask3(struct Context* context, struct Allocate* allocate) { | 131 __code createTask3(struct Context* context, struct Allocate* allocate) { |
132 allocate->size = sizeof(struct OdsQueue); | 132 allocate->size = sizeof(struct Queue); |
133 allocator(context); | 133 allocator(context); |
134 goto meta(context, CreateTask4); | 134 goto meta(context, CreateTask4); |
135 } | 135 } |
136 | 136 |
137 __code createTask3_stub(struct Context* context) { | 137 __code createTask3_stub(struct Context* context) { |
158 task->key = i; | 158 task->key = i; |
159 task->waitMe = waitMe; | 159 task->waitMe = waitMe; |
160 task->waitI = waitI; | 160 task->waitI = waitI; |
161 task->idsCount = 0; | 161 task->idsCount = 0; |
162 | 162 |
163 element->task = task; | 163 element->data = (union Data *)task; |
164 | 164 |
165 context->next = CreateData1; | 165 context->next = CreateData1; |
166 loopCounter->i++; | 166 loopCounter->i++; |
167 | 167 |
168 goto meta(context, SpawnTask); | 168 goto meta(context, SpawnTask); |
186 // task->key = i; | 186 // task->key = i; |
187 // task->waitMe = waitMe; | 187 // task->waitMe = waitMe; |
188 // task->waitI = waitI; | 188 // task->waitI = waitI; |
189 // task->idsCount = 1; | 189 // task->idsCount = 1; |
190 // | 190 // |
191 // element->task = task; | 191 // element->data = (union Data *)task; |
192 // | 192 // |
193 // context->next = CreateData1; | 193 // context->next = CreateData1; |
194 // loopCounter->i++; | 194 // loopCounter->i++; |
195 // | 195 // |
196 // goto meta_createTask2(context, activeQueue, PutQueue1); | 196 // goto meta_createTask2(context, activeQueue, PutQueue1); |
209 //__code createTask5(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) { |
210 // int i = loopCounter->i; | 210 // int i = loopCounter->i; |
211 // | 211 // |
212 // task->code = TaskB; | 212 // task->code = TaskB; |
213 // task->key = i; | 213 // task->key = i; |
214 // element->task = task; | 214 // element->data = (union Data *)task; |
215 // | 215 // |
216 // context->next = CreateData1; | 216 // context->next = CreateData1; |
217 // loopCounter->i++; | 217 // loopCounter->i++; |
218 // | 218 // |
219 // goto meta(context, WaitFor1); | 219 // goto meta(context, WaitFor1); |
235 __code putQueue1_stub(struct Context* context) { | 235 __code putQueue1_stub(struct Context* context) { |
236 goto putQueue1(context, &context->data[Allocate]->allocate); | 236 goto putQueue1(context, &context->data[Allocate]->allocate); |
237 } | 237 } |
238 | 238 |
239 __code putQueue2(struct Context* context, struct Element* new_element, struct Element* element, struct Queue* queue) { | 239 __code putQueue2(struct Context* context, struct Element* new_element, struct Element* element, struct Queue* queue) { |
240 new_element->task = element->task; | 240 new_element->data = element->data; |
241 | 241 |
242 if (queue->first) | 242 if (queue->first) |
243 goto meta(context, PutQueue3); | 243 goto meta(context, PutQueue3); |
244 else | 244 else |
245 goto meta(context, PutQueue4); | 245 goto meta(context, PutQueue4); |