annotate TaskManager/ChangeLog @ 354:cfd20d609ace draft

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