Open Qmin  0.8.0
GPU-accelerated Q-tensor-based liquid crystal simulations
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | Friends | List of all members
GPUArray< T > Class Template Reference

A class for handling data simultaneously on the CPU and GPU. More...

#include <gpuarray.h>

Collaboration diagram for GPUArray< T >:
Collaboration graph
[legend]

Public Member Functions

 GPUArray (bool neverGPU=false, bool _register=false)
 
 GPUArray (unsigned int num_elements, bool neverGPU=false, bool _register=false)
 The most common constructor takes in the desired size of the array. More...
 
virtual ~GPUArray ()
 
 GPUArray (const GPUArray &from)
 
GPUArrayoperator= (const GPUArray &rhs)
 
void swap (GPUArray &from)
 Swap two GPUarrays efficiently. More...
 
unsigned int getNumElements () const
 Get the size of the array. More...
 
void setRegistered (bool _reg)
 Switch from simple memcpys to HostRegister pinned memory copies. Not currently fully functional. More...
 
virtual void resize (unsigned int num_elements)
 Resize the array...performs operations on both the CPU and GPU. More...
 

Public Attributes

data_location::Enum Data_location
 Tracks the current location of the data. More...
 
bool noGPU
 

Protected Member Functions

void memclear (unsigned int first=0)
 
T * acquire (const access_location::Enum location, const access_mode::Enum mode) const
 
void release () const
 

Protected Attributes

T * d_data
 pointer to memory on device More...
 
T * h_data
 pointer to memory on host More...
 

Private Member Functions

void allocate ()
 
void deallocate ()
 
void memcpyDeviceToHost () const
 
void memcpyHostToDevice () const
 
T * resizeHostArray (unsigned int num_elements)
 
T * resizeDeviceArray (unsigned int num_elements)
 

Private Attributes

unsigned int Num_elements
 Number of elements. More...
 
bool Acquired
 Tracks whether the data has been acquired. More...
 
bool RegisterArray
 Tracks whether the data has been acquired. More...
 

Friends

class ArrayHandle< T >
 

Detailed Description

template<class T>
class GPUArray< T >

A class for handling data simultaneously on the CPU and GPU.

This class and accessor are based on GPUArray.h, from the HOOMD-Blue simulation package. It is, however, simplified. It takes care of cuda memory copying for templated arrays. A flag (default to false) when declaring a GPUArray controls whether the memory is HostRegistered but only handles synchronous copy operatations (no Asynch, no HostRegister, etc.) It is also only for 1D arrays of data. Importantly, the user accesses and handles data through the ArrayHandle class.

Constructor & Destructor Documentation

◆ GPUArray() [1/3]

template<class T >
GPUArray< T >::GPUArray ( bool  neverGPU = false,
bool  _register = false 
)

◆ GPUArray() [2/3]

template<class T >
GPUArray< T >::GPUArray ( unsigned int  num_elements,
bool  neverGPU = false,
bool  _register = false 
)

The most common constructor takes in the desired size of the array.

◆ ~GPUArray()

template<class T >
GPUArray< T >::~GPUArray ( )
virtual

◆ GPUArray() [3/3]

template<class T >
GPUArray< T >::GPUArray ( const GPUArray< T > &  from)

Member Function Documentation

◆ operator=()

template<class T >
GPUArray< T > & GPUArray< T >::operator= ( const GPUArray< T > &  rhs)

◆ swap()

template<class T >
void GPUArray< T >::swap ( GPUArray< T > &  from)
inline

Swap two GPUarrays efficiently.

a.swap(b) is: GPUArray c(a); a = b; b = c; It just swaps internal pointers

◆ getNumElements()

template<class T>
unsigned int GPUArray< T >::getNumElements ( ) const
inline

◆ setRegistered()

template<class T>
void GPUArray< T >::setRegistered ( bool  _reg)
inline

Switch from simple memcpys to HostRegister pinned memory copies. Not currently fully functional.

◆ resize()

template<class T >
void GPUArray< T >::resize ( unsigned int  num_elements)
virtual

◆ memclear()

template<class T >
void GPUArray< T >::memclear ( unsigned int  first = 0)
inlineprotected

◆ acquire()

template<class T >
T * GPUArray< T >::acquire ( const access_location::Enum  location,
const access_mode::Enum  mode 
) const
inlineprotected

Acquire does all the work, keeping track of when data needs to be copied, etc. It is called by the ArrayHandle class

◆ release()

template<class T>
void GPUArray< T >::release ( ) const
inlineprotected

◆ allocate()

template<class T >
void GPUArray< T >::allocate ( )
inlineprivate

◆ deallocate()

template<class T >
void GPUArray< T >::deallocate ( )
inlineprivate

◆ memcpyDeviceToHost()

template<class T >
void GPUArray< T >::memcpyDeviceToHost ( ) const
inlineprivate

◆ memcpyHostToDevice()

template<class T >
void GPUArray< T >::memcpyHostToDevice ( ) const
inlineprivate

◆ resizeHostArray()

template<class T >
T * GPUArray< T >::resizeHostArray ( unsigned int  num_elements)
inlineprivate

◆ resizeDeviceArray()

template<class T >
T * GPUArray< T >::resizeDeviceArray ( unsigned int  num_elements)
inlineprivate

Friends And Related Function Documentation

◆ ArrayHandle< T >

template<class T>
friend class ArrayHandle< T >
friend

Member Data Documentation

◆ Data_location

template<class T>
data_location::Enum GPUArray< T >::Data_location
mutable

Tracks the current location of the data.

Referenced by GPUArray< curandState >::swap().

◆ noGPU

template<class T>
bool GPUArray< T >::noGPU

◆ Num_elements

template<class T>
unsigned int GPUArray< T >::Num_elements
mutableprivate

◆ Acquired

template<class T>
bool GPUArray< T >::Acquired
mutableprivate

Tracks whether the data has been acquired.

Referenced by GPUArray< curandState >::release(), and GPUArray< curandState >::swap().

◆ RegisterArray

template<class T>
bool GPUArray< T >::RegisterArray
private

◆ d_data

template<class T>
T* GPUArray< T >::d_data
mutableprotected

pointer to memory on device

Referenced by GPUArray< curandState >::swap().

◆ h_data

template<class T>
T* GPUArray< T >::h_data
mutableprotected

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