spu_run — execute an spu context
#include <sys/spu.h>
int
spu_run( |
int | fd, |
unsigned int * | npc, | |
unsigned int * | event) ; |
The spu_run
() system call is
used on PowerPC machines that implement the Cell Broadband
Engine Architecture in order to access Synergistic Processor
Units (SPUs). The fd
argument is a file descriptor returned by spu_create(2) that
addresses a specific SPU context. When the context gets
scheduled to a physical SPU, it starts execution at the
instruction pointer passed in npc
.
Execution of SPU code happens synchronously, meaning that
spu_run
() does not return while
the SPU is still running. If there is a need to execute SPU
code in parallel with other code on either the main CPU or
other SPUs, a new thread of execution must be created first,
using the pthread_create(3) call for
instance.
When spu_run
() returns, the
current value of the SPU instruction pointer is written to
npc
, so one can call
spu_run
() again without having
to update the pointers.
event
can be a
NULL pointer or a pointer to an to a buffer that spu_run
() uses to return an extended status
code. The status code may be one of the following
constants:
SPE_EVENT_DMA_ALIGNMENT
A DMA alignment error occurred (SIGBUS
, si_code
set to
BUS_ADRALN
).
SPE_EVENT_INVALID_DMA
MFC DMA was invalid (SIGBUS
, si_code
set to
BUS_OBJERR
).
SPE_EVENT_SPE_DATA_STORAGE
A DMA storage error occurred (SIGBUS
, si_code
set to
BUS_ADRERR
).
SPE_EVENT_SPE_ERROR
Illegal instruction error (SIGBUS
, si_code
set to
BUS_ADRALN
).
If event
is NULL,
these errors will cause the corresponding signal listed above
to be delivered to the calling process.
On success spu_run
() returns
the value of the spu_status
register. On error
it returns −1 and sets errno
to one of the error codes listed
below. The spu_status
register value is
a bit mask of status codes and optionally a 14-bit code
returned from the stop-and-signal instruction on the SPU. The
bit masks for the status codes are:
SPU was stopped by stop-and-signal. In this case the
14-bit code returned from the instruction can be
retrieved with the mask 0x3fff0000
.
SPU was stopped by halt.
SPU is waiting for a channel.
SPU is in single-step mode.
SPU has tried to execute an invalid instruction.
SPU has tried to access an invalid channel.
If spu_run
() has not
returned an error, one or more bits among the lower eight
ones are always set.
fd
is in
non-blocking mode and spu_run
() would block.
fd
is not a
valid file descriptor.
npc
is not a
valid pointer or status
is neither NULL
nor a valid pointer.
A signal occurred while spu_run
() was in progress. The
npc
value has
been updated to the new program counter value if
necessary.
fd
is not a
file descriptor returned from spu_create(2).
There was not enough memory available to handle a page fault resulting from a Memory Flow Controller (MFC) direct memory access.
The functionality is not provided by the current system, because either the hardware does not provide SPUs or the spufs module is not loaded.
This call is Linux specific and only implemented by the ppc64 architecture. Programs using this system call are not portable.
Glibc does not provide a wrapper for this system call;
call it using syscall(2). Note however,
that spu_run
() is meant to be
used from libraries that implement a more abstract interface
to SPUs, not to be used from regular applications. See
http://www.bsc.es/projects/deepcomputing/linuxoncell/
for the recommended libraries.
close(2), spu_create(2), spufs(7)
This is _*_ nroff _*_ source. Emacs, gimme all those colors :) 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 |