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

Create an array of any type, that automatically manages the memory used to hold its elements (data will be stored both on the host and on the device). More...

#include <CudaArray.h>

Public Member Functions

 CudaArray ()
 Constructs an array with no elements.
 
 CudaArray (int size)
 
 CudaArray (const DeviceArray< Type > &originalArray)
 
 CudaArray (const HostArray< Type > &originalArray)
 
 CudaArray (CudaArray< Type > &&temporaryArray)
 
CudaArray< Type > & operator= (const CudaArray< Type > &originalArray)
 
CudaArray< Type > & operator= (const DeviceArray< Type > &originalArray)
 
CudaArray< Type > & operator= (const HostArray< Type > &originalArray)
 
CudaArray< Type > & operator= (const CudaArray< Type > &&temporaryArray)
 
Type & operator[] (int element)
 
Type operator[] (int element) const
 
int Length () const
 
Type * HostPointer () const
 
Type * DevicePointer () const
 
int ResizeWithoutPreservingData (int size)
 
void UpdateDevice ()
 Updates the device array data with the host array data.
 
void UpdateHost ()
 Updates the host array data with the device array data.
 
DeviceArray< Type > & GetDeviceArray ()
 
HostArray< Type > & GetHostArray ()
 
void Dispose ()
 Disposes the array.
 
void DisposeDevice ()
 Updates the host information and disposes the device array.
 
void DisposeHost ()
 Updates the device information and disposes the Host array.
 

Detailed Description

template<class Type>
class GPUMLib::CudaArray< Type >

Create an array of any type, that automatically manages the memory used to hold its elements (data will be stored both on the host and on the device).

Attention
The data on the host might differ from the data on the device. Use UpdateDevice and UpdateHost to syncronize data.

Definition at line 29 of file BaseArray.h.

Constructor & Destructor Documentation

CudaArray ( int  size)
inlineexplicit

Constructs an array with size elements

Parameters
sizenumber of elements of the array

Definition at line 48 of file CudaArray.h.

CudaArray ( const DeviceArray< Type > &  originalArray)
inline

Constructs an array with the same elements as another array

Parameters
originalArrayoriginal device array from where to copy the elements

Definition at line 52 of file CudaArray.h.

CudaArray ( const HostArray< Type > &  originalArray)
inline

Constructs an array with the same elements as another array

Parameters
originalArrayoriginal array from where to copy the elements

Definition at line 56 of file CudaArray.h.

CudaArray ( CudaArray< Type > &&  temporaryArray)
inline

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

Parameters
temporaryArraytemporary array containing the elements

Definition at line 60 of file CudaArray.h.

Member Function Documentation

Type* DevicePointer ( ) const
inline

Gets a pointer to the array data

Attention
Use with caution
Returns
a pointer to the array data

Definition at line 136 of file CudaArray.h.

DeviceArray<Type>& GetDeviceArray ( )
inline

Gets the device array

Attention
Use with caution
Returns
The device array

Definition at line 163 of file CudaArray.h.

HostArray<Type>& GetHostArray ( )
inline

Gets the device array

Attention
Use with caution
Returns
The device array

Definition at line 170 of file CudaArray.h.

Type* HostPointer ( ) const
inline

Gets a pointer to the host array data

Attention
Use with caution
Returns
a pointer to the host array data

Definition at line 129 of file CudaArray.h.

int Length ( ) const
inline

Gets the lenght of the array

Returns
the number of elements of the array

Definition at line 122 of file CudaArray.h.

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

Transforms this array into an array identical to another array

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

Definition at line 67 of file CudaArray.h.

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

Transforms this array into an array identical to another array

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

Definition at line 77 of file CudaArray.h.

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

Transforms this array into an array identical to another array

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

Definition at line 87 of file CudaArray.h.

CudaArray<Type>& operator= ( const CudaArray< Type > &&  temporaryArray)
inline

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

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

Definition at line 97 of file CudaArray.h.

Type& operator[] ( int  element)
inline

Gets a reference to an element of the host array

Parameters
elementposition of the desired element
Returns
a reference to an element desired

Definition at line 109 of file CudaArray.h.

Type operator[] ( int  element) const
inline

Gets an element of the host array

Parameters
elementposition of the desired element
Returns
the element desired

Definition at line 116 of file CudaArray.h.

int ResizeWithoutPreservingData ( int  size)
inline

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 143 of file CudaArray.h.


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