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