annotate TaskManager/ChangeLog @ 307:3fc86ddf5d1c draft

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