annotate TaskManager/ChangeLog @ 596:f1c2e11a2ef4 draft

add xdr_getpos
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Wed, 04 Nov 2009 22:52:06 +0900
parents fbcbcc5ad3b5
children 184d6d3f0cd9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
538
5641d121818e code_load in read()
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 503
diff changeset
1 2009-10-11 Shinji KONO <kono@ie.u-ryukyu.ac.jp>
5641d121818e code_load in read()
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 503
diff changeset
2
5641d121818e code_load in read()
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 503
diff changeset
3 単純な、rbuf, wbuf + write return size の task のAPI
5641d121818e code_load in read()
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 503
diff changeset
4 List DMA の API
5641d121818e code_load in read()
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 503
diff changeset
5 投入 cpu 別の spawn method
5641d121818e code_load in read()
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 503
diff changeset
6 Redering 時の内部からの DMA への直接アクセスへの禁止等など
5641d121818e code_load in read()
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 503
diff changeset
7
5641d121818e code_load in read()
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 503
diff changeset
8 set_post で登録する関数も、task のrun関数と同じ型にした方が便利そう。
5641d121818e code_load in read()
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 503
diff changeset
9
5641d121818e code_load in read()
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 503
diff changeset
10 SPU側でも配列(TaskList)ではなく、TaskQueue で管理すれば、
5641d121818e code_load in read()
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 503
diff changeset
11 renew task は簡単に実装できる。
5641d121818e code_load in read()
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 503
diff changeset
12
5641d121818e code_load in read()
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 503
diff changeset
13 SchedTask の renew かそうでないかの区別は全部なくす。ex_init とかは、
5641d121818e code_load in read()
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 503
diff changeset
14 なくなるはず。その代わり TaskQueue で管理する。
5641d121818e code_load in read()
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 503
diff changeset
15
5641d121818e code_load in read()
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 503
diff changeset
16 TaskList に inListData/outListData が入っているのは、やはりおかしい。
5641d121818e code_load in read()
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 503
diff changeset
17 もっとコンパクトであるべき。
5641d121818e code_load in read()
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 503
diff changeset
18
5641d121818e code_load in read()
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 503
diff changeset
19 TaskList は、こまめに終了をPPE側へ知らせるのではなく、TaskListの
5641d121818e code_load in read()
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 503
diff changeset
20 書き換えで知らせる方が良い。
5641d121818e code_load in read()
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 503
diff changeset
21
5641d121818e code_load in read()
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 503
diff changeset
22 SPUからPPUへ、create task 出来た方が良い。それはTaskList の書き出し
5641d121818e code_load in read()
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 503
diff changeset
23 で行なう。
5641d121818e code_load in read()
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 503
diff changeset
24
503
516d5c91d5b4 comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 489
diff changeset
25 2009-10-11 Shinji KONO <kono@ie.u-ryukyu.ac.jp>
516d5c91d5b4 comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 489
diff changeset
26
516d5c91d5b4 comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 489
diff changeset
27 ようやっと直せました。inListData/outListData は別に転送しないで、
516d5c91d5b4 comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 489
diff changeset
28 一緒に転送してしまった方が良い。どうせ、いつも転送しているのだから。
516d5c91d5b4 comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 489
diff changeset
29
516d5c91d5b4 comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 489
diff changeset
30 word_count が fifo の方が高速なのは、どうにかしてください。
516d5c91d5b4 comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 489
diff changeset
31
516d5c91d5b4 comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 489
diff changeset
32 Renew Task の addInData は、メインメモリからDMAするので正しいらしい。
516d5c91d5b4 comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 489
diff changeset
33 直し方を間違えた。
516d5c91d5b4 comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 489
diff changeset
34
516d5c91d5b4 comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 489
diff changeset
35 Task をmemcpyして、TaskList に入れているが、List DMA に直すべき。
516d5c91d5b4 comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 489
diff changeset
36 Simple Task を常に起動して、List DMA task は、その中で、Renew Task
516d5c91d5b4 comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 489
diff changeset
37 として起動するのが良いのでは? そうすれば、Task Load 自体を Task に
516d5c91d5b4 comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 489
diff changeset
38 出来る。
516d5c91d5b4 comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 489
diff changeset
39
516d5c91d5b4 comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 489
diff changeset
40 Renew Task の実行順序が filo になっている。このあたり変なので、
516d5c91d5b4 comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 489
diff changeset
41 修正するべきでしょう。Renew用の TaskList を持てば良いんじゃないか?
516d5c91d5b4 comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 489
diff changeset
42 task->self の ad-hoc な使い方が泣ける。ひどすぎます。
516d5c91d5b4 comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 489
diff changeset
43
489
1d893ffbc5ff comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 481
diff changeset
44 2009-10-06 Shinji KONO <kono@ie.u-ryukyu.ac.jp>
1d893ffbc5ff comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 481
diff changeset
45
1d893ffbc5ff comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 481
diff changeset
46 Task 内の create_task は、SchedTask に対してで、
1d893ffbc5ff comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 481
diff changeset
47 PPE 上では、Manager に対してだよね。だから、出来る
1d893ffbc5ff comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 481
diff changeset
48 ことがかなり異なる。これは、まずいだろ?
1d893ffbc5ff comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 481
diff changeset
49
1d893ffbc5ff comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 481
diff changeset
50 特に、PPE task に明示的に manager を渡すってのは、
1d893ffbc5ff comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 481
diff changeset
51 とっても変。
1d893ffbc5ff comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 481
diff changeset
52
1d893ffbc5ff comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 481
diff changeset
53 Renew Task の特別扱いが、いろいろ歪めているんだが、
1d893ffbc5ff comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 481
diff changeset
54 view.cc で使っているので落せない。
1d893ffbc5ff comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 481
diff changeset
55
481
f9ffcffb6d09 Double linked list modification done (tested on Mac OS X)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 468
diff changeset
56 2009-10-05 Shinji KONO <kono@ie.u-ryukyu.ac.jp>
f9ffcffb6d09 Double linked list modification done (tested on Mac OS X)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 468
diff changeset
57
f9ffcffb6d09 Double linked list modification done (tested on Mac OS X)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 468
diff changeset
58 TaskQueue のfree list の管理はシステムで一つであるべき。
503
516d5c91d5b4 comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 489
diff changeset
59 TaskQueue は double linked list が当然らしい。
481
f9ffcffb6d09 Double linked list modification done (tested on Mac OS X)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 468
diff changeset
60
468
796f72cb21d9 test_nogl on Mac OS X worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 400
diff changeset
61 2009-10-02 Shinji KONO <kono@ie.u-ryukyu.ac.jp>
796f72cb21d9 test_nogl on Mac OS X worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 400
diff changeset
62
796f72cb21d9 test_nogl on Mac OS X worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 400
diff changeset
63 DrawSpan で、~DrawSpan() で、allocate したデータを DMA_WAIT
796f72cb21d9 test_nogl on Mac OS X worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 400
diff changeset
64 して、free しているが、これは、抽象化違反。Task で明示的に
796f72cb21d9 test_nogl on Mac OS X worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 400
diff changeset
65 DMAするのは禁止。Task 内で、add_outData 出来れば良い。
796f72cb21d9 test_nogl on Mac OS X worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 400
diff changeset
66
796f72cb21d9 test_nogl on Mac OS X worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 400
diff changeset
67 renew が正しいような気がするが...
796f72cb21d9 test_nogl on Mac OS X worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 400
diff changeset
68
796f72cb21d9 test_nogl on Mac OS X worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 400
diff changeset
69 Task 内で大域変数は使えない。なので、smanager からallocateする
796f72cb21d9 test_nogl on Mac OS X worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 400
diff changeset
70 必要がある。Task の解放のタイミングではなくて、パイプラインの
796f72cb21d9 test_nogl on Mac OS X worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 400
diff changeset
71 タイミングでDMA waitとfreeを行なう必要がある。DrawSpan の場合は、
796f72cb21d9 test_nogl on Mac OS X worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 400
diff changeset
72 add_outData で良いが、内部で allocate/free は行なう必要がある。
796f72cb21d9 test_nogl on Mac OS X worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 400
diff changeset
73 put_segement がパイプライン動作するべきなのか?
796f72cb21d9 test_nogl on Mac OS X worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 400
diff changeset
74
796f72cb21d9 test_nogl on Mac OS X worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 400
diff changeset
75 固定のDMA tagが邪魔。
796f72cb21d9 test_nogl on Mac OS X worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 400
diff changeset
76
796f72cb21d9 test_nogl on Mac OS X worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 400
diff changeset
77 DrawSpan は全般的にダメだな〜
796f72cb21d9 test_nogl on Mac OS X worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 400
diff changeset
78
796f72cb21d9 test_nogl on Mac OS X worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 400
diff changeset
79 でも、その変更は大きいので、とりあえず動くようにしたい。
796f72cb21d9 test_nogl on Mac OS X worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 400
diff changeset
80
796f72cb21d9 test_nogl on Mac OS X worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 400
diff changeset
81 memset 0 は、7.7.3 SL1 Data Cache Range Set to Zero コマンド
796f72cb21d9 test_nogl on Mac OS X worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 400
diff changeset
82 つかうべき。SPE側でやっても良い。でも、本来は全面埋まるのが
796f72cb21d9 test_nogl on Mac OS X worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 400
diff changeset
83 普通なのでどうでも良いけど。
796f72cb21d9 test_nogl on Mac OS X worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 400
diff changeset
84
386
da7b1e5b8449 MemHash...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 381
diff changeset
85 2009-08-06 Shinji KONO <kono@ie.u-ryukyu.ac.jp>
da7b1e5b8449 MemHash...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 381
diff changeset
86
390
6087affae003 document
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 386
diff changeset
87 で、MemList/MemHash が TaskManager 側に移ったので、
6087affae003 document
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 386
diff changeset
88 これで、code の management を書くことが出来る。
6087affae003 document
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 386
diff changeset
89 そうすれば、SPEのメモリの限界をほんと気にする必要がなくなるはず。
6087affae003 document
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 386
diff changeset
90
6087affae003 document
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 386
diff changeset
91 その前に、get_segment の例題を直さないと。
6087affae003 document
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 386
diff changeset
92
6087affae003 document
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 386
diff changeset
93 DrawSpanRnew/reboot は使ってないらしい。
6087affae003 document
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 386
diff changeset
94
6087affae003 document
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 386
diff changeset
95 Tree は、配列にしないでlinkをSPE側からたどるようになっている。
6087affae003 document
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 386
diff changeset
96 それは良いのだが、Task 側で dma_wait するような実装は望ましくない。
6087affae003 document
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 386
diff changeset
97 この部分も書き直す必要がある。list 構造の SPE上の Iterator を
6087affae003 document
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 386
diff changeset
98 実装すれば良い。
386
da7b1e5b8449 MemHash...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 381
diff changeset
99
390
6087affae003 document
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 386
diff changeset
100 memory 関係のコードが scheduler の下にあるのは面白くない。
6087affae003 document
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 386
diff changeset
101
6087affae003 document
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 386
diff changeset
102 Scheduler で実装(__scheduler)に移譲している部分は、headerに
6087affae003 document
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 386
diff changeset
103 移した方が良い。
6087affae003 document
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 386
diff changeset
104
6087affae003 document
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 386
diff changeset
105 2009-08-06 Shinji KONO <kono@ie.u-ryukyu.ac.jp>
6087affae003 document
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 386
diff changeset
106
6087affae003 document
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 386
diff changeset
107 うーん、get_segemnt で、dma_wait のtagをなんとかする
6087affae003 document
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 386
diff changeset
108 必要があるらしい。get_tag() でなんとかなるけど、
6087affae003 document
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 386
diff changeset
109 他のtag との関係があるかな。
6087affae003 document
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 386
diff changeset
110
6087affae003 document
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 386
diff changeset
111 完全に見えなくするべきでしょうけど... 今はいい。
386
da7b1e5b8449 MemHash...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 381
diff changeset
112
381
ded8bb057315 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 376
diff changeset
113 2009-08-01 Shinji KONO <kono@ie.u-ryukyu.ac.jp>
ded8bb057315 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 376
diff changeset
114
390
6087affae003 document
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 386
diff changeset
115 MemList は動いたので、今度は TileHash を TaskManager 側に移動する
6087affae003 document
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 386
diff changeset
116 必要がある。
381
ded8bb057315 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 376
diff changeset
117
390
6087affae003 document
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 386
diff changeset
118 その後、コードのLRUを書けば、Cerium は一通り出来上がり。
381
ded8bb057315 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 376
diff changeset
119
390
6087affae003 document
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 386
diff changeset
120 TaskManager と Scheduler の関係が一貫してない。複雑すぎる。
381
ded8bb057315 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 376
diff changeset
121
ded8bb057315 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 376
diff changeset
122
363
73630476453a See Changelog
tkaito@localhost.localdomain
parents: 356
diff changeset
123 2009-07-24 Kaito TAGANO <tkaito@cr.ie.u-ryukyu.ac.jp>
390
6087affae003 document
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 386
diff changeset
124
363
73630476453a See Changelog
tkaito@localhost.localdomain
parents: 356
diff changeset
125 長さ別の freeList と単一の HashTable で管理する
73630476453a See Changelog
tkaito@localhost.localdomain
parents: 356
diff changeset
126 TileList を廃止
73630476453a See Changelog
tkaito@localhost.localdomain
parents: 356
diff changeset
127 class MemorySegment {
73630476453a See Changelog
tkaito@localhost.localdomain
parents: 356
diff changeset
128 MemorySegment *next;
73630476453a See Changelog
tkaito@localhost.localdomain
parents: 356
diff changeset
129 MemorySegment *prev;
73630476453a See Changelog
tkaito@localhost.localdomain
parents: 356
diff changeset
130 uint64 size;
73630476453a See Changelog
tkaito@localhost.localdomain
parents: 356
diff changeset
131 uint64 address;
73630476453a See Changelog
tkaito@localhost.localdomain
parents: 356
diff changeset
132 uint64 dummy;
73630476453a See Changelog
tkaito@localhost.localdomain
parents: 356
diff changeset
133 // uint32 data[0];
73630476453a See Changelog
tkaito@localhost.localdomain
parents: 356
diff changeset
134 }
73630476453a See Changelog
tkaito@localhost.localdomain
parents: 356
diff changeset
135
73630476453a See Changelog
tkaito@localhost.localdomain
parents: 356
diff changeset
136 class MemList {
73630476453a See Changelog
tkaito@localhost.localdomain
parents: 356
diff changeset
137 MemorySegment* first;
73630476453a See Changelog
tkaito@localhost.localdomain
parents: 356
diff changeset
138 MemorySegment* last;
73630476453a See Changelog
tkaito@localhost.localdomain
parents: 356
diff changeset
139
73630476453a See Changelog
tkaito@localhost.localdomain
parents: 356
diff changeset
140 MemList* createMemList(uint32 size, uint32 count);
73630476453a See Changelog
tkaito@localhost.localdomain
parents: 356
diff changeset
141 void addFirst(MemorySegment* e);
73630476453a See Changelog
tkaito@localhost.localdomain
parents: 356
diff changeset
142 void addLast(MemorySegment* e);
73630476453a See Changelog
tkaito@localhost.localdomain
parents: 356
diff changeset
143 MemorySegment* getFirst();
73630476453a See Changelog
tkaito@localhost.localdomain
parents: 356
diff changeset
144 MemorySegment* getLast();
73630476453a See Changelog
tkaito@localhost.localdomain
parents: 356
diff changeset
145 boolean remove(MemorySegment* e);
73630476453a See Changelog
tkaito@localhost.localdomain
parents: 356
diff changeset
146 void moveToFirst(MemorySegment* e); // or use();
73630476453a See Changelog
tkaito@localhost.localdomain
parents: 356
diff changeset
147 }
73630476453a See Changelog
tkaito@localhost.localdomain
parents: 356
diff changeset
148
73630476453a See Changelog
tkaito@localhost.localdomain
parents: 356
diff changeset
149 サイズ毎に freelist と activelist を持って、これを malloc free
73630476453a See Changelog
tkaito@localhost.localdomain
parents: 356
diff changeset
150 として使う。
73630476453a See Changelog
tkaito@localhost.localdomain
parents: 356
diff changeset
151 これのテストルーチンを書き終わったら、Tapestry をこれで書き直す
73630476453a See Changelog
tkaito@localhost.localdomain
parents: 356
diff changeset
152 LRU は使うたびに以下を呼び出す
73630476453a See Changelog
tkaito@localhost.localdomain
parents: 356
diff changeset
153
73630476453a See Changelog
tkaito@localhost.localdomain
parents: 356
diff changeset
154 void use(MemorySegment* e, MemList* active) {
73630476453a See Changelog
tkaito@localhost.localdomain
parents: 356
diff changeset
155 active.remove(e);
73630476453a See Changelog
tkaito@localhost.localdomain
parents: 356
diff changeset
156 active.addFirst(e);
73630476453a See Changelog
tkaito@localhost.localdomain
parents: 356
diff changeset
157 }
73630476453a See Changelog
tkaito@localhost.localdomain
parents: 356
diff changeset
158
73630476453a See Changelog
tkaito@localhost.localdomain
parents: 356
diff changeset
159
354
cfd20d609ace add example/get_segment and change spe/DrawSpan.cpp
koba
parents: 279
diff changeset
160 2009-07-15 Yusuke KOBAYASHI <koba@cr.ie.u-ryukyu.ac.jp>
cfd20d609ace add example/get_segment and change spe/DrawSpan.cpp
koba
parents: 279
diff changeset
161
cfd20d609ace add example/get_segment and change spe/DrawSpan.cpp
koba
parents: 279
diff changeset
162 PPU からMainMemory にResource を Access する API
cfd20d609ace add example/get_segment and change spe/DrawSpan.cpp
koba
parents: 279
diff changeset
163 長さ別の freeList と単一の HashTable で管理する
cfd20d609ace add example/get_segment and change spe/DrawSpan.cpp
koba
parents: 279
diff changeset
164
386
da7b1e5b8449 MemHash...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 381
diff changeset
165 読みだしAPI。set_rgb に相当。
da7b1e5b8449 MemHash...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 381
diff changeset
166 uint32 segment_id = smanager->get_segment(memaddr addr, *MemList m)
354
cfd20d609ace add example/get_segment and change spe/DrawSpan.cpp
koba
parents: 279
diff changeset
167 id は hash値に相当。
386
da7b1e5b8449 MemHash...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 381
diff changeset
168 addr で指定された PPU の Address が Hash にあるかどうか調べる。
da7b1e5b8449 MemHash...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 381
diff changeset
169 無ければ dma_load する。そして指定された id を返す。
da7b1e5b8449 MemHash...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 381
diff changeset
170
400
984e7890db0c Fix examples.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 390
diff changeset
171 確保 API。set_rgb に相当。読み出さないで、hash entry だけ確保する。put しかしない部分用
984e7890db0c Fix examples.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 390
diff changeset
172 uint32 segment_id = smanager->get_null_segment(memaddr addr, *MemList m)
984e7890db0c Fix examples.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 390
diff changeset
173 id は hash値に相当。
984e7890db0c Fix examples.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 390
diff changeset
174
386
da7b1e5b8449 MemHash...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 381
diff changeset
175 書き出しAPI、読みだしていること前提。
354
cfd20d609ace add example/get_segment and change spe/DrawSpan.cpp
koba
parents: 279
diff changeset
176 smanager->put_segment(wait_id);
386
da7b1e5b8449 MemHash...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 381
diff changeset
177
da7b1e5b8449 MemHash...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 381
diff changeset
178 MemorySegment* smanager->wait_segment(uint32 segment_id)
da7b1e5b8449 MemHash...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 381
diff changeset
179 id で指定された PPU の segment の copy の Address を返す。
da7b1e5b8449 MemHash...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 381
diff changeset
180 必要があれば dma_wait を行う。書き出しも待ち合わせる。
354
cfd20d609ace add example/get_segment and change spe/DrawSpan.cpp
koba
parents: 279
diff changeset
181
307
3fc86ddf5d1c clean up include
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 279
diff changeset
182 2009-06-8 Shinji KONO <kono@ie.u-ryukyu.ac.jp>
3fc86ddf5d1c clean up include
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 279
diff changeset
183
3fc86ddf5d1c clean up include
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 279
diff changeset
184 SchedTask/SchedTaskImpl の分離はあんまり意味がなかった。
3fc86ddf5d1c clean up include
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 279
diff changeset
185 SchedTaskBase が既にあるし。
3fc86ddf5d1c clean up include
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 279
diff changeset
186 とりあえず、__list とかは、private にしただけ。
3fc86ddf5d1c clean up include
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 279
diff changeset
187 ScheTaskImple を作っても、継承してprivateにすると、
3fc86ddf5d1c clean up include
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 279
diff changeset
188 warning は出るが、 User Task space の名前空間は結局汚れてしまう。
3fc86ddf5d1c clean up include
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 279
diff changeset
189
3fc86ddf5d1c clean up include
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 279
diff changeset
190 delegate するべきだと思うが、SchedTaskBase でないと、
3fc86ddf5d1c clean up include
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 279
diff changeset
191 動かないらしい。それだと、indirect が増えるので、ちょっといや。
3fc86ddf5d1c clean up include
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 279
diff changeset
192
279
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 276
diff changeset
193 2009-06-4 Shinji KONO <kono@ie.u-ryukyu.ac.jp>
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 276
diff changeset
194
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 276
diff changeset
195 set_symbol は、もういらないよね?
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 276
diff changeset
196
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 276
diff changeset
197 list dma 中心の実装にして、もっと細かく read/exec/write
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 276
diff changeset
198 した方が良いかも。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 276
diff changeset
199
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 276
diff changeset
200 post で、PPE task を渡せると良い。address は parameterとして送る
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 276
diff changeset
201
276
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
202 2009-02-13 Wataru MIYAGUNI <gongo@cr.ie.u-ryukyu.ac.jp>
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
203
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
204 * kernel/ppe/Random.cc (reset): fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
205 urandom -> random とどれも読めなかったら
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
206 gettimeofday() での時間から seed を求めるように
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
207
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
208 2009-02-12 Wataru MIYAGUNI <gongo@cr.ie.u-ryukyu.ac.jp>
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
209
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
210 * add: kernel/ppe/Random.cc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
211 乱数生成クラス。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
212 ゲームだとユーザ使うでしょうきっと。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
213 一応 /dev/random から seed 取る様にしてます
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
214
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
215 2009-02-04 Wataru MIYAGUNI <gongo@cr.ie.u-ryukyu.ac.jp>
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
216
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
217 * kernel/ppe/TaskManager.cc (TaskManager::allocate): rename
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
218 malloc -> allocate
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
219
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
220 * kernel/main.cc (main): fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
221 cerium_main を呼ぶのではなく、TMmain という名前にしました。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
222 ちょっと SDLmain をパクった感じで。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
223 まあ TaskManager の main で cerium_* って名前は微妙に変だからね。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
224
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
225 * kernel/ppe/TaskManager.cc (TaskManager::set_TMend): add
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
226 cerium_main があるんだから、cerium_end があってもいいじゃない。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
227 もっと言うと、TaskManager に main を隠すって流れなんだけど
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
228 終了を検知できないのはちとやりづらいかなと。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
229 たとえば測定とか。Task の post_func とかでもやれないことはないけどね。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
230 というわけで、ユーザが、プログラム終了時に呼ばれる関数を設定できるように。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
231
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
232 2009-01-20 Wataru MIYAGUNI <gongo@cr.ie.u-ryukyu.ac.jp>
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
233
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
234 * Cell/spe/SchedTask.cc (SchedTask::get_cpuid): add
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
235 printf デバッグ時に、どの CPU かって知りたい時があるので。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
236
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
237 PPE = 0
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
238 SPE = 0〜spu_num-1;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
239
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
240 PPE は 0 以外に分かりやすい数字がいいんだけどなー。SPE と被るし。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
241 -1 とかはエラーっぽいから好かない。まあいいんだけど。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
242
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
243 User Task では以下の様に使用します
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
244
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
245 int cpuid = smanager->get_cpuid();
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
246
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
247
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
248 * Cell/SpeThreads.cc (SpeThreads::spe_thread_run): fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
249 SPE_EXIT が出る時は正常終了だけど、これだと
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
250 エラーでたようなメッセージに見えてしまう(俺がそう見えてしまった)ので
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
251 ここは表示しなくてもいいかな。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
252
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
253 * kernel/ppe/MailManager.cc (MailManager::destroy): fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
254 無限ループになってた。この for() 間違ってるかな。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
255 なんか TaskQueueInfo.cc とかでも、結局 while() に直してるし。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
256
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
257 * kernel/ppe/TaskManager.cc (TaskManager::~TaskManager): add
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
258 kernel/main.ccで
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
259
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
260 delete manager;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
261
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
262 としているのに、TaskManagerImpl::~TaskManagerImpl が呼び出されず
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
263 どうしてかなと思ったら、そもそも ~TaskManager が無かった。あほか
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
264
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
265 2009-01-05 Wataru MIYAGUNI <gongo@cr.ie.u-ryukyu.ac.jp>
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
266
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
267 * all : fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
268 Scheduler::curIndex_taskList を削除し、
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
269 SchedTask に持たせる様に変更。(SchedTask::__cur_index)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
270 それに伴い、SchedTask::__init__() も cur_index を入れる様に変更
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
271
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
272 2008-12-24 Wataru MIYAGUNI <gongo@cr.ie.u-ryukyu.ac.jp>
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
273
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
274 * kernel/schedule/SchedTask.cc (SchedTask::ex_init_renew)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
275 (SchedTask::ex_init_normal): add
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
276 (SchedTask::__init__): fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
277
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
278 init でも ex_init を使える様に。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
279 あと、コンストラクタで渡していた引数を __init__() に渡す様にした。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
280 コンストラクタの引数あると、継承する時にいちいち親クラスのも書かないと
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
281 いけなかった。これ省略できないんだよな。めんどくさい。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
282
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
283 例.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
284 class Hoge : public SchedTask {
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
285 Hoge(int i) : Task(i) {}
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
286 };
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
287
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
288 なので、今までは Scheduler.h に SchedConstructor ってマクロを書いて
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
289 クラス名入れるだけで上の様な形になるようにしていた。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
290 でも、例えば
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
291
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
292 SchedTask -> Hoge -> Fuge っていうように Fuge ってタスクを
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
293 作りたいとき、上のままだと SchedTask に引数渡してしまうのでだめ。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
294 もうめんどくさいってことで、コンストラクタ全てデフォルトにして、
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
295 __init__() の引数に渡す様にしました。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
296
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
297 (SchedTask::__set_renewFlag): add
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
298
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
299 ここで、PPEで生成されたか(normal)、SPE で生成されたか(renew) の
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
300 判定を行い、ex_xxx の設定もする
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
301
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
302 (SchedTask::get_inputSize, SchedTask::get_outputSize): add
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
303
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
304 アドレスだけじゃなく、そのサイズも取れた方がいいだろう
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
305
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
306
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
307 2008-12-23 Wataru MIYAGUNI <gongo@cr.ie.u-ryukyu.ac.jp>
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
308
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
309 * Cell/spe/SchedTask.cc (SchedTask::get_outputAddr)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
310 (SchedTask::get_inputAddr): add
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
311
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
312 in/out のデータだけじゃなく、そのアドレスも取れた方がいいだろう
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
313
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
314 2008-12-22 Wataru MIYAGUNI <gongo@cr.ie.u-ryukyu.ac.jp>
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
315
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
316 * Cell/spe/SchedTask.cc (SchedTask::__init__, SchedTask::read)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
317 (SchedTask::exec, SchedTask::write): fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
318 (SchedTask::ex_read_normal, SchedTask::ex_read_renew)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
319 (SchedTask::ex_exec_normal, SchedTask::ex_exec_renew)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
320 (SchedTask::ex_write_normal, SchedTask::ex_write_renew): add
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
321
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
322 SPE 内で生成されたタスクは、PPE で生成されたものと違い
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
323
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
324 - add->inData
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
325 : PPE から DMA or SPE 内のものをそのまま使う
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
326 - PPE にタスクが終了したことを知らせる
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
327 : 生成されたタスクを待つ必要があるなら、その時点では送らない
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
328
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
329 とか、まあいろいろ処理が違うわけです。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
330 そして、タスク内生成タスクの判断をする
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
331
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
332 __flag_renewTask ? 0 = PPE で生成 : 1 = SPE で生成
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
333
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
334 という変数がある。これでいくつか処理を分けてるんだけど、
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
335 今までは
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
336
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
337 if (__flag_renewTask) {
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
338 } else {
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
339 }
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
340
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
341 ってやってた。これではいかんという事で、
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
342 __init__() 内で、関数ポインタに、
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
343
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
344 ex_xxxx_normal: PPE で生成されたタスクに対する処理
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
345 ex_xxxx_renew: SPE で生成されたタスクに対する処理
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
346
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
347 と入れて、if 文無しでやってみた。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
348 今は ex_write_xxx しか書いてないが、これからread/exec でも
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
349 出てくると思うので、作っておいた
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
350
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
351
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
352 2008-12-19 Wataru MIYAGUNI <gongo@cr.ie.u-ryukyu.ac.jp>
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
353
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
354 * Cell/spe/CellDmaManager.cc (CellDmaManager::dma_wait)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
355 (CellDmaManager::mail_write, CellDmaManager::mail_read): fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
356 writech、readch の関数を、wrap (って言い方でおk?)された関数に変更。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
357 最適化掛かってるっぽいし、長いよりはわかりやすいし。そのための wrap。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
358
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
359 例:
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
360 - before
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
361 spu_readch(SPU_RdInMspu_readch(SPU_RdInMbox);
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
362 - after
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
363 spu_read_in_mbox(void);
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
364
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
365 2008-11-05 Wataru MIYAGUNI <gongo@cr.ie.u-ryukyu.ac.jp>
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
366
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
367 * add: Task 内での API
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
368 Task 外での API は、今まで通り manager->create_task とかですが
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
369 タスク内でも、「オブジェクト->関数」の呼び出しがいいんじゃないか
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
370 って話になったので、付け加えました。今のところ、SchedTask.h の
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
371 内部クラスとして
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
372
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
373 STaskManager
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
374
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
375 ってのを加えて、ユーザはそのインスタンスである
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
376
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
377 smanager
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
378
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
379 からAPIにアクセスします。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
380 今までは __scheduler->dma_load とかいろいろやってたんですが
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
381 これからは全て smanager にしました。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
382 というわけで、ここに使える API 一覧。いずれゲーム班 wikiの方にも。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
383
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
384 - get_input, get_output, get_param
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
385 - create_task, wait_task
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
386 - global_alloc, global_get, global_free
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
387 - mainMem_alloc, mainMem_wait, mainMem_get
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
388 - dma_load, dma_store, dma_wait
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
389 - allocate
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
390
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
391 使い方は追々描きますが、
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
392 今のところ上に変更しなくてもそのままの記述で動くはずです。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
393 いずれは全て移行してもらうことになりますがきっと。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
394
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
395
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
396 * kernel/schedule/SchedTask.cc:
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
397 いろいろ関数が増えてますが、ラッパーです。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
398
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
399 2008-11-01 Wataru MIYAGUNI <gongo@cr.ie.u-ryukyu.ac.jp>
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
400
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
401 * add: kernel/main.cc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
402 main loop をユーザに書かせるのはめんどくさいので、
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
403 ライブラリ側で main() を書く事にしました。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
404 ユーザ側では main() の代わりに cerium_main() を
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
405 書かせるようにしています。引数は main() のをそのまま渡す感じで。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
406
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
407 Cerium 標準のオプションとして、-cpu は付けました。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
408 ゲームフレームワークってことで、-width とか -height は
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
409 標準でつけてもいいかなって話なので、これは後日実装。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
410 標準オプションで受け取った値にアクセスする方法も考えないと。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
411 manager->cpu とか manager->width とかは安易か?
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
412
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
413 * add: Cell/PpeScheduler.cc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
414 MainScheduler をそのまま使うと、
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
415 PPE のタスクで mainMem_alloc で確保した領域がアライメント
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
416 取れていないため、SPE で使うと余裕でバスエラー。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
417
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
418 Scheduler->allocate で poxis_memalign で使えるように。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
419
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
420 * move: kernel/schedule/FifoDmaManager.cc, MainScheduler.cc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
421 kernel というよりは Fifo バージョン用なので Fifo/ に移動。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
422
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
423
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
424 2008-10-21 Wataru MIYAGUNI <gongo@cr.ie.u-ryukyu.ac.jp>
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
425
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
426 * kernel/ppe/TaskManagerImpl.cc (TaskManagerImpl::systask_init): fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
427 下に述べてる SysTask_Finish を regist する部分
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
428
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
429 (TaskManagerImpl::spawn_task):
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
430
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
431 SysTask_Finish に対して、タスクが spawn されるたびに
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
432 wait_for を掛けて、待つようにしている。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
433
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
434 * add: kernel/systask/
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
435 久々の更新乙
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
436
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
437 プログラム動かすとき、タスクが SPE だけで、
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
438 PPE で待ってるタスクが無いとそのままプログラムが素通りするってことで
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
439 今まではユーザに、全てのタスクを待たせるタスクってのを書かせてた。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
440 まあもちろんめんどくさいので、いい加減追加した。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
441
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
442 system task っつーことで、spawn された全てのタスクを待つ
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
443 SysTask_Finish を作った。これでいちいち task_finish とか作らなくておk
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
444
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
445 2008-08-10 Wataru MIYAGUNI <gongo@cr.ie.u-ryukyu.ac.jp>
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
446
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
447 * thinking: add_update() ?
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
448 現在、タスクは input/output があるわけですよ。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
449 で、例えば
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
450
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
451 - 入力データ : PolygoPpack
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
452 - 出力データ : SpanPack
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
453
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
454 ってなわけですが、別のタスクで
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
455
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
456 - 入力データ : SceneGraphPack (更新前)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
457 - 出力データ : SceneGraphPack (更新後)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
458
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
459 ってのがある。つまり Update なわけだ。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
460 今のところ、同じアドレスを add_inData, add_outData に設定して
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
461 タスク内で memcpy(wbuf, rbuf, sizeof(SceneGraphPack) とかしてる。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
462 まあそれはそれでいいのかわるいのか。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
463
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
464 in/out だけじゃなくて update も必要?
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
465
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
466 2008-08-08 Wataru MIYAGUNI <gongo@cr.ie.u-ryukyu.ac.jp>
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
467
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
468 * add: ../include/TaskManager/base.h
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
469 通常の new/delete では、RTTI とか 例外処理とかで
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
470 -fno-exceptions や -fno-rtti をコンパイルオプションにしても
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
471 効かなかったんだけど、operator new/delete をオーバーライドして
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
472 中身を普通の malloc/free にすると、上の処理が無くなるので
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
473 オプションが効くようになる。結果コードサイズも減ると。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
474 SPE の場合、70〜80KBは減りました。使わない手は無い。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
475 つーことで、一応動いてる。。。といいたけど動いてないorz
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
476 最適化 (-O2 とか -O9) をかけると止まる。SPE 上でね。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
477 FIFO バージョンだと問題ない。SPEだとだめだ。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
478 今わかってる、止まる場所は Scheduler::run() 内の
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
479
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
480 task3->write();
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
481
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
482 だ。task1~3までのnewは(多分)できているんだけど
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
483 そこを呼び出すと SPE 自体が終了してしまう。謎だ
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
484
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
485 一応、俺作の new/delete は base.h に定義してあって、
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
486 通常の API との切り替えは、base.h にある
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
487 BASE_NEW_DELETE を切り替えるだけでおk。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
488 全てのファイルではなく、現在は SPE で使いそうなところだけやってます。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
489 いずれは全部やったほうがいいかな〜
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
490
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
491 ライブラリ側の最適化はアウトだけど、ユーザ側では問題ないです。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
492 なので、今は
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
493
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
494 ライブラリ側(libspemanager.a)は最適化無し(-O0)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
495 ユーザ側(SchedTaskを継承したやつね)は最適化しても無問題 (-O9)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
496
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
497 でっす。ここらへん完璧なれば、だいぶ楽になる。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
498 つーかもう C++ やめ(ry
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
499
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
500
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
501 2008-08-07 Wataru MIYAGUNI <gongo@cr.ie.u-ryukyu.ac.jp>
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
502
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
503 * change: mainMem_set -> mainMem_wait
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
504 allocate を待つんだから、なんとなく wait かな。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
505 あと、ユーザも使えるので、wait の方がわかりやすいと思ったり。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
506
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
507 2008-08-05 Wataru MIYAGUNI <gongo@cr.ie.u-ryukyu.ac.jp>
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
508
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
509 * add: mainMem_alloc, mainMem_set, mainMem_get
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
510 SPE から メインメモリの領域に対して allocate できないと
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
511 SceneGraphの生成やら、結構クリティカルな処理を
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
512 全部 PPE でやらないといけなくなるってことで実装しました。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
513
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
514 流れとして
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
515
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
516 1 タスク中に、mainMem(id,size) を実行する事で、
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
517 メインメモリに対して allocate のコマンドを発行。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
518
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
519 1.1 Scheduler から PPE に対して
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
520 - commmand (MY_SPE_COMMAND_MALLOC)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
521 - id (PPEから戻ってくるコマンドに必要)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
522 - size
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
523 を mailbox で送る
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
524
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
525 1.2 確保した領域はそのタスク内では取得できない(NULL が来ます)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
526 正確には、返事の mail をここでは read してないから
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
527
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
528 2. PPE では、受信した mail が MY_SPE_COMMAND_MALLOC だったら
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
529 次に来る mail が id と size であるとして read を行い、
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
530 size を元に allocate する。allocate が完了したら
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
531 - id
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
532 - allocate された領域のアドレス
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
533 を SPE に mail で送る
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
534
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
535 3. SPE Scheduler では、SchedTaskList::read で、
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
536 一つ前の TaskList 中で実行された mainMem_alloc の数だけ
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
537 PPE からのメールを待つ。mainMem_set() の処理です。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
538
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
539 4. create_task されたタスク内で mainMem_get(id) とすると
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
540 allocate したメインメモリ領域のアドレスが得られる。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
541
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
542 こんな感じ。結構ださい実装なので、もうちょいスマートにいきたいよね。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
543 例題は Game_project/student/master/gongo/MainMemMalloc にあります。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
544 README にもおんなじこと書いてます。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
545
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
546 * memo: The number of available entries of Inbound/Outbound Mailbox
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
547 Outbound (SPE -> PPE) のmailboxデータキュー保持数は
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
548
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
549 /* SPE プログラム中 */
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
550 #include <spu_mfcio.h>
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
551 spu_stat_out_mbox(void);
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
552
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
553 で調べる事が出来る。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
554
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
555 --- 記述例 ---
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
556 printf("Available capacity of SPU Outbound Mailbox\n");
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
557 printf(" %d\n", spu_stat_out_mbox());
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
558
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
559 --- 実行結果 --
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
560 Available capacity of SPU Outbound Mailbox
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
561 1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
562
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
563 Inbound (PPE -> SPE) の mailbox データキュー保持数は
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
564
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
565 /* PPE プログラム中 */
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
566 #include <libspe2.h>
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
567 spe_in_mbox_status(spe_context_ptr_t);
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
568
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
569 で調べられます。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
570
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
571 --- 記述例 ---
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
572 printf("the number of available entries = %d\n",
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
573 spe_in_mbox_status(spe_ctx));
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
574
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
575 --- 実行結果 ---
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
576 the number of available entries = 4
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
577
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
578 Outbound が少ないなー。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
579 In/Out 共に、キューが MAX の場合、減るまで wait 掛かるんだよな。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
580 それがどこまで影響あるかは実際にやらないと、ってことか。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
581
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
582 * fix: ファイル名の変更 (*.cpp -> *.cc)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
583 前々から先生に直せ言われてたので。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
584
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
585 cvs のファイル名を変える方法は簡単に二つ(てかこれだけ?)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
586
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
587 1. cvs rm hoge.cpp; cvs add hoge.cc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
588 2. リポジトリを直接変更 mv hoge.cpp,v hoge.cc,v
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
589
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
590 めんどくさかったので 2 でやりました。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
591 Attic (削除されたファイルがあるリポジトリディレクトリ?)にも
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
592 同じ処理を行えば、tag で update かけてもちゃんと反映されました。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
593
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
594 2008-07-22 Wataru MIYAGUNI <gongo@cr.ie.u-ryukyu.ac.jp>
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
595
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
596 * tag: open-campus-2008
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
597 次やる事は、Cell/spe 以下のコードサイズを減らすために
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
598 new/delete を消して malloc/free で統一する事。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
599 placement_new ってのを使えば、コンストラクタは呼べて
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
600 new ほどサイズ圧迫しないからこれにしようかな。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
601 逆の placement_delete ってのは自分で小細工しないと行けないらしい。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
602 まあ、これが旨く行けば 80KB ほど減るから。やるべきだろう。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
603
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
604 * Cell/spe/Scheduler.cpp (Scheduler::dma_load): アホなミスその2
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
605 自分で __scheduler->dma_store をやってもデータが送れない。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
606 そんな馬鹿な。つーことでいろいろ調べてもわからない。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
607 アドレスやサイズが違うのかと調べても違う。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
608 こうなったらっつーことでライブラリに printf 加えてみたら表示されない
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
609 あれ、おかしいな。たしかに Connector::dma_store に加えたはz・・
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
610
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
611 Scheduler::dma_store(void *buf, uint32 addr, uint32 size, uint32 mask)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
612 {
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
613 <<<
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
614 connector->dma_load(buf, addr, size, mask);
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
615 ========
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
616 connector->dma_store(buf, addr, size, mask);
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
617 >>>
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
618 }
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
619
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
620 なぜ store から load を呼んでるのか不思議だった。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
621 Scheduler::dma_load をコピペして dma_store にした後、
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
622 中の connector->dma_load を変えなかったってオチだな。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
623 下のミスと合わせて5,6時間費やしたよHAHAHA
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
624
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
625 * Cell/spe/SchedTask.cpp (SchedTask::exec): アホなミスその1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
626 Test/test_render で、
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
627 SpanPack のデータが時々壊れてる感じがする。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
628 送る前までは正常だから生成に問題は無いはず。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
629 つーことでいろいろ調べたがわからず。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
630 printf デバッグすると動く不思議
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
631 なんだ、printf で遅くなったらできるってことは
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
632 DMA が完了する前に SchedTask::run にきてんのか?
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
633 いやいや、そんなばかな。だってちゃんと wait し・・・
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
634
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
635 <<<
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
636 ============
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
637 __scheduler->dma_wait(DMA_READ);
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
638 >>>
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
639
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
640 はいはい wait し忘れ wait し忘れ
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
641
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
642 2008-07-16 Wataru MIYAGUNI <gongo@cr.ie.u-ryukyu.ac.jp>
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
643
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
644 * memo: if 文消した成果2 & memcpy するかしないかか
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
645 Renew Task では、inListData,outListData は新たに allocate して
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
646 使っているので、SchedTask にそって実行する場合、
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
647
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
648 __scheduler->dma_load(__inListData, (uint32)__task->inData,
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
649 sizeof(ListData), DMA_READ_IN_LIST);
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
650 __scheduler->dma_load(__outListData, (uint32)__task->outData,
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
651 sizeof(ListData), DMA_READ_OUT_LIST);
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
652
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
653 の代わりに
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
654
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
655 memcpy(__inListData, __task->inData, sizeof(ListData));
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
656 memcpy(__outListData, __task->outData, sizeof(ListData));
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
657 free(__task->inData);
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
658 free(__task->outData);
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
659
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
660 もしくは
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
661
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
662 __inListData = __task->inData;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
663 __outListData = __task->outData;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
664 (__task->inData と __task->outData は Destructor で free する)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
665
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
666 とやっています。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
667 memcpy が重いのはわかるんですが、下の方法では
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
668 Destructor で if 文使って free() しているわけです(このタスクが Renew か否か)。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
669 ですので、どっちが早いか試してみた。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
670
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
671 /**
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
672 * memcpy() して、すぐ free() する version
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
673 */
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
674 void
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
675 test_cpy(int flag, int *src)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
676 {
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
677 if (flag) {
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
678 memcpy(data, src, sizeof(int)*length);
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
679 free(src);
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
680 }
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
681 }
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
682
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
683 /**
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
684 * 参照で扱って、最後に free() する version
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
685 */
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
686 void
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
687 test_nocpy(int flag, int *src)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
688 {
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
689 if (flag) {
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
690 data = src;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
691 }
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
692
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
693 // この部分を SchedTask::~SchedTask() と
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
694 // 思ってください
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
695 if (flag) {
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
696 free(data);
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
697 }
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
698 }
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
699
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
700
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
701 これらの関数を10000回ループしました。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
702 src の allocate は関数の外でやっており、その部分は実行時間に含まれてません
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
703 flag は 1 or 0 の繰り返しです。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
704
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
705 - 実行結果 (1)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
706 :no copy
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
707 SPE time by SPU Decrementer: 0.035500
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
708 :copy
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
709 SPE time by SPU Decrementer: 0.057500
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
710
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
711 memcpy しないほうが速いらしいです。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
712 ためしに、flag を ずっと 1 にしてみました。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
713
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
714 - 実行結果 (2)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
715 :no copy
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
716 SPE time by SPU Decrementer: 0.055250
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
717 :copy
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
718 SPE time by SPU Decrementer: 0.053389
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
719
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
720 今度は copy するほうが早いという不思議。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
721 でもまあ、ずっと 1 ってことはないと思いますし、
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
722 むしろ flag == 1 になるほうが少ないと思うので、
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
723 no_copy version でやったほうがいいかな。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
724
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
725 おまけで、実行結果 (1) の環境で、test_nocpy を変えてみた
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
726
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
727 void
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
728 test_nocpy(int flag, int *src)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
729 {
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
730 if (flag) {
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
731 data = src;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
732 }
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
733
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
734 free((void*)(flag*(int)data));
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
735 }
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
736
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
737 キャストしまくりですが、単純に free(flag*data) だと
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
738 「invalid operands of types 'int' and 'int*' to binary 'operator*'」って
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
739 出るので、キャストで逃げました。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
740 で、実行結果なんですが
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
741
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
742 - 実行結果 (3)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
743 :no copy
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
744 SPE time by SPU Decrementer: 0.040375
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
745 :copy
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
746 SPE time by SPU Decrementer: 0.059500
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
747
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
748 遅くなってーら。キャストが悪いのか。乗算が重いのか。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
749 branch が無い? spe の if 文と対決しても遅いのかー。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
750 例題が間違ってる可能性もあるが・・・ if 文は使っていくかなー
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
751
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
752
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
753 2008-07-10 Wataru MIYAGUNI <gongo@cr.ie.u-ryukyu.ac.jp>
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
754
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
755 * fix: TaskGroup->group
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
756 今まで slist っていう、ライブラリの単方向リスト構造体?を
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
757 使ってたんだけど、まあいろいろあって、TaskQueue を使うようにしました。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
758 最初からこれにするつもりではあったけどね。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
759 RenewTask や static_alloc とかの実装を優先したので
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
760 ライブラリを使いました。といっても、書いてみると
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
761 それほと記述量無いので最初から行っても良かったかなーと思ったり。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
762
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
763 そんなわけで動いてます。つーか、やめてよかったよ slist。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
764 slist を使ったやつと使ってない奴のファイルサイズがやばい
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
765
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
766 -rwxr-xr-x 1 gongo gongo 120672 2008-07-10 14:29 spe-main*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
767 -rwxr-xr-x 1 gongo gongo 180368 2008-07-10 13:40 spe-main.bak*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
768
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
769 .bak が slist を使ってる、上のやつが使ってないversionです。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
770 まさか 60k も違ってくるとは思わなかった。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
771 SPE LS の容量が 256k と考えると、かなりの痛手だったよ。アブねえ。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
772 インラインとか最適化掛けまくってて、コード量が増えてるからかなー。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
773
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
774 「SPU C/C++ 言語拡張」とかで、C++ のライブラリがSPUでも使えるよ〜
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
775 って書いてたから入れてみたんだけど。罠だったか。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
776 おそらく SPU に移植した側の人も「サイズが増えるのを覚悟で使え」って
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
777 ことだったんだろう。なかったら文句言う人も居そうだし。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
778
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
779 2008-07-09 Wataru MIYAGUNI <gongo@cr.ie.u-ryukyu.ac.jp>
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
780
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
781 * fix: TaskGroup での task の扱い
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
782 下にもかいているけど (直したいところ (1))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
783 TaskGroup->group が持つ要素は int で持ってて、
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
784 それらは、同じく TaskGroup が持つ cur_id をインクリメントしていって、
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
785 それを要素としていました。つまり、TaskGroup->group は、厳密にいえば
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
786 「どの Task があるか」ではなく、「いくつのタスクがあるか」を
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
787 あらわしているだけでした。slist を使う意味もなかったわけです。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
788
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
789 そこで、SchedTask が持つ、RenewTaskList の解放のタイミングを
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
790 RenewTaskList の一番最後のタスクが delete されるときにしました。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
791 これによって、アドレスが被ることがなくなったので
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
792 TaskGroup->group の要素を TaskPtr にできました。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
793 この方が、TaskGroup の意味的にもしっくりくるのでよかばってん。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
794
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
795 * memo: if 文消した成果
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
796
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
797 #ifdef FREE_TEST
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
798 free((ListDataPtr)(__flag_renewTask*(int)(__inListData)));
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
799 free((ListDataPtr)(__flag_renewTask*(int)(__outListData)));
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
800 free((TaskListPtr)(__flag_renewTask*(int)(__list)));
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
801 #else
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
802 if (__flag_renewTask) {
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
803 free(__inListData);
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
804 free(__outListData);
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
805 free(__list);
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
806 }
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
807 #endif
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
808
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
809 こんな感じで、いくつかか if 文を消してみた。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
810 そして、PPE側の main.cc で gettimeofday で計測してみた (各10回)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
811
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
812
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
813 - if 文消した場合
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
814 time: 1.222000
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
815 time: 1.230000
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
816 time: 1.241000
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
817 time: 1.230000
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
818 time: 1.223000
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
819 time: 1.257000
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
820 time: 1.219000
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
821 time: 1.228000
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
822 time: 1.220000
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
823 time: 1.229000
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
824 avarage: 1.2299
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
825
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
826 - if 文消してない場合
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
827 time: 1.225000
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
828 time: 1.215000
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
829 time: 1.229000
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
830 time: 1.218000
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
831 time: 1.223000
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
832 time: 1.214000
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
833 time: 1.225000
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
834 time: 1.215000
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
835 time: 1.224000
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
836 time: 1.219000
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
837 avarage: 1.2207
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
838
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
839 あまり変わらな(ryむしr(ry
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
840 使い方がまずいのか、もっとと回数を増やせば変わってくるのかね。。。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
841 PPE でなく、 SPE のほうで計測すべきなのかなーとか思ったり思わなかったり。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
842
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
843
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
844 2008-07-08 Wataru MIYAGUNI <gongo@cr.ie.u-ryukyu.ac.jp>
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
845
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
846 * add: Renew Task の wait
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
847 Renew Task は今まで「生成されたやつ全部待つ」だったのを
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
848
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
849 void SchedTask::wait_task(TaskPtr task);
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
850
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
851 ってのを作って、任意のタスクに wait 掛けれるようにしました。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
852 名前が思いつかなかったお。。。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
853 動作確認済み・・・だと思います。例題・・・誰か例題を!(俺が
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
854
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
855
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
856 * fix: SchedTask の変数名
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
857 ユーザが継承して使う SchedTask クラスなんですが、
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
858 今まで変数は list, task などを使ってました。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
859 が、これは一般に使われやすい変数名です。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
860 その証拠に、俺も例題書いている時に task って名前が被ってました。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
861
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
862 run(r, w)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
863 {
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
864 ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
865
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
866 //TaskPtr task; <= 宣言してないのにエラーにならない
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
867 task = create_task(TASK_EXEC);
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
868 }
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
869
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
870 ってコードを書いてたせいで、Scheduler が使用する task を
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
871 上書きしたせいでバグってました。ってことがありました。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
872 上のように、宣言してないのに普通に通ってるのを気づきませんでした。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
873 今のところ変数名は __task とか __list にしてあります。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
874 private にしてもいいんだけどさ。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
875
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
876
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
877 2008-07-07 Wataru MIYAGUNI <gongo@cr.ie.u-ryukyu.ac.jp>
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
878
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
879 * fix: if 文を無くしてみた
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
880 下の方に 「if () が多い」って書きましたが、いろいろ小細工を。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
881 SchedTask をやってみました。例えば
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
882
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
883 if (cmd != 0) {
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
884 delete taskGroup;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
885 scheduler->mail_write(cmd);
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
886 }
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
887
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
888 ってのがありました。cmd ってのは taskGroup->status で
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
889 もし cmd が 0 でなければ、taskGroup はすでに空っぽで
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
890 待つべきタスクはすべて終了したので、taskGroup を delete し、
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
891 mailbox で cmd を PPE に送ります(cmd にはすでに送るべきコマンドがある)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
892 でまあ、これくらいなら
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
893
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
894 delete (int*)((cmd != 0)*(int)(taskGroup));
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
895 scheduler->mail_write(cmd);
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
896
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
897 ぐらいに直せました。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
898 delete や free では NULL を渡しても何もしない(?)って動作なので
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
899 これでも問題ない。つまり、cmd == 0 なら、taskGroup を
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
900 解放する必要は無いので NULL が delete に渡されるわけです
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
901 int* でキャストしてるのは、そのまま 0 を渡すと、
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
902 「int型を delete するのはできない」的なエラーがでるからです。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
903 。。。だったら int* じゃなくて TaskGroupPtr じゃね?とか思った今。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
904
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
905 あと、PPE 側で 「mail == 0 なら NOP」 的な処理を入れました。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
906 これによって、cmd が 0 かその他で if を書く必要がなくなりました。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
907 問題があるとすれば、 SPE -> PPE の mailbox の queue の長さ。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
908 NOP コマンドを送って、queue の制限に引っかかって
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
909 mail_write が止まるんじゃないかなーとか少し心配です。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
910 ここらへんは optimize の時間に考える事かな。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
911 どうせ PPE では mail しか読んでないし、
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
912 そこまで queue が埋まる事は無いと思いたい。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
913
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
914
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
915
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
916 あとはこんな感じかな
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
917
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
918 #if 1 // fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
919 free((void*)(flag_renewTask*(int)(list)));
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
920 #else
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
921 if (flag_renewTask) {
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
922 free(list);
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
923 }
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
924 #endif
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
925
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
926 動いてるのは確認したし、gdb で x/20i とかしたら
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
927 branch 命令が減ってるのは確認した。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
928 まあ -O9 とかで最適化掛けるとどっちも同じになるけどな。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
929
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
930
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
931 * add (API): static_alloc, static_get, static_free
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
932 SchedTask 自身だけが持つ領域ではなく、
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
933 SPE 上に複数のタスクが共有したい領域を作る
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
934 これは task::run() 内で使用する。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
935
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
936 - void* static_alloc(int id, int size);
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
937 @param [id] 領域ID。現在は 0〜31 まで使用可能 (Scheduler.h で定義)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
938 @param [size] 領域のサイズ
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
939 @return allocate した領域のポインタ。下の static_get の返り値と同じ
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
940
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
941 - void* static_get(int id);
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
942 @param [id] static_alloc で作った領域 ID。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
943 @return 領域のポインタ
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
944
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
945 - void static_free(int id);
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
946 @param [id] 解放したい領域の ID
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
947
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
948 こんな感じかなー。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
949 static_free はさすがにユーザに任せるだろう。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
950 static_free し忘れると SPE には致命的なので、ここはよく伝える必要有
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
951
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
952 例題は
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
953 cvs: firefly:Game_project/student/master/gongo/Static
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
954
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
955 まあ Renew と大体同じですけどね。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
956 int 型配列 data を共有にして、各タスクでインクリメントしてる
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
957
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
958 * TODO: TaskGroup の扱い
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
959 通常の Task では、task->self には
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
960 自分が終了した時に PPE に送るコマンド(自分自身)になりますが、
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
961 タスク中に生成されたタスク(もう何度も書くのめんどいんで Renew で)では
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
962 task->self は、task を待っている TaskGroup を表します。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
963
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
964 self という名前で意味が違うのでこういうことはやめたいんだが。。。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
965 といいながらやめないのが(ry
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
966
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
967 * memo:
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
968 下の 直したいところ (1) ってやつがよくわからんので、
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
969 現在の状況だけ
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
970
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
971 scheduler->add_groupTask() をするたびに
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
972
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
973 group.insert_front(cur_id++);
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
974
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
975 されます。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
976 そして、scheduler->remove_groupTask() されると
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
977
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
978 group.remove(--cur_id);
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
979
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
980 されます。要するに、どのタスクでも
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
981 cur_id だけが insert/remove されます。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
982 「どのタスクがあるか」ではなく「どれだけのタスクがあるか」ですね。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
983 実際にはしっかりと TaskPtr で管理したかったんですが、
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
984 下にも書いたアドレスが被る云々の問題でそれもできず。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
985 やり方はあると思うんですが。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
986
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
987 うーん、うまく説明できないな。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
988
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
989 * tag: v20080707
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
990 タスク内タスク生成を作りました。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
991
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
992 [TODO]
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
993 SPE 上で領域を共有する API の
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
994
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
995 - static_alloc
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
996 - static_get
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
997 - static_free
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
998
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
999 を速攻で実装しよう。。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1000
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1001 * add: タスク内タスク生成
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1002 一応できたんですが、直したい。。。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1003 仕様としては
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1004
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1005 - 現在のタスク(T1) の中でタスクを生成したとする (Tc = T2, T3, ...)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1006 - 本来、T1 が終了次第、T1 が終わった事を PPE に伝えるが、
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1007 ここでは、Tc が全て終わってから、T1 の終了を PPE に伝える
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1008 - Tc 内で再びタスクが生成されても(Tcc)、Tcc が終わってから T1 を(ry
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1009
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1010 現在は、生成したタスクすべてに対して wait_for をかけてる感じ。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1011 しかし、例えば Frame Buffer に書き込む時は待つ必要ない(はず)なので
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1012 タスク毎に wait_for を選べるようにした方がいいだろう。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1013
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1014 __ 例題
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1015 cvs firefly:Game_project/student/master/gongo/Renew
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1016
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1017 にあります。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1018 もうちょいちゃんとした例題が欲しいところです。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1019
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1020
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1021 __ 直したいところ (1)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1022
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1023 現在、Tc を管理する構造体として、TaskGroup を使ってます
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1024
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1025 class TaskGroup {
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1026 unsigned int command; // T1 が PPE に送るコマンド
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1027 __gnu_cxx::slist<int> group; // Tc がある Linked List
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1028
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1029 // function は省略
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1030 };
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1031
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1032 slist じゃなくて、TaskQueue みたいに自分で作っても良かったんだけど。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1033 group.empty() == true になったら、command を PPE に送るって感じです。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1034
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1035 で、slist が持つデータが TaskPtr じゃなくて int の理由。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1036 まあいろいろあるんだけど(何)、アドレスが重複してしまうことです。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1037 最初は、create_task で得られた TaskPtr をキーとして使うつもりだったけど
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1038 その TaskPtr は TaskList から取った物で (&list->takss[index] みたいな)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1039 なんでそれじゃだめなのか。buff_taskList[2] (Scheduler.cpp 参照) を
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1040 使うと、交互に使用するのでアドレスは被る。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1041 新たに allocate すれば問題は無いが (t1とする)、SPE の LS の問題で
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1042 使わなくなった TaskList は free していかないといけない。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1043 で、free -> 再び allocate したとき (t2とする)、t1 と t2 の
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1044 アドレスが被ることがあった。当然 TaskPtr も被ると。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1045 だから、アドレスではなく、TaskGorup が持つ
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1046 unsigned int cur_id を使う事にしました。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1047
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1048 なんかここまで自分で書いてて、
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1049 なんで出来ないのかまだわからんくなってきた。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1050
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1051 ので試しに戻してみたら * で * き * ま * し * た *
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1052 わけわからん。まあ勘違いだったのか、いろいろ別のところを直してるうちに
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1053 知らず知らずミスってたところも治ってたのか。まあいいか。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1054
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1055 と思っていろいろ試したらまた動かなくなった。。もうだめぽ
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1056 とりあえず、また unsigned int に戻しました。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1057 今のところ、0 <= cur_id <= 0xffff (65535) の範囲のキーを使うように。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1058
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1059
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1060 __ 直したいところ (2)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1061 if 文が多い。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1062 今は、「通常の Task」「タスク内で生成されたタスク」で挙動が違います。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1063 例えば
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1064
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1065 - SPE で allocate されたデータを使うので、通常 DMA を使うところは
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1066 アドレス参照や memcpy を使う
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1067 - TaskGroup を、上記の Tc や Tcc へ引き継がせるところ
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1068
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1069 なので、flag_renewTask とかいう変数で、ほぼ if 文 で書いてます。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1070 SPE でこの書き方はかなりまずい気がします。良い書き方はないものか。。。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1071 「通常の(ry」「タスク内(ry」で新たにインスタンスを作るってのも
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1072 考えはしましたが (SchedTask = 通常、SchedRenewTask = タスク内(ry とか)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1073 これだと ユーザー側も この二つを選んでやることになります。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1074 「このタスクは SchedRenewTask 、このタスクは通常」とかやるのは
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1075 かなりめんどくさいと思う。だからライブラリ側で分けるべきか。。。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1076 多重継承とかってこんなとき役に立つん?
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1077
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1078
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1079 2008-07-03 Wataru MIYAGUNI <gongo@cr.ie.u-ryukyu.ac.jp>
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1080
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1081 * TODO:
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1082 - add_param で渡せるパラメータの数を増やす。15もあればいいんじゃね?
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1083 - 今の実装では、
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1084
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1085 1. PPE でタスク(T1)が生成される
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1086 2. SPE で T1 が実行される
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1087 3. T1 が終わった事を PPE に mailbox で送る
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1088 送る情報は T1 自身。(PPE で生成された時のアドレス)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1089
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1090 なわけです。しかし、もし T1 から新たにタスクが生成された時はどうするか
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1091 仮に T1 から T2, T3, T4 が作られたとする。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1092 このとき、
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1093
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1094 1. T1 が終わった時点で、T1 から終了コマンドを送る
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1095 2. T1 だけでなく、T1 内で作られた T2, T3, T4 が終わってから
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1096 終了コマンドを送る
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1097
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1098 の二つが考えられる。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1099 PPE 側では T1 しか認識していないため、この判定は SPE 内でやることになる
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1100 必要な処理かと言われると微妙だが、欲しくなるのは間違いない。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1101 つーことで今これを実装中です。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1102
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1103
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1104 * tag: v20080703
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1105 - タスクに 32 bits パラメータを渡す add_param を実装(現在は3個まで)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1106 - SPE 内部でタスク生成ができるようになった
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1107
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1108 * add (API): SPE内部での create_task
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1109 今まで、SPE ではタスクを生成する事は出来ず、
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1110 PPE から送られてくるタスクを実行するだけでした。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1111 それだと不便だってことで SPE 内部でもできるようにしました。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1112 方法はPPEでやるのと同じく
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1113
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1114 task = create_task(TASK_EXEC);
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1115 task->add_inData(buff, sizeof(Buff));
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1116 task->add_param(data);
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1117
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1118 みたいな感じでいいです。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1119 spawn() や wait_for() は実装していません。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1120 SPE 内部で生成するタスク同士で依存関係作るのが
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1121 結構めんどくさいからです。spawn() も、しなくても勝手に実行します。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1122 PPE とそろえる意味で作ってもいいんだけどね。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1123 そのためには SPE にも TaskManager が必要になってくるなー。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1124
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1125
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1126 2008-06-24 Wataru MIYAGUNI <gongo@cr.ie.u-ryukyu.ac.jp>
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1127
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1128 * add (API): add_param, get_param
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1129 DMA で送れないけど、必要になってくる 4 バイトの情報があるとして
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1130 それは今までは
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1131
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1132 add_inData(param, 0);
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1133
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1134 とかして、「サイズ == 0 なら 32 bit のデータ」としていたけど
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1135 それは余りにも変なので(関数の意味的にもおかしい)ので、
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1136
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1137 add_param(parameter);
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1138
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1139 ってのを追加しました。タスク側では
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1140
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1141 get_param(index);
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1142
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1143 とかします。index は、add_param を呼び出した順番で決まります
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1144
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1145 add_param(x);
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1146 add_param(y);
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1147 add_param(z);
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1148
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1149 とあるとき、タスク側では
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1150
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1151 int x = get_param(0);
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1152 int z = get_param(2);
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1153
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1154 とします。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1155 今のところ parameter は 3つしか送れないことになってますが
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1156 後ほど、上限をあげます。15くらいあれば余裕だと思うんだがどうだい?
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1157 今は、SPE でのタスクの生成のルーチンを書くために、最低限な部分だけ
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1158 ってことで 3 つにしてます。それが出来次第、これもやります。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1159
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1160
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1161 2008-06-12 Wataru MIYAGUNI <gongo@cr.ie.u-ryukyu.ac.jp>
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1162
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1163 * Cell/CellTaskManagerImpl.cpp (CellTaskManagerImpl::set_runTaskList):
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1164 アホなミス(ry
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1165
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1166 「list が持つ TASK_MAX_SIZE を超えると、次の list へ next を」っていう
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1167 前回直したところがまたミスっててだな。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1168 簡単に言うと
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1169
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1170 TaskPtr task = &list[list->length++];
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1171 [task の初期化]
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1172
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1173 if (list->length > TASK_MAX_SIZE) {
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1174 [newList 生成]
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1175 newList = append(newList, topList[speid]);
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1176 topList[speid] = newList;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1177 }
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1178
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1179 ってやってたわけ。これだと、toplist[speid] に
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1180 length = 0 の list が来る可能性があると。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1181 で、spe に TaskList を送る条件は
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1182
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1183 1. taskList[speid]->length >= 1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1184 2. speid が次の TaskList を待っている状態
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1185
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1186 で、1 の条件に触れてしまい、TaskList が送られなくなって
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1187 プログラムが終了しないと。アホですね〜
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1188 上の if 文を &list[list->length++]; の前に持って行くだけでおk。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1189
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1190 2008-06-10 Wataru MIYAGUNI <gongo@cr.ie.u-ryukyu.ac.jp>
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1191
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1192 * Cell/CellTaskManagerImpl.cpp (CellTaskManagerImpl::set_runTaskList):
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1193 アホなミスしてました。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1194 list が持つ TASK_MAX_SIZE を超えると、次の list へ
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1195 next を繋げるはずなんだけど、speTaskList_bg[speid] とか読む時に
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1196 ちゃんと繋げられてなかったというかなんというか。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1197 簡単に言うと、タスク多くなると落ち(ry
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1198
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1199 * add (API): set_post
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1200
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1201 create_task(id, 0);
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1202
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1203 とかわざわざ 0 付けるのもアレなので、もうそれように
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1204
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1205 task->set_post(func)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1206
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1207 を追加しました。func は void (*func)(void) です。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1208 せっかくだから、引数に void* とか付けてもいいんじゃないかと。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1209
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1210
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1211 * fix (API): ListDMA API
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1212 タスク側で、ListDMA で指定したデータの取り方
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1213
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1214 run(rbuf, wbuf) として
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1215
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1216 // index は add_inData や add_outData で指定した(順番-1)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1217 get_input(rbuf, index);
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1218 get_input(wbuf, index);
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1219
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1220 返り値は void* なので、malloc っぽくキャストしてください。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1221 あと、4バイト以下のデータを送りたい場合、main で
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1222
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1223 add_inData(data, 0)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1224
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1225 と、アドレスは送りたいデータを則値で、サイズは 0 で指定するとおk。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1226 get_input で int なりなんなりでキャストすればいいじゃない!
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1227 例題は
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1228
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1229 Game_project/student/master/gongo/arr_cal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1230
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1231 で複数データ扱ってたり4バイト送ってたりしてます。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1232
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1233
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1234 * tag: v20080610
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1235 前回との違いは
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1236
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1237 - ListDMA の導入
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1238 - 凡ミスfix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1239
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1240 とかかな。何気にここには ListDMA の API 書いてなかったな。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1241
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1242 - task->add_inData(addr, size); // input
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1243 - task->add_outData(addr, size); // output
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1244
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1245 これで Input/Output のデータ領域を指定可能。複数できます。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1246 詳しくはいずれドキュメントに書く予定だが、
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1247
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1248 - addr は 16 バイトアライメントに取れてないと行けない
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1249 - size は 16 バイト倍数
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1250
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1251 ってのが最低条件。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1252 16 バイト未満のデータを送りたいとき(整数を2,3個とか)は考え中。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1253 addr に直接渡すって手法はできるとわかってるので、それでもいいかな。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1254 まあいろいろ問題はありますが、少しはできたんじゃないかな。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1255
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1256 次からは SPE 内でのタスク生成(再起動?)を書く予定
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1257
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1258 * Cell/CellTaskManagerImpl.cpp (CellTaskManagerImpl::set_runTaskList):
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1259 if (speid > machineNum) {
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1260 speid %= MAX_USE_SPE_NUM;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1261 }
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1262
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1263 から
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1264
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1265 if (speid >= machineNum) {
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1266 speid %= machineNum;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1267 }
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1268
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1269 に。なんという凡ミス
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1270
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1271 * Cell/spe/CellDmaManager.cpp (CellDmaManager::dma_loadList): fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1272 ListData が持つ ListElement は
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1273
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1274 class ListElement {
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1275 public:
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1276 int size;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1277 unsigned int addr;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1278 };
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1279
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1280 というデータ構造なわけだが、これは、spu_mfcio.h が持っていて
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1281 且つ List DMA で使用される
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1282
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1283 typedef struct mfc_list_element {
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1284 uint64_t notify : 1; /** Stall-and-notify bit */
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1285 uint64_t reserved : 16;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1286 uint64_t size : 15; /** Transfer size */
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1287 uint64_t eal : 32; /** Lower word of effective address */
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1288 } mfc_list_element_t;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1289
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1290 と同じである。notify と reserved は 0 となる (ストールは今は
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1291 考えていない)ので、結局は uint が 2 つの 8 バイト のデータ構造であれば
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1292 そのまま mfc_getl とか mfc_putl に遅れるわけである。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1293 今までは mfc_list_element_t 構造体に for 文でいちいち代入してたが
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1294 まあそれはなくなったっつーことで。dma_storeList もね。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1295
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1296
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1297 2008-05-30 Wataru MIYAGUNI <gongo@cr.ie.u-ryukyu.ac.jp>
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1298
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1299 * change (API): TaskManager Memory Allocate
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1300 manager->cerium_malloc(&buff, DEFAULT_ALIGNMENT, sizeof(Data))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1301
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1302 から
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1303
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1304 buff = (Data*)manager->malloc(sizeof(Data));
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1305
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1306 に変更しました。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1307 alignment の指定は全て TaskManager に埋め込んであります。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1308 記述は TaskManager.h に書いてあります。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1309
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1310 void* TaskManager::malloc(int size) {
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1311 return m_impl->allocate(DEFAULT_ALIGNMENT, size);
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1312 }
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1313
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1314 2008-05-29 Wataru MIYAGUNI <gongo@cr.ie.u-ryukyu.ac.jp>
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1315
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1316 * thinking: List DMA (4)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1317 Cell 版でも動いたのを確認。今、Cell 版で List DMA が動く条件は
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1318
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1319 1. List の各要素の転送サイズが 16 バイト倍数でなければならない
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1320 2. List の各要素の転送するデータのアドレスのアライメントを保証(16or128
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1321
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1322 2に関しては Cell の仕様なんでまあいいんだけど、
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1323 1は、ドキュメント見る分には
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1324
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1325 - Cell Broadband Engine アーキテクチャ version 1.01 より
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1326 - 7.5.3 get list
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1327 > リスト・サイズ・パラメータは、このDMAコマンドの場合は
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1328 > 8バイトの倍数でなければならず、また、リスト・アドレス・パラメータは、
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1329 > ローカルストレージの8バイト境界にアラインされなければなりません。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1330
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1331 って書いてるんだよな。int が 10 個の配列(40バイト) を送っても
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1332 見事に弾かれたんだよな。おのれバスエラーめ!
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1333 とりあえず、上の条件を満たせば行けました。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1334 送るデータのアロケートは
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1335
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1336 TaskManager::cerium_allocate(void **buff, int align, int size);
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1337
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1338 ってのを作りました。使い方は別項目で。だいたい posix_memalign 準拠。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1339
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1340 動くのはいいんだけど、これだとユーザに全部任せる事になります。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1341 特に、配列をアロケートした後、その途中の部分をリストに入れたい時。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1342 その配列の要素のサイズが16倍数じゃないとそこでエラーがでると。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1343 それをユーザに全部任せるのは、まあいけないこともないけどさ。。。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1344
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1345
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1346 * Cell/CellTaskManagerImpl.cpp (CellTaskManagerImpl::mail_check): fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1347 CellTaskManager は FifoTaskManager のオブジェクトを
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1348 ppeManager という変数で持っていて、作業を別々に行っているわけで。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1349 だけど両方のオブジェクトがもつ waitTaskQueue は同じじゃないと
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1350 ならないので、最初は TaskQueuePtr * とかで渡して
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1351 共有してたわけだけど、よくよく考えると、
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1352
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1353 - waitTaskQueue に task が append される時
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1354 CellTaskManager->append_waitTask()
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1355
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1356 - waitTaskQueue から task が remove されるとき(依存満たした時とか)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1357 FifoTaskManagerImpl->mail_check() 及び
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1358 CellTaskManagerImpl->mail_check() です。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1359
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1360 つまり、waitTaskQueue が共有されるのは mail_check だけなので、
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1361 CellTaskManagerImpl の mail_check で
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1362
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1363 ppeManager->mail_check(mail_list, &waitTaskQueue)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1364
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1365 として、ここで waitTaskQueue を参照渡ししてます。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1366 ppeManager->mail_check で waitTaskQueue の整理が終わって
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1367 戻ってくる事には waitTaskQueue が更新されていると。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1368
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1369 なんか文章がおかしいですね。気になる人は俺に直でお願いします。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1370 要するに、ppe と spe のそれぞれの TaskManagerImpl で
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1371 waitTaskQueue の共有が上手くいったというわけです。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1372
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1373
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1374 2008-05-24 Wataru MIYAGUNI <gongo@cr.ie.u-ryukyu.ac.jp>
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1375
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1376 * thinking: List DMA (3)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1377 現在実装中。Fifo 版では動いている模様。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1378 問題は Cell だよなー。考えないと行けない事がいくつか
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1379
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1380 - Input/Output データはアライメントされている?
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1381 アライメントされていなくても、こっちでアドレスずらして
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1382 DMAしてずらして run() に渡して〜とかもできるんだけど
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1383 かなりめんどくさい。それに、In ならともかく、
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1384 Out は変な領域に書き込みそうなので無理そう。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1385 これはもうユーザが、送るデータはすべて
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1386 Cerium_malloc 的なものを通したものだけ、っていう
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1387 制約にした方がいいかもしれない。てかそうなんだっけ。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1388
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1389 - 配列中のデータの指定
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1390 上の項目と少し関連があるんだが、例えば
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1391
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1392 int data[100]; // アライメントは取れてるとする
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1393
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1394 ってのがあって、そのなかの data[0]〜data[49]、
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1395 data[50] 〜 最後まで送りたいとする。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1396 最初のやつは &data[0] のアドレスは 16 bytes アライメントだけど、
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1397 &data[50] では、sizeof(int)*50 = おそらく 200 ずれて
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1398 16 bytes アライメントではなくなると。これだと DMA できない。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1399 ユーザがそこまで考えて、例えば data[32] から送る、とかでもいいけど。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1400 ライブラリ側で、少しは融通効くようにすべきかな。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1401 やるなら、アドレスずらして取って来て、ユーザが見るデータは
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1402 そのずらした分戻してから見せるって感じ。変な説明だが。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1403
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1404 うーん。今はとりあえず全てアライメント大丈夫な方向でやってみるか。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1405
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1406
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1407 2008-05-23 Wataru MIYAGUNI <gongo@cr.ie.u-ryukyu.ac.jp>
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1408
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1409 * Cell/SpeThreads.cpp (SpeThreads::init): スレッドの生成
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1410 今まで作られてたスレッドは
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1411
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1412 - spe_context_run を実行するだけのスレッド (spe_thread_run)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1413 - 上のスレッドを呼び出し、終了を待つスレッド (frontend_thread_run)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1414
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1415 2番目に何の意味があるのかということだが、
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1416 SPE 毎にスレッドを立ち上げておいて、
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1417 それぞれのSPEからのメールは、その担当するスレッドが見る、
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1418 って構想で作っていました。だけど、今は mailbox の扱いは
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1419 Cell/CellTaskManagerImpl::mail_check で行っているため
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1420 わざわざ2番目のスレッドを作る必要がなくなりました。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1421 つーことで、frontend_thread_run ではなく、
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1422 最初から spe_thread_run を起動すればおkとなりました。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1423
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1424 * Cell/SpeThreads.cpp (SpeThreads::get_mail): if 文排除
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1425 今までは
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1426
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1427 if (spe_out_mbox_read(spe_ctx[speid], &ret, 1) < 0) {
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1428 return ret;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1429 else
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1430 return -1;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1431
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1432 とやっていた。これは
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1433
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1434 - データを読めたらそれ(ret)を返す
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1435 - データが無かったら -1 を返す
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1436
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1437 ってことだったんだが、よくよく考えると、spe_out_mbox_read() は
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1438 データがなかった場合 ret の値を変えないので、最初に
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1439
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1440 unsigned int ret = (unsigned int)-1;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1441
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1442 としておけば、最終的に if 文無しの
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1443
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1444 spe_out_mbox_read(spe_ctx[speid], &ret, 1);
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1445 return ret;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1446
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1447 だけで済むわけだ。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1448
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1449 2008-05-22 Wataru MIYAGUNI <gongo@cr.ie.u-ryukyu.ac.jp>
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1450
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1451 * thinking: List DMA (2)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1452 MFC List DMA read の場合は(少なくともPPEでcreate_taskする時は)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1453 read size が決まっているので無問題。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1454 しかし、MFC List DMA write の場合。同じタスクでも
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1455 違うサイズを出力するということはありえるので問題。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1456 今までも、write の場合は task->run() の返す値が write size として
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1457 使う事にしていた。List DMA write の場合は、おそらく
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1458
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1459 - task->run() 内で write 用の List DMA 構造体を作って Scheduler に
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1460 渡して、task->write() でやってもらう
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1461
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1462 って感じ? でも(上の手法に限らず)、write のサイズが決まってないと
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1463 write 用バッファを生成しておく事ができないので
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1464 書き込めない or あらかじめ多めに取っておくってことが必要になる。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1465 後者は SPE には痛手(昔は強制16KB確保とかやってたな)なので微妙。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1466 前者は論外だろう。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1467
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1468 うーん、どうすっかな。Single DMA write の頃からこれは問題であって。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1469 最悪、ユーザが「write のサイズが変動しないようなタスクにする」とか?
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1470
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1471 * thinking: List DMA
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1472
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1473 構想としては以下のような考え。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1474
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1475 class Task {
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1476 int cmd;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1477 DataListDMA *rlist;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1478 DataListDMA *wlist;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1479 };
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1480
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1481 class DataListDMA {
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1482 int length; // リストの数
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1483 unsigned int addr[128]; // アドレス
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1484 int size[128]; // そのアドレスから取得するデータのサイズ
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1485 };
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1486
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1487 128 という数字は、一つのタスクが持てるリストの合計サイズを
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1488 1KB (= 1024B) にしようってことで 4*128+4*128 = 1024 としました。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1489 ListDMA を使う流れとしては
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1490
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1491 1. Scheduler から cmd にそった Task を生成する
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1492 2. Task のコンストラクタ(もしくは Task を生成する implement 内 )で
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1493 task->rlist, task->wlist を DMA read しておく (ここは通常のDMA)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1494 3. task->read() で MFC List DMA で List を読む
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1495
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1496 DataListDMA->length に関しては、Task の中に入れるのも有りかと思う。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1497 その場合は、2 の DMA read で、わざわざ 1KB 全部読む必要は無くなる。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1498
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1499
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1500 * tag: v20080522
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1501 - PPE 側のタスクも SPE と同じく、クラスオブジェクトとして登録
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1502 - PPE、SPE 側の TaskManagerImpl を整理。見やすくなったと思われ
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1503
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1504 こんなところかなー。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1505 テストプログラムは
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1506
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1507 Game_project/student/master/gongo/hello
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1508
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1509 にあります。DMA の例題まだだったぜHAHAHA
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1510 ここからは List DMA の処理を入れて行きたいと思います。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1511
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1512 現在の simple_render のバージョンは
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1513 PPE のタスクが関数ベースだった頃のなのでそのままでは動きません。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1514 List DMA ができるか、気晴らしに描き直すと思います。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1515
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1516 * Task 定義について
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1517 PPE も C++ のクラスオブジェクトとしてタスクを定義するようにしました。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1518 ちゃんとした API を考えたら改めて書きます。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1519
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1520 * メールチェックから次のタスクリスト生成までの流れの変更
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1521 今までの FifoTaskManagerImpl の mail_check では
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1522
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1523 1. mail_check
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1524 1.1 check_task_finish
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1525 1.1.1 notify_wait_taskQueue
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1526 1.1.1.1 append_activeTask (依存満たしたタスクを)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1527 1.2 get_runTaskList
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1528
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1529 と、全て mail_check の中で終わってたんですが、これを
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1530
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1531 1. mail_check
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1532 1.1 check_task_finish
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1533 1.1.1 notify_task_finish
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1534 2. wakeup_waitTask (つまり append_activeTask)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1535 3. get_runTaskList
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1536
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1537 というように分割しました。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1538 おかげで CellTaskManagerImpl の mail_check もすっきり。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1539
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1540 2008-05-13 Wataru MIYAGUNI <gongo@cr.ie.u-ryukyu.ac.jp>
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1541
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1542 * Cell/CellTaskManagerImpl.cpp (CellTaskManagerImpl::set_task):
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1543 // set_task って名前やめね?
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1544
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1545 どの SPE に振るかって判定を少し変更。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1546 cur_anySpeid の宣言場所のコメントにもあるけど、
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1547 これはインクリメントじゃなくて乱数の方が
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1548 より SPE_ANY っぽいのか。むしろ「仕事してない方に割り振る」ってのが
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1549 SPE_ANY の役目な気がするな。ウーム。。。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1550
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1551 2008-05-05 Wataru MIYAGUNI <gongo@cr.ie.u-ryukyu.ac.jp>
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1552
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1553 * Cell/CellTaskManagerImpl.cpp (CellTaskManagerImpl::mail_check):
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1554 PPE には実行するタスクが一つも無い時の動作がおかしかった。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1555 要するに、
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1556
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1557 PPE で実行するタスクは全て SPE で実行中のタスク待ち
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1558
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1559 って時。。。よけいわからなくなったな。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1560 まあなんだ、今まで 必ずタスクが PPE and SPE にあったんだけど
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1561 PPE or SPE ってか、どっちか片方でしか動いてない状況だと
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1562 終了判定というか、それがおかしかったっぽい。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1563
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1564 Hello World でのタスクは
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1565
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1566 1. "Hello World!!" と表示するタスク (2.) を発行するタスク
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1567 2. 表示するタスク
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1568 3. 2 が全て終わったら実行される、最後のタスク(番兵的な
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1569
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1570 この時、(2) が SPE だけで実行されてると、
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1571 (2) の終了を待つ (3) の判定?というか、それがおかしい
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1572
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1573
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1574 もう眠くてわけわからん。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1575 一応動いたんだけど、やはり描き直します。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1576 気持ち悪いほどやっつけな書き方してるので。これはきもい。。。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1577
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1578 2008-03-09 Wataru MIYAGUNI <gongo@cr.ie.u-ryukyu.ac.jp>
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1579
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1580 * memo: pthread_cond_wait
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1581 この ChangeLog に書くものでもないが、まあメモ。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1582
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1583 セマフォの P 動作は、基本的に
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1584
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1585 ---------------------
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1586 pthread_mutex_lock(&sem->mutex);
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1587
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1588 while(sem->value == 0) { // 資源が無い
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1589 // 条件付き変数に自分を登録して、ロックを解放して、他の
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1590 // プロセスが資源を解放してくれるのを待つ
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1591 pthread_cond_wait(&sem->cond,&sem->mutex);
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1592 }
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1593 // 自分の分の資源があったので、それを確保する */
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1594 sem->value--;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1595 // ロックを解放する
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1596 pthread_mutex_unlock(&sem->mutex);
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1597 ----------------------
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1598
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1599 こんな感じ。でコメントにもあるように、
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1600 pthread_cond_wait では、wait の前に unlock する。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1601 これがよくわかってなくて、「while の外で lock してるのに
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1602 「なんで他のプロセスが lock できるんだろう。」と。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1603 man 見ろよと思った。てか先生のページのコメントに書いてるよ!
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1604
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1605
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1606 2008-03-08 Wataru MIYAGUNI <gongo@cr.ie.u-ryukyu.ac.jp>
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1607
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1608 * memo: mailbox read の blocking/non-blocking
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1609 spe_out_mbox_read は non-blocking API なので、
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1610 これをぐるぐる回すと busy-wait になるので、
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1611 今の所 ppe 側の Scheduler がトップに戻る?時にメール確認する。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1612 で、spe_out_intr_mbox_read は blocking API 。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1613 spe_out_mbox_read との記述の違いは、予め
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1614 spe_event_handler_register で SPE_EVENT_OUT_INTR_MBOX を
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1615 登録しておく。spe 側では、
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1616
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1617 spu_writech(SPU_WrOutMbox, data)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1618
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1619 じゃなくて
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1620
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1621 spu_writech(SPU_WrOutIntrMbox, data)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1622
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1623 を使う必要がある。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1624 両者の mailbox read の速度を調べてみたけど、そんなに違いは感じない。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1625 まあベンチマークの取り方がへぼいせいかもしれないけど。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1626 ってことで、こっちの intr の方がいいんじゃないかと思う。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1627 これと セマフォを組み合わせて mail の処理は簡単になると思う。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1628 セマフォの処理が重いって話もあるが、どうなんだろうね。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1629
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1630 * Test/simple_render/task/create_span.cpp (half_triangle): fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1631 画面外の span を描画しようとして落ちるので、それの修正。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1632 polygon->span の時点で外してるけど、span を外すより
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1633 Polygon の時点で修正するべきかな?
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1634
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1635 * kernel/ppe/TaskManagerImpl.cpp (TaskManagerImpl::set_task): fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1636 返す TaskList が、mainTaskList の最後尾になってた。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1637 ってことで、TaskList のトップである bufferManager->mainTaskList を。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1638
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1639 * kernel/ppe/BufferManager.cpp (BufferManager::clear_taskList): fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1640 mainTaskList->length はクリアしてるのに、
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1641 mainTaskList->next をクリアし忘れてた。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1642 だから空の TaskList が送られてたのか・・・ちくしょう!
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1643
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1644 2008-03-07 Wataru MIYAGUNI <gongo@cr.ie.u-ryukyu.ac.jp>
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1645
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1646 * bug-fix (Test/simple_render): y座標の移動方向
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1647 (1) で、書き込む時に
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1648
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1649 y = height - y
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1650
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1651 としていた。千秋に聞いてみると、
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1652
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1653 「ポリゴンの y を増やす(+)と、画面上に進むようにした」
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1654
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1655 だそうです。なるほどねー。ってことで(2)でもやったら上に進んだよ。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1656
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1657 しかし、ゲーム的には上が + の方がわかりやすいかもしれんが、
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1658 プログラミング的には、framebuffer ベースでやるので、
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1659 下にいくと y++ ってほうが作りやすいかなーと思いつつ。どっちがいいかね
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1660
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1661 * bug (Test/simple_render): y座標の移動方向
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1662 Viewer::run_draw で、従来の、SpanPack をそのまま描画する方法(1)と、
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1663 SPE に渡すように、8分割したものとして描画する方法(2)で、
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1664 それぞれの y に +0.5 とかしたら、移動する方向が違う。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1665 (1)では上、(2)では下へ行く。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1666 送られてくる span には違いが見られず、
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1667 x 方向や 回転は問題ないので、おそらく draw 時の y の計算のバグだろう。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1668
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1669 1: polygon.cpp Polygon::draw(SPANPACK);
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1670 2: task/span_pack_draw.cpp run();
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1671
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1672 * Test/simple_render/spe/SpuDraw.cpp: ↓の続きの解決
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1673 render_y &= ~7
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1674
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1675 これでおkでした。先生ありがとうございます。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1676 今はマクロとして
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1677
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1678 #define YTOP(y) (y & ~7)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1679
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1680 ってやってますわ。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1681
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1682 2008-03-05 Wataru MIYAGUNI <gongo@cr.ie.u-ryukyu.ac.jp>
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1683
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1684 * memo: MFC List DMA の element の最大値
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1685 「Cell Broadband Engine Architecture Version 1.02」 より
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1686
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1687 P.55
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1688 The maximum number of elements is 2048.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1689 Each element describes a transfer of up to 16 KB.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1690
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1691 ってことらしいです。一度の転送での制限は普通のDMAと変わらず16KB。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1692 mfc_list_element_t は 2048 個まで設定できるってことか。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1693 テクスチャのロードで、分割しないなら MFC List DMA を使うことになるが、
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1694 2048 個もあれば充分?
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1695
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1696
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1697 * Test/simple_render/spe/SpuDraw.cpp: ↓の続き
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1698 と思ったけど、やっぱりずれるなあ。うーむ。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1699 とりあえず今は
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1700
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1701 if (render_y < 0) {
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1702 int tmpy = render_y%8;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1703 render_y -= tmpy + (tmpy != 0)*8;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1704 } else {
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1705 render_y -= (render_y%8);
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1706 }
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1707 render_y += 1080/2;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1708
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1709 で落ち着くことに。うーむ。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1710 もっと良い計算を考えるよりは span の生成時で
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1711 いろいろやるほうがいいのかなー
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1712
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1713 2008-03-04 Wataru MIYAGUNI <gongo@cr.ie.u-ryukyu.ac.jp>
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1714
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1715 * Test/simple_render/spe/SpuDraw.cpp: ↓の続き
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1716 よくよく考えてだな。。。マイナスが気になるなら
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1717
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1718 if (render_y < 0) {
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1719 int tmpy = render_y%8;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1720 render_y -= tmpy + (tmpy != 0)*8;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1721 } else {
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1722 render_y -= (render_y%8);
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1723 }
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1724 render_y += 1080/2;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1725
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1726 じゃなくて
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1727
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1728 render_y += 1080/2;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1729 render_y -= (render_y%8);
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1730
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1731 これでよくね?ってか元々そのための 1080/2 だった気が。。。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1732
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1733 * Test/simple_render/spe/SpuDraw.cpp: render_y の計算の修正
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1734 sp->span[0].y (SpanPack に格納されてる最初の Span の y 座標) から
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1735 この SpanPack が描画する範囲の一番上の y 座標を調べる。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1736
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1737 どういうことかっていうと、例えば SpanPack に入ってる Span が持つ
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1738 y 座標が 1 ~ 8 の時
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1739
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1740 1 -----
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1741 --
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1742 --------
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1743 ----
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1744 ---------
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1745 8 --
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1746
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1747 '-' は描画していると思ってください。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1748 この場合は、y = 1 がこの SpanPack の一番上、基準となる 座標ってこと。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1749 framebuffer に書き込むとき、y = 1 から順々に書いて行きます。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1750
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1751 で、sp->span[0].y ってのが、その基準となる y である保証が無いので、
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1752 sp->span[i].y 、つまりどの y からでも、基準となる y を求める
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1753 必要がある。その計算をミスってました。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1754
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1755 1 //////////
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1756 <- なぜか書き込まれていない
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1757 //////////
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1758 //////////
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1759
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1760 みたいに、歯抜けした部分があったので、いろいろ調べてみたら
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1761 この render_y がずれてるってことが判明しました。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1762 今までは
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1763
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1764 render_y = sp->span[0].y;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1765 render_y += 1080/2;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1766 render_y = (render_y/8)*8;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1767
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1768 ってことしてたんだけど、これだと sp->span[0].y が マイナスのとき
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1769 ずれることが判明。なので
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1770
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1771 if (render_y < 0) {
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1772 int tmpy = render_y%8;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1773 render_y -= tmpy + (tmpy != 0)*8;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1774 } else {
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1775 render_y -= (render_y%8);
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1776 }
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1777 render_y += 1080/2;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1778
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1779 こうするとできました。。。が、直したい。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1780 もう少し奇麗に描けると思うんだけどなー。if 文ぐらいは外したい
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1781
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1782 2008-03-03 Wataru MIYAGUNI <gongo@cr.ie.u-ryukyu.ac.jp>
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1783
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1784 * memo: 最適化の結果
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1785 ppe/spe ともに最適化なしの場合
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1786 263.444 FPS
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1787
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1788 ppe だけ -O9 で最適化
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1789 317.425 FPS
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1790
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1791 spe だけ -O9 で最適化
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1792 812.539 FPS
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1793
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1794 ppe/spe ともに -O9 で最適化
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1795 1610.58 FPS (吹いた
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1796
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1797
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1798 最初、ダブル最適化の画像を見た時の
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1799 あまりの早さにびびった。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1800 逆に「こ、これはバグか!?」と思った
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1801
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1802
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1803 2008-02-28 Wataru MIYAGUNI <gongo@cr.ie.u-ryukyu.ac.jp>
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1804
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1805 * kernel/ppe/BufferManager.cpp: remove_taskQueue_all()
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1806 taskQueue の create と free が釣り合って無くて、
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1807 queue が足りなくなる -> extend_pool -> 足りなく(ry
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1808 ってのを繰り返してメモリ的なセグメンテーションフォルとが出て
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1809 なんでかなと思ったら、task->wait_me を消去してなかった。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1810 task->wait_i は notify(ry で削除されるんだけど、
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1811 task->wait_me は、notify(ry に渡した後ほったらかしだった。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1812 ってことで、wait_me を全消しする関数を作りましたとさ。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1813 気持ち速度が増した気がする。気ね。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1814
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1815
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1816 2008-02-17 Wataru MIYAGUNI <gongo@cr.ie.u-ryukyu.ac.jp>
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1817
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1818 * Todo: 悩んでる所
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1819
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1820
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1821 * fix: kernel/ppe/HTask.cpp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1822 今まで、manager->create_task で生成したタスクは
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1823
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1824 - dependency の設定
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1825 manager->set_task_depend(master, slave) // slave は master を待つ
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1826
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1827 - 実行キューへの追加
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1828 manager->spawn_task(master);
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1829 manager->spawn_task(slave);
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1830
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1831 と、manager を介してやっていました。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1832 まあそれでもいいんだけど、特に dependency の所は
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1833 どっちがどっちを待つのかってのは、API見るだけじゃわからない。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1834 そこで、Task (HTask のこと) に、上二つに対応するような
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1835
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1836 void set_depend(HTaskPtr) と void spawn(void) を追加しました。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1837
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1838 - Usage
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1839 slave->set_depend(master); // slave は master を待つ
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1840 slave->spawn(); // slave をキューへ追加
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1841
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1842 結局は、それぞれの関数の中では、上の set_task_depend とかを
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1843 呼んでるんだけど、ユーザ側からするとこの方がわかりやすいと思います。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1844
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1845 2008-02-16 Wataru MIYAGUNI <gongo@cr.ie.u-ryukyu.ac.jp>
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1846
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1847 * tag: beta3
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1848 ダブルバッファリングを追加し、まあなんとか動いてるんじゃない?って
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1849 ところまでですが、所詮 Fifo バージョンなので、
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1850 そろそろ Cell を書き上げて、並列にちゃんと動いてるか確かめないとね
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1851
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1852 * add: kernel/ppe/DmaBuffer.cpp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1853 ダブルバッファリング用に作ったんだけど、
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1854 せっかくなので、DMA は、このオブジェクト(が持つ二つの領域)でしか
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1855 行えないようにする。ってのでどうでしょう。って話を先生としました。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1856 並列処理だし、ダブルバッファリングがデフォでいいでしょう。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1857 というか、したくなければ swap_buffer とかしなければおk。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1858
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1859 -Usage
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1860 DmaBuffer *buffer = manager->allocate(sizeof(SceneGraphPack));
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1861
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1862 今までと違い、create_task の in_addr と out_addr には
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1863 DmaBuffer をいれてください。ユーザが自分で malloc/new したやつは
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1864 エラーを出すようにしてる(seg faultだけどね!)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1865 汚いソースだが、実際に使ってる様子は Test/simple_render の
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1866 viewer.cpp で使ってます。sgp_buff と pp_buff ってやつね。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1867
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1868 もうすこしユーザに優しいAPIを作りたい・・・
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1869
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1870 2008-02-11 Wataru MIYAGUNI <gongo@cr.ie.u-ryukyu.ac.jp>
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1871
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1872 * add: Test/simple_render
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1873 chiaki の DataPack を使った Cube の表示プログラム。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1874 簡単に DataPack を TaskManager の scheduler (SpeManager) に渡して
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1875 処理してコピーして、を繰り返してるだけなんだけど
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1876 まあ動いてる気がするのでいいんじゃないでしょうか。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1877
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1878
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1879 2008-02-10 Wataru MIYAGUNI <gongo@cr.ie.u-ryukyu.ac.jp>
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1880
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1881 * tag: beta1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1882 この状況だと、できることよりもできないことを書くべき?違うか。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1883
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1884 - task (親) 中で task (子) を生成することはできない
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1885 正確には「生成はできる」だけど、その 子task が
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1886 親task に依存している別の task を無視して動くので
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1887 ちゃんとした結果にならないと。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1888 8日の Todo にも書いてあるけど、今の実装では
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1889 task が task を生成することを想定してない感じなので。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1890 完全に spe 用にのみ狙いを絞った実装であって
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1891 OS って言えない実装であるからして、書き直すの?
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1892 全ての関数を task しようとするとこうなる訳で、
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1893 ある部分だけやるってのはまあできるんだろうけど、うーん。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1894
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1895 - chiaki の simple_render が動かない
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1896 (追記) 解決しました
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1897 単に read/write buffer のサイズが足りないだけだった。アホスwww
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1898 まあ辱めの為の下は残しておこう
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1899
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1900 まだ cvs に commit してないけど、chiaki が書いた、
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1901 DataPack 対応の simple_render に TasKManager を組み込んでみた。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1902 といっても、OSっぽく書いたんじゃなく、今は
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1903 update_sgp と create_pp だけを task 化してみた。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1904 でまあ動いてるような気はするけど、ものすっごい malloc 系の warning が。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1905 時々長く動くよねみたいな感じになってしまっている。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1906 TaskManager が悪いのか、simple_render が悪いのか。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1907 この TaskManager、ある部分での malloc 系の問題に敏感だなあ。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1908 まあそうでなかったらバグの探しようも無いし、良いっちゃー良いんだが。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1909
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1910
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1911 2008-02-08 Wataru MIYAGUNI <gongo@cr.ie.u-ryukyu.ac.jp>
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1912
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1913 * add: kernel/ppe/SymTable.cpp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1914 今まで func[] = {add, sum, ...}
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1915 とかやってかっこわるい言われまくってたので
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1916 話し合いの通り Symbol Table みたいなものを作ることに
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1917
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1918 // 疑似コードね
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1919 struct sym_table {
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1920 char *sym; // シンボル
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1921 void *address; // シンボルが示すアドレス
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1922 } sym_table[] = {{"Sum", &Sum} , {"Draw", &draw}};
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1923
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1924 int fd = get_fd("Sum");
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1925 void *addr = get_address(fd);
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1926
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1927 table には "Sum" と "Draw" っていう二つのシンボルが登録されている。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1928 例えば、ユーザ(カーネル?)が "Sum" ってシンボルにアクセスしたい場合、
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1929 まずは get_fd で "Sum" に対する、file descripter を返す。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1930 ユーザは、その fd に従って get_address を取得することが出来る。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1931 TaskManager 的な使い方をするなら
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1932
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1933 // 俺は今、Draw 関数を使うタスクを生成したい
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1934 int fd = manager->open("Draw");
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1935 manager->create_task(fd, size, in, out, func);
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1936 manager->open では get_fd と同じ使い方です。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1937
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1938 まだ改良の余地ありそうですが、今は動いてるってことで。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1939
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1940
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1941 - 補足
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1942 なぜ file descripter と表すか
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1943
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1944 OS の昨日として、 fopen とかと同じ使い方もできるじゃない!
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1945
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1946
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1947 * Todo: task が task を生成する際の処理
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1948 今まで、 task が行う作業は、演算のみを行うような
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1949 単純な実装に決め打ちされているわけです。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1950 しかし、OS なんかだと、タスク中から別のタスクを生成するとか
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1951 ありありだと思われる。てか今のテストプログラムでなった。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1952
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1953 Test/Sum にあるプログラムで使われるタスク
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1954
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1955 - init2 // 貧相な名前ですまない
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1956 演算する数値とかバッファの初期化
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1957
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1958 - sum1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1959 ある範囲の整数 (i から i+16 とか) の総和
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1960
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1961 - sum2
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1962 sum1 で求められた、複数の範囲の総和を一つにまとめる
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1963 (ex. 複数の sum1 が 1->16, 17->32, 33->48 の総和を計算し、
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1964 sum2 で 上の3つの総和を計算する
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1965 要は 1->48 の総和を分割するっていうプログラムね
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1966
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1967 - finish
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1968 sum2 で求まった値を表示
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1969
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1970 この Sum というプログラム、というか OS と言おう。SumOS ね。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1971 SumOS は最初に TaskManager (所謂 kernel) を起動し、
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1972 init を起動する。init では、予め決められたタスクである
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1973 init2 と finish の二つのタスクを create して登録する。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1974 init2 と finish には依存関係がある (init2 が終わったら finish)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1975 init2 の中で、sum1 と sum2 というタスクが作られる。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1976 sum1 と sum2 にも依存関係はある (sum1 が終わったら sum2)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1977
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1978 今の実装だと、タスクが終了して初めて次のタスクへ行く。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1979 まあ当たり前なんだけど、例えばそのタスクの中で
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1980 新たにタスクが作られた場合、そのタスクが終了するまでは
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1981 実行されなくなってしまう。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1982 でまあ、今は、manager->create_task される度に
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1983 manager->run とかして、無理やり起動してる訳さ。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1984 何が無理矢理かっていうと、scheduler の役目をしている
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1985 SpeManager (これも名前変えないと) を2度呼び出してる訳。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1986 つまり、タスク中でタスクを作る度に、SpeManager オブジェクトを
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1987 new してるわけさ。いいのか?いや、動いてるけどね?
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1988
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1989 ちなみに、Cell version だと spe が勝手に取っていってくれるから
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1990 大丈夫かなと思いつつ、もし spe を1つしか使わない設定だったら微妙。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1991
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1992 要するに、タスク中でタスクが作られる場合の処理を考えないとね。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1993
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1994 2008-02-07 Wataru MIYAGUNI <gongo@cr.ie.u-ryukyu.ac.jp>
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1995
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1996 * memo: プログラミングの姿勢
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1997 scheduler とか、task の管理をする部分は
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1998 kernel programing のつもりで、
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1999 example とか、task に割り当てる処理を決めたりする部分は
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2000 user programing のつもりで。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2001
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2002 それぞれ違った視点で見る必要がある
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2003
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2004 * memo: OS というもの
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2005 OS 起動の流れ
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2006
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2007 - PC の電源を入れる
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2008 - BIOS が立ち上がる (OpenFirmWare, EFI, BIOS)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2009 - 起動デバイスをチェック (優先度とか種類とか)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2010 - 起動デバイスから Boot loader を起動
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2011 + BIOS によって、認識できるファイルシステムが違う(だっけ?)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2012 + ファイルシステムのどこに Boot Loader があるか知っている
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2013 + grub, grub2, lilo, kboot などがある
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2014 - Boot Loader が kernel を起動
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2015 + ネットワークブートの場合、TCP/IP や
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2016 ネットワークデバイス(イーサとか?)のドライバを持ってる必要がある
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2017 - kernel は、最初に scheduler を起動する
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2018 - scheduler の初期化 (init を呼ぶ?)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2019 - init では、事前?に設定されているスクリプトとかを呼ぶ
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2020 + linux とかだと /etc/rc にあるやつを init が呼ぶ
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2021 - login form が起動
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2022
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2023 補足 こっからユーザ
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2024 - login する
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2025 - shell を呼ぶ
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2026 + login shell かどうか確かめる
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2027 - ユーザに設定されてる起動スクリプト?を実行
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2028 - 晴れてログイン
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2029
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2030 2008-02-06 Wataru MIYAGUNI <gongo@cr.ie.u-ryukyu.ac.jp>
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2031
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2032 * kernel/spe/*.cpp: new と placement new
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2033 現在、spe kernel のタスクは、切り替わる毎に
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2034 new/delete を繰り返しています。今はこれでいいんだけど、
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2035 速度的にも、いずれは直さないといけないと思うわけで。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2036 で、予め allocate された領域を利用した placement new を使えば
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2037 new よりもそれなりに早くなるっぽい。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2038 例題として、与えられた回数分 new/delete を繰り返すプログラムと、
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2039 同じ回数分、placement new したときの速度の比較
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2040
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2041 for (int i = 0; i < num; i++) {
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2042
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2043 < task = new Task;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2044 < task->init(i);
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2045 < task->printID();
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2046 < delete task;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2047 ---
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2048 > task = new(buff) Task; // buff = malloc(BUFF_SIZE);
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2049 > task->init(id);
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2050 > task->printID(id);
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2051 }
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2052
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2053 placement new では、delete の必要は無い。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2054 その中で新たに allocate してるなら必要かもしれないが。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2055 速度比較は以下。no_new が placement new で、ln_new が new/delete 。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2056
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2057 % ./a.out 10 // 10 回
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2058 no_new: time: 0.012135(msec)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2059 ln_new: time: 0.003572(msec)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2060
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2061 % ./a.out 100
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2062 no_new: time: 0.022453(msec)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2063 ln_new: time: 0.018989(msec)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2064
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2065 % ./a.out 1000
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2066 no_new: time: 0.115277(msec)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2067 ln_new: time: 0.136335(msec)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2068
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2069 % ./a.out 10000
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2070 no_new: time: 1.056156(msec)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2071 ln_new: time: 1.322709(msec)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2072
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2073 % ./a.out 100000
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2074 no_new: time: 10.622221(msec)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2075 ln_new: time: 13.362414(msec)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2076
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2077 % ./a.out 1000000
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2078 no_new: time: 109.436496(msec)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2079 ln_new: time: 136.956872(msec)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2080
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2081 10、100 回だと負けてるが、まあ無視しよう(ぇ
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2082 回数が多くなるにつれて、ほんの少しだが no_new が勝ってる。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2083 どうなんだろうね。ちなみに printID を無くすと
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2084
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2085 % ./a.out 1000000
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2086 no_new: time: 0.008512(msec)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2087 ln_new: time: 27.100296(msec)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2088
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2089 I/O に左右され過ぎ。まあそんなもんだろうけどさ。