annotate TaskManager/ChangeLog @ 135:ac436cebae2a draft

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