annotate example/Bulk/README @ 2069:26aa08c9a1de draft default tip

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