SPU_RUN(2)

NAME
spu_run - execute an spu context

SYNOPSIS
#include <sys/spu.h>
int spu_run(int fd, unsigned int *npc, unsigned int *event);

DESCRIPTION
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.

RETURN VALUE
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:

0x02
    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.

0x04
    SPU was stopped by halt.

0x08
    SPU is waiting for a channel.

0x10
    SPU is in single-step mode.

0x20
    SPU has tried to execute an invalid instruction.

0x40
    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.

ERRORS

EAGAIN or EWOULDBLOCK
    fd is in non-blocking mode and spu_run() would block.

EBADF
    fd is not a valid file descriptor.

EFAULT
    npc is not a valid pointer or status is neither NULL nor a valid pointer.

EINTR
    A signal occurred while spu_run() was in progress. The npc value has been updated to the new program counter value if necessary.

EINVAL
    fd is not a file descriptor returned from spu_create(2).

ENOMEM
    There was not enough memory available to handle a page fault resulting from a Memory Flow Controller (MFC) direct memory access.

ENOSYS
    The functionality is not provided by the current system, because either the hardware does not provide SPUs or the spufs module is not loaded.

VERSIONS
The spu_run(2) system call was added to Linux in kernel 2.6.16.

CONFORMING TO
This call is Linux specific and only implemented by the ppc64 architecture. Programs using this system call are not portable.

NOTES
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.

BUGS
The code does not yet fully implement all features outlined here.

SEE ALSO
close(2), spu_create(2), spufs(7)