Login or Register

Getting Started Right Your First Offload Block

Your First Offload™ Block

Now You Have Offload™ Installed, Let's Look At The Process Of Offloading Code The To The SPU.

This article was updated on 2011-06-03 04:21:29


Regardless of how you decided to install Offload™, the first offload block that is attempted is a good sanity test for your installation.

Whether you decide to jump right in and integrate Offload™ with your current project, or you would rather create a project from scratch, it is advisable to start small and ensure the installation is working as is expected!

The first step is to create an C++ file, which will be compiled with Offload™. Once you have the given C++ file created, the next step is to set it to use Offload™. When using the Visual Studio 2008 integration, you can right-click on the desired file and select 'Activate Offload', or you could use a custom build step as either a Visual Studio custom build step, or within a makefile.

Create a function within your file:

#include <liboffload>
#include <stdio.h>
void offloadTestBlock()
{
	__blockingoffload()
	{
		printf("Hello world from the SPU!\n");
	};
}

By creating a corresponding header file to expose the function elsewhere in your code, or simply by using an extern offloadTestBlock();, you can link the offloaded function with your normal game code.

When using Visual Studio 2008 Integration, compiling the file as is normal will suffice to build the example.

This text contains Sony confidential information and can only be viewed by PS3-registered users - please login to view the text.


Now compiling this example will create a blocking SPU job which simply prints 'Hello world!' to the console.