annotate example/basic/README @ 638:671fca057ad3

hmmmm
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Thu, 19 Nov 2009 18:18:20 +0900
parents 5c194c71eca8
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
1 /*
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
2 * $Id: README,v 1.5 2008/10/20 10:02:01 gongo Exp $
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
3 */
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
4
638
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 109
diff changeset
5 - 概要
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
6
638
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 109
diff changeset
7 int の配列を送り、タスク(Twice) で、配列の要素を2倍にして送り返します。
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
8
638
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 109
diff changeset
9 PPE->SPE の DMA 転送は main.cc の twice_init に
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 109
diff changeset
10 書いてるのでわかってもらえるかなと信じて、タスク側で
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 109
diff changeset
11 そのデータの受け取り方を説明する。
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
12
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
13 -------------------------------------
638
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 109
diff changeset
14 PPE から送られてきたデータの受け取り
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
15 -------------------------------------
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
16
638
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 109
diff changeset
17 void *get_input(void *p, int index) を使う。
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
18
638
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 109
diff changeset
19 p には rbuf が入ります。今のところ確定なのでわざわざ書かせる必要も無いか。。。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 109
diff changeset
20 index は、create task 時に add_inData したと思うけど、その順番になります。
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
21
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
22 add_inData(data1, size1);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
23 add_inData(data2, size2);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
24
638
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 109
diff changeset
25 の順番で記述した場合、
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
26
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
27 data1 = get_input(rbuf, 0);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
28 data2 = get_input(rbuf, 0);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
29
638
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 109
diff changeset
30 で取れます。
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
31
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
32 -------------------------------------
638
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 109
diff changeset
33 PPE へデータを送る
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
34 -------------------------------------
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
35
638
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 109
diff changeset
36 void *get_output(void *p, int index) を使う。
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
37
638
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 109
diff changeset
38 p は wbuf, index は input と同じ感じでいいです。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 109
diff changeset
39 get_output で受け取った領域でデータを書けば、
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 109
diff changeset
40 このタスクが終了した後に、add_outData で指定したアドレスに書き込まれます。
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
41
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
42
638
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 109
diff changeset
43 - 実行方法
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
44
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
45 ./twice [-cpu spe_num] [-length data_length]
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
46
638
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 109
diff changeset
47 -cpu 使用する SPU の数
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 109
diff changeset
48 // 今回はあまり意味の無いオプションです。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 109
diff changeset
49 // 巨大な配列の場合、複数に振り分けてそれぞれで 2 倍させるっていう
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 109
diff changeset
50 // 処理を入れれば意味のあるものになります。誰か(ry
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
51
638
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 109
diff changeset
52 -length 配列の要素の数
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
53
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
54
638
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 109
diff changeset
55 - 実行例
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
56
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
57 % ./twice
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
58 before ---
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
59 0 1 2 3 4 5 6 7 8 9 10 11
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
60 after ---
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
61 0 2 4 6 8 10 12 14 16 18 20 22
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
62
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
63 % ./twice -length 20
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
64 before ---
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
65 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
66 after ---
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
67 0 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
68
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
69 % ./twice -length 15
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
70 before ---
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
71 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
72 zsh: bus error ./twice -length 15
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
73
638
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 109
diff changeset
74 上の場合、PS3上(SPE使った場合)では bus error が出ます。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 109
diff changeset
75 この理由は length にあって、送るデータのバイト数が
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 109
diff changeset
76 4バイト(int) x 15 = 60 バイト だからです。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 109
diff changeset
77 PPE <-> SPE での DMA 転送のサイズは
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 109
diff changeset
78 1,2,4,8バイト, もしくは 16バイト倍数と決まっています。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 109
diff changeset
79 このサイズに誤りがある場合、上のように bus error が出ます。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 109
diff changeset
80 この辺の詳しい仕様は、
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
81
638
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 109
diff changeset
82 Game_project/ps3/docs にある PDF や
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
83
638
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 109
diff changeset
84 Fixstars のサイト
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 109
diff changeset
85 http://cell.fixstars.com/ps3linux/index.php/3.3 DMA転送によるデータの受け渡し
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
86
638
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 109
diff changeset
87 とか見ればわかると思います