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

Inline Assembly

Offload KB - faq

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.

Source code containing PPU inline assembly usually cannot be offloaded. Therefore, the Offload compiler will issue an error message whenever an attempt is made to duplicate functions containing inline assembly.If possible, inline assembly should be replaced with GNU or AltiVec Intrinsics (where they are portable).

Otherwise, where this is not possible, functions with inline assembly should be overloaded by __offload functions that implement the same semantics of the SPU. That way, at overload resolution the compiler will be able to select the __offload function in SPU code. For example:

int func(int arg)
{
	__asm{/*some PPU assembly*/}
}

__offload int func(int arg) //overload for SPU
{
	//equivalent implementation for SPU
}

If func is called from within an offload block, the compiler will select the second function.

On real games or larger applications it is good practise to put all required __offload function definitions in a separate header file which can be included before the offload block/function that uses them. This enables a clear separation of offloaded code from main PPU code.

Often, though, a function may contain PPU inline assembly that may be difficult to replace by intrinsics that work on SPU, or even the PPU assembly may be too complex or cannot otherwise be emulated on the SPU. In that case it is best to outer-call the function on the PPU (see /kb/30.html). Outer calls though incur a performance penalty.