annotate TaskManager/ChangeLog @ 217:897aeb144569

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