annotate TaskManager/Cell/CellTaskManagerImpl.cc @ 664:beb0f17c19f9 draft

word count
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Thu, 03 Dec 2009 00:20:28 +0900
parents 7ba4ad4538b1
children 27fec8c70c9c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
321
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
1 #define DEBUG
f22280772f20 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
5fc79ff9c257 CellBufferManager removed
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 380
diff changeset
7 #include "CellTaskListInfo.h"
501
7ddbe22d4cdb Cell inData/outData DMA removal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 496
diff changeset
8 #include "HTaskInfo.h"
621
64e05530e333 Cell fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 620
diff changeset
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
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
11 #include "types.h"
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
12
501
7ddbe22d4cdb Cell inData/outData DMA removal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 496
diff changeset
13 CellTaskManagerImpl::~CellTaskManagerImpl()
67
7d2874fb0671 *** empty log message ***
gongo
parents: 66
diff changeset
14 {
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
15 delete speThreads;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
16 delete [] speTaskList;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
17 delete [] speTaskList_bg;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
18 /**
321
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
19 * bufferManager は
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
20 * ppeManager のなかで delete してもらう
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
21 */
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
22 // delete bufferManager;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
23 delete [] flag_sendTaskList;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
24
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
25 delete ppeManager;
67
7d2874fb0671 *** empty log message ***
gongo
parents: 66
diff changeset
26 }
7d2874fb0671 *** empty log message ***
gongo
parents: 66
diff changeset
27
57
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
28 void
501
7ddbe22d4cdb Cell inData/outData DMA removal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 496
diff changeset
29 CellTaskManagerImpl::init()
57
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
30 {
637
20665e4060ea not yet worked...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 635
diff changeset
31 spe_running = 0;
476
5fc79ff9c257 CellBufferManager removed
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 380
diff changeset
32 taskListImpl = new CellTaskListInfo;
664
beb0f17c19f9 word count
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 647
diff changeset
33 taskListImpl->init(16);
476
5fc79ff9c257 CellBufferManager removed
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 380
diff changeset
34
501
7ddbe22d4cdb Cell inData/outData DMA removal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 496
diff changeset
35 activeTaskQueue = new HTaskInfo();
481
f9ffcffb6d09 Double linked list modification done (tested on Mac OS X)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 479
diff changeset
36
501
7ddbe22d4cdb Cell inData/outData DMA removal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 496
diff changeset
37 htaskImpl = activeTaskQueue ; // any HTaskInfo
65
519d24aa7ac8 *** empty log message ***
gongo
parents: 61
diff changeset
38
519d24aa7ac8 *** empty log message ***
gongo
parents: 61
diff changeset
39 speThreads = new SpeThreads(machineNum);
519d24aa7ac8 *** empty log message ***
gongo
parents: 61
diff changeset
40 speThreads->init();
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
41
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
42 speTaskList = new TaskListPtr[machineNum];
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
43 speTaskList_bg = new TaskListPtr[machineNum];
476
5fc79ff9c257 CellBufferManager removed
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 380
diff changeset
44
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
45 for (int i = 0; i < machineNum; i++) {
476
5fc79ff9c257 CellBufferManager removed
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 380
diff changeset
46 speTaskList[i] = taskListImpl->create();
5fc79ff9c257 CellBufferManager removed
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 380
diff changeset
47 speTaskList_bg[i] = taskListImpl->create();
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
48 }
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
49
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
50 flag_sendTaskList = new int[machineNum];
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
51 for (int i = 0; i < machineNum; i++) {
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
52 flag_sendTaskList[i] = 1;
476
5fc79ff9c257 CellBufferManager removed
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 380
diff changeset
53 }
321
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
54 // PPE 側の管理をする Manager
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
55 ppeManager = new FifoTaskManagerImpl(machineNum);
479
bf2d2625485e Double Linked List base TaskQueue
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 476
diff changeset
56 // 大半のTaskQueueInfoは、共有される
637
20665e4060ea not yet worked...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 635
diff changeset
57 MainScheduler *mscheduler = new MainScheduler;
20665e4060ea not yet worked...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 635
diff changeset
58 ppeManager->init(mscheduler, this);
619
278db3ca751d RenewTask removal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 538
diff changeset
59
278db3ca751d RenewTask removal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 538
diff changeset
60 ppeManager->get_scheduler()->set_manager(this);
637
20665e4060ea not yet worked...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 635
diff changeset
61
619
278db3ca751d RenewTask removal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 538
diff changeset
62 schedTaskManager = new SchedTask();
278db3ca751d RenewTask removal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 538
diff changeset
63 schedTaskManager->init(0,0,0,ppeManager->get_scheduler());
57
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
64 }
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
65
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
66 void
501
7ddbe22d4cdb Cell inData/outData DMA removal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 496
diff changeset
67 CellTaskManagerImpl::append_activeTask(HTaskPtr task)
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
68 {
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
69 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
70 ppeManager->append_activeTask(task);
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
71 } else {
501
7ddbe22d4cdb Cell inData/outData DMA removal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 496
diff changeset
72 activeTaskQueue->addLast(task);
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
73 }
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
74 }
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
75
321
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
76 // SPE_ANY が指定されていた時に
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
77 // これをインクリメントしつつ呼ぶことにする。
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
78 // 乱数使ってもいいけどさ。
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
79 int cur_anySpeid = 0;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
80
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
81 /**
321
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
82 * ActiveTaskQueue から Task を
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
83 * 各 SPE に渡す TaskList に入れる
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
84 *
321
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
85 * ここの activeTaskQueue は FifoTaskManagerImpl のと意味が違い、
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
86 * spe に渡される Task だけ入っている
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
87 */
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
88 void
501
7ddbe22d4cdb Cell inData/outData DMA removal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 496
diff changeset
89 CellTaskManagerImpl::set_runTaskList()
70
178459e03f5c *** empty log message ***
gongo
parents: 67
diff changeset
90 {
321
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
91 // ここ...直すかな
70
178459e03f5c *** empty log message ***
gongo
parents: 67
diff changeset
92 TaskListPtr list;
481
f9ffcffb6d09 Double linked list modification done (tested on Mac OS X)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 479
diff changeset
93
70
178459e03f5c *** empty log message ***
gongo
parents: 67
diff changeset
94 TaskPtr task;
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
95 int speid;
70
178459e03f5c *** empty log message ***
gongo
parents: 67
diff changeset
96
501
7ddbe22d4cdb Cell inData/outData DMA removal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 496
diff changeset
97 while (HTaskPtr htask = activeTaskQueue->poll()) {
70
178459e03f5c *** empty log message ***
gongo
parents: 67
diff changeset
98
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
99 if (htask->cpu_type == SPE_ANY) {
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
100 speid = cur_anySpeid++;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
101 cur_anySpeid = (cur_anySpeid < machineNum)
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
102 ? cur_anySpeid : 0;
70
178459e03f5c *** empty log message ***
gongo
parents: 67
diff changeset
103 } else {
321
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
104 // -1 してるのは
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
105 // htask->cpu_type - CPU_SPE で
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
106 // SPE0 = 1, SPE1 = 2, ... SPE5 = 6 ってなってるので
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
107 // 配列的 (SPE0 = arr[0], SPE1 = arr[1]) にするため
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
108 speid = htask->cpu_type - CPU_SPE - 1;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
109
321
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
110 // SPU の数以上が指定されていれば
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
111 // とりあえず MAX_USE_SPE_NUM (実際に動く SPE の最大数) で
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
112 // あまり求めてそれを使うことにする。
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
113 // ここで判定するもんでもないか?
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
114 if (speid >= machineNum) {
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
115 speid %= machineNum;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
116 }
70
178459e03f5c *** empty log message ***
gongo
parents: 67
diff changeset
117 }
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
118
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
119 list = speTaskList_bg[speid];
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
120
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
121 if (list->length >= TASK_MAX_SIZE) {
476
5fc79ff9c257 CellBufferManager removed
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 380
diff changeset
122 TaskListPtr newList = taskListImpl->create();
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
123 newList = TaskListInfo::append(newList, speTaskList_bg[speid]);
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
124 speTaskList_bg[speid] = newList;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
125 list = newList;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
126 }
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
127
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
128 task = &list->tasks[list->length++];
631
30dd8a3deb4a Cell 64 bit tried, but not yet worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 621
diff changeset
129 TaskPtr stask = (TaskPtr) task;
30dd8a3deb4a Cell 64 bit tried, but not yet worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 621
diff changeset
130 *stask = *(TaskPtr) htask;
70
178459e03f5c *** empty log message ***
gongo
parents: 67
diff changeset
131 }
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
132 }
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
133
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
134 void
501
7ddbe22d4cdb Cell inData/outData DMA removal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 496
diff changeset
135 CellTaskManagerImpl::run()
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
136 {
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
137 TaskListPtr ppeTaskList = NULL;
70
178459e03f5c *** empty log message ***
gongo
parents: 67
diff changeset
138
321
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
139 // PPE 側で動く TaskList です
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
140 // FifoTaskManagerImpl::run と上手く合うように
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
141 // こんなことやってますよ
637
20665e4060ea not yet worked...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 635
diff changeset
142 //
20665e4060ea not yet worked...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 635
diff changeset
143 // 本来は、別 thread で動かすべきだろう...
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
144 ppeTaskList = ppeManager->get_runTaskList();
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
145 if (!ppeTaskList) {
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
146 goto cont;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
147 }
70
178459e03f5c *** empty log message ***
gongo
parents: 67
diff changeset
148
321
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
149 // SPE からの Mailbox Check は
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
150 // PPE 側の schedule から抜けて来たときに行う
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
151 // (speThreads で Blocking Mailbox read と
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
152 // セマフォとか使ってやってもいいが、今はこの方式で)
637
20665e4060ea not yet worked...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 635
diff changeset
153 //
20665e4060ea not yet worked...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 635
diff changeset
154 // すべてのspe task が finish task を待つ場合は、ppeTaskList の
20665e4060ea not yet worked...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 635
diff changeset
155 // 判定だけで十分だが、そうでない場合は、spe の task が残っているか
20665e4060ea not yet worked...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 635
diff changeset
156 // どうかを調べる必要がある。
20665e4060ea not yet worked...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 635
diff changeset
157 //
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
158 do {
647
7ba4ad4538b1 MailManager rewrite. not yet worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 640
diff changeset
159 ppeManager->schedule(ppeTaskList);
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
160 cont:
647
7ba4ad4538b1 MailManager rewrite. not yet worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 640
diff changeset
161 ppeTaskList = mail_check(waitTaskQueue);
637
20665e4060ea not yet worked...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 635
diff changeset
162 } while (ppeTaskList || spe_running >0);
70
178459e03f5c *** empty log message ***
gongo
parents: 67
diff changeset
163 }
178459e03f5c *** empty log message ***
gongo
parents: 67
diff changeset
164
65
519d24aa7ac8 *** empty log message ***
gongo
parents: 61
diff changeset
165 /**
321
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
166 * SPE からのメールをチェックする
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
167 *
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
168 * @param [mail_list]
321
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
169 * PPE 側で動く Scheduler からのメールリスト
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
170 * この中で PPE 側の mail check も行う
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
171 *
321
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
172 * @return PPE Scheduler に対してのメール。
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
173 * 次に実行する TaskList のアドレスや、終了コマンドを送る
640
ecf056ddd21a SimpeTask on Cell worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 638
diff changeset
174 */
ecf056ddd21a SimpeTask on Cell worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 638
diff changeset
175
ecf056ddd21a SimpeTask on Cell worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 638
diff changeset
176 TaskListPtr
647
7ba4ad4538b1 MailManager rewrite. not yet worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 640
diff changeset
177 CellTaskManagerImpl::mail_check(HTaskInfo *wait_queue)
57
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
178 {
321
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
179 // PPE Scheduler からの mail check
647
7ba4ad4538b1 MailManager rewrite. not yet worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 640
diff changeset
180 ppeManager->mail_check(waitTaskQueue);
65
519d24aa7ac8 *** empty log message ***
gongo
parents: 61
diff changeset
181
70
178459e03f5c *** empty log message ***
gongo
parents: 67
diff changeset
182 do {
631
30dd8a3deb4a Cell 64 bit tried, but not yet worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 621
diff changeset
183 memaddr data;
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
184
321
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
185 // SPE Scheduler からの mail check
244
e9735a64cd90 mail modify
e065746@localhost.localdomain
parents: 109
diff changeset
186 for (int id = 0; id < machineNum; id++) {
647
7ba4ad4538b1 MailManager rewrite. not yet worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 640
diff changeset
187 while (speThreads->has_mail(id, 1, &data)) {
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
188 /**
321
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
189 * MY_SPE_STATUS_READY: SPE が持ってた Task 全て終了
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
190 * MY_SPE_NOP: 特に意味のないコマンド
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
191 * それ以外:終了したタスク(PPEにあるのでアドレス
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
192 *
321
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
193 * MY_SPE_NOP が 0 なので、
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
194 * 下のように data > MY_SPE_NOP とかしています。
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
195 * 一目でよくわからない書き方なんで、直したいところですが。。。
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
196 */
321
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
197 // 名前あとでちゃんと決めよう => MY_SPE_... とかじゃなくて
631
30dd8a3deb4a Cell 64 bit tried, but not yet worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 621
diff changeset
198 if (data == (memaddr)MY_SPE_STATUS_READY) {
334
7bc5cbc5fe04 [in test_render] push L key , call show_dma_wait, but incomplete.
e065746@localhost.localdomain
parents: 321
diff changeset
199 //__debug_ppe("[SPE %d] finish\n", id);
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
200 flag_sendTaskList[id] = 1;
637
20665e4060ea not yet worked...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 635
diff changeset
201 spe_running--;
631
30dd8a3deb4a Cell 64 bit tried, but not yet worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 621
diff changeset
202 } else if (data == (memaddr)MY_SPE_COMMAND_MALLOC) {
334
7bc5cbc5fe04 [in test_render] push L key , call show_dma_wait, but incomplete.
e065746@localhost.localdomain
parents: 321
diff changeset
203 //__debug_ppe("[PPE] MALLOC COMMAND from [SPE %d]\n", id);
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
204
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
205 /**
321
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
206 * info[0] = alloc_id; (CellScheduler::mainMem_alloc 参照)
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
207 * info[1] = alloc_addr;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
208 */
631
30dd8a3deb4a Cell 64 bit tried, but not yet worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 621
diff changeset
209 memaddr alloc_info[2];
30dd8a3deb4a Cell 64 bit tried, but not yet worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 621
diff changeset
210 long alloc_size;
30dd8a3deb4a Cell 64 bit tried, but not yet worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 621
diff changeset
211 long command;
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
212
244
e9735a64cd90 mail modify
e065746@localhost.localdomain
parents: 109
diff changeset
213 speThreads->get_mail(id, 2, alloc_info);
631
30dd8a3deb4a Cell 64 bit tried, but not yet worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 621
diff changeset
214 command = (long)alloc_info[0];
30dd8a3deb4a Cell 64 bit tried, but not yet worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 621
diff changeset
215 alloc_size = (long)alloc_info[1];
244
e9735a64cd90 mail modify
e065746@localhost.localdomain
parents: 109
diff changeset
216
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
217
631
30dd8a3deb4a Cell 64 bit tried, but not yet worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 621
diff changeset
218 alloc_info[1] = (memaddr)allocate(alloc_size);
244
e9735a64cd90 mail modify
e065746@localhost.localdomain
parents: 109
diff changeset
219 /*
321
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
220 * allocate された領域は今の SPE buffer にリンクとして接続する
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
221 * ここでは TaskList を allocate(new) して登録してやろうか
244
e9735a64cd90 mail modify
e065746@localhost.localdomain
parents: 109
diff changeset
222 */
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
223
631
30dd8a3deb4a Cell 64 bit tried, but not yet worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 621
diff changeset
224 //__debug_ppe("[PPE] MALLOCED 0x%lx from [SPE %d]\n", alloc_info[1],id);
30dd8a3deb4a Cell 64 bit tried, but not yet worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 621
diff changeset
225 // 今のところ何もしてない。どうも、この allocate を free
30dd8a3deb4a Cell 64 bit tried, but not yet worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 621
diff changeset
226 // するのは、SPE task が返した値を見て行うらしい。それは、
30dd8a3deb4a Cell 64 bit tried, but not yet worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 621
diff changeset
227 // 忘れやすいのではないか?
300
68d4267cb4a4 remove TaskManager/Fifo/MainScheduler.o TaskManeger/Test/test_render/test_nogl
tkaito@localhost.localdomain
parents: 298
diff changeset
228 speThreads->add_output_tasklist(command, alloc_info[1], alloc_size);
275
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 273
diff changeset
229
621
64e05530e333 Cell fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 620
diff changeset
230 speThreads->send_mail(id, 2, alloc_info);
631
30dd8a3deb4a Cell 64 bit tried, but not yet worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 621
diff changeset
231 } else if (data > (memaddr)MY_SPE_NOP) {
334
7bc5cbc5fe04 [in test_render] push L key , call show_dma_wait, but incomplete.
e065746@localhost.localdomain
parents: 321
diff changeset
232 //__debug_ppe("[PPE] recv from [SPE %d] : 0x%x\n", id, data);
619
278db3ca751d RenewTask removal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 538
diff changeset
233 HTaskPtr task = (HTaskPtr)data;
278db3ca751d RenewTask removal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 538
diff changeset
234 task->post_func(schedTaskManager, task->post_arg1, task->post_arg2);
647
7ba4ad4538b1 MailManager rewrite. not yet worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 640
diff changeset
235 check_task_finish(task,waitTaskQueue);
70
178459e03f5c *** empty log message ***
gongo
parents: 67
diff changeset
236 }
65
519d24aa7ac8 *** empty log message ***
gongo
parents: 61
diff changeset
237 }
519d24aa7ac8 *** empty log message ***
gongo
parents: 61
diff changeset
238 }
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
239
321
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
240 // 依存関係を満たしたタスクをアクティブに
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
241 wakeup_waitTask();
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
242
321
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
243 // SPE に送る TaskList の準備
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
244 set_runTaskList();
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
245
321
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
246 // TaskList 待ちの SPE に TaskList を送る
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
247 for (int i = 0; i < machineNum; i++) {
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
248 if (flag_sendTaskList[i] == 1 && speTaskList_bg[i]->length >= 1 ) {
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
249 send_taskList(i);
637
20665e4060ea not yet worked...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 635
diff changeset
250 spe_running++;
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
251 }
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
252 }
70
178459e03f5c *** empty log message ***
gongo
parents: 67
diff changeset
253
321
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
254 // 現在の FifoTaskManager の仕様では
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
255 // ・PPE で実行するタスクが無くなれば終了する
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
256 // であり、この場合もし SPE にタスクが残っていても
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
257 // メインループから抜けてプログラム終了となってしまうので
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
258 // ここでストップかけてます。
481
f9ffcffb6d09 Double linked list modification done (tested on Mac OS X)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 479
diff changeset
259 } while (ppeManager->activeTaskQueue->empty() && !waitTaskQueue->empty());
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
260
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
261 return ppeManager->get_runTaskList();
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
262 }
66
1034077dd217 *** empty log message ***
gongo
parents: 65
diff changeset
263
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
264 /**
321
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
265 * 条件を満たしたら SPE に TaskList を送信する
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
266 * 条件1. SPE が持ってた TaskList を終了して、次の TaskList を待ってる
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
267 * 条件2. SPE に送る TaskList に Task がある
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
268 *
321
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
269 * SPE で実行終了した TaskList [speTaskList] と
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
270 * これから実行する TaskList [speTaskList_bg] のバッファを入れ替える
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
271 * ついでに実行終了したやつは clear しておく。
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
272 */
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
273 void
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
274 CellTaskManagerImpl::send_taskList(int id)
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
275 {
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
276 TaskListPtr tmp;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
277
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
278 tmp = speTaskList[id];
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
279 speTaskList[id] = speTaskList_bg[id];
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
280 speTaskList_bg[id] = tmp;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
281
476
5fc79ff9c257 CellBufferManager removed
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 380
diff changeset
282 taskListImpl->clear_taskList(speTaskList_bg[id]);
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
283
631
30dd8a3deb4a Cell 64 bit tried, but not yet worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 621
diff changeset
284 speThreads->send_mail(id, 1, (memaddr *)&speTaskList[id]);
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
285 flag_sendTaskList[id] = 0;
57
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
286 }
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
287
380
fcd53a8b777c ps3 fix
e065701@localhost.localdomain
parents: 356
diff changeset
288
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
289 #ifdef __CERIUM_CELL__
57
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
290 TaskManagerImpl*
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
291 create_impl(int num)
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
292 {
67
7d2874fb0671 *** empty log message ***
gongo
parents: 66
diff changeset
293 return new CellTaskManagerImpl(num);
57
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
294 }
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
295 #endif // __CERIUM_CELL