BehaveRT::DeviceArrayWrapper< Type > Class Template Reference

This class provides some utilities for host/device memory allocation. More...

Inheritance diagram for BehaveRT::DeviceArrayWrapper< Type >:

BehaveRT::DeviceDataWrapper BehaveRT::InstallableEntity

List of all members.

Public Member Functions

 DeviceArrayWrapper (DeviceInterface *deviceInterface, int size, int dimension=1, bool useDoubleBufferingOnDevice=true, bool useVbo=false)
 ~DeviceArrayWrapper ()
 Deallocate host and device memory.
Type * getReadDeviceArray ()
 Returns the array on current read position.
Type * getWriteDeviceArray ()
 Returns the array on current write position.
bool useVbo ()
 Returns true if VBO is enabled.
int getReadVbo ()
 Returns the VBO index on current read position.
int getWriteVbo ()
 Returns the VBO index on current write position.
int getElementBytesCount ()
 Returns the size of one element: sizeof(Type) * dimension.
int getBytesCount ()
 Returns the size of the whole array: sizeof(Type) * dimension * size.
Type * getHostArray ()
 Returns the host "image" of the array.
int getSize ()
 Returns the size of the array.
const type_info * getType ()
 Returns type information: a reference to typeid(Type).
void swapPosReadWrite ()
 If double-buffering is enabled, swaps the current read position with the current write position.
void copyArrayToDevice ()
 Copies the whole array from host to device.
void copyArrayToDevice (int offsetElements)
 Copies one element of the array from host to device.
void copyArrayToDevice (int offsetElements, int numElements)
 Copies a window of the array from host to device.
void copyArrayFromDevice ()
 Copies the whole array from device to host.
void copyArrayFromDevice (int offsetElements)
 Copies one element of the array from device to host.
void copyArrayFromDevice (int offsetElements, int numElements)
 Copies a window of array from device to host.
Type getHostArrayElement (int index, bool copyFromDevice=false)
void setHostArrayElement (int index, Type *element, bool copyToDevice=false)
void bindToField (int &field)
void reset (char val)
 Set all the element of the host array to val.


Detailed Description

template<class Type>
class BehaveRT::DeviceArrayWrapper< Type >

This class provides some utilities for host/device memory allocation.

Helps the interaction between the device "image" and the host "image" of an array.

Objects of this class are feature of the simulation engine.

Similar to GPUArray entity included in the CUDA SDK 2.1.


Constructor & Destructor Documentation

template<class Type >
BehaveRT::DeviceArrayWrapper< Type >::DeviceArrayWrapper ( DeviceInterface deviceInterface,
int  size,
int  dimension = 1,
bool  useDoubleBufferingOnDevice = true,
bool  useVbo = false 
) [inline]

Allocate and initialize arrays. Allocate on host and device size * dimension * sizeof(Type) bytes. Register the feature on the DeviceDataRepository.

Parameters:
deviceInterface reference to DeviceInterface
size number of elements
dimension number of dimensions (1D, 2D, 3D, ...)
useDoubleBufferingOnDevice double image on device, for doublebuffering
useVbo OpenGL Vertex Buffer Object assotiation


Member Function Documentation

template<class Type >
void BehaveRT::DeviceArrayWrapper< Type >::bindToField ( int &  field  )  [inline]

Create a link between the feature represented by the DeviceArrayWrapper and an element of the DeviceDataRepository.

template<class Type >
Type BehaveRT::DeviceArrayWrapper< Type >::getHostArrayElement ( int  index,
bool  copyFromDevice = false 
) [inline]

Returns:
an element of the host array
Parameters:
index of the element
copyFromDevice if true, copies the element from device

template<class Type >
void BehaveRT::DeviceArrayWrapper< Type >::setHostArrayElement ( int  index,
Type *  element,
bool  copyToDevice = false 
) [inline]

Set an elemento of the host array

Parameters:
index index of the element
element data to write on the array element
copyToDevice if true, copies the element to device


The documentation for this class was generated from the following file:

Generated on Mon Oct 19 13:19:44 2009 for BehaveRT by  doxygen 1.5.7.1