1 .\" Copyright (c) International Business Machines Corp., 2006
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.
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.
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,
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>
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
30 .TH SPU_RUN 2 2007-11-25 Linux "Linux Programmer's Manual"
32 spu_run \- SPU ¥³¥ó¥Æ¥¥¹¥È¤ò¼Â¹Ô¤¹¤ë
35 .B #include <sys/spu.h>
37 .BI "int spu_run(int " fd ", unsigned int *" npc \
38 ", unsigned int *" event ");"
42 ¥·¥¹¥Æ¥à¥³¡¼¥ë¤Ï¡¢Cell Broadband Engine ¥¢¡¼¥¥Æ¥¯¥Á¥ã¤ò¼ÂÁõ¤·¤¿
43 PowerPC ¥Þ¥·¥ó¤Ç Synergistic Processor Units (SPU) ¤Ë¥¢¥¯¥»¥¹¤¹¤ë¤¿¤á¤Ë
48 ¤¬ÊÖ¤¹¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Ç¡¢
49 ÆÃÄê¤Î SPU ¥³¥ó¥Æ¥¥¹¥È¤ò»²¾È¤¹¤ë¡£
50 ¤½¤Î¥³¥ó¥Æ¥¥¹¥È¤¬ÊªÍý SPU ¤Ë³ä¤êÅö¤Æ¤é¤ì¤ë¤È¡¢
52 ¤ÇÅϤµ¤ì¤¿Ì¿Îá¥Ý¥¤¥ó¥¿ (instruction pointer) ¤«¤é¼Â¹Ô¤¬³«»Ï¤µ¤ì¤ë¡£
54 SPU ¥³¡¼¥É¤Î¼Â¹Ô¤ÏƱ´üŪ (synchronously) ¤Ë¹Ô¤ï¤ì¤ë¡¢¤Ä¤Þ¤ê
58 SPU ¥³¡¼¥É¤Î¼Â¹Ô¤ò¥á¥¤¥ó CPU ¤ä¾¤Î SPU ¤ÈʹԤ·¤Æ¹Ô¤¦É¬Íפ¬¤¢¤ë¾ì¹ç¤Ï¡¢
59 ºÇ½é¤Ë¡¢¤½¤Î SPU ¥³¡¼¥É¤ò¼Â¹Ô¤¹¤ë¿·¤·¤¤¥¹¥ì¥Ã¥É¤ò¡¢(Î㤨¤Ð
60 .BR pthread_create (3)
61 ¤Ê¤É¤ò»È¤Ã¤Æ) À¸À®¤·¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
64 ¤¬ÊÖ¤ë¤È¤¤Ë¤Ï¡¢SPU ¤Î¥×¥í¥°¥é¥à¥«¥¦¥ó¥¿¤Î¸½ºßÃͤ¬
71 ¥Ý¥¤¥ó¥¿¤ò»È¤¦¤³¤È¤¬¤Ç¤¤ë¡£
74 °ú¤¿ô¤Ë¤Ï¡¢³ÈÄ¥¥¹¥Æ¡¼¥¿¥¹¥³¡¼¥ÉÍѤΥХåե¡¤ò»ØÄꤹ¤ë¡£
75 .B SPU_CREATE_EVENTS_ENABLED
76 ¥Õ¥é¥°ÉÕ¤¤Ç SPU ¥³¥ó¥Æ¥¥¹¥È¤¬ºîÀ®¤µ¤ì¤ë¤È¡¢
78 ¤¬ÊÖ¤ëÁ°¤Ë Linux ¥«¡¼¥Í¥ë¤Ë¤è¤ê¤³¤Î¥Ð¥Ã¥Õ¥¡¤Ë
79 ³ÈÄ¥¥¹¥Æ¡¼¥¿¥¹¥³¡¼¥É¤¬³ÊǼ¤µ¤ì¤ë¡£
81 ¥¹¥Æ¡¼¥¿¥¹¥³¡¼¥É¤Ë¤Ï°Ê²¼¤ÎÄê¿ô¤¬°ì¤Ä°Ê¾åÆþ¤ë¡£
83 .B SPE_EVENT_DMA_ALIGNMENT
84 DMA (direct memory access) ¤Î¥¢¥é¥¤¥á¥ó¥È¡¦¥¨¥é¡¼¤¬È¯À¸¤·¤¿¡£
86 .B SPE_EVENT_INVALID_DMA
87 ̵¸ú¤Ê MFC (Memory Flow Controller) DMA ¥³¥Þ¥ó¥É¤ò¹Ô¤ª¤¦¤È¤·¤¿¡£
89 .B SPE_EVENT_SPE_DATA_STORAGE
90 DMA ¥¹¥È¥ì¡¼¥¸¡¦¥¨¥é¡¼¤¬È¯À¸¤·¤¿¡£
92 .B SPE_EVENT_SPE_ERROR
93 ÉÔÀµ¤ÊÌ¿Î᤬¼Â¹Ô¤µ¤ì¤¿¡£
97 °ú¤¿ô¤È¤·¤Æ͸ú¤ÊÃͤǤ¢¤ë¡£
98 ¤³¤Î¾ì¹ç¡¢¥¤¥Ù¥ó¥È¤Ï¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤ËÊó¹ð¤µ¤ì¤Ê¤¤¡£
105 ¥¨¥é¡¼¤Î¾ì¹ç¡¢\-1 ¤òÊÖ¤·¡¢
107 ¤ò²¼µ¤Î¥¨¥é¡¼¥³¡¼¥É¤Î¤¤¤º¤ì¤«¤ËÀßÄꤹ¤ë¡£
110 ¥ì¥¸¥¹¥¿¤ÎÃͤϡ¢¥¹¥Æ¡¼¥¿¥¹¥³¡¼¥É¤È SPU ¤Î
112 Ì¿Î᤬ÊÖ¤¹ 14 ¥Ó¥Ã¥È¤Î¥³¡¼¥É¤Î
113 ¥Ó¥Ã¥È¥Þ¥¹¥¯¤Ç¹½À®¤µ¤ì¤ë¡£
114 ¸å¼Ô¤Î 14 ¥Ó¥Ã¥È¤Î¥³¡¼¥É¤Ï¥ª¥×¥·¥ç¥ó¤Ç¤¢¤ë¡£
115 ¥¹¥Æ¡¼¥¿¥¹¥³¡¼¥É¤Î¥Ó¥Ã¥È¥Þ¥¹¥¯¤Ï²¼µ¤ÎÄ̤ê¤Ç¤¢¤ë¡£
128 SPU ¤Ï¥Á¥ã¥ó¥Í¥ë¤Î¥¦¥§¥¤¥ÈÃæ¤Ç¤¢¤ë¡£
131 SPU ¤Ï¥·¥ó¥°¥ë¥¹¥Æ¥Ã¥×¥â¡¼¥É¤Ç¤¢¤Ã¤¿¡£
134 SPU ¤¬ÉÔÀµ¤ÊÌ¿Îá¤ò¼Â¹Ô¤·¤è¤¦¤È¤·¤¿¡£
137 SPU ¤¬ÉÔÀµ¤Ê¥Á¥ã¥ó¥Í¥ë¤Ë¥¢¥¯¥»¥¹¤·¤è¤¦¤È¤·¤¿¡£
140 ¤³¤ÎÃͤΥޥ¹¥¯¤òŬÍѤ·¤ÆÆÀ¤é¤ì¤¿¥Ó¥Ã¥ÈÃͤˤϡ¢
141 stop-and-signal Ì¿Îᤫ¤éÊÖ¤µ¤ì¤¿¥³¡¼¥É¤¬Æþ¤Ã¤Æ¤¤¤ë¡£
142 ¤³¤ì¤é¤Î¥Ó¥Ã¥È¤Ï 0x02 ¥Ó¥Ã¥È¤¬¥»¥Ã¥È¤µ¤ì¤Æ¤¤¤ë¾ì¹ç¤Ë¤Î¤ß͸ú¤Ç¤¢¤ë¡£
145 ¤¬¥¨¥é¡¼¤òÊÖ¤µ¤Ê¤«¤Ã¤¿¾ì¹ç¡¢²¼°Ì 8 ¥Ó¥Ã¥È¤Î¤¦¤Á 1 ¤Ä°Ê¾å¤Ï
151 ¤¬Í¸ú¤Ê¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Ç¤Ê¤¤¡£
155 ¤¬Í¸ú¤Ê¥Ý¥¤¥ó¥¿¤Ç¤Ê¤¤¡£¤Þ¤¿¤Ï
157 ¤¬ NULL °Ê³°¤Ç¡¢¤·¤«¤â̵¸ú¤Ê¥Ý¥¤¥ó¥¿¤Ç¤¢¤ë¡£
161 ¤Î¼Â¹ÔÃæ¤Ë¥·¥°¥Ê¥ë¤¬È¯À¸¤·¤¿¡£
166 ¤ÎÃͤϿ·¤·¤¤¥×¥í¥°¥é¥à¥«¥¦¥ó¥¿¤ÎÃͤ˹¹¿·¤µ¤ì¤ë¡£
172 ¤¬ÊÖ¤·¤¿Í¸ú¤Ê¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Ç¤Ê¤¤¡£
175 Memory Flow Controller (MFC) DMA ¤Ë¤è¤êȯÀ¸¤·¤¿¥Ú¡¼¥¸¥Õ¥©¡¼¥ë¥È¤ò
176 ½èÍý¤¹¤ë¤Î¤ËɬÍפʥá¥â¥ê¤¬¤Ê¤«¤Ã¤¿¡£
179 µ¡Ç½¤¬Æ°ºîÃæ¤Î¥·¥¹¥Æ¥à¤ÇÄ󶡤µ¤ì¤Æ¤¤¤Ê¤¤¡£Íýͳ¤Ï¡¢
180 ¥Ï¡¼¥É¥¦¥§¥¢¤Ç SPU ¤¬Ä󶡤µ¤ì¤Æ¤¤¤Ê¤¤¤«¡¢
181 spufs ¥â¥¸¥å¡¼¥ë¤¬¥í¡¼¥É¤µ¤ì¤Æ¤¤¤Ê¤¤¤«¡¢¤Î¤É¤Á¤é¤«¤Ç¤¢¤ë¡£
184 ¥·¥¹¥Æ¥à¥³¡¼¥ë¤Ï¥«¡¼¥Í¥ë 2.6.16 ¤Ç Linux ¤ËÄɲ䵤줿¡£
186 ¤³¤Î¥·¥¹¥Æ¥à¥³¡¼¥ë¤Ï Linux ¸ÇͤǤ¢¤ê¡¢
187 PowerPC ¥¢¡¼¥¥Æ¥¯¥Á¥ã¤Ç¤Î¤ß¼ÂÁõ¤µ¤ì¤Æ¤¤¤ë¡£
188 ¤³¤Î¥·¥¹¥Æ¥à¥³¡¼¥ë¤ò»È¤Ã¤¿¥×¥í¥°¥é¥à¤Ï°Ü¿¢À¤¬¤Ê¤¤¡£
190 glibc ¤Ï¤³¤Î¥·¥¹¥Æ¥à¥³¡¼¥ë¤ËÂФ¹¤ë¥é¥Ã¥Ñ¡¼´Ø¿ô¤òÄ󶡤·¤Æ¤¤¤Ê¤¤¡£
194 ¤Ï ¤è¤êÃê¾ÝÅ٤ι⤤ SPU ¤Ø¤Î¥¤¥ó¥¿¥Õ¥§¡¼¥¹¤ò¼ÂÁõ¤¹¤ë¥é¥¤¥Ö¥é¥ê¤«¤é
195 ÍøÍѤµ¤ì¤ë¤³¤È¤ò°Õ¿Þ¤·¤¿¤â¤Î¤Ç¤¢¤ê¡¢Ä̾ï¤Î¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤«¤é
196 »ÈÍѤϰտޤµ¤ì¤Æ¤¤¤Ê¤¤¡£¿ä¾©¤Î¥é¥¤¥Ö¥é¥ê¤Ë¤Ä¤¤¤Æ¤Ï
197 .I http://www.bsc.es/projects/deepcomputing/linuxoncell/
200 °Ê²¼¤Ï¡¢´Êñ¤Ê 1 Ì¿Îá¤Î SPU ¥×¥í¥°¥é¥à¤ò
202 ¥·¥¹¥Æ¥à¥³¡¼¥ë¤ò»È¤Ã¤Æ¼Â¹Ô¤µ¤»¤ëÎã¤Ç¤¢¤ë¡£
209 #include <sys/types.h>
212 #define handle_error(msg) \\
213 do { perror(msg); exit(EXIT_FAILURE); } while (0)
217 int context, fd, spu_status;
218 uint32_t instruction, npc;
220 context = spu_create("/spu/example\-context", 0, 0755);
222 handle_error("spu_create");
224 /* write a \(aqstop 0x1234\(aq instruction to the SPU\(aqs
227 instruction = 0x00001234;
229 fd = open("/spu/example\-context/mem", O_RDWR);
231 handle_error("open");
232 write(fd, &instruction, sizeof(instruction));
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
240 spu_status = spu_run(context, &npc, NULL);
241 if (spu_status == \-1)
242 handle_error("open");
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)
248 printf("SPU Status: 0x%08x\\n", spu_status);
254 .\" Arnd Bergmann <arndb@de.ibm.com>, Jeremy Kerr <jk@ozlabs.org>
258 .BR capabilities (7),