annotate example/Pipeline/README @ 963:62b72c6199f3 draft

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