PSCF v1.2
|
Dynamic array on the GPU device with aligned data. More...
#include <DeviceArray.h>
Public Types | |
typedef Data | ElementType |
Data type of each element. | |
Public Member Functions | |
DeviceArray () | |
Default constructor. | |
DeviceArray (int capacity) | |
Allocating constructor. | |
DeviceArray (DeviceArray< Data > const &other) | |
Copy constructor. | |
virtual | ~DeviceArray () |
Destructor. | |
void | allocate (int capacity) |
Allocate the underlying C array on the device. | |
void | associate (DeviceArray< Data > &arr, int beginId, int capacity) |
Associate this object with a slice of a different DeviceArray. | |
void | deallocate () |
Dellocate the underlying C array. | |
void | dissociate () |
Dissociate this object from the associated array. | |
virtual DeviceArray< Data > & | operator= (const DeviceArray< Data > &other) |
Assignment operator, assign from another DeviceArray<Data> array. | |
virtual DeviceArray< Data > & | operator= (const HostDArray< Data > &other) |
Assignment operator, assignment from HostDArray<Data> host array. | |
int | capacity () const |
Return allocated capacity. | |
bool | isAllocated () const |
Return true if the array has been allocated, false otherwise. | |
bool | isOwner () const |
Does this object own the underlying data? | |
Data * | cArray () |
Return pointer to underlying C array. | |
Data const * | cArray () const |
Return const pointer to underlying C array. | |
Protected Attributes | |
Data * | dataPtr_ |
Pointer to a C array of Data elements on the GPU device. | |
int | capacity_ |
Allocated size (capacity) of the array. | |
DeviceArray< Data > const * | ownerPtr_ |
Pointer to array that owns this data, if isOwner_ == false. | |
int | ownerCapacity_ |
Capacity of parent array, if isOwner_ == false. | |
Data const * | ownerDataPtr_ |
Const pointer to parent array, if isOwner_ == false. | |
Dynamic array on the GPU device with aligned data.
This class wraps an aligned C array with elements of type Data that is allocated in GPU device global memory. All member functions may be called from the CPU host, but this class does not offer access to individual elements via the subscript operator, operator[].
A DeviceArray can have one of two different relationships with its underlying data. In case 1, the data are owned by this object, so the allocation and destruction of the C array are performed by this object. In case 2, this object is instead "associated" with a slice of an array owned by a different DeviceArray. If this is the case, this object is not responsible for allocation or destruction of the underlying C array, and merely acts as a reference to the slice of the other array to which it is associated.
Definition at line 32 of file rpg/System.h.
Data Pscf::DeviceArray< Data >::ElementType |
Data type of each element.
Definition at line 50 of file DeviceArray.h.
Pscf::DeviceArray< Data >::DeviceArray | ( | ) |
Default constructor.
Definition at line 210 of file DeviceArray.h.
Pscf::DeviceArray< Data >::DeviceArray | ( | int | capacity | ) |
Allocating constructor.
This function calls allocate(capacity) internally.
capacity | number of elements to allocate |
Definition at line 222 of file DeviceArray.h.
References Pscf::DeviceArray< Data >::allocate(), and Pscf::DeviceArray< Data >::capacity().
Pscf::DeviceArray< Data >::DeviceArray | ( | DeviceArray< Data > const & | other | ) |
Copy constructor.
other | DeviceArray<Data> to be copied (input) |
Definition at line 236 of file DeviceArray.h.
References UTIL_THROW.
|
virtual |
Destructor.
Deletes underlying C array, if allocated previously.
Definition at line 252 of file DeviceArray.h.
void Pscf::DeviceArray< Data >::allocate | ( | int | capacity | ) |
Allocate the underlying C array on the device.
Exception | if the array is already allocated. |
capacity | number of elements to allocate. |
Definition at line 264 of file DeviceArray.h.
References UTIL_THROW.
Referenced by Pscf::DeviceArray< Data >::DeviceArray(), Pscf::Prdc::Cuda::Reduce::innerProduct(), Pscf::Prdc::Cuda::Reduce::max(), Pscf::Prdc::Cuda::Reduce::maxAbs(), Pscf::Prdc::Cuda::Reduce::min(), Pscf::Prdc::Cuda::Reduce::minAbs(), and Pscf::Prdc::Cuda::Reduce::sum().
void Pscf::DeviceArray< Data >::associate | ( | DeviceArray< Data > & | arr, |
int | beginId, | ||
int | capacity ) |
Associate this object with a slice of a different DeviceArray.
Exception | if the array is already allocated. |
arr | parent array that owns the data |
beginId | index in the parent array at which this array starts |
capacity | number of elements to allocate |
Definition at line 285 of file DeviceArray.h.
References UTIL_CHECK, and UTIL_THROW.
Referenced by Pscf::Prdc::Cuda::CField< D >::associate(), Pscf::Prdc::Cuda::RField< D >::associate(), and Pscf::Prdc::Cuda::RFieldDft< D >::associate().
void Pscf::DeviceArray< Data >::deallocate | ( | ) |
Dellocate the underlying C array.
Exception | if the array is not allocated. |
Exception | if this object does not own the array. |
Definition at line 311 of file DeviceArray.h.
References UTIL_THROW.
Referenced by Pscf::Prdc::Cuda::Reduce::innerProduct(), Pscf::Prdc::Cuda::Reduce::max(), Pscf::Prdc::Cuda::Reduce::maxAbs(), Pscf::Prdc::Cuda::Reduce::min(), Pscf::Prdc::Cuda::Reduce::minAbs(), and Pscf::Prdc::Cuda::Reduce::sum().
void Pscf::DeviceArray< Data >::dissociate | ( | ) |
Dissociate this object from the associated array.
Exception | if this object is not associated with an array. |
Definition at line 330 of file DeviceArray.h.
References UTIL_THROW.
|
virtual |
Assignment operator, assign from another DeviceArray<Data> array.
Performs a deep copy, by copying values of all elements from device memory to device memory.
This function will allocate memory if this (LHS) array is not allocated. If this is allocated, it must have the same dimensions as the RHS DeviceArray<Data>.
other | DeviceArray<Data> on rhs of assignent (input) |
Definition at line 350 of file DeviceArray.h.
References UTIL_THROW.
Referenced by Pscf::Prdc::Cuda::CField< D >::operator=(), Pscf::Prdc::Cuda::RField< D >::operator=(), and Pscf::Prdc::Cuda::RFieldDft< D >::operator=().
|
virtual |
Assignment operator, assignment from HostDArray<Data> host array.
Performs a deep copy from a RHS HostDArray<Data> host array to this LHS DeviceArray<Data> device array, by copying underlying C array from host memory to device memory.
This function will allocate memory if this (LHS) DeviceArray<Data> is not allocated. If this is allocated, it must have the same dimensions as the RHS HostDArray<Data>.
other | HostDArray<Data> on RHS of assignent (input) |
Definition at line 383 of file DeviceArray.h.
References Util::Array< Data >::capacity(), Util::Array< Data >::cArray(), Util::DArray< T >::isAllocated(), and UTIL_THROW.
|
inline |
Return allocated capacity.
Definition at line 460 of file DeviceArray.h.
Referenced by Pscf::Rpg::addEqMulVVc(), Pscf::Prdc::Cuda::VecOp::addEqS(), Pscf::Prdc::Cuda::VecOp::addEqS(), Pscf::Prdc::Cuda::VecOp::addEqS(), Pscf::Prdc::Cuda::VecOp::addEqS(), Pscf::Prdc::Cuda::VecOp::addEqS(), Pscf::Prdc::Cuda::VecOp::addEqS(), Pscf::Prdc::Cuda::VecOp::addEqV(), Pscf::Prdc::Cuda::VecOp::addEqV(), Pscf::Prdc::Cuda::VecOp::addEqV(), Pscf::Prdc::Cuda::VecOp::addEqV(), Pscf::Prdc::Cuda::VecOp::addEqV(), Pscf::Prdc::Cuda::VecOp::addEqV(), Pscf::Prdc::Cuda::VecOp::addEqVc(), Pscf::Prdc::Cuda::VecOp::addVcVc(), Pscf::Prdc::Cuda::VecOp::addVcVcVc(), Pscf::Prdc::Cuda::VecOp::addVS(), Pscf::Prdc::Cuda::VecOp::addVS(), Pscf::Prdc::Cuda::VecOp::addVS(), Pscf::Prdc::Cuda::VecOp::addVS(), Pscf::Prdc::Cuda::VecOp::addVS(), Pscf::Prdc::Cuda::VecOp::addVS(), Pscf::Prdc::Cuda::VecOp::addVS(), Pscf::Prdc::Cuda::VecOp::addVS(), Pscf::Prdc::Cuda::VecOp::addVV(), Pscf::Prdc::Cuda::VecOp::addVV(), Pscf::Prdc::Cuda::VecOp::addVV(), Pscf::Prdc::Cuda::VecOp::addVV(), Pscf::Prdc::Cuda::VecOp::addVV(), Pscf::Prdc::Cuda::VecOp::addVV(), Pscf::Prdc::Cuda::VecOp::addVV(), Pscf::Prdc::Cuda::VecOp::addVV(), Pscf::Rpg::VecOpFts::computeDField(), Pscf::Rpg::WaveList< D >::computedKSq(), Pscf::Rpg::VecOpFts::computeForceBias(), Pscf::HostDArray< Data >::copySlice(), Pscf::DeviceArray< Data >::DeviceArray(), Pscf::Prdc::Cuda::VecOp::divEqS(), Pscf::Prdc::Cuda::VecOp::divEqS(), Pscf::Prdc::Cuda::VecOp::divEqS(), Pscf::Prdc::Cuda::VecOp::divEqS(), Pscf::Prdc::Cuda::VecOp::divEqV(), Pscf::Prdc::Cuda::VecOp::divEqV(), Pscf::Prdc::Cuda::VecOp::divEqV(), Pscf::Prdc::Cuda::VecOp::divEqV(), Pscf::Prdc::Cuda::VecOp::divEqVc(), Pscf::Prdc::Cuda::VecOp::divVS(), Pscf::Prdc::Cuda::VecOp::divVS(), Pscf::Prdc::Cuda::VecOp::divVS(), Pscf::Prdc::Cuda::VecOp::divVS(), Pscf::Prdc::Cuda::VecOp::divVV(), Pscf::Prdc::Cuda::VecOp::divVV(), Pscf::Prdc::Cuda::VecOp::divVV(), Pscf::Prdc::Cuda::VecOp::divVV(), Pscf::Prdc::Cuda::VecOp::eqS(), Pscf::Prdc::Cuda::VecOp::eqS(), Pscf::Prdc::Cuda::VecOp::eqS(), Pscf::Prdc::Cuda::VecOp::eqS(), Pscf::Prdc::Cuda::VecOp::eqV(), Pscf::Prdc::Cuda::VecOp::eqV(), Pscf::Prdc::Cuda::VecOp::eqV(), Pscf::Prdc::Cuda::VecOp::eqV(), Pscf::Prdc::Cuda::VecOp::eqVPair(), Pscf::Prdc::Cuda::VecOp::expV(), Pscf::Prdc::Cuda::VecOp::expV(), Pscf::Prdc::Cuda::VecOp::expV(), Pscf::Prdc::Cuda::VecOp::expV(), Pscf::Prdc::Cuda::VecOp::expVc(), Pscf::Prdc::Cuda::FFTBatched< D >::forwardTransform(), Pscf::Rpg::VecOpFts::fourierMove(), Pscf::Prdc::Cuda::Reduce::innerProduct(), Pscf::Prdc::Cuda::FFTBatched< D >::inverseTransformUnsafe(), Pscf::Prdc::Cuda::Reduce::max(), Pscf::Prdc::Cuda::Reduce::maxAbs(), Pscf::Rpg::VecOpFts::mcftsScale(), Pscf::Prdc::Cuda::Reduce::min(), Pscf::Prdc::Cuda::Reduce::minAbs(), Pscf::Prdc::Cuda::VecOp::mulEqS(), Pscf::Prdc::Cuda::VecOp::mulEqS(), Pscf::Prdc::Cuda::VecOp::mulEqS(), Pscf::Prdc::Cuda::VecOp::mulEqS(), Pscf::Prdc::Cuda::VecOp::mulEqS(), Pscf::Prdc::Cuda::VecOp::mulEqS(), Pscf::Prdc::Cuda::VecOp::mulEqV(), Pscf::Prdc::Cuda::VecOp::mulEqV(), Pscf::Prdc::Cuda::VecOp::mulEqV(), Pscf::Prdc::Cuda::VecOp::mulEqV(), Pscf::Prdc::Cuda::VecOp::mulEqV(), Pscf::Prdc::Cuda::VecOp::mulEqV(), Pscf::Prdc::Cuda::VecOp::mulEqVPair(), Pscf::Prdc::Cuda::VecOp::mulVS(), Pscf::Prdc::Cuda::VecOp::mulVS(), Pscf::Prdc::Cuda::VecOp::mulVS(), Pscf::Prdc::Cuda::VecOp::mulVS(), Pscf::Prdc::Cuda::VecOp::mulVS(), Pscf::Prdc::Cuda::VecOp::mulVS(), Pscf::Prdc::Cuda::VecOp::mulVS(), Pscf::Prdc::Cuda::VecOp::mulVS(), Pscf::Prdc::Cuda::VecOp::mulVV(), Pscf::Prdc::Cuda::VecOp::mulVV(), Pscf::Prdc::Cuda::VecOp::mulVV(), Pscf::Prdc::Cuda::VecOp::mulVV(), Pscf::Prdc::Cuda::VecOp::mulVV(), Pscf::Prdc::Cuda::VecOp::mulVV(), Pscf::Prdc::Cuda::VecOp::mulVV(), Pscf::Prdc::Cuda::VecOp::mulVV(), Pscf::Prdc::Cuda::VecOp::mulVVPair(), Pscf::CudaRandom::normal(), Pscf::CudaRandom::normal(), Pscf::HostDArray< Data >::operator=(), Pscf::Rpg::realMulVConjVV(), Pscf::Rpg::richardsonEx(), Pscf::Rpg::WFieldContainer< D >::setRGrid(), Pscf::Prdc::Cuda::VecOp::sqNormV(), Pscf::Prdc::Cuda::VecOp::sqSqNormV(), Pscf::Prdc::Cuda::VecOp::subEqS(), Pscf::Prdc::Cuda::VecOp::subEqS(), Pscf::Prdc::Cuda::VecOp::subEqS(), Pscf::Prdc::Cuda::VecOp::subEqS(), Pscf::Prdc::Cuda::VecOp::subEqS(), Pscf::Prdc::Cuda::VecOp::subEqS(), Pscf::Prdc::Cuda::VecOp::subEqV(), Pscf::Prdc::Cuda::VecOp::subEqV(), Pscf::Prdc::Cuda::VecOp::subEqV(), Pscf::Prdc::Cuda::VecOp::subEqV(), Pscf::Prdc::Cuda::VecOp::subEqV(), Pscf::Prdc::Cuda::VecOp::subEqV(), Pscf::Prdc::Cuda::VecOp::subVS(), Pscf::Prdc::Cuda::VecOp::subVS(), Pscf::Prdc::Cuda::VecOp::subVS(), Pscf::Prdc::Cuda::VecOp::subVS(), Pscf::Prdc::Cuda::VecOp::subVS(), Pscf::Prdc::Cuda::VecOp::subVS(), Pscf::Prdc::Cuda::VecOp::subVS(), Pscf::Prdc::Cuda::VecOp::subVS(), Pscf::Prdc::Cuda::VecOp::subVV(), Pscf::Prdc::Cuda::VecOp::subVV(), Pscf::Prdc::Cuda::VecOp::subVV(), Pscf::Prdc::Cuda::VecOp::subVV(), Pscf::Prdc::Cuda::VecOp::subVV(), Pscf::Prdc::Cuda::VecOp::subVV(), Pscf::Prdc::Cuda::VecOp::subVV(), Pscf::Prdc::Cuda::VecOp::subVV(), Pscf::Prdc::Cuda::VecOp::subVVS(), Pscf::Prdc::Cuda::Reduce::sum(), Pscf::CudaRandom::uniform(), and Pscf::CudaRandom::uniform().
bool Pscf::DeviceArray< Data >::isAllocated | ( | ) | const |
Return true if the array has been allocated, false otherwise.
Definition at line 444 of file DeviceArray.h.
References UTIL_CHECK.
Referenced by Pscf::HostDArray< Data >::copySlice(), Pscf::Prdc::Cuda::Reduce::innerProduct(), Pscf::Prdc::Cuda::Reduce::max(), Pscf::Prdc::Cuda::Reduce::maxAbs(), Pscf::Prdc::Cuda::Reduce::min(), Pscf::Prdc::Cuda::Reduce::minAbs(), Pscf::HostDArray< Data >::operator=(), and Pscf::Prdc::Cuda::Reduce::sum().
|
inline |
Does this object own the underlying data?
Definition at line 467 of file DeviceArray.h.
Data * Pscf::DeviceArray< Data >::cArray | ( | ) |
Return pointer to underlying C array.
Definition at line 412 of file DeviceArray.h.
References UTIL_CHECK.
Referenced by Pscf::Rpg::addEqMulVVc(), Pscf::Prdc::Cuda::VecOp::addEqS(), Pscf::Prdc::Cuda::VecOp::addEqS(), Pscf::Prdc::Cuda::VecOp::addEqS(), Pscf::Prdc::Cuda::VecOp::addEqV(), Pscf::Prdc::Cuda::VecOp::addEqV(), Pscf::Prdc::Cuda::VecOp::addEqV(), Pscf::Prdc::Cuda::VecOp::addEqVc(), Pscf::Prdc::Cuda::VecOp::addVcVc(), Pscf::Prdc::Cuda::VecOp::addVcVcVc(), Pscf::Prdc::Cuda::VecOp::addVMany(), Pscf::Prdc::Cuda::VecOp::addVMany(), Pscf::Prdc::Cuda::VecOp::addVS(), Pscf::Prdc::Cuda::VecOp::addVS(), Pscf::Prdc::Cuda::VecOp::addVS(), Pscf::Prdc::Cuda::VecOp::addVS(), Pscf::Prdc::Cuda::VecOp::addVV(), Pscf::Prdc::Cuda::VecOp::addVV(), Pscf::Prdc::Cuda::VecOp::addVV(), Pscf::Prdc::Cuda::VecOp::addVV(), Pscf::Rpg::VecOpFts::computeDField(), Pscf::Rpg::WaveList< D >::computedKSq(), Pscf::Rpg::VecOpFts::computeForceBias(), Pscf::Rpg::WaveList< D >::computeKSq(), Pscf::Rpg::WaveList< D >::computeMinimumImages(), Pscf::HostDArray< Data >::copySlice(), Pscf::Prdc::Cuda::VecOp::divEqS(), Pscf::Prdc::Cuda::VecOp::divEqS(), Pscf::Prdc::Cuda::VecOp::divEqV(), Pscf::Prdc::Cuda::VecOp::divEqV(), Pscf::Prdc::Cuda::VecOp::divEqVc(), Pscf::Prdc::Cuda::VecOp::divVS(), Pscf::Prdc::Cuda::VecOp::divVS(), Pscf::Prdc::Cuda::VecOp::divVV(), Pscf::Prdc::Cuda::VecOp::divVV(), Pscf::Prdc::Cuda::VecOp::eqS(), Pscf::Prdc::Cuda::VecOp::eqS(), Pscf::Prdc::Cuda::VecOp::eqV(), Pscf::Prdc::Cuda::VecOp::eqV(), Pscf::Prdc::Cuda::VecOp::eqVPair(), Pscf::Prdc::Cuda::VecOp::expV(), Pscf::Prdc::Cuda::VecOp::expV(), Pscf::Prdc::Cuda::VecOp::expVc(), Pscf::Prdc::Cuda::FFTBatched< D >::forwardTransform(), Pscf::Rpg::VecOpFts::fourierMove(), Pscf::Rpg::ExtGenFilm< D >::generate(), Pscf::Prdc::Cuda::Reduce::innerProduct(), Pscf::Prdc::Cuda::FFTBatched< D >::inverseTransformUnsafe(), Pscf::Prdc::Cuda::Reduce::max(), Pscf::Prdc::Cuda::Reduce::maxAbs(), Pscf::Rpg::VecOpFts::mcftsScale(), Pscf::Prdc::Cuda::Reduce::min(), Pscf::Prdc::Cuda::Reduce::minAbs(), Pscf::Prdc::Cuda::VecOp::mulEqS(), Pscf::Prdc::Cuda::VecOp::mulEqS(), Pscf::Prdc::Cuda::VecOp::mulEqS(), Pscf::Prdc::Cuda::VecOp::mulEqV(), Pscf::Prdc::Cuda::VecOp::mulEqV(), Pscf::Prdc::Cuda::VecOp::mulEqV(), Pscf::Prdc::Cuda::VecOp::mulEqVPair(), Pscf::Prdc::Cuda::VecOp::mulVMany(), Pscf::Prdc::Cuda::VecOp::mulVMany(), Pscf::Prdc::Cuda::VecOp::mulVS(), Pscf::Prdc::Cuda::VecOp::mulVS(), Pscf::Prdc::Cuda::VecOp::mulVS(), Pscf::Prdc::Cuda::VecOp::mulVS(), Pscf::Prdc::Cuda::VecOp::mulVV(), Pscf::Prdc::Cuda::VecOp::mulVV(), Pscf::Prdc::Cuda::VecOp::mulVV(), Pscf::Prdc::Cuda::VecOp::mulVV(), Pscf::Prdc::Cuda::VecOp::mulVVPair(), Pscf::CudaRandom::normal(), Pscf::CudaRandom::normal(), Pscf::HostDArray< Data >::operator=(), Pscf::Rpg::realMulVConjVV(), Pscf::Rpg::richardsonEx(), Pscf::Prdc::Cuda::VecOp::sqNormV(), Pscf::Prdc::Cuda::VecOp::sqSqNormV(), Pscf::Rpg::ExtGenFilm< D >::stressTerm(), Pscf::Prdc::Cuda::VecOp::subEqS(), Pscf::Prdc::Cuda::VecOp::subEqS(), Pscf::Prdc::Cuda::VecOp::subEqS(), Pscf::Prdc::Cuda::VecOp::subEqV(), Pscf::Prdc::Cuda::VecOp::subEqV(), Pscf::Prdc::Cuda::VecOp::subEqV(), Pscf::Prdc::Cuda::VecOp::subVS(), Pscf::Prdc::Cuda::VecOp::subVS(), Pscf::Prdc::Cuda::VecOp::subVS(), Pscf::Prdc::Cuda::VecOp::subVS(), Pscf::Prdc::Cuda::VecOp::subVV(), Pscf::Prdc::Cuda::VecOp::subVV(), Pscf::Prdc::Cuda::VecOp::subVV(), Pscf::Prdc::Cuda::VecOp::subVV(), Pscf::Prdc::Cuda::VecOp::subVVS(), Pscf::Prdc::Cuda::Reduce::sum(), Pscf::CudaRandom::uniform(), and Pscf::CudaRandom::uniform().
const Data * Pscf::DeviceArray< Data >::cArray | ( | ) | const |
Return const pointer to underlying C array.
Definition at line 428 of file DeviceArray.h.
References UTIL_CHECK.
|
protected |
Pointer to a C array of Data elements on the GPU device.
Definition at line 176 of file DeviceArray.h.
|
protected |
Allocated size (capacity) of the array.
Definition at line 179 of file DeviceArray.h.
|
protected |
Pointer to array that owns this data, if isOwner_ == false.
Used to check that parent array has not been deallocated and/or reallocated.
Definition at line 187 of file DeviceArray.h.
|
protected |
Capacity of parent array, if isOwner_ == false.
Used to check that parent array has not been deallocated and/or reallocated.
Definition at line 195 of file DeviceArray.h.
|
protected |
Const pointer to parent array, if isOwner_ == false.
Used to check that parent array has not been deallocated and/or reallocated.
Definition at line 203 of file DeviceArray.h.