CellGPU  0.8.0
GPU-accelerated simulations of cells
Public Member Functions | Protected Member Functions | Protected 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>

Public Member Functions

 GPUArray (bool _register=false)
 
 GPUArray (unsigned int num_elements, bool _register=false)
 The most common constructor takes in the desired size of the array.
 
 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.
 
void setRegistered (bool _reg)
 Switch from simple memcpys to HostRegister pinned memory copies. Not currently fully functional.
 
virtual void resize (unsigned int num_elements)
 Resize the array...performs operations on both the CPU and GPU.
 

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 * h_data
 pointer to memory on host
 

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.

Member Function Documentation

◆ 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

Referenced by Simulation::computeForces().

◆ 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


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