comparison TaskManager/Cell/CellTaskManagerImpl.cc @ 720:dac59b74e02a

Cell fix
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Sat, 19 Dec 2009 10:43:19 +0900
parents cafffff0f45a
children 2b167196cb27
comparison
equal deleted inserted replaced
719:cafffff0f45a 720:dac59b74e02a
9 #include "SchedTask.h" 9 #include "SchedTask.h"
10 #include "MainScheduler.h" 10 #include "MainScheduler.h"
11 #include "types.h" 11 #include "types.h"
12 #include "SysFunc.h" 12 #include "SysFunc.h"
13 13
14 static void send_alloc_reply(SpeThreads *speThreads); 14 static void send_alloc_reply(CellTaskManagerImpl *tm, int id, SpeThreads *speThreads);
15 15
16 CellTaskManagerImpl::~CellTaskManagerImpl() 16 CellTaskManagerImpl::~CellTaskManagerImpl()
17 { 17 {
18 delete speThreads; 18 delete speThreads;
19 delete [] speTaskList; 19 delete [] speTaskList;
160 160
161 do { 161 do {
162 // PPE side 162 // PPE side
163 ppeTaskList = ppeManager->get_runTaskList(); 163 ppeTaskList = ppeManager->get_runTaskList();
164 ppeManager->schedule(ppeTaskList); 164 ppeManager->schedule(ppeTaskList);
165 ppeManager->mail_check(waitTaskQueue); 165 ppeManager->mail_check();
166 // SPE side 166 // SPE side
167 do { 167 do {
168 mail_check(waitTaskQueue); 168 mail_check();
169 // SPE に送る TaskList の準備 169 // SPE に送る TaskList の準備
170 set_runTaskList(); 170 set_runTaskList();
171 // TaskList 待ちの SPE に TaskList を送る 171 // TaskList 待ちの SPE に TaskList を送る
172 for (int i = 0; i < machineNum; i++) { 172 for (int i = 0; i < machineNum; i++) {
173 if (flag_sendTaskList[i] == 1 && speTaskList_bg[i]->length >= 1 ) { 173 if (flag_sendTaskList[i] == 1 && speTaskList_bg[i]->length >= 1 ) {
195 // MY_SPE_STATUS_READY: SPE が持ってた Task 全て終了 195 // MY_SPE_STATUS_READY: SPE が持ってた Task 全て終了
196 flag_sendTaskList[id] = 1; 196 flag_sendTaskList[id] = 1;
197 spe_running--; 197 spe_running--;
198 } else if (data == (memaddr)MY_SPE_COMMAND_MALLOC) { 198 } else if (data == (memaddr)MY_SPE_COMMAND_MALLOC) {
199 // MY_SPE_COMMAND_MALLOC SPE からのmain memory request 199 // MY_SPE_COMMAND_MALLOC SPE からのmain memory request
200 send_alloc_reply(speThreads); 200 send_alloc_reply(this, id, speThreads);
201 } else if (data > (memaddr)MY_SPE_NOP) { 201 } else if (data > (memaddr)MY_SPE_NOP) {
202 // 終了したタスク(PPEにあるのでアドレス) 202 // 終了したタスク(PPEにあるのでアドレス)
203 HTaskPtr task = (HTaskPtr)data; 203 HTaskPtr task = (HTaskPtr)data;
204 task->post_func(schedTaskManager, task->post_arg1, task->post_arg2); 204 task->post_func(schedTaskManager, task->post_arg1, task->post_arg2);
205 check_task_finish(task,waitTaskQueue); 205 check_task_finish(task,waitTaskQueue);
208 } 208 }
209 } 209 }
210 } 210 }
211 211
212 static void 212 static void
213 send_alloc_reply(SpeThreads *speThreads) 213 send_alloc_reply(CellTaskManagerImpl *tm, int id, SpeThreads *speThreads)
214 { 214 {
215 215
216 /** 216 /**
217 * info[0] = alloc_id; (CellScheduler::mainMem_alloc 参照) 217 * info[0] = alloc_id; (CellScheduler::mainMem_alloc 参照)
218 * info[1] = alloc_addr; 218 * info[1] = alloc_addr;
224 speThreads->get_mail(id, 2, alloc_info); 224 speThreads->get_mail(id, 2, alloc_info);
225 command = (long)alloc_info[0]; 225 command = (long)alloc_info[0];
226 alloc_size = (long)alloc_info[1]; 226 alloc_size = (long)alloc_info[1];
227 227
228 228
229 alloc_info[1] = (memaddr)allocate(alloc_size); 229 alloc_info[1] = (memaddr)tm->allocate(alloc_size);
230 //__debug_ppe("[PPE] MALLOCED 0x%lx from [SPE %d]\n", alloc_info[1],id); 230 //__debug_ppe("[PPE] MALLOCED 0x%lx from [SPE %d]\n", alloc_info[1],id);
231 // 今のところ何もしてない。どうも、この allocate を free 231 // 今のところ何もしてない。どうも、この allocate を free
232 // するのは、SPE task が返した値を見て行うらしい。それは、 232 // するのは、SPE task が返した値を見て行うらしい。それは、
233 // 忘れやすいのではないか? 233 // 忘れやすいのではないか?
234 speThreads->add_output_tasklist(command, alloc_info[1], alloc_size); 234 speThreads->add_output_tasklist(command, alloc_info[1], alloc_size);