annotate TaskManager/Cell/CellTaskManagerImpl.cc @ 356:b89ba1d96fff

merge heads
author aaa
date Fri, 17 Jul 2009 15:04:02 +0900
parents 81b25e5d5379 20f2459041cb
children b4b8345b5366
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"
61
6bc72fde6615 *** empty log message ***
gongo
parents: 60
diff changeset
7 #include "CellBufferManager.h"
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
8 #include "PpeScheduler.h"
57
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
9 #include "types.h"
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
10
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
11 CellTaskManagerImpl::~CellTaskManagerImpl(void)
67
7d2874fb0671 *** empty log message ***
gongo
parents: 66
diff changeset
12 {
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
13 delete speThreads;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
14 delete [] speTaskList;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
15 delete [] speTaskList_bg;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
16 /**
321
f64d75473f95 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
17 * bufferManager は
f64d75473f95 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
18 * ppeManager のなかで delete してもらう
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
19 */
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
20 // delete bufferManager;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
21 delete [] flag_sendTaskList;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
22
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
23 delete ppeManager;
67
7d2874fb0671 *** empty log message ***
gongo
parents: 66
diff changeset
24 }
7d2874fb0671 *** empty log message ***
gongo
parents: 66
diff changeset
25
57
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
26 void
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
27 CellTaskManagerImpl::init(void)
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
28 {
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
29 bufferManager = new CellBufferManager(machineNum);
57
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
30 bufferManager->init();
65
519d24aa7ac8 *** empty log message ***
gongo
parents: 61
diff changeset
31
519d24aa7ac8 *** empty log message ***
gongo
parents: 61
diff changeset
32 speThreads = new SpeThreads(machineNum);
519d24aa7ac8 *** empty log message ***
gongo
parents: 61
diff changeset
33 speThreads->init();
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
34
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
35 speTaskList = new TaskListPtr[machineNum];
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
36 speTaskList_bg = new TaskListPtr[machineNum];
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
37 for (int i = 0; i < machineNum; i++) {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
38 speTaskList[i] = bufferManager->create_taskList();
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
39 speTaskList_bg[i] = bufferManager->create_taskList();
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
40 }
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
41
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
42 flag_sendTaskList = new int[machineNum];
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
43 for (int i = 0; i < machineNum; i++) {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
44 flag_sendTaskList[i] = 1;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
45 }
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
46
321
f64d75473f95 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
47 // PPE 側の管理をする Manager
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
48 ppeManager = new FifoTaskManagerImpl(machineNum);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
49 ppeManager->init(new PpeScheduler, bufferManager);
57
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
50 }
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
51
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
52 void
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
53 CellTaskManagerImpl::append_activeTask(HTaskPtr task)
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
54 {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
55 TaskQueuePtr q;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
56
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
57 q = bufferManager->create_taskQueue(task);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
58 if (task->cpu_type == CPU_PPE) {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
59 ppeManager->append_activeTask(task);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
60 } else {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
61 activeTaskQueue = TaskQueue::append(activeTaskQueue, q);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
62 }
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
63 }
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
64
321
f64d75473f95 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
65 // SPE_ANY が指定されていた時に
f64d75473f95 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
66 // これをインクリメントしつつ呼ぶことにする。
f64d75473f95 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
67 // 乱数使ってもいいけどさ。
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
68 int cur_anySpeid = 0;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
69
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
70 /**
321
f64d75473f95 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
71 * ActiveTaskQueue から Task を
f64d75473f95 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
72 * 各 SPE に渡す TaskList に入れる
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
73 *
321
f64d75473f95 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
74 * ここの activeTaskQueue は FifoTaskManagerImpl のと意味が違い、
f64d75473f95 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
75 * spe に渡される Task だけ入っている
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
76 */
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
77 void
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
78 CellTaskManagerImpl::set_runTaskList(void)
70
178459e03f5c *** empty log message ***
gongo
parents: 67
diff changeset
79 {
321
f64d75473f95 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
80 // ここ...直すかな
70
178459e03f5c *** empty log message ***
gongo
parents: 67
diff changeset
81 TaskListPtr list;
178459e03f5c *** empty log message ***
gongo
parents: 67
diff changeset
82 TaskQueuePtr queue;
178459e03f5c *** empty log message ***
gongo
parents: 67
diff changeset
83 TaskQueuePtr d;
178459e03f5c *** empty log message ***
gongo
parents: 67
diff changeset
84 HTaskPtr htask;
178459e03f5c *** empty log message ***
gongo
parents: 67
diff changeset
85 TaskPtr task;
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
86 int speid;
70
178459e03f5c *** empty log message ***
gongo
parents: 67
diff changeset
87
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
88 queue = activeTaskQueue;
70
178459e03f5c *** empty log message ***
gongo
parents: 67
diff changeset
89 if (queue == NULL) {
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
90 return ;
70
178459e03f5c *** empty log message ***
gongo
parents: 67
diff changeset
91 }
178459e03f5c *** empty log message ***
gongo
parents: 67
diff changeset
92
178459e03f5c *** empty log message ***
gongo
parents: 67
diff changeset
93 while (queue) {
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
94 htask = (HTaskPtr)queue->task;
70
178459e03f5c *** empty log message ***
gongo
parents: 67
diff changeset
95 d = queue;
178459e03f5c *** empty log message ***
gongo
parents: 67
diff changeset
96 queue = queue->next;
178459e03f5c *** empty log message ***
gongo
parents: 67
diff changeset
97
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
98 if (htask->cpu_type == SPE_ANY) {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
99 speid = cur_anySpeid++;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
100 cur_anySpeid = (cur_anySpeid < machineNum)
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
101 ? cur_anySpeid : 0;
70
178459e03f5c *** empty log message ***
gongo
parents: 67
diff changeset
102 } else {
321
f64d75473f95 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
103 // -1 してるのは
f64d75473f95 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
104 // htask->cpu_type - CPU_SPE で
f64d75473f95 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
105 // SPE0 = 1, SPE1 = 2, ... SPE5 = 6 ってなってるので
f64d75473f95 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
106 // 配列的 (SPE0 = arr[0], SPE1 = arr[1]) にするため
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
107 speid = htask->cpu_type - CPU_SPE - 1;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
108
321
f64d75473f95 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
109 // SPU の数以上が指定されていれば
f64d75473f95 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
110 // とりあえず MAX_USE_SPE_NUM (実際に動く SPE の最大数) で
f64d75473f95 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
111 // あまり求めてそれを使うことにする。
f64d75473f95 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
112 // ここで判定するもんでもないか?
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
113 if (speid >= machineNum) {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
114 speid %= machineNum;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
115 }
70
178459e03f5c *** empty log message ***
gongo
parents: 67
diff changeset
116 }
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
117
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
118 list = speTaskList_bg[speid];
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
119
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
120 if (list->length >= TASK_MAX_SIZE) {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
121 TaskListPtr newList = bufferManager->create_taskList();
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
122 newList = TaskListInfo::append(newList, speTaskList_bg[speid]);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
123 speTaskList_bg[speid] = newList;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
124 list = newList;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
125 }
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
126
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
127 task = &list->tasks[list->length++];
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
128 #if 0
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
129 task->command = htask->command;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
130 task->inData = htask->inData;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
131 task->outData = htask->outData;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
132 task->self = (unsigned int)htask;
79
83b57e03d3ef *** empty log message ***
gongo
parents: 76
diff changeset
133 #else
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
134 memcpy(task, htask, sizeof(Task));
79
83b57e03d3ef *** empty log message ***
gongo
parents: 76
diff changeset
135 #endif
70
178459e03f5c *** empty log message ***
gongo
parents: 67
diff changeset
136
178459e03f5c *** empty log message ***
gongo
parents: 67
diff changeset
137 bufferManager->free_taskQueue(d);
178459e03f5c *** empty log message ***
gongo
parents: 67
diff changeset
138 }
178459e03f5c *** empty log message ***
gongo
parents: 67
diff changeset
139
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
140 activeTaskQueue = NULL;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
141 }
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
142
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
143 void
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
144 CellTaskManagerImpl::run(void)
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
145 {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
146 TaskListPtr ppeTaskList = NULL;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
147 MailQueuePtr ppeMail = NULL;
70
178459e03f5c *** empty log message ***
gongo
parents: 67
diff changeset
148
321
f64d75473f95 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
149 // PPE 側で動く TaskList です
f64d75473f95 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
150 // FifoTaskManagerImpl::run と上手く合うように
f64d75473f95 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
151 // こんなことやってますよ
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
152 ppeTaskList = ppeManager->get_runTaskList();
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
153 if (!ppeTaskList) {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
154 goto cont;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
155 }
70
178459e03f5c *** empty log message ***
gongo
parents: 67
diff changeset
156
321
f64d75473f95 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
157 // SPE からの Mailbox Check は
f64d75473f95 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
158 // PPE 側の schedule から抜けて来たときに行う
f64d75473f95 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
159 // (speThreads で Blocking Mailbox read と
f64d75473f95 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
160 // セマフォとか使ってやってもいいが、今はこの方式で)
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
161 do {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
162 ppeMail = ppeManager->schedule(ppeTaskList);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
163 cont:
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
164 ppeTaskList = mail_check(ppeMail);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
165 } while (ppeTaskList);
70
178459e03f5c *** empty log message ***
gongo
parents: 67
diff changeset
166 }
178459e03f5c *** empty log message ***
gongo
parents: 67
diff changeset
167
65
519d24aa7ac8 *** empty log message ***
gongo
parents: 61
diff changeset
168 /**
321
f64d75473f95 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
169 * SPE からのメールをチェックする
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
170 *
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
171 * @param [mail_list]
321
f64d75473f95 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
172 * PPE 側で動く Scheduler からのメールリスト
f64d75473f95 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
173 * この中で PPE 側の mail check も行う
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
174 *
321
f64d75473f95 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
175 * @return PPE Scheduler に対してのメール。
f64d75473f95 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
176 * 次に実行する TaskList のアドレスや、終了コマンドを送る
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
177 */TaskListPtr
65
519d24aa7ac8 *** empty log message ***
gongo
parents: 61
diff changeset
178 CellTaskManagerImpl::mail_check(MailQueuePtr mail_list)
57
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
179 {
321
f64d75473f95 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
180 // PPE Scheduler からの mail check
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
181 ppeManager->mail_check(mail_list, &waitTaskQueue);
65
519d24aa7ac8 *** empty log message ***
gongo
parents: 61
diff changeset
182
70
178459e03f5c *** empty log message ***
gongo
parents: 67
diff changeset
183 do {
244
59c3b9df3c67 mail modify
e065746@localhost.localdomain
parents: 109
diff changeset
184 unsigned int data;
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
185
321
f64d75473f95 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
186 // SPE Scheduler からの mail check
244
59c3b9df3c67 mail modify
e065746@localhost.localdomain
parents: 109
diff changeset
187 for (int id = 0; id < machineNum; id++) {
59c3b9df3c67 mail modify
e065746@localhost.localdomain
parents: 109
diff changeset
188 while (speThreads->check_mail(id, 1, &data)) {
70
178459e03f5c *** empty log message ***
gongo
parents: 67
diff changeset
189
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
190 /**
321
f64d75473f95 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
191 * MY_SPE_STATUS_READY: SPE が持ってた Task 全て終了
f64d75473f95 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
192 * MY_SPE_NOP: 特に意味のないコマンド
f64d75473f95 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
193 * それ以外:終了したタスク(PPEにあるのでアドレス
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
194 *
321
f64d75473f95 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
195 * MY_SPE_NOP が 0 なので、
f64d75473f95 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
196 * 下のように data > MY_SPE_NOP とかしています。
f64d75473f95 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
197 * 一目でよくわからない書き方なんで、直したいところですが。。。
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
198 */
321
f64d75473f95 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
199 // 名前あとでちゃんと決めよう => MY_SPE_... とかじゃなくて
70
178459e03f5c *** empty log message ***
gongo
parents: 67
diff changeset
200 if (data == MY_SPE_STATUS_READY) {
334
20f2459041cb [in test_render] push L key , call show_dma_wait, but incomplete.
e065746@localhost.localdomain
parents: 321
diff changeset
201 //__debug_ppe("[SPE %d] finish\n", id);
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
202 flag_sendTaskList[id] = 1;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
203 } else if (data == MY_SPE_COMMAND_MALLOC) {
334
20f2459041cb [in test_render] push L key , call show_dma_wait, but incomplete.
e065746@localhost.localdomain
parents: 321
diff changeset
204 //__debug_ppe("[PPE] MALLOC COMMAND from [SPE %d]\n", id);
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
205
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
206 /**
321
f64d75473f95 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
207 * info[0] = alloc_id; (CellScheduler::mainMem_alloc 参照)
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
208 * info[1] = alloc_addr;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
209 */
244
59c3b9df3c67 mail modify
e065746@localhost.localdomain
parents: 109
diff changeset
210 unsigned int alloc_info[3];
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
211 int alloc_size;
244
59c3b9df3c67 mail modify
e065746@localhost.localdomain
parents: 109
diff changeset
212 int command;
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
213
244
59c3b9df3c67 mail modify
e065746@localhost.localdomain
parents: 109
diff changeset
214 speThreads->get_mail(id, 2, alloc_info);
59c3b9df3c67 mail modify
e065746@localhost.localdomain
parents: 109
diff changeset
215 command = alloc_info[0];
253
1d8b8a4ac453 usr_help_str is nessesary for example
tkaito@localhost.localdomain
parents: 244
diff changeset
216 alloc_size = alloc_info[1];
244
59c3b9df3c67 mail modify
e065746@localhost.localdomain
parents: 109
diff changeset
217
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
218
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
219 alloc_info[1] = (unsigned int)allocate(alloc_size);
244
59c3b9df3c67 mail modify
e065746@localhost.localdomain
parents: 109
diff changeset
220 /*
321
f64d75473f95 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
221 * allocate された領域は今の SPE buffer にリンクとして接続する
f64d75473f95 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
222 * ここでは TaskList を allocate(new) して登録してやろうか
244
59c3b9df3c67 mail modify
e065746@localhost.localdomain
parents: 109
diff changeset
223 */
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
224
334
20f2459041cb [in test_render] push L key , call show_dma_wait, but incomplete.
e065746@localhost.localdomain
parents: 321
diff changeset
225 //__debug_ppe("[PPE] MALLOCED 0x%x from [SPE %d]\n", alloc_info[1],id);
300
0691f38195f6 remove TaskManager/Fifo/MainScheduler.o TaskManeger/Test/test_render/test_nogl
tkaito@localhost.localdomain
parents: 298
diff changeset
226 speThreads->add_output_tasklist(command, alloc_info[1], alloc_size);
273
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 271
diff changeset
227
244
59c3b9df3c67 mail modify
e065746@localhost.localdomain
parents: 109
diff changeset
228 speThreads->send_mail(id, 2, alloc_info);
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
229 } else if (data > MY_SPE_NOP) {
334
20f2459041cb [in test_render] push L key , call show_dma_wait, but incomplete.
e065746@localhost.localdomain
parents: 321
diff changeset
230 //__debug_ppe("[PPE] recv from [SPE %d] : 0x%x\n", id, data);
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
231 check_task_finish((HTaskPtr)data);
70
178459e03f5c *** empty log message ***
gongo
parents: 67
diff changeset
232 }
65
519d24aa7ac8 *** empty log message ***
gongo
parents: 61
diff changeset
233 }
519d24aa7ac8 *** empty log message ***
gongo
parents: 61
diff changeset
234 }
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
235
321
f64d75473f95 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
236 // 依存関係を満たしたタスクをアクティブに
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
237 wakeup_waitTask();
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
238
321
f64d75473f95 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
239 // SPE に送る TaskList の準備
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
240 set_runTaskList();
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
241
321
f64d75473f95 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
242 // TaskList 待ちの SPE に TaskList を送る
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
243 for (int i = 0; i < machineNum; i++) {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
244 if (flag_sendTaskList[i] == 1 && speTaskList_bg[i]->length >= 1 ) {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
245 send_taskList(i);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
246 }
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
247 }
70
178459e03f5c *** empty log message ***
gongo
parents: 67
diff changeset
248
321
f64d75473f95 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
249 // 現在の FifoTaskManager の仕様では
f64d75473f95 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
250 // ・PPE で実行するタスクが無くなれば終了する
f64d75473f95 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
251 // であり、この場合もし SPE にタスクが残っていても
f64d75473f95 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
252 // メインループから抜けてプログラム終了となってしまうので
f64d75473f95 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
253 // ここでストップかけてます。
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
254 } while (!ppeManager->activeTaskQueue && waitTaskQueue);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
255
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
256 return ppeManager->get_runTaskList();
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
257 }
66
1034077dd217 *** empty log message ***
gongo
parents: 65
diff changeset
258
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
259 /**
321
f64d75473f95 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
260 * 条件を満たしたら SPE に TaskList を送信する
f64d75473f95 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
261 * 条件1. SPE が持ってた TaskList を終了して、次の TaskList を待ってる
f64d75473f95 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
262 * 条件2. SPE に送る TaskList に Task がある
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
263 *
321
f64d75473f95 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
264 * SPE で実行終了した TaskList [speTaskList] と
f64d75473f95 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
265 * これから実行する TaskList [speTaskList_bg] のバッファを入れ替える
f64d75473f95 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
266 * ついでに実行終了したやつは clear しておく。
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
267 */
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
268 void
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
269 CellTaskManagerImpl::send_taskList(int id)
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
270 {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
271 TaskListPtr tmp;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
272
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
273 tmp = speTaskList[id];
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
274 speTaskList[id] = speTaskList_bg[id];
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
275 speTaskList_bg[id] = tmp;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
276
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
277 bufferManager->clear_taskList(speTaskList_bg[id]);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
278
244
59c3b9df3c67 mail modify
e065746@localhost.localdomain
parents: 109
diff changeset
279 speThreads->send_mail(id, 1, (unsigned int *)&speTaskList[id]);
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
280 flag_sendTaskList[id] = 0;
57
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
281 }
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
282
65
519d24aa7ac8 *** empty log message ***
gongo
parents: 61
diff changeset
283
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
284 void*
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
285 CellTaskManagerImpl::allocate(int size)
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
286 {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
287 void *buff;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
288
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
289 posix_memalign(&buff, DEFAULT_ALIGNMENT, size);
244
59c3b9df3c67 mail modify
e065746@localhost.localdomain
parents: 109
diff changeset
290
321
f64d75473f95 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
291 // bzero はコストが高いのでやりたくない
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
292 bzero(buff, size);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
293
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
294 return buff;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
295 }
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
296
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
297 #ifdef __CERIUM_CELL__
57
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
298 TaskManagerImpl*
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
299 create_impl(int num)
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
300 {
67
7d2874fb0671 *** empty log message ***
gongo
parents: 66
diff changeset
301 return new CellTaskManagerImpl(num);
57
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
302 }
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
303 #endif // __CERIUM_CELL