Mercurial > hg > Game > Cerium
annotate TaskManager/kernel/schedule/Scheduler.cc @ 1737:6bd9a57eb44d draft
minor fix
author | Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp> |
---|---|
date | Sat, 02 Nov 2013 17:34:40 +0900 |
parents | 91b690b27066 |
children | 94a824cde2e4 |
rev | line source |
---|---|
1142
801d57ae1e29
cut compile CreatePolygonTask on spe side because not enough spe memory. We have to use code loading.
yutaka@localhost.localdomain
parents:
1124
diff
changeset
|
1 //#include <stdio.h> |
50 | 2 #include <stdlib.h> |
736 | 3 #include <stdarg.h> |
42 | 4 #include "Scheduler.h" |
736 | 5 #include "SchedTask.h" |
42 | 6 #include "SchedNop.h" |
923
382a48afb061
fix DMA/Mail wait profiler
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
893
diff
changeset
|
7 #include "SysFunc.h" |
42 | 8 #include "error.h" |
386 | 9 #include <assert.h> |
621 | 10 #include "TaskManagerImpl.h" |
42 | 11 |
313
25dfa7499162
fix ppu mail box waiting (mainMem allocate)
kono@localhost.localdomain
parents:
301
diff
changeset
|
12 /* |
25dfa7499162
fix ppu mail box waiting (mainMem allocate)
kono@localhost.localdomain
parents:
301
diff
changeset
|
13 * Edit kernel/schedule/xx.cc, Cell/spe/xx.cc will be over writen by this. |
25dfa7499162
fix ppu mail box waiting (mainMem allocate)
kono@localhost.localdomain
parents:
301
diff
changeset
|
14 * Do not edit Cell/spe/xx.cc unless there is no kernel/schedule/xx.cc files. |
25dfa7499162
fix ppu mail box waiting (mainMem allocate)
kono@localhost.localdomain
parents:
301
diff
changeset
|
15 */ |
25dfa7499162
fix ppu mail box waiting (mainMem allocate)
kono@localhost.localdomain
parents:
301
diff
changeset
|
16 |
698
72b2da99e875
no compile error for Task Array
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
690
diff
changeset
|
17 TaskObject task_list[MAX_TASK_OBJECT]; |
109 | 18 |
1147 | 19 #ifndef NOT_CHECK |
20 int entry_cmd[MAX_TASK_OBJECT]; | |
21 int task_count = 0; | |
22 #endif | |
23 | |
501
7ddbe22d4cdb
Cell inData/outData DMA removal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
483
diff
changeset
|
24 Scheduler::~Scheduler() |
109 | 25 { |
26 delete connector; | |
27 } | |
28 | |
1510
81f1afd1851f
separate TaskObject and GpuTaskObject
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1480
diff
changeset
|
29 int |
664 | 30 null_run(SchedTask* smanager, void* r, void *w) |
31 { | |
1464
3f2230d79eba
TaskList no compile errors
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1421
diff
changeset
|
32 smanager->printf("Calling Undefined Task %d\n", smanager->atask->command); |
664 | 33 return 0; |
34 } | |
35 | |
1471 | 36 void null_loader(Scheduler *m, int task_id); |
689
ecf63089f5bb
Task Array generation worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
664
diff
changeset
|
37 |
301
7f991471d43f
remove deprecated source. not work.
tkaito@localhost.localdomain
parents:
298
diff
changeset
|
38 /*! @brief speTaskの入出力のパイプラインバッファを確保する |
7f991471d43f
remove deprecated source. not work.
tkaito@localhost.localdomain
parents:
298
diff
changeset
|
39 */ |
7f991471d43f
remove deprecated source. not work.
tkaito@localhost.localdomain
parents:
298
diff
changeset
|
40 |
1631 | 41 void |
42 init_task_list(TaskObject* task_list) { | |
43 for (int i = 0; i< MAX_TASK_OBJECT; i++) { | |
44 task_list[i].run = null_run; | |
45 task_list[i].load = null_loader; | |
46 task_list[i].wait = null_loader; | |
47 task_list[i].gputask = new GpuTaskObject(); | |
48 | |
49 #ifndef NOT_CHECK | |
1637
a0014faececa
fix conflict set cpu
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1631
diff
changeset
|
50 entry_cmd[i] = NULL; |
1631 | 51 #endif |
52 | |
53 } | |
54 } | |
55 | |
1229
424c1f16e704
add args useRefDma
Daichi TOMA <e085740@ie.u-ryukyu.ac.jp>
parents:
1213
diff
changeset
|
56 //useRefDmaは、0という初期値が設定されている。 |
42 | 57 void |
1479
163220e54cc0
remove hard code for TaskLog
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
1471
diff
changeset
|
58 Scheduler::init(TaskManagerImpl *m, int useRefDma, int export_task_log) |
42 | 59 { |
388
3d1e86396d16
MemHash (OS X version)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
387
diff
changeset
|
60 hash = 0; |
664 | 61 |
1147 | 62 #ifndef NOT_CHECK |
63 task_count = 0; | |
64 #endif | |
65 | |
635
c56f6847fb87
SimpleTask worked on Mac OS X
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
634
diff
changeset
|
66 set_manager(m); |
1229
424c1f16e704
add args useRefDma
Daichi TOMA <e085740@ie.u-ryukyu.ac.jp>
parents:
1213
diff
changeset
|
67 init_impl(useRefDma); |
109 | 68 |
69 for (int i = 0; i < 2; i++) { | |
800
54f0180cea0f
run16 word count ( not yet worked. )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
792
diff
changeset
|
70 buff_taskList[i] = (TaskListPtr)m->allocate(sizeof(TaskList)); |
109 | 71 } |
373 | 72 |
109 | 73 buffFlag_taskList = 0; |
74 | |
298 | 75 // bzero でもいいけど |
109 | 76 for (int i = 0; i < MAX_GLOBAL_AREA; i++) { |
373 | 77 globalList[i] = NULL; |
109 | 78 } |
79 | |
80 for (int i = 0; i < MAX_MAINMEM_AREA; i++) { | |
631
30dd8a3deb4a
Cell 64 bit tried, but not yet worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
625
diff
changeset
|
81 mainMemList[i] = (memaddr)NULL; |
109 | 82 } |
373 | 83 |
42 | 84 } |
85 | |
86 void | |
690 | 87 Scheduler::run(SchedTaskBase* task1) |
42 | 88 { |
690 | 89 |
90 // Pipeline Stage | |
91 SchedTaskBase* task2 = new SchedNop(); | |
92 SchedTaskBase* task3 = new SchedNop(); | |
42 | 93 // main loop |
94 do { | |
1510
81f1afd1851f
separate TaskObject and GpuTaskObject
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1480
diff
changeset
|
95 |
1448
3ee29c1733d1
separate function for GpuTest
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1421
diff
changeset
|
96 task1->read(); |
3ee29c1733d1
separate function for GpuTest
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1421
diff
changeset
|
97 task2->exec(); |
3ee29c1733d1
separate function for GpuTest
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1421
diff
changeset
|
98 task3->write(); |
1510
81f1afd1851f
separate TaskObject and GpuTaskObject
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1480
diff
changeset
|
99 |
81f1afd1851f
separate TaskObject and GpuTaskObject
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1480
diff
changeset
|
100 delete task3; |
81f1afd1851f
separate TaskObject and GpuTaskObject
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1480
diff
changeset
|
101 |
373 | 102 task3 = task2; |
103 task2 = task1; | |
1448
3ee29c1733d1
separate function for GpuTest
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1421
diff
changeset
|
104 //SchedMailの場合、Mailの待ちが入る |
3ee29c1733d1
separate function for GpuTest
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1421
diff
changeset
|
105 task1 = task1->next(this, 0); |
1510
81f1afd1851f
separate TaskObject and GpuTaskObject
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1480
diff
changeset
|
106 |
42 | 107 } while (task1); |
108 | |
109 delete task3; | |
110 delete task2; | |
50 | 111 } |
48 | 112 |
50 | 113 |
114 void | |
501
7ddbe22d4cdb
Cell inData/outData DMA removal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
483
diff
changeset
|
115 Scheduler::finish() |
50 | 116 { |
109 | 117 free(buff_taskList[0]); |
118 free(buff_taskList[1]); | |
42 | 119 } |
120 | |
109 | 121 /** |
298 | 122 * あらかじめ memory allocte してある TaskList の領域を |
123 * パイプラインの各処理が交代して使う。 | |
109 | 124 */ |
42 | 125 TaskListPtr |
501
7ddbe22d4cdb
Cell inData/outData DMA removal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
483
diff
changeset
|
126 Scheduler::get_curListBuf() |
42 | 127 { |
109 | 128 buffFlag_taskList ^= 1; |
129 | |
130 return buff_taskList[buffFlag_taskList]; | |
131 } | |
132 | |
871
d30617ef4b20
fix get segment dma tag zero problem
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
804
diff
changeset
|
133 |
386 | 134 /* |
1585 | 135 ここから下は、memory 以下にあるべき |
136 */ | |
386 | 137 |
109 | 138 void* |
139 Scheduler::global_alloc(int id, int size) | |
140 { | |
792 | 141 |
800
54f0180cea0f
run16 word count ( not yet worked. )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
792
diff
changeset
|
142 globalList[id] = manager->allocate(size); |
792 | 143 |
109 | 144 return globalList[id]; |
145 } | |
146 | |
147 void* | |
148 Scheduler::global_get(int id) | |
149 { | |
150 return globalList[id]; | |
151 } | |
152 | |
153 void | |
373 | 154 Scheduler::global_set(int id, void *addr) |
155 { | |
156 globalList[id] = addr; | |
157 } | |
158 | |
159 void | |
109 | 160 Scheduler::global_free(int id) |
161 { | |
162 free(globalList[id]); | |
163 globalList[id] = NULL; | |
164 } | |
165 | |
166 /** | |
298 | 167 * mainMem_alloc で確保したメインメモリの領域アドレスを返す。 |
168 * これは Fifo, Cell で共通 | |
109 | 169 */ |
631
30dd8a3deb4a
Cell 64 bit tried, but not yet worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
625
diff
changeset
|
170 memaddr |
109 | 171 Scheduler::mainMem_get(int id) |
172 { | |
173 return mainMemList[id]; | |
42 | 174 } |
175 | |
1510
81f1afd1851f
separate TaskObject and GpuTaskObject
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1480
diff
changeset
|
176 /** |
423
609758f9f350
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
177 * Task load API |
609758f9f350
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
178 */ |
425 | 179 void |
872 | 180 Scheduler::allocate_code_segment(int size, int count, struct tbl *table) |
425 | 181 { |
437 | 182 // 既に overlay 領域があるので、それを追加する必要がある... |
442 | 183 code_segment_pool = createMemList(size, count); |
872 | 184 if (table) { |
185 MemorySegment* here = (MemorySegment*)( | |
1585 | 186 manager->allocate(sizeof(MemorySegment))); |
1737 | 187 here->data = &(table->vma); |
872 | 188 here->size = size; |
1510
81f1afd1851f
separate TaskObject and GpuTaskObject
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1480
diff
changeset
|
189 here->address = (memaddr)here; |
81f1afd1851f
separate TaskObject and GpuTaskObject
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1480
diff
changeset
|
190 code_segment_pool->addLast(here); |
872 | 191 } |
425 | 192 } |
42 | 193 |
423
609758f9f350
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
194 static void |
609758f9f350
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
195 load_task(Scheduler *m, int task_id) |
609758f9f350
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
196 { |
609758f9f350
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
197 MemorySegment *s = m->get_segment( |
1585 | 198 task_list[task_id].location, |
199 m->code_segment_pool, | |
200 task_list[task_id].end-task_list[task_id].location); | |
423
609758f9f350
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
201 task_list[task_id].segment = s; |
871
d30617ef4b20
fix get segment dma tag zero problem
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
804
diff
changeset
|
202 // calcurate call address |
1510
81f1afd1851f
separate TaskObject and GpuTaskObject
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1480
diff
changeset
|
203 TaskObjectRun run = |
871
d30617ef4b20
fix get segment dma tag zero problem
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
804
diff
changeset
|
204 (TaskObjectRun)( |
1585 | 205 (char*)task_list[task_id].segment->data + |
206 task_list[task_id].entry_offset); | |
871
d30617ef4b20
fix get segment dma tag zero problem
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
804
diff
changeset
|
207 task_list[task_id].run = run; |
874 | 208 #if 0 |
873
c50f39fbb6ca
fix hash problem ( unsigned int-> long overflow )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
872
diff
changeset
|
209 m->printf("loadng task id %d at 0x%x entry 0x%x location 0x%x\n",task_id, |
1585 | 210 (unsigned int)(task_list[task_id].segment->data ), |
211 (unsigned int)( | |
212 (char*)task_list[task_id].segment->data + | |
213 task_list[task_id].entry_offset), | |
214 task_list[task_id].location); | |
538 | 215 #endif |
423
609758f9f350
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
216 } |
609758f9f350
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
217 |
1471 | 218 void |
423
609758f9f350
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
219 null_loader(Scheduler *m, int task_id) |
609758f9f350
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
220 { |
609758f9f350
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
221 } |
609758f9f350
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
222 |
609758f9f350
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
223 static void |
609758f9f350
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
224 wait_load(Scheduler *m, int task_id) |
609758f9f350
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
225 { |
555 | 226 #if 0 |
442 | 227 MemorySegment *s = task_list[task_id].segment; |
228 if (s) | |
1510
81f1afd1851f
separate TaskObject and GpuTaskObject
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1480
diff
changeset
|
229 m->printf("wait load task id %d 0x%x\n",task_id,(int)s->data); |
442 | 230 else |
1510
81f1afd1851f
separate TaskObject and GpuTaskObject
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1480
diff
changeset
|
231 m->printf("wait load task id %d 000000\n",task_id); |
538 | 232 #endif |
423
609758f9f350
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
233 // wait for code segment load |
609758f9f350
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
234 m->wait_segment(task_list[task_id].segment); |
538 | 235 #if 0 |
736 | 236 m->printf("wait load task id %d done. creator = 0x%x entry_offset = 0x%x\n",task_id, |
1585 | 237 (unsigned int)(task_list[task_id].run), |
238 task_list[task_id].entry_offset); | |
538 | 239 #endif |
423
609758f9f350
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
240 } |
609758f9f350
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
241 |
609758f9f350
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
242 static void |
609758f9f350
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
243 null_waiter(Scheduler *m, int task_id) |
609758f9f350
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
244 { |
609758f9f350
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
245 } |
609758f9f350
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
246 |
1510
81f1afd1851f
separate TaskObject and GpuTaskObject
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1480
diff
changeset
|
247 extern void |
1058
d3cb29f1eccb
create task_name_list array in Scheduler.h
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
1024
diff
changeset
|
248 register_task(int cmd, TaskObjectRun run, const char *str) |
42 | 249 { |
464
0d64bdb63005
task run is mere C function now.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
461
diff
changeset
|
250 task_list[cmd].run = run; |
423
609758f9f350
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
251 task_list[cmd].load = null_loader; |
609758f9f350
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
252 task_list[cmd].wait = null_waiter; |
1147 | 253 task_list[cmd].name = str; |
254 | |
255 #ifndef NOT_CHECK | |
1510
81f1afd1851f
separate TaskObject and GpuTaskObject
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1480
diff
changeset
|
256 entry_cmd[task_count++] = cmd; |
1147 | 257 #endif |
258 | |
42 | 259 } |
373 | 260 |
1510
81f1afd1851f
separate TaskObject and GpuTaskObject
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1480
diff
changeset
|
261 extern void |
81f1afd1851f
separate TaskObject and GpuTaskObject
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1480
diff
changeset
|
262 register_dynamic_task(int cmd, |
1585 | 263 memaddr start, int size, |
264 TaskObjectRun run, int entry_offset, | |
265 const char *str) | |
423
609758f9f350
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
266 { |
464
0d64bdb63005
task run is mere C function now.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
461
diff
changeset
|
267 task_list[cmd].run = run; |
423
609758f9f350
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
268 task_list[cmd].location = start; |
442 | 269 size &= 0xfffffffe; |
441 | 270 task_list[cmd].end = start+size; |
423
609758f9f350
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
271 task_list[cmd].entry_offset = entry_offset; |
609758f9f350
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
272 task_list[cmd].load = load_task; |
609758f9f350
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
273 task_list[cmd].wait = wait_load; |
1147 | 274 task_list[cmd].name = str; |
275 | |
276 #ifndef NOT_CHECK | |
1510
81f1afd1851f
separate TaskObject and GpuTaskObject
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1480
diff
changeset
|
277 entry_cmd[task_count++] = cmd; |
1147 | 278 #endif |
279 | |
538 | 280 #if 0 |
1585 | 281 this->printf("cmd = %d\n",cmd); |
282 this->printf("locatation = 0x%x\n",start); | |
283 this->printf("end = 0x%x\n",start+size); | |
284 this->printf("size = 0x%x\n",size); | |
285 this->printf("entry = 0x%x\n",entry_offset); | |
538 | 286 #endif |
439 | 287 |
423
609758f9f350
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
288 } |
609758f9f350
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
289 |
609758f9f350
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
290 |
373 | 291 /*! |
386 | 292 |
293 size 単位のMemory Segment を count 個作る | |
294 | |
373 | 295 @param [size] リストの要素1つのサイズ |
296 @param [count] 要素数 | |
297 @return allocate した領域のポインタ | |
298 | |
1585 | 299 */ |
373 | 300 MemList* |
301 Scheduler::createMemList(int size, int count) | |
302 { | |
303 uint32 head_size = round_up16(sizeof(MemorySegment)); | |
304 uint32 seg_size = round_up16(head_size+size); | |
800
54f0180cea0f
run16 word count ( not yet worked. )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
792
diff
changeset
|
305 char* mseg = (char*)manager->allocate(seg_size*count); |
373 | 306 MemList* mlist = new MemList((MemorySegment*)mseg); |
307 | |
388
3d1e86396d16
MemHash (OS X version)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
387
diff
changeset
|
308 if (!hash) { |
1510
81f1afd1851f
separate TaskObject and GpuTaskObject
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1480
diff
changeset
|
309 hash = new MemHash(); |
388
3d1e86396d16
MemHash (OS X version)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
387
diff
changeset
|
310 } |
3d1e86396d16
MemHash (OS X version)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
387
diff
changeset
|
311 |
373 | 312 for(int i = 0; i < count; i++) { |
313 MemorySegment* next = (MemorySegment*)(mseg+seg_size*i); | |
314 char* data = (char*)next+head_size; | |
315 next->data = (void*)data; | |
386 | 316 next->size = size; |
1510
81f1afd1851f
separate TaskObject and GpuTaskObject
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1480
diff
changeset
|
317 next->address = (memaddr)next; |
373 | 318 mlist->addLast(next); |
319 } | |
320 | |
321 return mlist; | |
322 } | |
386 | 323 |
324 /*! | |
325 | |
1585 | 326 Main Memory のSegmentを取得する |
386 | 327 |
328 @param [addr] Main Memory のアドレス | |
329 @param [m] Mem List | |
330 @return allocate した領域のポインタ | |
1585 | 331 memory directory にあるべきだが... |
386 | 332 |
1585 | 333 */ |
1510
81f1afd1851f
separate TaskObject and GpuTaskObject
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1480
diff
changeset
|
334 MemorySegment * |
81f1afd1851f
separate TaskObject and GpuTaskObject
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1480
diff
changeset
|
335 Scheduler::get_segment(memaddr addr, MemList *m) |
386 | 336 { |
1154 | 337 #ifdef USE_CACHE |
338 | |
449
0bed2a9889f5
get_segment fixed. and test_nogl rollback to 426. move!
kazz@henri.cr.ie.u-ryukyu.ac.jp
parents:
442
diff
changeset
|
339 MemorySegment *s = m->getFirst(); |
1510
81f1afd1851f
separate TaskObject and GpuTaskObject
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1480
diff
changeset
|
340 return get_segment(addr, m, s->size); |
1154 | 341 |
342 #else | |
343 | |
1161
cc1a50cac83d
use MemorySegment API for pp load. do not check execution of the cell side. to be continued..
Yutaka_Kinjyo
parents:
1156
diff
changeset
|
344 //addr が空だった場合はどうなるか |
1162 | 345 //こうすると単純にFIFOか |
1420 | 346 // そうじゃなくて、単にbufferを余計に取って毎回DMAしているだけだよね。 |
1161
cc1a50cac83d
use MemorySegment API for pp load. do not check execution of the cell side. to be continued..
Yutaka_Kinjyo
parents:
1156
diff
changeset
|
347 |
cc1a50cac83d
use MemorySegment API for pp load. do not check execution of the cell side. to be continued..
Yutaka_Kinjyo
parents:
1156
diff
changeset
|
348 MemorySegment *s = m->getLast(); |
cc1a50cac83d
use MemorySegment API for pp load. do not check execution of the cell side. to be continued..
Yutaka_Kinjyo
parents:
1156
diff
changeset
|
349 m->moveToFirst(s); |
1213
a49c02dffe6f
DMA connector reogranization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1175
diff
changeset
|
350 s->tag = connector->get_tag(); |
1163 | 351 s->address = addr; |
1417 | 352 s->data = connector->dma_load1(s->data, addr, s->size, s->tag); |
1154 | 353 |
354 return s; | |
355 | |
356 #endif | |
357 | |
437 | 358 } |
359 | |
1173 | 360 /*! |
361 | |
1585 | 362 free な Segmentを取得する(SPEのLSから) |
363 書き込み専用の場合、dma_loadは必要ないので | |
364 こういう感じになるのかな. | |
1173 | 365 |
366 @param [addr] Main Memory のアドレス | |
367 @param [m] Mem List | |
368 @return allocate した領域のポインタ | |
1585 | 369 memory directory にあるべきだが... |
1173 | 370 |
1585 | 371 */ |
1173 | 372 |
1510
81f1afd1851f
separate TaskObject and GpuTaskObject
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1480
diff
changeset
|
373 MemorySegment * |
81f1afd1851f
separate TaskObject and GpuTaskObject
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1480
diff
changeset
|
374 Scheduler::get_free_segment(memaddr addr, MemList *m) |
1173 | 375 { |
376 | |
377 | |
378 if(addr == NULL) { | |
379 return NULL; | |
380 } | |
381 | |
382 MemorySegment *s = m->getLast(); | |
383 m->moveToFirst(s); | |
1213
a49c02dffe6f
DMA connector reogranization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1175
diff
changeset
|
384 s->tag = connector->get_tag(); |
1173 | 385 s->address = addr; |
386 | |
387 return s; | |
388 | |
389 } | |
390 | |
1175 | 391 /*! |
392 | |
393 指定した MemorySegment を上書きする | |
394 | |
395 @param [s] 上書きするMemorySegment | |
396 @param [addr] 上書きするdataへのアドレス | |
397 | |
1585 | 398 */ |
1175 | 399 |
400 void | |
1510
81f1afd1851f
separate TaskObject and GpuTaskObject
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1480
diff
changeset
|
401 Scheduler::overwrite_segment(MemorySegment *s, memaddr addr) |
1175 | 402 { |
403 | |
404 if(addr == NULL) { | |
405 return; | |
406 } | |
407 | |
408 s->address = addr; | |
1417 | 409 s->data = connector->dma_load1(s->data, addr, s->size, s->tag); |
1175 | 410 |
411 } | |
412 | |
1173 | 413 |
1585 | 414 int |
415 Scheduler::max_cpu() | |
416 { // todo | |
1612 | 417 return maxcpu-1; |
1585 | 418 } |
419 | |
420 int | |
421 Scheduler::min_cpu() | |
422 { // todo | |
1611
6c8f9791262e
fix min_cpu and max_cpu
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1588
diff
changeset
|
423 return mincpu; |
1585 | 424 } |
425 | |
1510
81f1afd1851f
separate TaskObject and GpuTaskObject
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1480
diff
changeset
|
426 MemorySegment * |
81f1afd1851f
separate TaskObject and GpuTaskObject
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1480
diff
changeset
|
427 Scheduler::get_segment(memaddr addr, MemList *m, int size) |
437 | 428 { |
1124 | 429 |
437 | 430 // memory segment のsizeをoverride する場合がある |
386 | 431 MemorySegment *s = hash->get(addr); |
1123 | 432 |
386 | 433 if (s) { |
1124 | 434 |
1510
81f1afd1851f
separate TaskObject and GpuTaskObject
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1480
diff
changeset
|
435 /* 既に load されている */ |
1585 | 436 // this->printf("get_segement loaded %llx 0x%x size 0x%d\n",addr,s->data,size); |
1510
81f1afd1851f
separate TaskObject and GpuTaskObject
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1480
diff
changeset
|
437 m->moveToFirst(s); |
81f1afd1851f
separate TaskObject and GpuTaskObject
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1480
diff
changeset
|
438 return s; |
386 | 439 } |
1154 | 440 |
1121 | 441 |
1510
81f1afd1851f
separate TaskObject and GpuTaskObject
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1480
diff
changeset
|
442 /* LRU なので、もっとも使われてない segment を上書きする */ |
386 | 443 s = m->getLast(); |
444 m->moveToFirst(s); | |
445 | |
446 memaddr old_addr = s->address; | |
1213
a49c02dffe6f
DMA connector reogranization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1175
diff
changeset
|
447 s->tag = connector->get_tag(); |
1417 | 448 s->data = connector->dma_load1(s->data, addr, size, s->tag); |
386 | 449 /* 前のをhashから削除 */ |
450 hash->remove(old_addr); | |
451 /* 新しいaddress を登録 */ | |
452 s->address = addr; | |
453 hash->put(s->address, s); | |
454 | |
1585 | 455 // this->printf("get_segement %llx 0x%x size 0x%d\n",addr, s->data,size); |
439 | 456 |
386 | 457 return s; |
458 } | |
459 | |
423
609758f9f350
Code load implementation... (not yet tested)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
460 |
1173 | 461 |
386 | 462 /*! |
463 | |
1585 | 464 Main Memory のSegmentを書き出す |
465 Segment は get_segement されていて、 | |
466 追い出されていてはいけない。 | |
467 それを保証するのは難しい? | |
386 | 468 |
469 @param [addr] Main Memory のアドレス | |
470 @param [m] Mem List | |
471 @return allocate した領域のポインタ | |
472 | |
1585 | 473 */ |
386 | 474 void |
475 Scheduler::put_segment(MemorySegment *s) | |
476 { | |
1163 | 477 |
478 if (s == NULL) return; | |
1213
a49c02dffe6f
DMA connector reogranization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1175
diff
changeset
|
479 s->tag = connector->get_tag(); |
a49c02dffe6f
DMA connector reogranization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1175
diff
changeset
|
480 connector->dma_store(s->data, s->address, s->size, s->tag); |
386 | 481 } |
482 | |
483 /*! | |
484 | |
1585 | 485 Main Memory のSegmentを読込、書き出しを待つ |
386 | 486 |
487 @param [id] MemorySegment のid | |
488 | |
1585 | 489 */ |
386 | 490 void |
387
b6fce69839b5
no compile error but not worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
386
diff
changeset
|
491 Scheduler::wait_segment(MemorySegment *s) |
386 | 492 { |
1163 | 493 if (s == NULL) return; |
1213
a49c02dffe6f
DMA connector reogranization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1175
diff
changeset
|
494 if (s->tag) connector->dma_wait(s->tag); |
391 | 495 s->tag = 0; |
386 | 496 } |
497 | |
1510
81f1afd1851f
separate TaskObject and GpuTaskObject
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1480
diff
changeset
|
498 long Scheduler::get_random() { |
621 | 499 #if defined(__SPU__) |
1510
81f1afd1851f
separate TaskObject and GpuTaskObject
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1480
diff
changeset
|
500 return 0; |
621 | 501 #else |
1510
81f1afd1851f
separate TaskObject and GpuTaskObject
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1480
diff
changeset
|
502 return random(); |
621 | 503 #endif |
504 | |
505 } | |
506 | |
1510
81f1afd1851f
separate TaskObject and GpuTaskObject
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1480
diff
changeset
|
507 int |
736 | 508 Scheduler::printf(const char * format, ...) |
509 { | |
786
043c98537bc5
fix early free of TaskArray, add SchedTaskArrayNop stage.
yutaka@localhost.localdomain
parents:
743
diff
changeset
|
510 #if !defined(__SPU__) || 1 |
736 | 511 va_list ap; |
512 va_start(ap,format); | |
743 | 513 int ret= vprintf0(format, ap); |
736 | 514 va_end(ap); |
515 return ret; | |
516 #else | |
517 return 0; | |
518 #endif | |
519 } | |
520 | |
1510
81f1afd1851f
separate TaskObject and GpuTaskObject
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1480
diff
changeset
|
521 int |
743 | 522 Scheduler::vprintf0(const char * format, va_list ap) |
736 | 523 { |
786
043c98537bc5
fix early free of TaskArray, add SchedTaskArrayNop stage.
yutaka@localhost.localdomain
parents:
743
diff
changeset
|
524 #if !defined(__SPU__) || 1 |
736 | 525 int ret= vprintf(format, ap); |
526 return ret; | |
527 #else | |
528 return 0; | |
529 #endif | |
530 } | |
531 | |
386 | 532 /* end */ |