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

class ReadWriteArray<>

Offload KB - offload-library

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.

Include: <liboffload>

The ReadWriteArray class template is instantiated within Offload contexts. It will DMA the data into local store on construction and also DMAs it back to main memory on destruction.

Usage:

#include <liboffload>
#define SIZE 128

class ParamsBlock
{
	int param1, param2, param3, param4;
};

ParamsBlock gParams[SIZE] __ALIGN16;

int DoSomeWork()
{
	int ret = 0;
	liboffload::data::ReadWriteArray<ParamsBlock, SIZE> localParams(&gParams[0]);
	for(int i = 0; i < SIZE; i++)
	{
		ret += localParams[i].param1;
	}

	for(int i = 0; i < SIZE; i++)
	{
		localParams[i].param2 = ret;
	}
	return ret;
}

Limitations:

The __outer PPU pointer passed to the constructor must be aligned to 16 bytes, or naturally aligned if size is < 16.Reference types are not supported.

The size of the local array must be a compile-time constant.