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