arrow_back_ios Back to List

What are Virtual Domains?

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.

Virtual domains enable calls to PPU virtual methods and PPU callbacks from the SPU. A virtual domain is a list of functions specified by the programmer and attached to an offload block. This domain tells the compiler to explicitly offload the functions in that list to SPU. If a virtual method or callback is invoked inside this offload block (or the functions it calls), that domain is used to call the correct offloaded method. Failure to attach a correct domain may result in runtime errors (See /kb/77 .html and /kb/78).html.

The following example illustrates the use of domains:

struct dev
	virtual void f(){}
	virtual void f(int){}

void test()
	__blockingoffload [dev::f] // both overloads dev::f are in the domain
	__blockingoffload [(void(dev::*)(int)) &dev::f] //offloading f(int) only

A more complex example of a domain declaration is this:

	( void (*)			(int * ,int __outer * ,test *)) & fptrtest,  //offload fptrtest with signature "void(int*,int __outer*, test*)
	( void (test::*)	(int __outer * , int * ))& test::f,
	( void (test::*)	(int * , int __outer * )) & test::f,
	( void (test::*)	(int * , int __outer * )) & test::f this // offload method test::f with signature "void(int*,int __outer*)" with a local (SPU) this pointer

A useful command line option to help building the correct domain by inspecting the vcall/callback call-sites is -offloadshowptrcalls (See /kb/82.html) which prints the signature used at the call-sites.

The compiler is able to issue warnings on wrong or incomplete domain declarations in many situations. See /kb/97.html, /kb/98.html, /kb/99.html and /kb/100.html for reference. If any of those warnings occur, the offloaded code is likely to cause the runtime error described in /kb/77 .html and /kb/78.html.

More details and examples on domains can be found in the Offload language specification document and the systems manual, both of which are part of the latest Offload release.