Mercurial > hg > Game > Cerium
annotate TaskManager/Cell/CellTaskManagerImpl.cc @ 1624:c0482a63d811 draft
fix
author | Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 28 May 2013 17:57:33 +0900 |
parents | 93569219173e |
children | 4fed76f4d101 |
rev | line source |
---|---|
321 | 1 #define DEBUG |
2 #include "error.h" | |
57 | 3 #include <stdio.h> |
4 #include <stdlib.h> | |
5 #include <string.h> | |
6 #include "CellTaskManagerImpl.h" | |
956
197b7e19a345
unified queue worked on Mac OS X
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
940
diff
changeset
|
7 #include "HTask.h" |
197b7e19a345
unified queue worked on Mac OS X
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
940
diff
changeset
|
8 #include "QueueInfo.h" |
1428
af2adce9752e
add to export TaskLog
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
1362
diff
changeset
|
9 #include "ExportTaskLog.h" |
621 | 10 #include "SchedTask.h" |
635
c56f6847fb87
SimpleTask worked on Mac OS X
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
631
diff
changeset
|
11 #include "MainScheduler.h" |
57 | 12 #include "types.h" |
672 | 13 #include "SysFunc.h" |
1490
5517f93e2706
CellTaskManager call CpuThreads
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1482
diff
changeset
|
14 #ifdef __CERIUM_GPU__ |
5517f93e2706
CellTaskManager call CpuThreads
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1482
diff
changeset
|
15 #include "GpuThreads.h" |
5517f93e2706
CellTaskManager call CpuThreads
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1482
diff
changeset
|
16 #endif |
1179 | 17 static void send_alloc_reply(CellTaskManagerImpl *tm, int id, |
1606 | 18 Threads *speThreads); |
57 | 19 |
1179 | 20 CellTaskManagerImpl::~CellTaskManagerImpl() { |
1499 | 21 delete speThreads; |
22 delete[] speTaskList; | |
23 delete ppeManager; | |
67 | 24 } |
25 | |
1479
163220e54cc0
remove hard code for TaskLog
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
1477
diff
changeset
|
26 void CellTaskManagerImpl::init(int spuIdle_,int useRefDma,int export_task_log) { |
1499 | 27 spe_running = 0; |
28 spuIdle = spuIdle_; | |
109 | 29 |
1499 | 30 // 実行される Task 用の パイプライン用のダブルバッファ |
31 speTaskList = new QueueInfo<TaskList>*[machineNum]; // spe上の走っている Task の配列 | |
32 taskListInfo = new QueueInfo<TaskList>*[machineNum]; // 次に走る Task の配列 | |
476
5fc79ff9c257
CellBufferManager removed
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
380
diff
changeset
|
33 |
1077 | 34 |
1499 | 35 for (int i = 0; i < machineNum; i++) { |
36 taskListInfo[i] = new QueueInfo<TaskList> (taskListPool); | |
37 speTaskList[i] = new QueueInfo<TaskList> (taskListPool); | |
38 } | |
109 | 39 |
1499 | 40 // PPE 側の管理をする Manager |
41 ppeManager = new FifoTaskManagerImpl(machineNum); | |
42 // 大半のTaskQueueInfoは、共有される | |
43 MainScheduler *mscheduler = new MainScheduler; | |
44 set_scheduler(mscheduler); | |
45 ppeManager->init(mscheduler, this, useRefDma); // ここで HTaskInfo が共有される。 | |
1077 | 46 |
1499 | 47 speThreads->init(); |
1362
6b4a0846afcb
Spe Threads Init moved
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
1229
diff
changeset
|
48 |
1499 | 49 // 実行可能な HTask のリスト。 FifoTaskManager と共有される |
50 activeTaskQueue = ppeManager->activeTaskQueue; | |
51 // HTask の factory。 HTaskInfo ならなんでもいい。 | |
52 htaskImpl = activeTaskQueue; // any HTaskInfo | |
1179 | 53 |
1077 | 54 |
1499 | 55 ppeManager->get_scheduler()->set_manager(this); |
637 | 56 |
1499 | 57 // Task 内からManager->task_create() とかするときに必要なTaskManager。 |
58 // 現状では ppe 側からしか動かない | |
59 // spe 側から Task create できない | |
60 schedTaskManager = new SchedTask(); | |
61 schedTaskManager->init(0, 0, ppeManager->get_scheduler(), 0); | |
62 ppeManager->schedTaskManager = schedTaskManager; | |
1479
163220e54cc0
remove hard code for TaskLog
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
1477
diff
changeset
|
63 |
1499 | 64 _export_task_log = export_task_log; |
57 | 65 } |
66 | |
1179 | 67 void CellTaskManagerImpl::append_activeTask(HTaskPtr task) { |
1499 | 68 if (task->cpu_type == CPU_PPE) { |
69 ppeManager->append_activeTask(task); | |
70 } else { | |
71 activeTaskQueue->addLast(task); | |
72 } | |
109 | 73 } |
74 | |
321 | 75 // SPE_ANY が指定されていた時に |
76 // これをインクリメントしつつ呼ぶことにする。 | |
940
e01b551f25d6
unknown dead lock still...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
939
diff
changeset
|
77 unsigned int cur_anySpeid = 0; |
109 | 78 |
79 /** | |
321 | 80 * ActiveTaskQueue から Task を |
938
20beb83a5a22
dead lock still remains. zombi problem?
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
937
diff
changeset
|
81 * 各 SPE に渡す (backgound) TaskList に入れる |
109 | 82 * |
321 | 83 * ここの activeTaskQueue は FifoTaskManagerImpl のと意味が違い、 |
84 * spe に渡される Task だけ入っている | |
109 | 85 */ |
1179 | 86 void CellTaskManagerImpl::set_runTaskList(QueueInfo<HTask> *activeTaskQueue) { |
1499 | 87 int speid; |
88 HTaskPtr htask = activeTaskQueue->getFirst(); | |
89 while (htask != NULL) { | |
90 if (htask->cpu_type == CPU_PPE) { | |
91 htask = activeTaskQueue->getNext(htask); | |
92 } else { | |
93 if (htask->cpu_type == SPE_ANY) { | |
94 speid = cur_anySpeid++; | |
1494
289e427bd49f
fix set param kernelArg
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1492
diff
changeset
|
95 #ifdef __CERIUM_GPU__ |
1499 | 96 } else if (htask->cpu_type == GPU_0) { |
97 speid = htask->cpu_type - 1; | |
98 #endif | |
99 } else { | |
1492
73f4bfaeaf99
fix select cpu type
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1491
diff
changeset
|
100 // -1 してるのは |
73f4bfaeaf99
fix select cpu type
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1491
diff
changeset
|
101 // htask->cpu_type - CPU_SPE で |
73f4bfaeaf99
fix select cpu type
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1491
diff
changeset
|
102 // SPE0 = 1, SPE1 = 2, ... SPE5 = 6 ってなってるので |
73f4bfaeaf99
fix select cpu type
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1491
diff
changeset
|
103 // 配列的 (SPE0 = arr[0], SPE1 = arr[1]) にするため |
73f4bfaeaf99
fix select cpu type
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1491
diff
changeset
|
104 speid = htask->cpu_type - CPU_SPE - 1; |
73f4bfaeaf99
fix select cpu type
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1491
diff
changeset
|
105 } |
73f4bfaeaf99
fix select cpu type
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1491
diff
changeset
|
106 speid %= machineNum; |
73f4bfaeaf99
fix select cpu type
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1491
diff
changeset
|
107 |
73f4bfaeaf99
fix select cpu type
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1491
diff
changeset
|
108 set_taskList(htask, taskListInfo[speid]); |
73f4bfaeaf99
fix select cpu type
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1491
diff
changeset
|
109 |
73f4bfaeaf99
fix select cpu type
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1491
diff
changeset
|
110 HTaskPtr next = activeTaskQueue->getNext(htask); |
73f4bfaeaf99
fix select cpu type
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1491
diff
changeset
|
111 activeTaskQueue->remove(htask); |
73f4bfaeaf99
fix select cpu type
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1491
diff
changeset
|
112 htask = next; |
73f4bfaeaf99
fix select cpu type
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1491
diff
changeset
|
113 |
73f4bfaeaf99
fix select cpu type
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1491
diff
changeset
|
114 } |
73f4bfaeaf99
fix select cpu type
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1491
diff
changeset
|
115 } |
109 | 116 } |
117 | |
1179 | 118 void CellTaskManagerImpl::sendTaskList() { |
1499 | 119 for (int id = 0; id < machineNum; id++) { |
120 mail_check(id); | |
121 if (!speTaskList[id]->empty()) { | |
1606 | 122 continue; // まだ、走ってる |
1499 | 123 } |
124 if (!taskListInfo[id]->empty()) { | |
125 // SPE に送る TaskList の準備 | |
126 send_taskList(id); | |
127 spe_running++; | |
128 } | |
129 } | |
721 | 130 } |
131 | |
1179 | 132 void CellTaskManagerImpl::poll() { |
1499 | 133 set_runTaskList(activeTaskQueue); |
134 // TaskList 待ちの SPE に TaskList を送る | |
135 sendTaskList(); | |
808 | 136 } |
137 | |
1179 | 138 void CellTaskManagerImpl::debug_check_spe_idle( |
1606 | 139 QueueInfo<HTask> * activeTaskQueue, int spe_running_) { |
1499 | 140 printf("spu_idle! spe_running = %d : activeTaskQueue->length = %d \n", |
1606 | 141 spe_running_, activeTaskQueue->length()); |
1499 | 142 HTaskPtr task = activeTaskQueue->getFirst(); |
143 int tmp_i = 0; | |
144 do { | |
145 printf("task_name = %s ,", ppeManager->get_task_name(task)); | |
146 printf("cpu = [%d], count = %d", task->cpu_type, tmp_i); | |
147 tmp_i++; | |
148 } while ((task = activeTaskQueue->getNext(task)) != 0); | |
149 printf("\n"); | |
1057
8cd123d2f3ca
debug_check_spu_idle add. commandline option [-spuidle].
tkaito@henri
parents:
972
diff
changeset
|
150 } |
8cd123d2f3ca
debug_check_spu_idle add. commandline option [-spuidle].
tkaito@henri
parents:
972
diff
changeset
|
151 |
1179 | 152 void CellTaskManagerImpl::run() { |
1437
fa6723e7d329
fix GpuTaskManagerImpl
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
1429
diff
changeset
|
153 int spu_limit = spuIdle; |
fa6723e7d329
fix GpuTaskManagerImpl
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
1429
diff
changeset
|
154 if (machineNum == 0) { |
fa6723e7d329
fix GpuTaskManagerImpl
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
1429
diff
changeset
|
155 ppeManager->run(); |
fa6723e7d329
fix GpuTaskManagerImpl
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
1429
diff
changeset
|
156 return; |
fa6723e7d329
fix GpuTaskManagerImpl
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
1429
diff
changeset
|
157 } |
1125 | 158 |
1437
fa6723e7d329
fix GpuTaskManagerImpl
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
1429
diff
changeset
|
159 do { |
fa6723e7d329
fix GpuTaskManagerImpl
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
1429
diff
changeset
|
160 // PPE side |
fa6723e7d329
fix GpuTaskManagerImpl
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
1429
diff
changeset
|
161 ppeManager->poll(); |
fa6723e7d329
fix GpuTaskManagerImpl
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
1429
diff
changeset
|
162 // SPE side |
fa6723e7d329
fix GpuTaskManagerImpl
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
1429
diff
changeset
|
163 do { |
fa6723e7d329
fix GpuTaskManagerImpl
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
1429
diff
changeset
|
164 poll(); |
fa6723e7d329
fix GpuTaskManagerImpl
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
1429
diff
changeset
|
165 } while (ppeManager->activeTaskQueue->empty() && spe_running > 0); |
1179 | 166 |
1437
fa6723e7d329
fix GpuTaskManagerImpl
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
1429
diff
changeset
|
167 if (spe_running < spu_limit) { |
fa6723e7d329
fix GpuTaskManagerImpl
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
1429
diff
changeset
|
168 debug_check_spe_idle(ppeManager->activeTaskQueue, spe_running); |
fa6723e7d329
fix GpuTaskManagerImpl
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
1429
diff
changeset
|
169 } |
1179 | 170 |
1437
fa6723e7d329
fix GpuTaskManagerImpl
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
1429
diff
changeset
|
171 } while (!ppeManager->activeTaskQueue->empty() || !activeTaskQueue->empty() || spe_running > 0); |
fa6723e7d329
fix GpuTaskManagerImpl
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
1429
diff
changeset
|
172 if (!waitTaskQueue->empty()) { |
fa6723e7d329
fix GpuTaskManagerImpl
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
1429
diff
changeset
|
173 show_dead_lock_info(); |
fa6723e7d329
fix GpuTaskManagerImpl
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
1429
diff
changeset
|
174 } |
1179 | 175 |
937
ecafd19a1d83
Sort working on spu cpu == 1 or -a case
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
936
diff
changeset
|
176 } |
ecafd19a1d83
Sort working on spu cpu == 1 or -a case
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
936
diff
changeset
|
177 |
1179 | 178 static void loop_check(HTask *p, HTask *me, int depth) { |
1499 | 179 if (p == me) |
180 printf("*%lx ", (long) p); // loop | |
181 if (depth == 0) | |
182 return; | |
183 QueueInfo<TaskQueue> *w = p->wait_i; | |
184 if (w) { | |
185 for (TaskQueue *q = w->getFirst(); q; q = w->getNext(q)) { | |
186 loop_check(q->task, me, depth - 1); | |
187 } | |
188 } | |
939 | 189 } |
190 | |
1179 | 191 void CellTaskManagerImpl::show_dead_lock_info() { |
1499 | 192 get_scheduler()-> printf("Dead lock detected\n ppe queue %d\n", |
1606 | 193 ppeManager->activeTaskQueue->length()); |
1499 | 194 // 確か waitQueue は共通... |
195 // get_scheduler()-> printf(" wait queue %d\n",ppeManager->waitTaskQueue->length()); | |
196 get_scheduler()-> printf(" wait queue %d\n", waitTaskQueue->length()); | |
197 for (HTask *p = waitTaskQueue->getFirst(); p; p = waitTaskQueue->getNext(p)) { | |
198 printf(" Waiting task%d %lx", p->command, (long) p); | |
199 QueueInfo<TaskQueue> *w = p->wait_i; | |
200 if (w) { | |
201 for (TaskQueue *q = w->getFirst(); q; q = w->getNext(q)) { | |
202 printf(" waiting task%d %lx", q->task->command, | |
1606 | 203 (long) q->task); |
1499 | 204 if (!waitTaskQueue->find(q->task)) { |
205 printf("!"); // stray task | |
206 } | |
207 loop_check(q->task, p, 10); | |
208 } | |
209 } | |
210 printf("\n"); | |
211 } | |
212 get_scheduler()-> printf(" spe queue %d\n", activeTaskQueue->length()); | |
213 for (int i = 0; i < machineNum; i++) { | |
214 get_scheduler()-> printf(" spe %d send %d wait %d\n", i, | |
1606 | 215 speTaskList[i]->length(), taskListInfo[i]->length()); |
1499 | 216 } |
70 | 217 } |
218 | |
65 | 219 /** |
321 | 220 * SPE からのメールをチェックする |
640
ecf056ddd21a
SimpeTask on Cell worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
638
diff
changeset
|
221 */ |
ecf056ddd21a
SimpeTask on Cell worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
638
diff
changeset
|
222 |
1179 | 223 void CellTaskManagerImpl::mail_check(int id) { |
1499 | 224 memaddr data; |
109 | 225 |
1499 | 226 // SPE Scheduler からの mail check |
1608
8841d97c37e5
debug CpuThreads::spawn_task
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1606
diff
changeset
|
227 while (speThreads->has_mail(id,1,&data)) { |
1499 | 228 if (data == (memaddr) MY_SPE_STATUS_READY) { |
229 // MY_SPE_STATUS_READY: SPE が持ってた Task 全て終了 | |
230 // freeAll する前に循環リストに戻す | |
231 speTaskList[id]->getLast()->next = speTaskList[id]; | |
232 speTaskList[id]->freeAll(); | |
233 spe_running--; | |
234 // printf("SPE %d status ready, %d running\n",id, spe_running); | |
235 } else if (data == (memaddr) MY_SPE_COMMAND_MALLOC) { | |
236 // MY_SPE_COMMAND_MALLOC SPE からのmain memory request | |
237 send_alloc_reply(this, id, speThreads); | |
1605
5b99bcc6bdb0
fix mail_check and init dim_count and init _export_task_log.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1585
diff
changeset
|
238 } else if (data == (memaddr) MY_SPE_NOP) { |
5b99bcc6bdb0
fix mail_check and init dim_count and init _export_task_log.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1585
diff
changeset
|
239 continue; |
5b99bcc6bdb0
fix mail_check and init dim_count and init _export_task_log.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1585
diff
changeset
|
240 } else { |
830 | 241 #ifdef TASK_LIST_MAIL |
1606 | 242 // multi dimensionだったらカウントする |
1499 | 243 TaskListPtr list = (TaskListPtr)data; |
1624 | 244 if (--list->self->flag.dim_count == 0) |
1606 | 245 check_task_list_finish(schedTaskManager, list, waitTaskQueue); |
830 | 246 #else |
1499 | 247 // 終了したタスク(PPEにあるのでアドレス) |
248 HTaskPtr task = (HTaskPtr) data; | |
1151 | 249 #if 0 |
1499 | 250 if (task->cpu_type != CPU_SPE) { |
251 const char *name = get_task_name(task); | |
252 if (name != NULL) { | |
253 printf("[SPE] "); | |
254 printf("Task id : %d, ", task->command); | |
255 printf("Task name : %s\n", name); | |
256 } | |
257 } | |
1150 | 258 #endif |
1147 | 259 #ifndef NOT_CHECK |
260 | |
1499 | 261 if (task != NULL) { |
262 //SPE で処理された Task が返ってくるはず。それがもし、type PPE なら・・・ | |
263 if (task->cpu_type == CPU_PPE) { | |
264 printf("attention : PPE task run on SPE\n"); | |
265 printf("Task id : %d\n", task->command); | |
266 const char *name = get_task_name(task); | |
267 if (name != NULL) { | |
268 printf("Task name : %s\n", name); | |
269 } | |
270 } | |
271 } | |
1147 | 272 |
273 #endif | |
1179 | 274 |
1499 | 275 task->post_func(schedTaskManager, task->post_arg1, task->post_arg2); |
276 check_task_finish(task, waitTaskQueue); | |
830 | 277 #endif |
1499 | 278 } |
1606 | 279 // MY_SPE_NOP: 特に意味のないコマンド |
1499 | 280 } |
719
cc1b7333de92
clean up scheduler main loop
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
718
diff
changeset
|
281 } |
109 | 282 |
1179 | 283 void CellTaskManagerImpl::polling() { |
1499 | 284 // may call recursively check_task_list_finish() |
285 // we need fifo here | |
286 for (int i = 0; i < machineNum; i++) { | |
287 mail_check(i); | |
288 } | |
833
577bde5d0cec
poling (may recurse..)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
830
diff
changeset
|
289 } |
577bde5d0cec
poling (may recurse..)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
830
diff
changeset
|
290 |
1179 | 291 static void send_alloc_reply(CellTaskManagerImpl *tm, int id, |
1606 | 292 Threads *speThreads) { |
1179 | 293 |
1499 | 294 /** |
295 * info[0] = alloc_id; (CellScheduler::mainMem_alloc 参照) | |
296 * info[1] = alloc_addr; | |
297 */ | |
298 memaddr alloc_info[2]; | |
299 long alloc_size; | |
300 long command; | |
275 | 301 |
1499 | 302 speThreads->get_mail(id, 2, alloc_info); |
303 command = (long) alloc_info[0]; | |
304 alloc_size = (long) alloc_info[1]; | |
109 | 305 |
1499 | 306 alloc_info[1] = (memaddr) tm->allocate(alloc_size); |
307 //__debug_ppe("[PPE] MALLOCED 0x%lx from [SPE %d]\n", alloc_info[1],id); | |
308 // 今のところ何もしてない。どうも、この allocate を free | |
309 // するのは、SPE task が返した値を見て行うらしい。それは、 | |
310 // 忘れやすいのではないか? | |
311 speThreads->add_output_tasklist(command, alloc_info[1], alloc_size); | |
109 | 312 |
1499 | 313 speThreads->send_mail(id, 2, alloc_info); |
109 | 314 } |
66 | 315 |
109 | 316 /** |
321 | 317 * 条件を満たしたら SPE に TaskList を送信する |
318 * 条件1. SPE が持ってた TaskList を終了して、次の TaskList を待ってる | |
319 * 条件2. SPE に送る TaskList に Task がある | |
109 | 320 * |
808 | 321 * SPE で実行終了した speTaskList と |
322 * これから実行する taskListInfo のバッファを入れ替える | |
109 | 323 */ |
1179 | 324 void CellTaskManagerImpl::send_taskList(int id) { |
1499 | 325 // speTaskList は走り終わった ppe の Task の List. |
326 // taskListInfo はこれから走る Task の List. | |
327 // 交換して実行する | |
328 QueueInfo<TaskList> *tmp = taskListInfo[id]; | |
329 taskListInfo[id] = speTaskList[id]; | |
330 speTaskList[id] = tmp; | |
109 | 331 |
1499 | 332 // speTaskList は本来は循環リストなのだけど、実行中は線形リストである。 |
333 // spe の Task が終了した時点でなおす。 | |
334 tmp->getLast()->next = 0; | |
335 TaskListPtr p = tmp->getFirst(); | |
336 // printf("SPE %d task list sending\n",id); | |
1608
8841d97c37e5
debug CpuThreads::spawn_task
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1606
diff
changeset
|
337 |
8841d97c37e5
debug CpuThreads::spawn_task
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1606
diff
changeset
|
338 // speThreads->send_mail(id, 1, p); |
1580
806b4658ced6
add multi dimension
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1561
diff
changeset
|
339 speThreads->spawn_task(id, p); |
1608
8841d97c37e5
debug CpuThreads::spawn_task
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1606
diff
changeset
|
340 |
1499 | 341 // printf("SPE %d task list sent\n",id); |
57 | 342 } |
343 | |
672 | 344 void CellTaskManagerImpl::show_profile() { |
1499 | 345 for (int id = 0; id < machineNum; id++) { |
346 HTaskPtr t = schedTaskManager->create_task(ShowTime, 0, 0, 0, 0); | |
347 t->set_cpu((CPU_TYPE) (id + SPE_0)); | |
348 t->spawn(); | |
349 } | |
672 | 350 } |
351 | |
352 void CellTaskManagerImpl::start_profile() { | |
1499 | 353 for (int id = 0; id < machineNum; id++) { |
354 HTaskPtr t = schedTaskManager->create_task(StartProfile, 0, 0, 0, 0); | |
355 t->set_cpu((CPU_TYPE) (id + SPE_0)); | |
356 t->spawn(); | |
357 } | |
672 | 358 } |
359 | |
1428
af2adce9752e
add to export TaskLog
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
1362
diff
changeset
|
360 void CellTaskManagerImpl::export_task_log() { |
af2adce9752e
add to export TaskLog
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
1362
diff
changeset
|
361 ExportTaskLog _export(taskLogQueue); |
af2adce9752e
add to export TaskLog
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
1362
diff
changeset
|
362 _export.printOut(); |
af2adce9752e
add to export TaskLog
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
1362
diff
changeset
|
363 } |
af2adce9752e
add to export TaskLog
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
1362
diff
changeset
|
364 |
1179 | 365 void CellTaskManagerImpl::print_arch() { |
1606 | 366 printf("CellTaskManager\n"); |
1067 | 367 } |
368 | |
1427
db5c022d871c
task array uses TaskList. (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1362
diff
changeset
|
369 TaskListPtr CellTaskManagerImpl::createTaskList() |
db5c022d871c
task array uses TaskList. (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1362
diff
changeset
|
370 { |
1480
f2512fb94223
GpuTaskManager no compile error
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1479
diff
changeset
|
371 TaskListPtr tl = taskListInfo[0]->create(); |
f2512fb94223
GpuTaskManager no compile error
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1479
diff
changeset
|
372 bzero(tl->tasks,sizeof(Task)*TASK_MAX_SIZE); |
1561
e8c9a7099bcc
add set NDRange param
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1501
diff
changeset
|
373 return tl; |
e8c9a7099bcc
add set NDRange param
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1501
diff
changeset
|
374 } |
e8c9a7099bcc
add set NDRange param
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1501
diff
changeset
|
375 |
1481 | 376 #if defined (__CERIUM_CELL__)||defined (__CERIUM_GPU__) |
1480
f2512fb94223
GpuTaskManager no compile error
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1479
diff
changeset
|
377 TaskManagerImpl *create_impl(int num, int useRefDma) |
f2512fb94223
GpuTaskManager no compile error
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1479
diff
changeset
|
378 { |
109 | 379 #ifdef __CERIUM_CELL__ |
1480
f2512fb94223
GpuTaskManager no compile error
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1479
diff
changeset
|
380 Threads *cpus = new SpeThreads(num); |
1585 | 381 |
1481 | 382 #elif __CERIUM_GPU__ |
1501
8d6fee66ff65
it looks like working...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1499
diff
changeset
|
383 int num_gpu = 1; |
8d6fee66ff65
it looks like working...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1499
diff
changeset
|
384 Threads *cpus = new CpuThreads(num, useRefDma,num_gpu); |
8d6fee66ff65
it looks like working...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1499
diff
changeset
|
385 num += num_gpu; // for GPU |
1481 | 386 #else |
1480
f2512fb94223
GpuTaskManager no compile error
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1479
diff
changeset
|
387 Threads *cpus = new CpuThreads(num, useRefDma); |
f2512fb94223
GpuTaskManager no compile error
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1479
diff
changeset
|
388 #endif |
1499 | 389 return new CellTaskManagerImpl(num, cpus); |
57 | 390 } |
109 | 391 #endif // __CERIUM_CELL |