GPUMLib  0.2.2
GPU Machine Learning Library
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
DeviceArray< Type > Class Template Reference

Create an array of any type, on the device, that automatically manages the memory used to hold its elements. More...

#include <DeviceArray.h>

Inheritance diagram for DeviceArray< Type >:
BaseArray< Type >

Public Member Functions

void Dispose ()
 Disposes the array.
 
 DeviceArray ()
 Constructs an array with no elements.
 
 DeviceArray (int size)
 
 DeviceArray (const HostArray< Type > &originalArray)
 
 DeviceArray (const DeviceArray< Type > &originalArray)
 
 DeviceArray (const Type *originalArray, int size)
 
 DeviceArray (DeviceArray< Type > &&temporaryArray)
 
DeviceArray< Type > & operator= (const HostArray< Type > &originalArray)
 
DeviceArray< Type > & operator= (const DeviceArray< Type > &originalArray)
 
DeviceArray< Type > & operator= (DeviceArray< Type > &&temporaryArray)
 
void TransferOwnerShipFrom (DeviceArray< Type > &other)
 
 ~DeviceArray ()
 Destructor.
 
int Length () const
 
Type * Pointer () const
 
int ResizeWithoutPreservingData (int size)
 

Protected Member Functions

void Init ()
 
void MoveFrom (BaseArray< Type > &other)
 

Protected Attributes

Type * arrayData
 
int size
 

Detailed Description

template<class Type>
class GPUMLib::DeviceArray< Type >

Create an array of any type, on the device, that automatically manages the memory used to hold its elements.

Definition at line 33 of file DeviceArray.h.

Constructor & Destructor Documentation

DeviceArray ( int  size)
inlineexplicit

Constructs an array with size elements

Parameters
sizenumber of elements of the array

Definition at line 56 of file DeviceArray.h.

DeviceArray ( const HostArray< Type > &  originalArray)
inline

Constructs a device array with the same elements as an host array

Parameters
originalArrayhost array from where to copy the elements

Definition at line 62 of file DeviceArray.h.

DeviceArray ( const DeviceArray< Type > &  originalArray)
inline

Constructs a device array with the same elements as another device array

Parameters
originalArrayarray from where to copy the elements

Definition at line 69 of file DeviceArray.h.

DeviceArray ( const Type *  originalArray,
int  size 
)
inline

Constructs a device array with the same elements as those in an host array

Parameters
originalArrayarray data from where to copy the elements
sizenumber of elements to copy

Definition at line 77 of file DeviceArray.h.

DeviceArray ( DeviceArray< Type > &&  temporaryArray)
inline

Constructs a device array using the elements of a temporary device array (rvalue)

Parameters
temporaryArraytemporary array containing the elements

Definition at line 84 of file DeviceArray.h.

Member Function Documentation

int Length ( ) const
inlineinherited

Gets the length of the array. You can use this function to check if the array was effectively allocated.

Returns
the number of elements of the array

Definition at line 63 of file BaseArray.h.

DeviceArray<Type>& operator= ( const HostArray< Type > &  originalArray)
inline

Transforms this array into an array with the same data as an host array

Parameters
originalArrayarray from where to copy the elements
Returns
a reference to this array

Definition at line 91 of file DeviceArray.h.

DeviceArray<Type>& operator= ( const DeviceArray< Type > &  originalArray)
inline

Transforms this array into an array identical to another array

Parameters
originalArrayarray from where to copy the elements
Returns
a reference to this array

Definition at line 103 of file DeviceArray.h.

DeviceArray<Type>& operator= ( DeviceArray< Type > &&  temporaryArray)
inline

Replaces the elements of this device array by the elements of a temporary device array (rvalue)

Parameters
temporaryArraytemporary array containing the elements
Returns
a reference to this array

Definition at line 115 of file DeviceArray.h.

Type* Pointer ( ) const
inlineinherited

Gets a pointer to the array data

Attention
Use with caution
Returns
a pointer to the array data

Definition at line 70 of file BaseArray.h.

int ResizeWithoutPreservingData ( int  size)
inlineinherited

Resizes the array without preserving its data

Parameters
sizenew size of the array
Returns
the number of elements of the array after being resized.

Definition at line 77 of file BaseArray.h.

void TransferOwnerShipFrom ( DeviceArray< Type > &  other)
inline

Releases its own resources (elements) and obtains ownership of another array resources. The other array will no longer have any elements. In other words, it moves the elements from one device array to another.

Parameters
otherarray containing the elements to be moved.

Definition at line 128 of file DeviceArray.h.


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