annotate src/parallel_execution/TaskManagerImpl.cbc @ 395:864cd4e346e9

Fix taskManager
author Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
date Tue, 01 Aug 2017 20:09:33 +0900
parents 99c50356d917
children fc4fcd441700
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
269
5170539348ec rename TaskManagerImpl.cbc
mir3636
parents:
diff changeset
1 #include "../context.h"
278
23767f714f4a fix generate_stub
mir3636
parents: 277
diff changeset
2
269
5170539348ec rename TaskManagerImpl.cbc
mir3636
parents:
diff changeset
3 #include <stdio.h>
5170539348ec rename TaskManagerImpl.cbc
mir3636
parents:
diff changeset
4
5170539348ec rename TaskManagerImpl.cbc
mir3636
parents:
diff changeset
5 void createWorkers(struct Context* context, TaskManager* taskManeger, TaskManagerImpl* taskManagerImpl);
5170539348ec rename TaskManagerImpl.cbc
mir3636
parents:
diff changeset
6
280
2c2e4e597eb0 generate no compile errors
mir3636
parents: 279
diff changeset
7 TaskManager* createTaskManagerImpl(struct Context* context, int numCPU, int numGPU, int numIO) {
269
5170539348ec rename TaskManagerImpl.cbc
mir3636
parents:
diff changeset
8 struct TaskManager* taskManager = new TaskManager();
326
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 319
diff changeset
9 // 0...numIO-1 IOProcessor
269
5170539348ec rename TaskManagerImpl.cbc
mir3636
parents:
diff changeset
10 // numIO...numIO+numGPU-1 GPUProcessor
5170539348ec rename TaskManagerImpl.cbc
mir3636
parents:
diff changeset
11 // numIO+numGPU...numIO+numGPU+numCPU-1 CPUProcessor
5170539348ec rename TaskManagerImpl.cbc
mir3636
parents:
diff changeset
12 taskManager->io = 0;
5170539348ec rename TaskManagerImpl.cbc
mir3636
parents:
diff changeset
13 taskManager->gpu = numIO;
5170539348ec rename TaskManagerImpl.cbc
mir3636
parents:
diff changeset
14 taskManager->cpu = numIO+numGPU;
5170539348ec rename TaskManagerImpl.cbc
mir3636
parents:
diff changeset
15 taskManager->maxCPU = numIO+numGPU+numCPU;
393
99c50356d917 fix generate_stub.pl
mir3636
parents: 392
diff changeset
16 taskManager->spawnTasks = C_spawnTasksTaskManagerImpl;
395
864cd4e346e9 Fix taskManager
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 393
diff changeset
17 taskManager->spawn = C_spawnTaskManagerImpl;
864cd4e346e9 Fix taskManager
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 393
diff changeset
18 taskManager->shutdown = C_shutdownTaskManagerImpl;
269
5170539348ec rename TaskManagerImpl.cbc
mir3636
parents:
diff changeset
19 struct TaskManagerImpl* taskManagerImpl = new TaskManagerImpl();
280
2c2e4e597eb0 generate no compile errors
mir3636
parents: 279
diff changeset
20 taskManagerImpl -> activeQueue = createSingleLinkedQueue(context);
2c2e4e597eb0 generate no compile errors
mir3636
parents: 279
diff changeset
21 taskManagerImpl -> taskQueue = createSingleLinkedQueue(context);
269
5170539348ec rename TaskManagerImpl.cbc
mir3636
parents:
diff changeset
22 taskManagerImpl -> numWorker = taskManager->maxCPU;
352
3e01e963eb2d Fix compile error for calc example but not work
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 349
diff changeset
23 taskManagerImpl -> loopCounter = new LoopCounter();
3e01e963eb2d Fix compile error for calc example but not work
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 349
diff changeset
24 taskManagerImpl -> loopCounter -> i = 0;
269
5170539348ec rename TaskManagerImpl.cbc
mir3636
parents:
diff changeset
25 createWorkers(context, taskManager, taskManagerImpl);
316
54d203daf06b CUDAtwice.cbc is called.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 312
diff changeset
26 taskManager->taskManager = (union Data*)taskManagerImpl;
269
5170539348ec rename TaskManagerImpl.cbc
mir3636
parents:
diff changeset
27 return taskManager;
5170539348ec rename TaskManagerImpl.cbc
mir3636
parents:
diff changeset
28 }
5170539348ec rename TaskManagerImpl.cbc
mir3636
parents:
diff changeset
29
5170539348ec rename TaskManagerImpl.cbc
mir3636
parents:
diff changeset
30 void createWorkers(struct Context* context, TaskManager* taskManager, TaskManagerImpl* taskManagerImpl) {
5170539348ec rename TaskManagerImpl.cbc
mir3636
parents:
diff changeset
31 int i = 0;
5170539348ec rename TaskManagerImpl.cbc
mir3636
parents:
diff changeset
32 taskManagerImpl->workers = (Worker**)ALLOC_ARRAY(context, Worker, taskManager->maxCPU);
5170539348ec rename TaskManagerImpl.cbc
mir3636
parents:
diff changeset
33 for (;i<taskManager->gpu;i++) {
280
2c2e4e597eb0 generate no compile errors
mir3636
parents: 279
diff changeset
34 Queue* queue = createSynchronizedQueue(context);
269
5170539348ec rename TaskManagerImpl.cbc
mir3636
parents:
diff changeset
35 taskManagerImpl->workers[i] = (Worker*)createCPUWorker(context, i, queue);
5170539348ec rename TaskManagerImpl.cbc
mir3636
parents:
diff changeset
36 }
5170539348ec rename TaskManagerImpl.cbc
mir3636
parents:
diff changeset
37 for (;i<taskManager->cpu;i++) {
312
7dd5a7d52a67 USE_CUDAWorker flag only for CUDAtwice
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 288
diff changeset
38 #ifdef USE_CUDAWorker
7dd5a7d52a67 USE_CUDAWorker flag only for CUDAtwice
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 288
diff changeset
39 Queue* queue = createSynchronizedQueue(context);
319
a15511b1a6e0 separate cuda.c, and USE_CUDA_MAIN_THREAD flag
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 317
diff changeset
40 #ifndef USE_CUDA_MAIN_THREAD
a15511b1a6e0 separate cuda.c, and USE_CUDA_MAIN_THREAD flag
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 317
diff changeset
41 taskManagerImpl->workers[i] = (Worker*)createCUDAWorker(context, i, queue,0);
a15511b1a6e0 separate cuda.c, and USE_CUDA_MAIN_THREAD flag
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 317
diff changeset
42 #else
316
54d203daf06b CUDAtwice.cbc is called.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 312
diff changeset
43 taskManagerImpl->workers[i] = (Worker*)queue;
319
a15511b1a6e0 separate cuda.c, and USE_CUDA_MAIN_THREAD flag
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 317
diff changeset
44 #endif
269
5170539348ec rename TaskManagerImpl.cbc
mir3636
parents:
diff changeset
45 #else
280
2c2e4e597eb0 generate no compile errors
mir3636
parents: 279
diff changeset
46 Queue* queue = createSynchronizedQueue(context);
269
5170539348ec rename TaskManagerImpl.cbc
mir3636
parents:
diff changeset
47 taskManagerImpl->workers[i] = (Worker*)createCPUWorker(context, i, queue);
326
f23f6d0aa4e9 Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 319
diff changeset
48 #endif
269
5170539348ec rename TaskManagerImpl.cbc
mir3636
parents:
diff changeset
49 }
5170539348ec rename TaskManagerImpl.cbc
mir3636
parents:
diff changeset
50 for (;i<taskManager->maxCPU;i++) {
280
2c2e4e597eb0 generate no compile errors
mir3636
parents: 279
diff changeset
51 Queue* queue = createSynchronizedQueue(context);
269
5170539348ec rename TaskManagerImpl.cbc
mir3636
parents:
diff changeset
52 taskManagerImpl->workers[i] = (Worker*)createCPUWorker(context, i, queue);
5170539348ec rename TaskManagerImpl.cbc
mir3636
parents:
diff changeset
53 }
5170539348ec rename TaskManagerImpl.cbc
mir3636
parents:
diff changeset
54 }
5170539348ec rename TaskManagerImpl.cbc
mir3636
parents:
diff changeset
55
395
864cd4e346e9 Fix taskManager
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 393
diff changeset
56 __code spawnTasksTaskManagerImpl(struct TaskManagerImpl* taskManagerImpl, struct Context** tasks, __code next1(...), struct TaskManager* taskManager) {
353
b07078bd1f2c Add spawn Tasks to TaskManagerImpl
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 352
diff changeset
57 int i = taskManagerImpl->loopCounter->i;
372
d6ce4273e7d1 Add dimension task spawn
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 355
diff changeset
58 if(i < GET_SIZE(tasks)) {
d6ce4273e7d1 Add dimension task spawn
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 355
diff changeset
59 struct Context* task = tasks[i];
355
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 353
diff changeset
60 taskManagerImpl->loopCounter->i++;
374
fb50cf8aa615 Add Iterator Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 372
diff changeset
61 task->taskManager = &taskManager->taskManager->TaskManager;
353
b07078bd1f2c Add spawn Tasks to TaskManagerImpl
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 352
diff changeset
62 taskManager->context = task;
395
864cd4e346e9 Fix taskManager
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 393
diff changeset
63 taskManager->next = C_spawnTasksTaskManagerImpl;
372
d6ce4273e7d1 Add dimension task spawn
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 355
diff changeset
64 goto meta(context, C_setWaitTask);
353
b07078bd1f2c Add spawn Tasks to TaskManagerImpl
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 352
diff changeset
65 }
b07078bd1f2c Add spawn Tasks to TaskManagerImpl
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 352
diff changeset
66 taskManagerImpl->loopCounter->i = 0;
395
864cd4e346e9 Fix taskManager
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 393
diff changeset
67 goto meta(context, C_spawnTasksTaskManagerImpl1);
353
b07078bd1f2c Add spawn Tasks to TaskManagerImpl
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 352
diff changeset
68 }
b07078bd1f2c Add spawn Tasks to TaskManagerImpl
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 352
diff changeset
69
395
864cd4e346e9 Fix taskManager
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 393
diff changeset
70 __code spawnTasksTaskManagerImpl_stub(struct Context* context) {
353
b07078bd1f2c Add spawn Tasks to TaskManagerImpl
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 352
diff changeset
71 TaskManagerImpl* taskManager = (TaskManagerImpl*)GearImpl(context, TaskManager, taskManager);
395
864cd4e346e9 Fix taskManager
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 393
diff changeset
72 goto spawnTasksTaskManagerImpl(context,
353
b07078bd1f2c Add spawn Tasks to TaskManagerImpl
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 352
diff changeset
73 taskManager,
392
36964b9ac5fd Fix taskManager
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 376
diff changeset
74 Gearef(context, TaskManager)->tasks,
395
864cd4e346e9 Fix taskManager
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 393
diff changeset
75 Gearef(context, TaskManager)->next1,
864cd4e346e9 Fix taskManager
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 393
diff changeset
76 Gearef(context, TaskManager));
353
b07078bd1f2c Add spawn Tasks to TaskManagerImpl
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 352
diff changeset
77 }
b07078bd1f2c Add spawn Tasks to TaskManagerImpl
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 352
diff changeset
78
395
864cd4e346e9 Fix taskManager
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 393
diff changeset
79 __code spawnTasksTaskManagerImpl1(struct TaskManagerImpl* taskManagerImpl, struct Context** tasks, __code next1(...), struct TaskManager* taskManager) {
353
b07078bd1f2c Add spawn Tasks to TaskManagerImpl
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 352
diff changeset
80 int i = taskManagerImpl->loopCounter->i;
372
d6ce4273e7d1 Add dimension task spawn
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 355
diff changeset
81 if(i < GET_SIZE(tasks)) {
d6ce4273e7d1 Add dimension task spawn
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 355
diff changeset
82 struct Context* task = tasks[i];
355
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 353
diff changeset
83 taskManagerImpl->loopCounter->i++;
353
b07078bd1f2c Add spawn Tasks to TaskManagerImpl
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 352
diff changeset
84 taskManager->context = task;
395
864cd4e346e9 Fix taskManager
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 393
diff changeset
85 taskManager->next = C_spawnTasksTaskManagerImpl1;
864cd4e346e9 Fix taskManager
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 393
diff changeset
86 goto meta(context, C_spawnTaskManagerImpl);
353
b07078bd1f2c Add spawn Tasks to TaskManagerImpl
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 352
diff changeset
87 }
b07078bd1f2c Add spawn Tasks to TaskManagerImpl
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 352
diff changeset
88 taskManagerImpl->loopCounter->i = 0;
392
36964b9ac5fd Fix taskManager
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 376
diff changeset
89 goto meta(context, next1);
353
b07078bd1f2c Add spawn Tasks to TaskManagerImpl
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 352
diff changeset
90 }
b07078bd1f2c Add spawn Tasks to TaskManagerImpl
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 352
diff changeset
91
395
864cd4e346e9 Fix taskManager
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 393
diff changeset
92 __code spawnTasksTaskManagerImpl1_stub(struct Context* context) {
353
b07078bd1f2c Add spawn Tasks to TaskManagerImpl
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 352
diff changeset
93 TaskManagerImpl* taskManager = (TaskManagerImpl*)GearImpl(context, TaskManager, taskManager);
395
864cd4e346e9 Fix taskManager
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 393
diff changeset
94 goto spawnTasksTaskManagerImpl1(context,
353
b07078bd1f2c Add spawn Tasks to TaskManagerImpl
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 352
diff changeset
95 taskManager,
392
36964b9ac5fd Fix taskManager
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 376
diff changeset
96 Gearef(context, TaskManager)->tasks,
395
864cd4e346e9 Fix taskManager
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 393
diff changeset
97 Gearef(context, TaskManager)->next1,
864cd4e346e9 Fix taskManager
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 393
diff changeset
98 Gearef(context, TaskManager));
353
b07078bd1f2c Add spawn Tasks to TaskManagerImpl
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 352
diff changeset
99 }
b07078bd1f2c Add spawn Tasks to TaskManagerImpl
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 352
diff changeset
100
372
d6ce4273e7d1 Add dimension task spawn
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 355
diff changeset
101 __code setWaitTask(struct Queue* queue, struct LoopCounter* loopCounter, struct Context* task, __code next(...)) {
348
c03159481cb6 Par goto exchange inline expansion
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 327
diff changeset
102 int i = loopCounter->i;
372
d6ce4273e7d1 Add dimension task spawn
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 355
diff changeset
103 if(task->idg+i < task->maxIdg) {
348
c03159481cb6 Par goto exchange inline expansion
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 327
diff changeset
104 queue->queue = (Data *)GET_WAIT_LIST(task->data[task->idg + i]);
372
d6ce4273e7d1 Add dimension task spawn
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 355
diff changeset
105 queue->next = C_setWaitTask;
d6ce4273e7d1 Add dimension task spawn
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 355
diff changeset
106 queue->data = (Data *)task;
d6ce4273e7d1 Add dimension task spawn
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 355
diff changeset
107 loopCounter->i++;
348
c03159481cb6 Par goto exchange inline expansion
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 327
diff changeset
108 goto meta(context, queue->queue->Queue.put);
c03159481cb6 Par goto exchange inline expansion
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 327
diff changeset
109 }
352
3e01e963eb2d Fix compile error for calc example but not work
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 349
diff changeset
110 loopCounter->i = 0;
3e01e963eb2d Fix compile error for calc example but not work
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 349
diff changeset
111 goto next(...);
327
534601ed8c50 Running dependency example for single thread and single task
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 326
diff changeset
112 }
534601ed8c50 Running dependency example for single thread and single task
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 326
diff changeset
113
534601ed8c50 Running dependency example for single thread and single task
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 326
diff changeset
114 __code setWaitTask_stub(struct Context* context) {
353
b07078bd1f2c Add spawn Tasks to TaskManagerImpl
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 352
diff changeset
115 struct Context* task = Gearef(context, TaskManager)->context;
372
d6ce4273e7d1 Add dimension task spawn
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 355
diff changeset
116 goto setWaitTask(context,
d6ce4273e7d1 Add dimension task spawn
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 355
diff changeset
117 Gearef(context, Queue),
d6ce4273e7d1 Add dimension task spawn
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 355
diff changeset
118 Gearef(task, LoopCounter),
d6ce4273e7d1 Add dimension task spawn
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 355
diff changeset
119 task,
d6ce4273e7d1 Add dimension task spawn
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 355
diff changeset
120 Gearef(context, TaskManager)->next);
d6ce4273e7d1 Add dimension task spawn
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 355
diff changeset
121 }
d6ce4273e7d1 Add dimension task spawn
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 355
diff changeset
122
395
864cd4e346e9 Fix taskManager
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 393
diff changeset
123 __code spawnTaskManagerImpl(struct TaskManagerImpl* taskManager, struct Iterator* iterator, struct Context* task, __code next(...)) {
269
5170539348ec rename TaskManagerImpl.cbc
mir3636
parents:
diff changeset
124 if (task->idgCount == 0) {
374
fb50cf8aa615 Add Iterator Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 372
diff changeset
125 if(task->iterator != NULL && task->iterate == 0) {
fb50cf8aa615 Add Iterator Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 372
diff changeset
126 iterator->iterator = (union Data*)task->iterator;
fb50cf8aa615 Add Iterator Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 372
diff changeset
127 iterator->task = task;
fb50cf8aa615 Add Iterator Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 372
diff changeset
128 iterator->next = next;
376
b46f38645587 Run oneDimIterator_test
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 374
diff changeset
129 pthread_mutex_unlock(&taskManager->mutex);
374
fb50cf8aa615 Add Iterator Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 372
diff changeset
130 goto meta(context, task->iterator->exec);
372
d6ce4273e7d1 Add dimension task spawn
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 355
diff changeset
131 }
327
534601ed8c50 Running dependency example for single thread and single task
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 326
diff changeset
132 goto meta(context, C_taskSend);
269
5170539348ec rename TaskManagerImpl.cbc
mir3636
parents:
diff changeset
133 }
374
fb50cf8aa615 Add Iterator Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 372
diff changeset
134 pthread_mutex_unlock(&taskManager->mutex);
fb50cf8aa615 Add Iterator Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 372
diff changeset
135 goto next(...);
269
5170539348ec rename TaskManagerImpl.cbc
mir3636
parents:
diff changeset
136 }
5170539348ec rename TaskManagerImpl.cbc
mir3636
parents:
diff changeset
137
395
864cd4e346e9 Fix taskManager
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 393
diff changeset
138 __code spawnTaskManagerImpl_stub(struct Context* context) {
269
5170539348ec rename TaskManagerImpl.cbc
mir3636
parents:
diff changeset
139 TaskManagerImpl* taskManager = (TaskManagerImpl*)GearImpl(context, TaskManager, taskManager);
353
b07078bd1f2c Add spawn Tasks to TaskManagerImpl
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 352
diff changeset
140 pthread_mutex_lock(&taskManager->mutex);
395
864cd4e346e9 Fix taskManager
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 393
diff changeset
141 goto spawnTaskManagerImpl(context,
348
c03159481cb6 Par goto exchange inline expansion
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 327
diff changeset
142 taskManager,
374
fb50cf8aa615 Add Iterator Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 372
diff changeset
143 Gearef(context, Iterator),
353
b07078bd1f2c Add spawn Tasks to TaskManagerImpl
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 352
diff changeset
144 Gearef(context, TaskManager)->context,
b07078bd1f2c Add spawn Tasks to TaskManagerImpl
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 352
diff changeset
145 Gearef(context, TaskManager)->next);
269
5170539348ec rename TaskManagerImpl.cbc
mir3636
parents:
diff changeset
146 }
5170539348ec rename TaskManagerImpl.cbc
mir3636
parents:
diff changeset
147
327
534601ed8c50 Running dependency example for single thread and single task
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 326
diff changeset
148 __code taskSend(struct TaskManagerImpl* taskManager, struct Queue* queue, struct Context* task, __code next(...)) {
374
fb50cf8aa615 Add Iterator Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 372
diff changeset
149 // set workerId
fb50cf8aa615 Add Iterator Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 372
diff changeset
150 task->workerId = taskManager->sendWorkerIndex;
fb50cf8aa615 Add Iterator Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 372
diff changeset
151 if(++taskManager->sendWorkerIndex >= taskManager->numWorker) {
fb50cf8aa615 Add Iterator Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 372
diff changeset
152 taskManager->sendWorkerIndex = 0;
fb50cf8aa615 Add Iterator Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 372
diff changeset
153 }
269
5170539348ec rename TaskManagerImpl.cbc
mir3636
parents:
diff changeset
154 struct Queue* tasks = taskManager->workers[task->workerId]->tasks;
5170539348ec rename TaskManagerImpl.cbc
mir3636
parents:
diff changeset
155 queue->queue = (union Data*)tasks;
5170539348ec rename TaskManagerImpl.cbc
mir3636
parents:
diff changeset
156 queue->data = (union Data*)task;
5170539348ec rename TaskManagerImpl.cbc
mir3636
parents:
diff changeset
157 queue->next = next;
327
534601ed8c50 Running dependency example for single thread and single task
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 326
diff changeset
158 pthread_mutex_unlock(&taskManager->mutex);
269
5170539348ec rename TaskManagerImpl.cbc
mir3636
parents:
diff changeset
159 goto meta(context, tasks->put);
5170539348ec rename TaskManagerImpl.cbc
mir3636
parents:
diff changeset
160 }
5170539348ec rename TaskManagerImpl.cbc
mir3636
parents:
diff changeset
161
327
534601ed8c50 Running dependency example for single thread and single task
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 326
diff changeset
162 __code taskSend_stub(struct Context* context) {
269
5170539348ec rename TaskManagerImpl.cbc
mir3636
parents:
diff changeset
163 TaskManagerImpl* taskManager = (TaskManagerImpl*)GearImpl(context, TaskManager, taskManager);
353
b07078bd1f2c Add spawn Tasks to TaskManagerImpl
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 352
diff changeset
164 goto taskSend(context,
b07078bd1f2c Add spawn Tasks to TaskManagerImpl
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 352
diff changeset
165 taskManager, Gearef(context, Queue),
b07078bd1f2c Add spawn Tasks to TaskManagerImpl
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 352
diff changeset
166 Gearef(context, TaskManager)->context,
b07078bd1f2c Add spawn Tasks to TaskManagerImpl
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 352
diff changeset
167 Gearef(context, TaskManager)->next);
269
5170539348ec rename TaskManagerImpl.cbc
mir3636
parents:
diff changeset
168 }
5170539348ec rename TaskManagerImpl.cbc
mir3636
parents:
diff changeset
169
395
864cd4e346e9 Fix taskManager
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 393
diff changeset
170 __code shutdownTaskManagerImpl(struct LoopCounter* loopCounter, struct TaskManager* taskManager, struct TaskManagerImpl* taskManagerImpl, struct Queue* queue, __code next(...)) {
269
5170539348ec rename TaskManagerImpl.cbc
mir3636
parents:
diff changeset
171 int i = loopCounter->i;
5170539348ec rename TaskManagerImpl.cbc
mir3636
parents:
diff changeset
172 if (taskManager->cpu <= i && i < taskManager->maxCPU) {
5170539348ec rename TaskManagerImpl.cbc
mir3636
parents:
diff changeset
173 struct Queue* tasks = taskManagerImpl->workers[i]->tasks;
5170539348ec rename TaskManagerImpl.cbc
mir3636
parents:
diff changeset
174 queue->queue = (union Data*)tasks;
5170539348ec rename TaskManagerImpl.cbc
mir3636
parents:
diff changeset
175 queue->data = NULL;
395
864cd4e346e9 Fix taskManager
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 393
diff changeset
176 queue->next = C_shutdownTaskManagerImpl1;
269
5170539348ec rename TaskManagerImpl.cbc
mir3636
parents:
diff changeset
177 goto meta(context, tasks->put);
5170539348ec rename TaskManagerImpl.cbc
mir3636
parents:
diff changeset
178 }
5170539348ec rename TaskManagerImpl.cbc
mir3636
parents:
diff changeset
179
5170539348ec rename TaskManagerImpl.cbc
mir3636
parents:
diff changeset
180 loopCounter->i = 0;
282
a3448b0f0a56 Add input data gear
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 280
diff changeset
181 goto meta(context, next);
269
5170539348ec rename TaskManagerImpl.cbc
mir3636
parents:
diff changeset
182 }
5170539348ec rename TaskManagerImpl.cbc
mir3636
parents:
diff changeset
183
395
864cd4e346e9 Fix taskManager
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 393
diff changeset
184 __code shutdownTaskManagerImpl_stub(struct Context* context) {
269
5170539348ec rename TaskManagerImpl.cbc
mir3636
parents:
diff changeset
185 TaskManagerImpl* taskManagerImpl = (TaskManagerImpl*)GearImpl(context, TaskManager, taskManager);
395
864cd4e346e9 Fix taskManager
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 393
diff changeset
186 goto shutdownTaskManagerImpl(context, Gearef(context, LoopCounter), &Gearef(context, TaskManager)->taskManager->TaskManager, taskManagerImpl, Gearef(context, Queue), Gearef(context, TaskManager)->next);
269
5170539348ec rename TaskManagerImpl.cbc
mir3636
parents:
diff changeset
187 }
282
a3448b0f0a56 Add input data gear
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 280
diff changeset
188
395
864cd4e346e9 Fix taskManager
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 393
diff changeset
189 __code shutdownTaskManagerImpl1(struct LoopCounter* loopCounter, TaskManagerImpl* taskManagerImpl) {
282
a3448b0f0a56 Add input data gear
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 280
diff changeset
190 int i = loopCounter->i;
a3448b0f0a56 Add input data gear
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 280
diff changeset
191 pthread_join(taskManagerImpl->workers[i]->worker->CPUWorker.thread, NULL);
a3448b0f0a56 Add input data gear
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 280
diff changeset
192 loopCounter->i++;
395
864cd4e346e9 Fix taskManager
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 393
diff changeset
193 goto meta(context, C_shutdownTaskManagerImpl);
282
a3448b0f0a56 Add input data gear
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 280
diff changeset
194 }
a3448b0f0a56 Add input data gear
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 280
diff changeset
195
395
864cd4e346e9 Fix taskManager
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 393
diff changeset
196 __code shutdownTaskManagerImpl1_stub(struct Context* context) {
282
a3448b0f0a56 Add input data gear
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 280
diff changeset
197 TaskManagerImpl* taskManagerImpl = (TaskManagerImpl*)GearImpl(context, TaskManager, taskManager);
395
864cd4e346e9 Fix taskManager
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 393
diff changeset
198 goto shutdownTaskManagerImpl1(context, Gearef(context, LoopCounter), taskManagerImpl);
282
a3448b0f0a56 Add input data gear
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 280
diff changeset
199 }