annotate src/sendTask.cbc @ 1:73127e0ab57c

(none)
author soto@cr.ie.u-ryukyu.ac.jp
date Tue, 08 Sep 2020 18:38:08 +0900
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
soto@cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
1 __code spawnTaskManagerImpl(struct TaskManagerImpl* taskManager, struct Context* task, __code next(...)) {
soto@cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
2 if (task->idgCount == 0) {
soto@cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
3 goto taskSend();
soto@cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
4 }
soto@cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
5 goto next(...);
soto@cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
6 }
soto@cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
7
soto@cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
8 __code taskSend(struct TaskManagerImpl* taskManager, struct Context* task, __code next(...)) {
soto@cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
9 if (task->gpu) {
soto@cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
10 goto taskSend1();
soto@cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
11 } else {
soto@cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
12 goto taskSend2();
soto@cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
13 }
soto@cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
14 }
soto@cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
15
soto@cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
16 __code taskSend1(struct TaskManagerImpl* taskManager, struct Context* task, __code next(...)) {
soto@cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
17 int workerId = taskManager->sendGPUWorkerIndex;
soto@cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
18 if(++taskManager->sendGPUWorkerIndex >= taskManager->cpu) {
soto@cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
19 taskManager->sendGPUWorkerIndex = taskManager->gpu;
soto@cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
20 }
soto@cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
21 struct Queue* queue = taskManager->workers[workerId]->tasks;
soto@cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
22 goto queue->put(task, next(...));
soto@cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
23 }
soto@cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
24
soto@cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
25 __code taskSend2(struct TaskManagerImpl* taskManager, struct Context* task, __code next(...)) {
soto@cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
26 int workerId = taskManager->sendCPUWorkerIndex;
soto@cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
27 if(++taskManager->sendCPUWorkerIndex >= taskManager->maxCPU) {
soto@cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
28 taskManager->sendCPUWorkerIndex = taskManager->cpu;
soto@cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
29 }
soto@cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
30 struct Queue* queue = taskManager->workers[workerId]->tasks;
soto@cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
31 goto queue->put(task, next(...));
soto@cr.ie.u-ryukyu.ac.jp
parents:
diff changeset
32 }