annotate TaskManager/Cell/CellTaskManagerImpl.cc @ 481:f9ffcffb6d09 draft

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