OSDN Git Service

(split) Apply minor changes from v3.32 to v3.35 in the upstream.
[linuxjm/LDP_man-pages.git] / release / man2 / spu_run.2
1 .\" Copyright (c) International Business Machines Corp., 2006
2 .\"
3 .\" This program is free software; you can redistribute it and/or
4 .\" modify it under the terms of the GNU General Public License as
5 .\" published by the Free Software Foundation; either version 2 of
6 .\" the License, or (at your option) any later version.
7 .\"
8 .\" This program is distributed in the hope that it will be useful,
9 .\" but WITHOUT ANY WARRANTY; without even the implied warranty of
10 .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
11 .\" the GNU General Public License for more details.
12 .\"
13 .\" You should have received a copy of the GNU General Public License
14 .\" along with this program; if not, write to the Free Software
15 .\" Foundation, Inc., 59 Temple Place, Suite 330, Boston,
16 .\" MA 02111-1307 USA
17 .\"
18 .\" HISTORY:
19 .\" 2005-09-28, created by Arnd Bergmann <arndb@de.ibm.com>
20 .\" 2006-06-16, revised by Eduardo M. Fleury <efleury@br.ibm.com>
21 .\" 2007-07-10, some polishing by mtk
22 .\" 2007-09-28, updates for newer kernels, added example
23 .\"             by Jeremy Kerr <jk@ozlabs.org>
24 .\"
25 .\" Japanese Version Copyright (c) 2007  Akihiro MOTOKI
26 .\"         all rights reserved.
27 .\" Translated 2007-10-19, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
28 .\" Updated 2008-11-10, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v3.04
29 .\" 
30 .TH SPU_RUN 2 2007-11-25 Linux "Linux Programmer's Manual"
31 .SH Ì¾Á°
32 spu_run \- SPU ¥³¥ó¥Æ¥­¥¹¥È¤ò¼Â¹Ô¤¹¤ë
33 .SH ½ñ¼°
34 .nf
35 .B #include <sys/spu.h>
36
37 .BI "int spu_run(int " fd ", unsigned int *" npc \
38 ", unsigned int *" event ");"
39 .fi
40 .SH ÀâÌÀ
41 .BR spu_run ()
42 ¥·¥¹¥Æ¥à¥³¡¼¥ë¤Ï¡¢Cell Broadband Engine ¥¢¡¼¥­¥Æ¥¯¥Á¥ã¤ò¼ÂÁõ¤·¤¿
43 PowerPC ¥Þ¥·¥ó¤Ç Synergistic Processor Units (SPU) ¤Ë¥¢¥¯¥»¥¹¤¹¤ë¤¿¤á¤Ë
44 »ÈÍѤµ¤ì¤ë¡£
45 .I fd
46 °ú¤­¿ô¤Ï¡¢
47 .BR spu_create (2)
48 ¤¬ÊÖ¤¹¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Ç¡¢
49 ÆÃÄê¤Î SPU ¥³¥ó¥Æ¥­¥¹¥È¤ò»²¾È¤¹¤ë¡£
50 ¤½¤Î¥³¥ó¥Æ¥­¥¹¥È¤¬ÊªÍý SPU ¤Ë³ä¤êÅö¤Æ¤é¤ì¤ë¤È¡¢
51 .I npc
52 ¤ÇÅϤµ¤ì¤¿Ì¿Îá¥Ý¥¤¥ó¥¿ (instruction pointer) ¤«¤é¼Â¹Ô¤¬³«»Ï¤µ¤ì¤ë¡£
53
54 SPU ¥³¡¼¥É¤Î¼Â¹Ô¤ÏƱ´üŪ (synchronously) ¤Ë¹Ô¤ï¤ì¤ë¡¢¤Ä¤Þ¤ê
55 SPU ¤¬¼Â¹ÔÃæ¤Ï
56 .BR spu_run ()
57 ¤ÏÄä»ß (block) ¤¹¤ë¡£
58 SPU ¥³¡¼¥É¤Î¼Â¹Ô¤ò¥á¥¤¥ó CPU ¤ä¾¤Î SPU ¤ÈʹԤ·¤Æ¹Ô¤¦É¬Íפ¬¤¢¤ë¾ì¹ç¤Ï¡¢
59 ºÇ½é¤Ë¡¢¤½¤Î SPU ¥³¡¼¥É¤ò¼Â¹Ô¤¹¤ë¿·¤·¤¤¥¹¥ì¥Ã¥É¤ò¡¢(Î㤨¤Ð
60 .BR pthread_create (3)
61 ¤Ê¤É¤ò»È¤Ã¤Æ) À¸À®¤·¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
62
63 .BR spu_run ()
64 ¤¬ÊÖ¤ë¤È¤­¤Ë¤Ï¡¢SPU ¤Î¥×¥í¥°¥é¥à¥«¥¦¥ó¥¿¤Î¸½ºßÃͤ¬
65 .I npc
66 ¤Ë½ñ¤­¹þ¤Þ¤ì¤ë¡£
67 ¤³¤ì¤Ë¤è¤ê¡¢Ï¢Â³¤¹¤ë
68 .BR spu_run ()
69 ¤Î¸Æ¤Ó½Ð¤·¤ÇƱ¤¸
70 .I npc
71 ¥Ý¥¤¥ó¥¿¤ò»È¤¦¤³¤È¤¬¤Ç¤­¤ë¡£
72
73 .I event
74 °ú¤­¿ô¤Ë¤Ï¡¢³ÈÄ¥¥¹¥Æ¡¼¥¿¥¹¥³¡¼¥ÉÍѤΥХåե¡¤ò»ØÄꤹ¤ë¡£
75 .B SPU_CREATE_EVENTS_ENABLED
76 ¥Õ¥é¥°ÉÕ¤­¤Ç SPU ¥³¥ó¥Æ¥­¥¹¥È¤¬ºîÀ®¤µ¤ì¤ë¤È¡¢
77 .BR spu_run ()
78 ¤¬ÊÖ¤ëÁ°¤Ë Linux ¥«¡¼¥Í¥ë¤Ë¤è¤ê¤³¤Î¥Ð¥Ã¥Õ¥¡¤Ë
79 ³ÈÄ¥¥¹¥Æ¡¼¥¿¥¹¥³¡¼¥É¤¬³ÊǼ¤µ¤ì¤ë¡£
80
81 ¥¹¥Æ¡¼¥¿¥¹¥³¡¼¥É¤Ë¤Ï°Ê²¼¤ÎÄê¿ô¤¬°ì¤Ä°Ê¾åÆþ¤ë¡£
82 .TP
83 .B SPE_EVENT_DMA_ALIGNMENT
84 DMA (direct memory access) ¤Î¥¢¥é¥¤¥á¥ó¥È¡¦¥¨¥é¡¼¤¬È¯À¸¤·¤¿¡£
85 .TP
86 .B SPE_EVENT_INVALID_DMA
87 ̵¸ú¤Ê MFC (Memory Flow Controller) DMA ¥³¥Þ¥ó¥É¤ò¹Ô¤ª¤¦¤È¤·¤¿¡£
88 .TP
89 .B SPE_EVENT_SPE_DATA_STORAGE
90 DMA ¥¹¥È¥ì¡¼¥¸¡¦¥¨¥é¡¼¤¬È¯À¸¤·¤¿¡£
91 .TP
92 .B SPE_EVENT_SPE_ERROR
93 ÉÔÀµ¤ÊÌ¿Î᤬¼Â¹Ô¤µ¤ì¤¿¡£
94 .PP
95 NULL ¤Ï
96 .I event
97 °ú¤­¿ô¤È¤·¤ÆÍ­¸ú¤ÊÃͤǤ¢¤ë¡£
98 ¤³¤Î¾ì¹ç¡¢¥¤¥Ù¥ó¥È¤Ï¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤ËÊó¹ð¤µ¤ì¤Ê¤¤¡£
99 .SH ÊÖ¤êÃÍ
100 À®¸ù¤¹¤ë¤È¡¢
101 .BR spu_run ()
102 ¤Ï
103 .I spu_status
104 ¥ì¥¸¥¹¥¿¤ÎÃͤòÊÖ¤¹¡£
105 ¥¨¥é¡¼¤Î¾ì¹ç¡¢\-1 ¤òÊÖ¤·¡¢
106 .I errno
107 ¤ò²¼µ­¤Î¥¨¥é¡¼¥³¡¼¥É¤Î¤¤¤º¤ì¤«¤ËÀßÄꤹ¤ë¡£
108
109 .I spu_status
110 ¥ì¥¸¥¹¥¿¤ÎÃͤϡ¢¥¹¥Æ¡¼¥¿¥¹¥³¡¼¥É¤È SPU ¤Î
111 .B stop-and-signal
112 Ì¿Î᤬ÊÖ¤¹ 14 ¥Ó¥Ã¥È¤Î¥³¡¼¥É¤Î
113 ¥Ó¥Ã¥È¥Þ¥¹¥¯¤Ç¹½À®¤µ¤ì¤ë¡£
114 ¸å¼Ô¤Î 14 ¥Ó¥Ã¥È¤Î¥³¡¼¥É¤Ï¥ª¥×¥·¥ç¥ó¤Ç¤¢¤ë¡£
115 ¥¹¥Æ¡¼¥¿¥¹¥³¡¼¥É¤Î¥Ó¥Ã¥È¥Þ¥¹¥¯¤Ï²¼µ­¤ÎÄ̤ê¤Ç¤¢¤ë¡£
116 .TP
117 .B 0x02
118 SPU ¤¬
119 .B stop-and-signal
120 Ì¿Îá¤ÇÄä»ß¤·¤¿¡£
121 .TP
122 .B 0x04
123 SPU ¤¬
124 .B "halt (Ää»ß)"
125 Ì¿Îá¤Ç»ß¤Þ¤Ã¤¿¡£
126 .TP
127 .B 0x08
128 SPU ¤Ï¥Á¥ã¥ó¥Í¥ë¤Î¥¦¥§¥¤¥ÈÃæ¤Ç¤¢¤ë¡£
129 .TP
130 .B 0x10
131 SPU ¤Ï¥·¥ó¥°¥ë¥¹¥Æ¥Ã¥×¥â¡¼¥É¤Ç¤¢¤Ã¤¿¡£
132 .TP
133 .B 0x20
134 SPU ¤¬ÉÔÀµ¤ÊÌ¿Îá¤ò¼Â¹Ô¤·¤è¤¦¤È¤·¤¿¡£
135 .TP
136 .B 0x40
137 SPU ¤¬ÉÔÀµ¤Ê¥Á¥ã¥ó¥Í¥ë¤Ë¥¢¥¯¥»¥¹¤·¤è¤¦¤È¤·¤¿¡£
138 .TP
139 .B 0x3fff0000
140 ¤³¤ÎÃͤΥޥ¹¥¯¤òŬÍѤ·¤ÆÆÀ¤é¤ì¤¿¥Ó¥Ã¥ÈÃͤˤϡ¢
141 stop-and-signal Ì¿Îᤫ¤éÊÖ¤µ¤ì¤¿¥³¡¼¥É¤¬Æþ¤Ã¤Æ¤¤¤ë¡£
142 ¤³¤ì¤é¤Î¥Ó¥Ã¥È¤Ï 0x02 ¥Ó¥Ã¥È¤¬¥»¥Ã¥È¤µ¤ì¤Æ¤¤¤ë¾ì¹ç¤Ë¤Î¤ßÍ­¸ú¤Ç¤¢¤ë¡£
143 .PP
144 .BR spu_run ()
145 ¤¬¥¨¥é¡¼¤òÊÖ¤µ¤Ê¤«¤Ã¤¿¾ì¹ç¡¢²¼°Ì 8 ¥Ó¥Ã¥È¤Î¤¦¤Á 1 ¤Ä°Ê¾å¤Ï
146 ¾ï¤Ë¥»¥Ã¥È¤µ¤ì¤ë¡£
147 .SH ¥¨¥é¡¼
148 .TP
149 .B EBADF
150 .I fd
151 ¤¬Í­¸ú¤Ê¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Ç¤Ê¤¤¡£
152 .TP
153 .B EFAULT
154 .I npc
155 ¤¬Í­¸ú¤Ê¥Ý¥¤¥ó¥¿¤Ç¤Ê¤¤¡£¤Þ¤¿¤Ï
156 .I event
157 ¤¬ NULL °Ê³°¤Ç¡¢¤·¤«¤â̵¸ú¤Ê¥Ý¥¤¥ó¥¿¤Ç¤¢¤ë¡£
158 .TP
159 .B EINTR
160 .BR spu_run ()
161 ¤Î¼Â¹ÔÃæ¤Ë¥·¥°¥Ê¥ë¤¬È¯À¸¤·¤¿¡£
162 .BR signal (7)
163 »²¾È¡£
164 ɬÍפǤ¢¤ì¤Ð¡¢
165 .I npc
166 ¤ÎÃͤϿ·¤·¤¤¥×¥í¥°¥é¥à¥«¥¦¥ó¥¿¤ÎÃͤ˹¹¿·¤µ¤ì¤ë¡£
167 .TP
168 .B EINVAL
169 .I fd
170 ¤¬
171 .BR spu_create (2)
172 ¤¬ÊÖ¤·¤¿Í­¸ú¤Ê¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Ç¤Ê¤¤¡£
173 .TP
174 .B ENOMEM
175 Memory Flow Controller (MFC) DMA ¤Ë¤è¤êȯÀ¸¤·¤¿¥Ú¡¼¥¸¥Õ¥©¡¼¥ë¥È¤ò
176 ½èÍý¤¹¤ë¤Î¤ËɬÍפʥá¥â¥ê¤¬¤Ê¤«¤Ã¤¿¡£
177 .TP
178 .B ENOSYS
179 µ¡Ç½¤¬Æ°ºîÃæ¤Î¥·¥¹¥Æ¥à¤ÇÄ󶡤µ¤ì¤Æ¤¤¤Ê¤¤¡£Íýͳ¤Ï¡¢
180 ¥Ï¡¼¥É¥¦¥§¥¢¤Ç SPU ¤¬Ä󶡤µ¤ì¤Æ¤¤¤Ê¤¤¤«¡¢
181 spufs ¥â¥¸¥å¡¼¥ë¤¬¥í¡¼¥É¤µ¤ì¤Æ¤¤¤Ê¤¤¤«¡¢¤Î¤É¤Á¤é¤«¤Ç¤¢¤ë¡£
182 .SH ¥Ð¡¼¥¸¥ç¥ó
183 .BR spu_run ()
184 ¥·¥¹¥Æ¥à¥³¡¼¥ë¤Ï¥«¡¼¥Í¥ë 2.6.16 ¤Ç Linux ¤ËÄɲ䵤줿¡£
185 .SH ½àµò
186 ¤³¤Î¥·¥¹¥Æ¥à¥³¡¼¥ë¤Ï Linux ¸ÇÍ­¤Ç¤¢¤ê¡¢
187 PowerPC ¥¢¡¼¥­¥Æ¥¯¥Á¥ã¤Ç¤Î¤ß¼ÂÁõ¤µ¤ì¤Æ¤¤¤ë¡£
188 ¤³¤Î¥·¥¹¥Æ¥à¥³¡¼¥ë¤ò»È¤Ã¤¿¥×¥í¥°¥é¥à¤Ï°Ü¿¢À­¤¬¤Ê¤¤¡£
189 .SH Ãí°Õ
190 glibc ¤Ï¤³¤Î¥·¥¹¥Æ¥à¥³¡¼¥ë¤ËÂФ¹¤ë¥é¥Ã¥Ñ¡¼´Ø¿ô¤òÄ󶡤·¤Æ¤¤¤Ê¤¤¡£
191 .BR syscall (2)
192 ¤ò»È¤¦¤³¤È¡£¤¿¤À¤·¡¢
193 .BR spu_run ()
194 ¤Ï ¤è¤êÃê¾ÝÅ٤ι⤤ SPU ¤Ø¤Î¥¤¥ó¥¿¥Õ¥§¡¼¥¹¤ò¼ÂÁõ¤¹¤ë¥é¥¤¥Ö¥é¥ê¤«¤é
195 ÍøÍѤµ¤ì¤ë¤³¤È¤ò°Õ¿Þ¤·¤¿¤â¤Î¤Ç¤¢¤ê¡¢Ä̾ï¤Î¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤«¤é
196 »ÈÍѤϰտޤµ¤ì¤Æ¤¤¤Ê¤¤¡£¿ä¾©¤Î¥é¥¤¥Ö¥é¥ê¤Ë¤Ä¤¤¤Æ¤Ï
197 .I http://www.bsc.es/projects/deepcomputing/linuxoncell/
198 ¤ò»²¾È¤Î¤³¤È¡£
199 .SH Îã
200 °Ê²¼¤Ï¡¢´Êñ¤Ê 1 Ì¿Îá¤Î SPU ¥×¥í¥°¥é¥à¤ò
201 .BR spu_run ()
202 ¥·¥¹¥Æ¥à¥³¡¼¥ë¤ò»È¤Ã¤Æ¼Â¹Ô¤µ¤»¤ëÎã¤Ç¤¢¤ë¡£
203
204 .nf
205 #include <stdlib.h>
206 #include <stdint.h>
207 #include <unistd.h>
208 #include <stdio.h>
209 #include <sys/types.h>
210 #include <fcntl.h>
211
212 #define handle_error(msg) \\
213     do { perror(msg); exit(EXIT_FAILURE); } while (0)
214
215 int main(void)
216 {
217     int context, fd, spu_status;
218     uint32_t instruction, npc;
219
220     context = spu_create("/spu/example\-context", 0, 0755);
221     if (context == \-1)
222         handle_error("spu_create");
223
224     /* write a \(aqstop 0x1234\(aq instruction to the SPU\(aqs
225      * local store memory
226      */
227     instruction = 0x00001234;
228
229     fd = open("/spu/example\-context/mem", O_RDWR);
230     if (fd == \-1)
231         handle_error("open");
232     write(fd, &instruction, sizeof(instruction));
233
234     /* set npc to the starting instruction address of the
235      * SPU program. Since we wrote the instruction at the
236      * start of the mem file, the entry point will be 0x0
237      */
238     npc = 0;
239
240     spu_status = spu_run(context, &npc, NULL);
241     if (spu_status == \-1)
242         handle_error("open");
243
244     /* we should see a status code of 0x1234002:
245      *   0x00000002 (spu was stopped due to stop\-and\-signal)
246      * | 0x12340000 (the stop\-and\-signal code)
247      */
248     printf("SPU Status: 0x%08x\\n", spu_status);
249
250     exit(EXIT_SUCCESS);
251 }
252 .fi
253 .\" .SH AUTHORS
254 .\" Arnd Bergmann <arndb@de.ibm.com>, Jeremy Kerr <jk@ozlabs.org>
255 .SH ´ØÏ¢¹àÌÜ
256 .BR close (2),
257 .BR spu_create (2),
258 .BR capabilities (7),
259 .BR spufs (7)