1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259
|
.\" Copyright (c) International Business Machines Corp., 2006
.\"
.\" This program is free software; you can redistribute it and/or
.\" modify it under the terms of the GNU General Public License as
.\" published by the Free Software Foundation; either version 2 of
.\" the License, or (at your option) any later version.
.\"
.\" This program is distributed in the hope that it will be useful,
.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
.\" the GNU General Public License for more details.
.\"
.\" You should have received a copy of the GNU General Public License
.\" along with this program; if not, write to the Free Software
.\" Foundation, Inc., 59 Temple Place, Suite 330, Boston,
.\" MA 02111-1307 USA
.\"
.\" HISTORY:
.\" 2005-09-28, created by Arnd Bergmann <arndb@de.ibm.com>
.\" 2006-06-16, revised by Eduardo M. Fleury <efleury@br.ibm.com>
.\" 2007-07-10, some polishing by mtk
.\" 2007-09-28, updates for newer kernels, added example
.\" by Jeremy Kerr <jk@ozlabs.org>
.\"
.\" Japanese Version Copyright (c) 2007 Akihiro MOTOKI
.\" all rights reserved.
.\" Translated 2007-10-19, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
.\" Updated 2008-11-10, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v3.04
.\"
.TH SPU_RUN 2 2007-11-25 Linux "Linux Programmer's Manual"
.SH ̾
spu_run \- SPU ƥȤ¹Ԥ
.SH
.nf
.B #include <sys/spu.h>
.BI "int spu_run(int " fd ", unsigned int *" npc \
", unsigned int *" event ");"
.fi
.SH
.BR spu_run ()
ƥॳϡCell Broadband Engine ƥ
PowerPC ޥ Synergistic Processor Units (SPU) ˥뤿
Ѥ롣
.I fd
ϡ
.BR spu_create (2)
֤եǥץǡ
SPU ƥȤȤ롣
ΥƥȤʪ SPU ˳Ƥȡ
.I npc
Ϥ줿̿ݥ (instruction pointer) ¹ԤϤ롣
SPU ɤμ¹ԤƱŪ (synchronously) ˹Ԥ롢Ĥޤ
SPU ¹
.BR spu_run ()
(block) 롣
SPU ɤμ¹Ԥᥤ CPU ¾ SPU ¹ԤƹԤɬפϡ
ǽˡ SPU ɤ¹Ԥ뿷åɤ(㤨
.BR pthread_create (3)
ʤɤȤä) ʤФʤʤ
.BR spu_run ()
֤ȤˤϡSPU Υץ५θͤ
.I npc
˽ޤ롣
ˤꡢϢ³
.BR spu_run ()
θƤӽФƱ
.I npc
ݥȤȤǤ롣
.I event
ˤϡĥơѤΥХåեꤹ롣
.B SPU_CREATE_EVENTS_ENABLED
ե饰դ SPU ƥȤȡ
.BR spu_run ()
֤ Linux ͥˤꤳΥХåե
ĥơɤǼ롣
ơɤˤϰʲİʾ롣
.TP
.B SPE_EVENT_DMA_ALIGNMENT
DMA (direct memory access) Υ饤ȡ顼ȯ
.TP
.B SPE_EVENT_INVALID_DMA
̵ MFC (Memory Flow Controller) DMA ޥɤԤȤ
.TP
.B SPE_EVENT_SPE_DATA_STORAGE
DMA ȥ졼顼ȯ
.TP
.B SPE_EVENT_SPE_ERROR
̿¹Ԥ줿
.PP
NULL
.I event
ȤͭͤǤ롣
ξ硢٥ȤϸƤӽФΥץ𤵤ʤ
.SH ֤
ȡ
.BR spu_run ()
.I spu_status
쥸֤ͤ
顼ξ硢\-1 ֤
.I errno
Υ顼ɤΤ줫ꤹ롣
.I spu_status
쥸ͤϡơɤ SPU
.B stop-and-signal
֤̿ 14 ӥåȤΥɤ
ӥåȥޥǹ롣
Ԥ 14 ӥåȤΥɤϥץǤ롣
ơɤΥӥåȥޥϲ̤Ǥ롣
.TP
.B 0x02
SPU
.B stop-and-signal
̿ߤ
.TP
.B 0x04
SPU
.B "halt ()"
̿ǻߤޤä
.TP
.B 0x08
SPU ϥͥΥǤ롣
.TP
.B 0x10
SPU ϥ륹ƥåץ⡼ɤǤä
.TP
.B 0x20
SPU ̿¹Ԥ褦Ȥ
.TP
.B 0x40
SPU ʥͥ˥褦Ȥ
.TP
.B 0x3fff0000
ͤΥޥŬѤ줿ӥåͤˤϡ
stop-and-signal ̿ᤫ֤줿ɤäƤ롣
ΥӥåȤ 0x02 ӥåȤåȤƤˤΤͭǤ롣
.PP
.BR spu_run ()
顼֤ʤä硢 8 ӥåȤΤ 1 İʾ
˥åȤ롣
.SH 顼
.TP
.B EBADF
.I fd
ͭʥեǥץǤʤ
.TP
.B EFAULT
.I npc
ͭʥݥǤʤޤ
.I event
NULL ʳǡ̵ʥݥǤ롣
.TP
.B EINTR
.BR spu_run ()
μ¹˥ʥ뤬ȯ
.BR signal (7)
ȡ
ɬפǤС
.I npc
ͤϿץ५ͤ˹롣
.TP
.B EINVAL
.I fd
.BR spu_create (2)
֤ͭʥեǥץǤʤ
.TP
.B ENOMEM
Memory Flow Controller (MFC) DMA ˤȯڡեȤ
Τɬפʥ꤬ʤä
.TP
.B ENOSYS
ǽưΥƥƤʤͳϡ
ϡɥ SPU Ƥʤ
spufs ⥸塼뤬ɤƤʤΤɤ餫Ǥ롣
.SH С
.BR spu_run ()
ƥॳϥͥ 2.6.16 Linux ɲä줿
.SH
Υƥॳ Linux ͭǤꡢ
PowerPC ƥǤΤƤ롣
ΥƥॳȤäץϰܿʤ
.SH
glibc ϤΥƥॳФåѡؿƤʤ
.BR syscall (2)
Ȥȡ
.BR spu_run ()
٤ι⤤ SPU ؤΥե饤֥꤫
Ѥ뤳ȤտޤΤǤꡢ̾Υץꥱ
ѤϰտޤƤʤ侩Υ饤֥ˤĤƤ
.I http://www.bsc.es/projects/deepcomputing/linuxoncell/
ȤΤȡ
.SH
ʲϡñ 1 ̿ SPU ץ
.BR spu_run ()
ƥॳȤäƼ¹ԤǤ롣
.nf
#include <stdlib.h>
#include <stdint.h>
#include <unistd.h>
#include <stdio.h>
#include <sys/types.h>
#include <fcntl.h>
#define handle_error(msg) \\
do { perror(msg); exit(EXIT_FAILURE); } while (0)
int main(void)
{
int context, fd, spu_status;
uint32_t instruction, npc;
context = spu_create("/spu/example\-context", 0, 0755);
if (context == -1)
handle_error("spu_create");
/* write a \(aqstop 0x1234\(aq instruction to the SPU\(aqs
* local store memory
*/
instruction = 0x00001234;
fd = open("/spu/example\-context/mem", O_RDWR);
if (fd == -1)
handle_error("open");
write(fd, &instruction, sizeof(instruction));
/* set npc to the starting instruction address of the
* SPU program. Since we wrote the instruction at the
* start of the mem file, the entry point will be 0x0
*/
npc = 0;
spu_status = spu_run(context, &npc, NULL);
if (spu_status == -1)
handle_error("open");
/* we should see a status code of 0x1234002:
* 0x00000002 (spu was stopped due to stop\-and\-signal)
* | 0x12340000 (the stop\-and\-signal code)
*/
printf("SPU Status: 0x%08x\\n", spu_status);
exit(EXIT_SUCCESS);
}
.fi
.\" .SH AUTHORS
.\" Arnd Bergmann <arndb@de.ibm.com>, Jeremy Kerr <jk@ozlabs.org>
.SH Ϣ
.BR close (2),
.BR spu_create (2),
.BR capabilities (7),
.BR spufs (7)
|