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