annotate TaskManager/Cell/CellTaskManagerImpl.cc @ 721:a0cfe7b28882 draft

cleanups..
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Sat, 19 Dec 2009 12:12:09 +0900
parents fc380dcad630
children 55d70a61dedc
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"
672
27fec8c70c9c add profiling code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 664
diff changeset
12 #include "SysFunc.h"
27fec8c70c9c add profiling code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 664
diff changeset
13
720
fc380dcad630 Cell fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 719
diff changeset
14 static void send_alloc_reply(CellTaskManagerImpl *tm, int id, SpeThreads *speThreads);
57
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
15
501
7ddbe22d4cdb Cell inData/outData DMA removal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 496
diff changeset
16 CellTaskManagerImpl::~CellTaskManagerImpl()
67
7d2874fb0671 *** empty log message ***
gongo
parents: 66
diff changeset
17 {
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
18 delete speThreads;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
19 delete [] speTaskList;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
20 delete [] speTaskList_bg;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
21 /**
321
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
22 * bufferManager は
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
23 * ppeManager のなかで delete してもらう
109
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 bufferManager;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
26 delete [] flag_sendTaskList;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
27
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
28 delete ppeManager;
67
7d2874fb0671 *** empty log message ***
gongo
parents: 66
diff changeset
29 }
7d2874fb0671 *** empty log message ***
gongo
parents: 66
diff changeset
30
57
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
31 void
501
7ddbe22d4cdb Cell inData/outData DMA removal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 496
diff changeset
32 CellTaskManagerImpl::init()
57
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
33 {
637
20665e4060ea not yet worked...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 635
diff changeset
34 spe_running = 0;
476
5fc79ff9c257 CellBufferManager removed
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 380
diff changeset
35 taskListImpl = new CellTaskListInfo;
664
beb0f17c19f9 word count
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 647
diff changeset
36 taskListImpl->init(16);
476
5fc79ff9c257 CellBufferManager removed
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 380
diff changeset
37
501
7ddbe22d4cdb Cell inData/outData DMA removal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 496
diff changeset
38 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
39
501
7ddbe22d4cdb Cell inData/outData DMA removal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 496
diff changeset
40 htaskImpl = activeTaskQueue ; // any HTaskInfo
65
519d24aa7ac8 *** empty log message ***
gongo
parents: 61
diff changeset
41
519d24aa7ac8 *** empty log message ***
gongo
parents: 61
diff changeset
42 speThreads = new SpeThreads(machineNum);
519d24aa7ac8 *** empty log message ***
gongo
parents: 61
diff changeset
43 speThreads->init();
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
44
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
45 speTaskList = new TaskListPtr[machineNum];
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
46 speTaskList_bg = new TaskListPtr[machineNum];
476
5fc79ff9c257 CellBufferManager removed
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 380
diff changeset
47
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
48 for (int i = 0; i < machineNum; i++) {
476
5fc79ff9c257 CellBufferManager removed
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 380
diff changeset
49 speTaskList[i] = taskListImpl->create();
5fc79ff9c257 CellBufferManager removed
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 380
diff changeset
50 speTaskList_bg[i] = taskListImpl->create();
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
51 }
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
52
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
53 flag_sendTaskList = new int[machineNum];
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
54 for (int i = 0; i < machineNum; i++) {
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
55 flag_sendTaskList[i] = 1;
476
5fc79ff9c257 CellBufferManager removed
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 380
diff changeset
56 }
321
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
57 // PPE 側の管理をする Manager
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
58 ppeManager = new FifoTaskManagerImpl(machineNum);
479
bf2d2625485e Double Linked List base TaskQueue
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 476
diff changeset
59 // 大半のTaskQueueInfoは、共有される
637
20665e4060ea not yet worked...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 635
diff changeset
60 MainScheduler *mscheduler = new MainScheduler;
20665e4060ea not yet worked...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 635
diff changeset
61 ppeManager->init(mscheduler, this);
619
278db3ca751d RenewTask removal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 538
diff changeset
62
278db3ca751d RenewTask removal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 538
diff changeset
63 ppeManager->get_scheduler()->set_manager(this);
637
20665e4060ea not yet worked...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 635
diff changeset
64
619
278db3ca751d RenewTask removal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 538
diff changeset
65 schedTaskManager = new SchedTask();
278db3ca751d RenewTask removal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 538
diff changeset
66 schedTaskManager->init(0,0,0,ppeManager->get_scheduler());
57
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
67 }
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
68
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
69 void
501
7ddbe22d4cdb Cell inData/outData DMA removal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 496
diff changeset
70 CellTaskManagerImpl::append_activeTask(HTaskPtr task)
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
71 {
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
72 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
73 ppeManager->append_activeTask(task);
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
74 } else {
501
7ddbe22d4cdb Cell inData/outData DMA removal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 496
diff changeset
75 activeTaskQueue->addLast(task);
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
76 }
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 // SPE_ANY が指定されていた時に
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
80 // これをインクリメントしつつ呼ぶことにする。
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
81 // 乱数使ってもいいけどさ。
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
82 int cur_anySpeid = 0;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
83
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 から Task を
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
86 * 各 SPE に渡す TaskList に入れる
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
87 *
321
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
88 * ここの activeTaskQueue は FifoTaskManagerImpl のと意味が違い、
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
89 * spe に渡される Task だけ入っている
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
90 */
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
91 void
501
7ddbe22d4cdb Cell inData/outData DMA removal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 496
diff changeset
92 CellTaskManagerImpl::set_runTaskList()
70
178459e03f5c *** empty log message ***
gongo
parents: 67
diff changeset
93 {
178459e03f5c *** empty log message ***
gongo
parents: 67
diff changeset
94 TaskListPtr list;
704
ec6c897448ca Compatibility mode works.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 672
diff changeset
95 SimpleTaskPtr task;
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
96 int speid;
70
178459e03f5c *** empty log message ***
gongo
parents: 67
diff changeset
97
501
7ddbe22d4cdb Cell inData/outData DMA removal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 496
diff changeset
98 while (HTaskPtr htask = activeTaskQueue->poll()) {
70
178459e03f5c *** empty log message ***
gongo
parents: 67
diff changeset
99
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
100 if (htask->cpu_type == SPE_ANY) {
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
101 speid = cur_anySpeid++;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
102 cur_anySpeid = (cur_anySpeid < machineNum)
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
103 ? cur_anySpeid : 0;
70
178459e03f5c *** empty log message ***
gongo
parents: 67
diff changeset
104 } else {
321
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
105 // -1 してるのは
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
106 // htask->cpu_type - CPU_SPE で
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
107 // SPE0 = 1, SPE1 = 2, ... SPE5 = 6 ってなってるので
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
108 // 配列的 (SPE0 = arr[0], SPE1 = arr[1]) にするため
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
109 speid = htask->cpu_type - CPU_SPE - 1;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
110
321
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
111 // SPU の数以上が指定されていれば
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
112 // とりあえず MAX_USE_SPE_NUM (実際に動く SPE の最大数) で
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
113 // あまり求めてそれを使うことにする。
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
114 // ここで判定するもんでもないか?
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
115 if (speid >= machineNum) {
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
116 speid %= machineNum;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
117 }
70
178459e03f5c *** empty log message ***
gongo
parents: 67
diff changeset
118 }
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
119
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
120 list = speTaskList_bg[speid];
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
121
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
122 if (list->length >= TASK_MAX_SIZE) {
476
5fc79ff9c257 CellBufferManager removed
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 380
diff changeset
123 TaskListPtr newList = taskListImpl->create();
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
124 newList = TaskListInfo::append(newList, speTaskList_bg[speid]);
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
125 speTaskList_bg[speid] = newList;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
126 list = newList;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
127 }
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
128
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
129 task = &list->tasks[list->length++];
713
97adb3fe85c6 remove SIMPLE_TASK conditional
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 704
diff changeset
130
704
ec6c897448ca Compatibility mode works.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 672
diff changeset
131 if (htask->command==TaskArray1) {
ec6c897448ca Compatibility mode works.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 672
diff changeset
132 // compatibility
ec6c897448ca Compatibility mode works.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 672
diff changeset
133 // Task with ListData is stored in the ListData
ec6c897448ca Compatibility mode works.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 672
diff changeset
134 int next = (htask->r_size+sizeof(SimpleTask))/sizeof(SimpleTask);
ec6c897448ca Compatibility mode works.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 672
diff changeset
135 if (list->length+next>=TASK_MAX_SIZE) {
ec6c897448ca Compatibility mode works.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 672
diff changeset
136 list->length--;
ec6c897448ca Compatibility mode works.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 672
diff changeset
137 TaskListPtr newList = taskListImpl->create();
ec6c897448ca Compatibility mode works.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 672
diff changeset
138 newList = TaskListInfo::append(newList, speTaskList_bg[speid]);
ec6c897448ca Compatibility mode works.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 672
diff changeset
139 speTaskList_bg[speid] = newList;
ec6c897448ca Compatibility mode works.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 672
diff changeset
140 list = newList;
ec6c897448ca Compatibility mode works.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 672
diff changeset
141 task = &list->tasks[list->length++];
ec6c897448ca Compatibility mode works.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 672
diff changeset
142 }
ec6c897448ca Compatibility mode works.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 672
diff changeset
143 Task *array = (Task*)&list->tasks[list->length];
ec6c897448ca Compatibility mode works.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 672
diff changeset
144 list->length += next;
ec6c897448ca Compatibility mode works.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 672
diff changeset
145 memcpy(array, htask->rbuf, htask->r_size);
ec6c897448ca Compatibility mode works.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 672
diff changeset
146 free(htask->rbuf);
ec6c897448ca Compatibility mode works.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 672
diff changeset
147 htask->rbuf = 0; htask->r_size = 0;
ec6c897448ca Compatibility mode works.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 672
diff changeset
148 *task = *(SimpleTask*)htask;
ec6c897448ca Compatibility mode works.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 672
diff changeset
149 } else {
ec6c897448ca Compatibility mode works.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 672
diff changeset
150 *task = *(SimpleTask*)htask;
ec6c897448ca Compatibility mode works.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 672
diff changeset
151 }
ec6c897448ca Compatibility mode works.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 672
diff changeset
152
70
178459e03f5c *** empty log message ***
gongo
parents: 67
diff changeset
153 }
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
154 }
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
155
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
156 void
721
a0cfe7b28882 cleanups..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 720
diff changeset
157 CellTaskManager::sednTaskList()
a0cfe7b28882 cleanups..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 720
diff changeset
158 {
a0cfe7b28882 cleanups..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 720
diff changeset
159 for (int i = 0; i < machineNum; i++) {
a0cfe7b28882 cleanups..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 720
diff changeset
160 if (flag_sendTaskList[i] == 1 && speTaskList_bg[i]->length >= 1 ) {
a0cfe7b28882 cleanups..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 720
diff changeset
161 send_taskList(i);
a0cfe7b28882 cleanups..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 720
diff changeset
162 spe_running++;
a0cfe7b28882 cleanups..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 720
diff changeset
163 }
a0cfe7b28882 cleanups..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 720
diff changeset
164 }
a0cfe7b28882 cleanups..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 720
diff changeset
165 }
a0cfe7b28882 cleanups..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 720
diff changeset
166
a0cfe7b28882 cleanups..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 720
diff changeset
167 void
501
7ddbe22d4cdb Cell inData/outData DMA removal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 496
diff changeset
168 CellTaskManagerImpl::run()
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
169 {
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
170 TaskListPtr ppeTaskList = NULL;
70
178459e03f5c *** empty log message ***
gongo
parents: 67
diff changeset
171
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
172 do {
719
cc1b7333de92 clean up scheduler main loop
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 718
diff changeset
173 // PPE side
cc1b7333de92 clean up scheduler main loop
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 718
diff changeset
174 ppeTaskList = ppeManager->get_runTaskList();
721
a0cfe7b28882 cleanups..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 720
diff changeset
175 if (ppeTaskList)
a0cfe7b28882 cleanups..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 720
diff changeset
176 ppeManager->sendTaskList(ppeTaskList);
720
fc380dcad630 Cell fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 719
diff changeset
177 ppeManager->mail_check();
719
cc1b7333de92 clean up scheduler main loop
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 718
diff changeset
178 // SPE side
cc1b7333de92 clean up scheduler main loop
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 718
diff changeset
179 do {
720
fc380dcad630 Cell fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 719
diff changeset
180 mail_check();
719
cc1b7333de92 clean up scheduler main loop
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 718
diff changeset
181 // SPE に送る TaskList の準備
cc1b7333de92 clean up scheduler main loop
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 718
diff changeset
182 set_runTaskList();
cc1b7333de92 clean up scheduler main loop
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 718
diff changeset
183 // TaskList 待ちの SPE に TaskList を送る
721
a0cfe7b28882 cleanups..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 720
diff changeset
184 sednTaskList();
a0cfe7b28882 cleanups..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 720
diff changeset
185 } while (ppeManager->activeTaskQueue->empty());
a0cfe7b28882 cleanups..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 720
diff changeset
186 } while (ppeTaskList || spe_running >0);
a0cfe7b28882 cleanups..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 720
diff changeset
187 if (!waitTaskQueue->empty()) {
a0cfe7b28882 cleanups..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 720
diff changeset
188 fprintf(stderr,"Dead lock detected\n");
a0cfe7b28882 cleanups..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 720
diff changeset
189 }
70
178459e03f5c *** empty log message ***
gongo
parents: 67
diff changeset
190 }
178459e03f5c *** empty log message ***
gongo
parents: 67
diff changeset
191
65
519d24aa7ac8 *** empty log message ***
gongo
parents: 61
diff changeset
192 /**
321
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
193 * SPE からのメールをチェックする
640
ecf056ddd21a SimpeTask on Cell worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 638
diff changeset
194 */
ecf056ddd21a SimpeTask on Cell worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 638
diff changeset
195
719
cc1b7333de92 clean up scheduler main loop
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 718
diff changeset
196 void
cc1b7333de92 clean up scheduler main loop
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 718
diff changeset
197 CellTaskManagerImpl::mail_check()
57
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
198 {
719
cc1b7333de92 clean up scheduler main loop
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 718
diff changeset
199 memaddr data;
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
200
719
cc1b7333de92 clean up scheduler main loop
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 718
diff changeset
201 // SPE Scheduler からの mail check
cc1b7333de92 clean up scheduler main loop
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 718
diff changeset
202 for (int id = 0; id < machineNum; id++) {
cc1b7333de92 clean up scheduler main loop
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 718
diff changeset
203 while (speThreads->has_mail(id, 1, &data)) {
cc1b7333de92 clean up scheduler main loop
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 718
diff changeset
204 if (data == (memaddr)MY_SPE_STATUS_READY) {
cc1b7333de92 clean up scheduler main loop
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 718
diff changeset
205 // MY_SPE_STATUS_READY: SPE が持ってた Task 全て終了
cc1b7333de92 clean up scheduler main loop
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 718
diff changeset
206 flag_sendTaskList[id] = 1;
cc1b7333de92 clean up scheduler main loop
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 718
diff changeset
207 spe_running--;
cc1b7333de92 clean up scheduler main loop
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 718
diff changeset
208 } else if (data == (memaddr)MY_SPE_COMMAND_MALLOC) {
cc1b7333de92 clean up scheduler main loop
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 718
diff changeset
209 // MY_SPE_COMMAND_MALLOC SPE からのmain memory request
720
fc380dcad630 Cell fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 719
diff changeset
210 send_alloc_reply(this, id, speThreads);
719
cc1b7333de92 clean up scheduler main loop
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 718
diff changeset
211 } else if (data > (memaddr)MY_SPE_NOP) {
cc1b7333de92 clean up scheduler main loop
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 718
diff changeset
212 // 終了したタスク(PPEにあるのでアドレス)
cc1b7333de92 clean up scheduler main loop
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 718
diff changeset
213 HTaskPtr task = (HTaskPtr)data;
cc1b7333de92 clean up scheduler main loop
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 718
diff changeset
214 task->post_func(schedTaskManager, task->post_arg1, task->post_arg2);
cc1b7333de92 clean up scheduler main loop
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 718
diff changeset
215 check_task_finish(task,waitTaskQueue);
cc1b7333de92 clean up scheduler main loop
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 718
diff changeset
216 }
cc1b7333de92 clean up scheduler main loop
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 718
diff changeset
217 // MY_SPE_NOP: 特に意味のないコマンド
cc1b7333de92 clean up scheduler main loop
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 718
diff changeset
218 }
cc1b7333de92 clean up scheduler main loop
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 718
diff changeset
219 }
cc1b7333de92 clean up scheduler main loop
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 718
diff changeset
220 }
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
221
719
cc1b7333de92 clean up scheduler main loop
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 718
diff changeset
222 static void
720
fc380dcad630 Cell fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 719
diff changeset
223 send_alloc_reply(CellTaskManagerImpl *tm, int id, SpeThreads *speThreads)
719
cc1b7333de92 clean up scheduler main loop
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 718
diff changeset
224 {
275
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 273
diff changeset
225
719
cc1b7333de92 clean up scheduler main loop
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 718
diff changeset
226 /**
cc1b7333de92 clean up scheduler main loop
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 718
diff changeset
227 * info[0] = alloc_id; (CellScheduler::mainMem_alloc 参照)
cc1b7333de92 clean up scheduler main loop
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 718
diff changeset
228 * info[1] = alloc_addr;
cc1b7333de92 clean up scheduler main loop
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 718
diff changeset
229 */
cc1b7333de92 clean up scheduler main loop
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 718
diff changeset
230 memaddr alloc_info[2];
cc1b7333de92 clean up scheduler main loop
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 718
diff changeset
231 long alloc_size;
cc1b7333de92 clean up scheduler main loop
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 718
diff changeset
232 long command;
cc1b7333de92 clean up scheduler main loop
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 718
diff changeset
233
cc1b7333de92 clean up scheduler main loop
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 718
diff changeset
234 speThreads->get_mail(id, 2, alloc_info);
cc1b7333de92 clean up scheduler main loop
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 718
diff changeset
235 command = (long)alloc_info[0];
cc1b7333de92 clean up scheduler main loop
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 718
diff changeset
236 alloc_size = (long)alloc_info[1];
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
237
719
cc1b7333de92 clean up scheduler main loop
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 718
diff changeset
238
720
fc380dcad630 Cell fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 719
diff changeset
239 alloc_info[1] = (memaddr)tm->allocate(alloc_size);
719
cc1b7333de92 clean up scheduler main loop
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 718
diff changeset
240 //__debug_ppe("[PPE] MALLOCED 0x%lx from [SPE %d]\n", alloc_info[1],id);
cc1b7333de92 clean up scheduler main loop
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 718
diff changeset
241 // 今のところ何もしてない。どうも、この allocate を free
cc1b7333de92 clean up scheduler main loop
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 718
diff changeset
242 // するのは、SPE task が返した値を見て行うらしい。それは、
cc1b7333de92 clean up scheduler main loop
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 718
diff changeset
243 // 忘れやすいのではないか?
cc1b7333de92 clean up scheduler main loop
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 718
diff changeset
244 speThreads->add_output_tasklist(command, alloc_info[1], alloc_size);
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
245
719
cc1b7333de92 clean up scheduler main loop
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 718
diff changeset
246 speThreads->send_mail(id, 2, alloc_info);
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
247 }
66
1034077dd217 *** empty log message ***
gongo
parents: 65
diff changeset
248
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
249 /**
321
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
250 * 条件を満たしたら SPE に TaskList を送信する
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
251 * 条件1. SPE が持ってた TaskList を終了して、次の TaskList を待ってる
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
252 * 条件2. SPE に送る TaskList に Task がある
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
253 *
321
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
254 * SPE で実行終了した TaskList [speTaskList] と
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
255 * これから実行する TaskList [speTaskList_bg] のバッファを入れ替える
f22280772f20 merge 317
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 318
diff changeset
256 * ついでに実行終了したやつは clear しておく。
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
257 */
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
258 void
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
259 CellTaskManagerImpl::send_taskList(int id)
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
260 {
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
261 TaskListPtr tmp;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
262
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
263 tmp = speTaskList[id];
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
264 speTaskList[id] = speTaskList_bg[id];
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
265 speTaskList_bg[id] = tmp;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
266
476
5fc79ff9c257 CellBufferManager removed
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 380
diff changeset
267 taskListImpl->clear_taskList(speTaskList_bg[id]);
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
268
631
30dd8a3deb4a Cell 64 bit tried, but not yet worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 621
diff changeset
269 speThreads->send_mail(id, 1, (memaddr *)&speTaskList[id]);
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
270 flag_sendTaskList[id] = 0;
57
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
271 }
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
272
672
27fec8c70c9c add profiling code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 664
diff changeset
273 void CellTaskManagerImpl::show_profile() {
27fec8c70c9c add profiling code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 664
diff changeset
274 for (int id = 0; id < machineNum; id++) {
27fec8c70c9c add profiling code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 664
diff changeset
275 HTaskPtr t = create_task(ShowTime);
27fec8c70c9c add profiling code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 664
diff changeset
276 t->set_cpu((CPU_TYPE)(id+2));
27fec8c70c9c add profiling code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 664
diff changeset
277 t->spawn();
27fec8c70c9c add profiling code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 664
diff changeset
278 }
27fec8c70c9c add profiling code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 664
diff changeset
279 }
27fec8c70c9c add profiling code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 664
diff changeset
280
27fec8c70c9c add profiling code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 664
diff changeset
281 void CellTaskManagerImpl::start_profile() {
27fec8c70c9c add profiling code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 664
diff changeset
282 for (int id = 0; id < machineNum; id++) {
27fec8c70c9c add profiling code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 664
diff changeset
283 HTaskPtr t = create_task(StartProfile);
27fec8c70c9c add profiling code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 664
diff changeset
284 t->set_cpu((CPU_TYPE)(id+2));
27fec8c70c9c add profiling code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 664
diff changeset
285 t->spawn();
27fec8c70c9c add profiling code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 664
diff changeset
286 }
27fec8c70c9c add profiling code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 664
diff changeset
287 }
27fec8c70c9c add profiling code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 664
diff changeset
288
380
fcd53a8b777c ps3 fix
e065701@localhost.localdomain
parents: 356
diff changeset
289
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
290 #ifdef __CERIUM_CELL__
57
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
291 TaskManagerImpl*
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
292 create_impl(int num)
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
293 {
67
7d2874fb0671 *** empty log message ***
gongo
parents: 66
diff changeset
294 return new CellTaskManagerImpl(num);
57
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
295 }
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents: 88
diff changeset
296 #endif // __CERIUM_CELL