Overview
The SPU thread management API provides functions for creating, running, and managing SPU threads on the PlayStation 3’s Cell Broadband Engine. SPU threads are dedicated programs running on the Synergistic Processing Elements (SPEs).Key Concepts
- SPU Thread Group: A collection of SPU threads that run together
- SPU Image: Binary code loaded from an ELF file to execute on an SPU
- Local Store: 256 KB of memory private to each SPU
- Mailbox Communication: Message passing between PPU and SPU threads
SPU Image Management
sysSpuImageOpen
Create a SPU image from an ELF file.Pointer to the SPU image structure to be initialized
Path to the SPU ELF file
Zero if successful, nonzero on error
sysSpuImageImport
Import a SPU image from an ELF file in memory.Pointer to the image structure to be updated
Pointer to ELF data in memory
Type of the image file (generally set to 0)
Zero if successful, nonzero on error
sysSpuImageClose
Close an opened SPU image file.Pointer to the SPU image structure
Zero if successful, nonzero on error
Thread Group Management
sysSpuThreadGroupCreate
Create a SPU thread group.Pointer to the returned thread group identifier
Number of SPU threads in the group (1-6)
Priority of the thread group
Pointer to a thread group attribute structure
Zero if successful, nonzero on error
sysSpuThreadGroupStart
Start execution of all threads in a SPU thread group.Thread group identifier
Zero if successful, nonzero on error
sysSpuThreadGroupJoin
Wait for a SPU thread group to finish execution.Thread group identifier
Pointer to returned termination cause
Pointer to returned termination status
Zero if successful, nonzero on error
sysSpuThreadGroupDestroy
Destroy a SPU thread group.Thread group identifier
Zero if successful, nonzero on error
Thread Management
sysSpuThreadInitialize
Initialize a SPU thread within a thread group.Pointer to the returned thread identifier
Thread group identifier
Index of thread in group (0 to group size - 1)
Pointer to the SPU image structure
Pointer to thread attributes
Pointer to arguments for the thread’s main function
Zero if successful, nonzero on error
sysSpuThreadSetArguments
Set or update SPU thread arguments.Thread identifier
Pointer to the arguments list
Zero if successful, nonzero on error
sysSpuThreadGetExitStatus
Get the exit status of a terminated SPU thread.Thread identifier
Pointer to the returned exit status
Zero if successful, nonzero on error
Mailbox Communication
sysSpuThreadWriteMb
Write to a SPU thread’s inbound mailbox.Thread identifier
32-bit value to write to mailbox
Zero if successful, nonzero on error
sysSpuThreadWriteSignal
Write to a SPU thread’s signal notification register.Thread identifier
Signal register number (0 for register 1, 1 for register 2)
Value to write to the signal register
Zero if successful, nonzero on error
Local Store Access
sysSpuThreadWriteLocalStorage
Write a value to a SPU thread’s local store memory.Thread identifier
Address in local store (0-262143)
Value to write
Data type size
Zero if successful, nonzero on error
sysSpuThreadReadLocalStorage
Read a value from a SPU thread’s local store memory.Thread identifier
Address in local store
Pointer to store the read value
Data type size
Zero if successful, nonzero on error
SPU-Side Functions
These functions are called from within SPU code:spu_thread_exit
Terminate the running SPU thread.Exit status value returned to PPU
spu_thread_group_exit
Terminate the entire SPU thread group.Thread group exit status
spu_thread_group_yield
Voluntarily yield execution to allow thread group scheduling.Example Usage
Basic SPU Thread Creation
Mailbox Communication Example
Constants
Thread Attributes
SPU_THREAD_ATTR_NONE- No special attributesSPU_THREAD_ATTR_ASYNC_INT_ENABLE- Enable asynchronous interruptsSPU_THREAD_ATTR_DEC_SYNC_TB_ENABLE- Synchronize decrementer with PPU time base
Thread Group Types
SPU_THREAD_GROUP_TYPE_NORMAL- Normal thread groupSPU_THREAD_GROUP_TYPE_SEQUENTIAL- Sequential executionSPU_THREAD_GROUP_TYPE_SYSTEM- System thread groupSPU_THREAD_GROUP_TYPE_MEMORY_FROM_CONTAINER- Use memory container
Signal Configuration
SPU_SIGNAL1_OVERWRITE- Signal 1 in overwrite modeSPU_SIGNAL1_OR- Signal 1 in OR modeSPU_SIGNAL2_OVERWRITE- Signal 2 in overwrite modeSPU_SIGNAL2_OR- Signal 2 in OR mode
Memory-Mapped Addresses
SPU thread resources are memory-mapped starting at0xF0000000: