annotate TaskManager/ChangeLog @ 391:492e60453124 draft

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