annotate TaskManager/Cell/CellTaskManagerImpl.cc @ 809:76a39ad68846

fix
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Sat, 22 May 2010 23:23:29 +0900
parents 8a6f1fa038de
children ff684304e1d3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
321
f64d75473f95 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
1 #define DEBUG
f64d75473f95 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
2 #include "error.h"
57
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
3 #include <stdio.h>
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
4 #include <stdlib.h>
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
5 #include <string.h>
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
6 #include "CellTaskManagerImpl.h"
476
926d6aff886c CellBufferManager removed
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 380
diff changeset
7 #include "CellTaskListInfo.h"
501
4a2c9ff53605 Cell inData/outData DMA removal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 496
diff changeset
8 #include "HTaskInfo.h"
621
5b178db5988a Cell fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 620
diff changeset
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
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
11 #include "types.h"
672
3b6290c05f9f add profiling code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 664
diff changeset
12 #include "SysFunc.h"
3b6290c05f9f add profiling code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 664
diff changeset
13
720
dac59b74e02a Cell fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 719
diff changeset
14 static void send_alloc_reply(CellTaskManagerImpl *tm, int id, SpeThreads *speThreads);
57
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
15
501
4a2c9ff53605 Cell inData/outData DMA removal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 496
diff changeset
16 CellTaskManagerImpl::~CellTaskManagerImpl()
67
7d2874fb0671 *** empty log message ***
gongo
parents: 66
diff changeset
17 {
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
18 delete speThreads;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
19 delete [] speTaskList;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
20
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
21 delete ppeManager;
67
7d2874fb0671 *** empty log message ***
gongo
parents: 66
diff changeset
22 }
7d2874fb0671 *** empty log message ***
gongo
parents: 66
diff changeset
23
57
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
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
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
26 {
637
5530fa36d42e not yet worked...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 635
diff changeset
27 spe_running = 0;
476
926d6aff886c CellBufferManager removed
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 380
diff changeset
28 taskListImpl = new CellTaskListInfo;
808
8a6f1fa038de TaskListInfo version
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 801
diff changeset
29
476
926d6aff886c CellBufferManager removed
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 380
diff changeset
30
501
4a2c9ff53605 Cell inData/outData DMA removal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 496
diff changeset
31 activeTaskQueue = new HTaskInfo();
481
4896dffad67c Double linked list modification done (tested on Mac OS X)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 479
diff changeset
32
501
4a2c9ff53605 Cell inData/outData DMA removal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 496
diff changeset
33 htaskImpl = activeTaskQueue ; // any HTaskInfo
65
519d24aa7ac8 *** empty log message ***
gongo
parents: 61
diff changeset
34
519d24aa7ac8 *** empty log message ***
gongo
parents: 61
diff changeset
35 speThreads = new SpeThreads(machineNum);
519d24aa7ac8 *** empty log message ***
gongo
parents: 61
diff changeset
36 speThreads->init();
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
37
808
8a6f1fa038de TaskListInfo version
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 801
diff changeset
38 speTaskList = new TaskListInfoPtr[machineNum];
476
926d6aff886c CellBufferManager removed
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 380
diff changeset
39
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
40 for (int i = 0; i < machineNum; i++) {
808
8a6f1fa038de TaskListInfo version
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 801
diff changeset
41 speTaskList[i] = new TaskListInfo();
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
42 }
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
43
321
f64d75473f95 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
44 // PPE 側の管理をする Manager
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
45 ppeManager = new FifoTaskManagerImpl(machineNum);
479
5bda98b0b56d Double Linked List base TaskQueue
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 476
diff changeset
46 // 大半のTaskQueueInfoは、共有される
637
5530fa36d42e not yet worked...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 635
diff changeset
47 MainScheduler *mscheduler = new MainScheduler;
5530fa36d42e not yet worked...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 635
diff changeset
48 ppeManager->init(mscheduler, this);
619
0decff4e867b RenewTask removal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 506
diff changeset
49
0decff4e867b RenewTask removal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 506
diff changeset
50 ppeManager->get_scheduler()->set_manager(this);
637
5530fa36d42e not yet worked...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 635
diff changeset
51
619
0decff4e867b RenewTask removal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 506
diff changeset
52 schedTaskManager = new SchedTask();
0decff4e867b RenewTask removal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 506
diff changeset
53 schedTaskManager->init(0,0,0,ppeManager->get_scheduler());
57
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
54 }
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
55
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
56 void
501
4a2c9ff53605 Cell inData/outData DMA removal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 496
diff changeset
57 CellTaskManagerImpl::append_activeTask(HTaskPtr task)
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
58 {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
59 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
60 ppeManager->append_activeTask(task);
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
61 } else {
501
4a2c9ff53605 Cell inData/outData DMA removal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 496
diff changeset
62 activeTaskQueue->addLast(task);
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
63 }
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
64 }
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
65
321
f64d75473f95 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
66 // SPE_ANY が指定されていた時に
f64d75473f95 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
67 // これをインクリメントしつつ呼ぶことにする。
f64d75473f95 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
68 // 乱数使ってもいいけどさ。
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
69 int cur_anySpeid = 0;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
70
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
71 /**
321
f64d75473f95 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
72 * ActiveTaskQueue から Task を
f64d75473f95 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
73 * 各 SPE に渡す TaskList に入れる
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
74 *
321
f64d75473f95 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
75 * ここの activeTaskQueue は FifoTaskManagerImpl のと意味が違い、
f64d75473f95 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
76 * spe に渡される Task だけ入っている
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
77 */
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
78 void
501
4a2c9ff53605 Cell inData/outData DMA removal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 496
diff changeset
79 CellTaskManagerImpl::set_runTaskList()
70
178459e03f5c *** empty log message ***
gongo
parents: 67
diff changeset
80 {
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
81 int speid;
70
178459e03f5c *** empty log message ***
gongo
parents: 67
diff changeset
82
501
4a2c9ff53605 Cell inData/outData DMA removal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 496
diff changeset
83 while (HTaskPtr htask = activeTaskQueue->poll()) {
70
178459e03f5c *** empty log message ***
gongo
parents: 67
diff changeset
84
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
85 if (htask->cpu_type == SPE_ANY) {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
86 speid = cur_anySpeid++;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
87 cur_anySpeid = (cur_anySpeid < machineNum)
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
88 ? cur_anySpeid : 0;
70
178459e03f5c *** empty log message ***
gongo
parents: 67
diff changeset
89 } else {
321
f64d75473f95 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
90 // -1 してるのは
f64d75473f95 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
91 // htask->cpu_type - CPU_SPE で
f64d75473f95 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
92 // SPE0 = 1, SPE1 = 2, ... SPE5 = 6 ってなってるので
f64d75473f95 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
93 // 配列的 (SPE0 = arr[0], SPE1 = arr[1]) にするため
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
94 speid = htask->cpu_type - CPU_SPE - 1;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
95
321
f64d75473f95 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
96 // SPU の数以上が指定されていれば
f64d75473f95 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
97 // とりあえず MAX_USE_SPE_NUM (実際に動く SPE の最大数) で
f64d75473f95 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
98 // あまり求めてそれを使うことにする。
f64d75473f95 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
99 // ここで判定するもんでもないか?
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
100 if (speid >= machineNum) {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
101 speid %= machineNum;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
102 }
70
178459e03f5c *** empty log message ***
gongo
parents: 67
diff changeset
103 }
808
8a6f1fa038de TaskListInfo version
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 801
diff changeset
104 set_taskList(htask, taskListInfo[speid]);
70
178459e03f5c *** empty log message ***
gongo
parents: 67
diff changeset
105 }
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
106 }
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
107
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
108 void
722
abad59c7e3ac CellTaskManager fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 721
diff changeset
109 CellTaskManagerImpl::sendTaskList()
721
2b167196cb27 cleanups..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 720
diff changeset
110 {
2b167196cb27 cleanups..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 720
diff changeset
111 for (int i = 0; i < machineNum; i++) {
808
8a6f1fa038de TaskListInfo version
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 801
diff changeset
112 if ( taskListInfo[i]->length() > 0 ) {
721
2b167196cb27 cleanups..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 720
diff changeset
113 send_taskList(i);
2b167196cb27 cleanups..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 720
diff changeset
114 spe_running++;
2b167196cb27 cleanups..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 720
diff changeset
115 }
2b167196cb27 cleanups..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 720
diff changeset
116 }
2b167196cb27 cleanups..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 720
diff changeset
117 }
2b167196cb27 cleanups..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 720
diff changeset
118
2b167196cb27 cleanups..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 720
diff changeset
119 void
808
8a6f1fa038de TaskListInfo version
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 801
diff changeset
120 CellTaskManagerImpl::poll()
8a6f1fa038de TaskListInfo version
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 801
diff changeset
121 {
8a6f1fa038de TaskListInfo version
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 801
diff changeset
122 mail_check();
8a6f1fa038de TaskListInfo version
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 801
diff changeset
123 // SPE に送る TaskList の準備
8a6f1fa038de TaskListInfo version
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 801
diff changeset
124 set_runTaskList();
8a6f1fa038de TaskListInfo version
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 801
diff changeset
125 // TaskList 待ちの SPE に TaskList を送る
8a6f1fa038de TaskListInfo version
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 801
diff changeset
126 sendTaskList();
8a6f1fa038de TaskListInfo version
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 801
diff changeset
127 }
8a6f1fa038de TaskListInfo version
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 801
diff changeset
128
8a6f1fa038de TaskListInfo version
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 801
diff changeset
129 void
501
4a2c9ff53605 Cell inData/outData DMA removal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 496
diff changeset
130 CellTaskManagerImpl::run()
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
131 {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
132 do {
719
cafffff0f45a clean up scheduler main loop
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 718
diff changeset
133 // PPE side
808
8a6f1fa038de TaskListInfo version
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 801
diff changeset
134 ppeManager->poll();
719
cafffff0f45a clean up scheduler main loop
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 718
diff changeset
135 // SPE side
cafffff0f45a clean up scheduler main loop
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 718
diff changeset
136 do {
808
8a6f1fa038de TaskListInfo version
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 801
diff changeset
137 poll();
722
abad59c7e3ac CellTaskManager fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 721
diff changeset
138 } while (ppeManager->activeTaskQueue->empty() && spe_running >0 );
808
8a6f1fa038de TaskListInfo version
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 801
diff changeset
139 } while (!ppeManager->taskListInfo->empty() || spe_running >0);
721
2b167196cb27 cleanups..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 720
diff changeset
140 if (!waitTaskQueue->empty()) {
736
31d0a5baafdf cut printf
hiroki@localhost.localdomain
parents: 722
diff changeset
141 get_scheduler()->printf("Dead lock detected\n");
721
2b167196cb27 cleanups..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 720
diff changeset
142 }
70
178459e03f5c *** empty log message ***
gongo
parents: 67
diff changeset
143 }
178459e03f5c *** empty log message ***
gongo
parents: 67
diff changeset
144
65
519d24aa7ac8 *** empty log message ***
gongo
parents: 61
diff changeset
145 /**
321
f64d75473f95 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
146 * SPE からのメールをチェックする
640
a909c50081c2 SimpeTask on Cell worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 638
diff changeset
147 */
a909c50081c2 SimpeTask on Cell worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 638
diff changeset
148
719
cafffff0f45a clean up scheduler main loop
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 718
diff changeset
149 void
cafffff0f45a clean up scheduler main loop
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 718
diff changeset
150 CellTaskManagerImpl::mail_check()
57
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
151 {
719
cafffff0f45a clean up scheduler main loop
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 718
diff changeset
152 memaddr data;
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
153
719
cafffff0f45a clean up scheduler main loop
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 718
diff changeset
154 // SPE Scheduler からの mail check
cafffff0f45a clean up scheduler main loop
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 718
diff changeset
155 for (int id = 0; id < machineNum; id++) {
cafffff0f45a clean up scheduler main loop
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 718
diff changeset
156 while (speThreads->has_mail(id, 1, &data)) {
cafffff0f45a clean up scheduler main loop
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 718
diff changeset
157 if (data == (memaddr)MY_SPE_STATUS_READY) {
cafffff0f45a clean up scheduler main loop
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 718
diff changeset
158 // MY_SPE_STATUS_READY: SPE が持ってた Task 全て終了
808
8a6f1fa038de TaskListInfo version
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 801
diff changeset
159 speTaskList[id]->freeAll();
719
cafffff0f45a clean up scheduler main loop
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 718
diff changeset
160 spe_running--;
cafffff0f45a clean up scheduler main loop
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 718
diff changeset
161 } else if (data == (memaddr)MY_SPE_COMMAND_MALLOC) {
cafffff0f45a clean up scheduler main loop
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 718
diff changeset
162 // MY_SPE_COMMAND_MALLOC SPE からのmain memory request
720
dac59b74e02a Cell fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 719
diff changeset
163 send_alloc_reply(this, id, speThreads);
719
cafffff0f45a clean up scheduler main loop
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 718
diff changeset
164 } else if (data > (memaddr)MY_SPE_NOP) {
cafffff0f45a clean up scheduler main loop
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 718
diff changeset
165 // 終了したタスク(PPEにあるのでアドレス)
cafffff0f45a clean up scheduler main loop
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 718
diff changeset
166 HTaskPtr task = (HTaskPtr)data;
cafffff0f45a clean up scheduler main loop
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 718
diff changeset
167 task->post_func(schedTaskManager, task->post_arg1, task->post_arg2);
cafffff0f45a clean up scheduler main loop
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 718
diff changeset
168 check_task_finish(task,waitTaskQueue);
cafffff0f45a clean up scheduler main loop
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 718
diff changeset
169 }
cafffff0f45a clean up scheduler main loop
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 718
diff changeset
170 // MY_SPE_NOP: 特に意味のないコマンド
cafffff0f45a clean up scheduler main loop
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 718
diff changeset
171 }
cafffff0f45a clean up scheduler main loop
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 718
diff changeset
172 }
cafffff0f45a clean up scheduler main loop
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 718
diff changeset
173 }
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
174
719
cafffff0f45a clean up scheduler main loop
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 718
diff changeset
175 static void
720
dac59b74e02a Cell fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 719
diff changeset
176 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
177 {
273
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 271
diff changeset
178
719
cafffff0f45a clean up scheduler main loop
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 718
diff changeset
179 /**
cafffff0f45a clean up scheduler main loop
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 718
diff changeset
180 * 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
181 * info[1] = alloc_addr;
cafffff0f45a clean up scheduler main loop
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 718
diff changeset
182 */
cafffff0f45a clean up scheduler main loop
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 718
diff changeset
183 memaddr alloc_info[2];
cafffff0f45a clean up scheduler main loop
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 718
diff changeset
184 long alloc_size;
cafffff0f45a clean up scheduler main loop
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 718
diff changeset
185 long command;
cafffff0f45a clean up scheduler main loop
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 718
diff changeset
186
cafffff0f45a clean up scheduler main loop
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 718
diff changeset
187 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
188 command = (long)alloc_info[0];
cafffff0f45a clean up scheduler main loop
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 718
diff changeset
189 alloc_size = (long)alloc_info[1];
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
190
719
cafffff0f45a clean up scheduler main loop
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 718
diff changeset
191
720
dac59b74e02a Cell fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 719
diff changeset
192 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
193 //__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
194 // 今のところ何もしてない。どうも、この allocate を free
cafffff0f45a clean up scheduler main loop
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 718
diff changeset
195 // するのは、SPE task が返した値を見て行うらしい。それは、
cafffff0f45a clean up scheduler main loop
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 718
diff changeset
196 // 忘れやすいのではないか?
cafffff0f45a clean up scheduler main loop
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 718
diff changeset
197 speThreads->add_output_tasklist(command, alloc_info[1], alloc_size);
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
198
719
cafffff0f45a clean up scheduler main loop
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 718
diff changeset
199 speThreads->send_mail(id, 2, alloc_info);
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
200 }
66
1034077dd217 *** empty log message ***
gongo
parents: 65
diff changeset
201
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
202 /**
321
f64d75473f95 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
203 * 条件を満たしたら SPE に TaskList を送信する
f64d75473f95 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
204 * 条件1. SPE が持ってた TaskList を終了して、次の TaskList を待ってる
f64d75473f95 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
205 * 条件2. SPE に送る TaskList に Task がある
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
206 *
808
8a6f1fa038de TaskListInfo version
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 801
diff changeset
207 * SPE で実行終了した speTaskList と
8a6f1fa038de TaskListInfo version
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 801
diff changeset
208 * これから実行する taskListInfo のバッファを入れ替える
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
209 */
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
210 void
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
211 CellTaskManagerImpl::send_taskList(int id)
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
212 {
808
8a6f1fa038de TaskListInfo version
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 801
diff changeset
213 if (taskListInfo[id]->empty()) return;
8a6f1fa038de TaskListInfo version
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 801
diff changeset
214 TaskListInfoPtr tmp = taskListInfo[id];
8a6f1fa038de TaskListInfo version
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 801
diff changeset
215 taskListInfo[id] = speTaskList[id];
8a6f1fa038de TaskListInfo version
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 801
diff changeset
216 speTaskList[id] = tmp;
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
217
809
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 808
diff changeset
218 tmp->getLast()->next = 0;
808
8a6f1fa038de TaskListInfo version
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 801
diff changeset
219 speThreads->send_mail(id, 1, (memaddr *)tmp->getFirst());
57
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
220 }
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
221
672
3b6290c05f9f add profiling code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 664
diff changeset
222 void CellTaskManagerImpl::show_profile() {
3b6290c05f9f add profiling code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 664
diff changeset
223 for (int id = 0; id < machineNum; id++) {
3b6290c05f9f add profiling code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 664
diff changeset
224 HTaskPtr t = create_task(ShowTime);
3b6290c05f9f add profiling code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 664
diff changeset
225 t->set_cpu((CPU_TYPE)(id+2));
3b6290c05f9f add profiling code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 664
diff changeset
226 t->spawn();
3b6290c05f9f add profiling code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 664
diff changeset
227 }
3b6290c05f9f add profiling code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 664
diff changeset
228 }
3b6290c05f9f add profiling code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 664
diff changeset
229
3b6290c05f9f add profiling code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 664
diff changeset
230 void CellTaskManagerImpl::start_profile() {
3b6290c05f9f add profiling code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 664
diff changeset
231 for (int id = 0; id < machineNum; id++) {
3b6290c05f9f add profiling code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 664
diff changeset
232 HTaskPtr t = create_task(StartProfile);
3b6290c05f9f add profiling code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 664
diff changeset
233 t->set_cpu((CPU_TYPE)(id+2));
3b6290c05f9f add profiling code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 664
diff changeset
234 t->spawn();
3b6290c05f9f add profiling code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 664
diff changeset
235 }
3b6290c05f9f add profiling code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 664
diff changeset
236 }
3b6290c05f9f add profiling code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 664
diff changeset
237
380
b4b8345b5366 ps3 fix
e065701@localhost.localdomain
parents: 356
diff changeset
238
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
239 #ifdef __CERIUM_CELL__
57
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
240 TaskManagerImpl*
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
241 create_impl(int num)
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
242 {
67
7d2874fb0671 *** empty log message ***
gongo
parents: 66
diff changeset
243 return new CellTaskManagerImpl(num);
57
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
244 }
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
245 #endif // __CERIUM_CELL