Overview
SPU threads provide a flexible way to run SPU programs with automatic scheduling and resource management. Unlike raw SPUs, thread groups can exceed the number of physical SPUs (6), with the system handling context switching automatically.For most applications, SPU thread groups are the recommended approach over raw SPU management. They provide better abstraction and easier multi-threading support.
Thread Group Workflow
The complete lifecycle of SPU thread execution:Complete Example
Here’s a full working example demonstrating SPU thread creation and signal-based communication:Multiple Thread Groups
Running multiple SPU threads in parallel for maximum performance:Parallel Execution Example
Thread Group Control
Priority Management
Thread Priority
Suspend and Resume
Thread Control
Forced Termination
Termination
Signal Notification
SPU threads have two signal notification registers for fast PPU-to-SPU communication:Signal Register Modes
Signal Register Modes
Overwrite Mode: New signal value replaces the old valueOR Mode: New signal value is OR’ed with the existing value
Signal Communication
SPU: Read Signals
Event-Based Communication
Event queues provide structured message passing between PPU and SPU:PPU Side: Event Setup
Event Queue Creation
SPU Side: Send Events
SPU Event Sending
Local Store Access
PPU can directly read/write SPU local store memory:Direct Local Store Access
Thread Attributes
Thread Group Attributes
Thread Group Configuration
Thread Attributes
Thread Configuration
Thread Exit Status
Exit Status Handling
Best Practices
Use Appropriate Thread Count
Run at most 6 SPU threads simultaneously to avoid context switching overhead
Align Data Structures
Ensure all shared data is 16-byte (or better, 128-byte) aligned
Prefer Events Over Polling
Use event queues instead of polling memory locations
Set Appropriate Priorities
Higher priorities (larger numbers) for time-critical tasks
Common Patterns
Fire-and-Forget Pattern
Quick Task Execution
Producer-Consumer Pattern
Work Queue Processing
Related Functions
- sysSpuThreadGroupCreate (sys/spu.h:791)
- sysSpuThreadInitialize (sys/spu.h:549)
- sysSpuThreadWriteSignal (sys/spu.h:705)
- spu_thread_send_event (sys/spu_event.h:39)
- spu_thread_exit (sys/spu_thread.h:39)
Next Steps
DMA Transfers
Learn efficient data transfer between PPU and SPU
SPURS Framework
High-level task scheduling for complex workloads