Mercurial > hg > GearsTemplate
comparison src/parallel_execution/TaskIterator.cbc @ 456:95f58f2b2c0e
Add TaskIterator
author | Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 11 Dec 2017 16:26:55 +0900 |
parents | |
children | 8d7e5d48cad3 |
comparison
equal
deleted
inserted
replaced
451:dcc42f3e7e97 | 456:95f58f2b2c0e |
---|---|
1 #include "../context.h" | |
2 #include <stdio.h> | |
3 | |
4 createTaskIterator(struct Context, struct List list) { | |
5 struct Iterator* iterator = new Iterator(); | |
6 struct TaskIterator* taskIterator = new TaskIterator(); | |
7 iterator->itearot = (union Data*)taskIterator; | |
8 iterator->exec = C_execTaskIterator; | |
9 iterator->barrier = C_barrierTaskIterator; | |
10 taskIterator->taskList = list; | |
11 } | |
12 | |
13 __code execTaskIterator(struct taskIterator* iterator, struct TaskManager* taskManager, struct Context* task, __code next(...)) { | |
14 if (iterator->list->next == null) { | |
15 goto next(...); | |
16 } | |
17 iterator->list = list->next; | |
18 struct Context* task = (struct Context*)iterator->list->data; | |
19 struct TaskManager taskManager = task->taskManager; | |
20 taskManager->spawn(task, C_execTaskIterator); | |
21 } | |
22 | |
23 __code barrierTaskIterator(struct MultiDimIterator* iterator, struct Context* task, __code next(...), __code whenWait(...)) { | |
24 if (__sync_fetch_and_sub(&iterator->count, 1) == 1) { | |
25 goto next(...); | |
26 } | |
27 goto whenWait(...); | |
28 } |