Intel Announces Agreement to Acquire Codeplay Software; Expanding our Open Standards Vision. Learn more here.
arrow_back_ios Back to List

Job Functions

Offload KB - features

Old Content Alert

Please note that this is a old document archive and the will most likely be out-dated or superseded by various other products and is purely here for historical purposes.

Games engines often implement some kind of job/task system which manages some form of a job list. The application adds jobs into that list, and a scheduler runs them. On the PS3 such a job system may have to be able to handle PPU jobs as well as SPU jobs, and often there may be the need to run the same task on PPU and SPU depending on the availability of the cores. With Offload such SPU jobs can be easily created using "suspended" Offload blocks. Such an Offload block creates a suspended SPU job and returns a handle which can be used by the task scheduler to resume that job at a later stage.

The following function creates a suspended SPU task and returns a handle of that task:

int CreateSPUJob(int arg)
    int handle = __offload suspended (arg) //offload block with suspended keyword, capturing arg (in a very lambda-like way)
    return handle;

To resume this SPU task, the Offload runtime function offloadThreadStart must be called with the handle of the suspended offload block as the argument:


The Offload compiler also supports the new function modifier __offloadjob which is essentially syntactic sugar for creating jobs using offload blocks. Using __offloadjob the above function CreateSPUJob becomes:

__offloadjob int CreateSPUJob(int arg)