PSCF v1.2
|
Field of real values on a regular mesh, allocated on a GPU device. More...
#include <RField.h>
Public Member Functions | |
RField () | |
Default constructor. | |
RField (IntVec< D > const &meshDimensions) | |
Allocating constructor. | |
RField (RField< D > const &other) | |
Copy constructor. | |
virtual | ~RField () |
Destructor. | |
void | allocate (IntVec< D > const &meshDimensions) |
Allocate the underlying C array for data on a regular mesh. | |
void | associate (DeviceArray< cudaReal > &arr, int beginId, IntVec< D > const &meshDimensions) |
Associate this object with a slice of another DeviceArray. | |
RField< D > & | operator= (const RField< D > &other) |
Assignment operator, assignment from another RField<D>. | |
RField< D > & | operator= (const HostDArray< cudaReal > &other) |
Assignment operator, assignment from a HostDArray<cudaReal>. | |
IntVec< D > const & | meshDimensions () const |
Return mesh dimensions by constant reference. | |
template<class Archive > | |
void | serialize (Archive &ar, const unsigned int version) |
Serialize a Field to/from an Archive. | |
![]() | |
DeviceArray () | |
Default constructor. | |
DeviceArray (int capacity) | |
Allocating constructor. | |
DeviceArray (DeviceArray< cudaReal > const &other) | |
Copy constructor. | |
virtual | ~DeviceArray () |
Destructor. | |
void | allocate (int capacity) |
Allocate the underlying C array on the device. | |
void | associate (DeviceArray< cudaReal > &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< cudaReal > & | operator= (const DeviceArray< cudaReal > &other) |
Assignment operator, assign from another DeviceArray<Data> array. | |
virtual DeviceArray< cudaReal > & | operator= (const HostDArray< cudaReal > &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? | |
cudaReal * | cArray () |
Return pointer to underlying C array. | |
cudaReal const * | cArray () const |
Return const pointer to underlying C array. | |
Additional Inherited Members | |
![]() | |
typedef cudaReal | ElementType |
Data type of each element. | |
![]() | |
cudaReal * | dataPtr_ |
Pointer to a C array of Data elements on the GPU device. | |
int | capacity_ |
Allocated size (capacity) of the array. | |
DeviceArray< cudaReal > const * | ownerPtr_ |
Pointer to array that owns this data, if isOwner_ == false. | |
int | ownerCapacity_ |
Capacity of parent array, if isOwner_ == false. | |
cudaReal const * | ownerDataPtr_ |
Const pointer to parent array, if isOwner_ == false. | |
Field of real values on a regular mesh, allocated on a GPU device.
Type cudaReal is float or double, depending on preprocessor macro.
Definition at line 13 of file rpg/fts/perturbation/Perturbation.h.
Pscf::Prdc::Cuda::RField< D >::RField | ( | ) |
Default constructor.
Pscf::Prdc::Cuda::RField< D >::RField | ( | IntVec< D > const & | meshDimensions | ) |
Allocating constructor.
Allocates memory by calling allocate(meshDimensions) internally.
meshDimensions | number of grid points in each dimension |
Definition at line 32 of file cuda/RField.tpp.
References Pscf::Prdc::Cpu::RField< D >::allocate(), and Pscf::Prdc::Cpu::RField< D >::meshDimensions().
Pscf::Prdc::Cuda::RField< D >::RField | ( | RField< D > const & | other | ) |
Copy constructor.
Allocates new memory and copies all elements by value.
other | the RField to be copied. |
|
virtual |
Destructor.
Deletes underlying C array, if allocated previously.
void Pscf::Prdc::Cuda::RField< D >::allocate | ( | IntVec< D > const & | meshDimensions | ) |
Allocate the underlying C array for data on a regular mesh.
Exception | if the RField is already allocated. |
meshDimensions | number of grid points in each dimension |
References Pscf::Prdc::Cuda::RField< D >::associate().
void Pscf::Prdc::Cuda::RField< D >::associate | ( | DeviceArray< cudaReal > & | arr, |
int | beginId, | ||
IntVec< D > const & | meshDimensions ) |
Associate this object with a slice of another 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 |
meshDimensions | number of grid points in each dimension |
Definition at line 71 of file cuda/RField.tpp.
References Pscf::DeviceArray< Data >::associate(), and UTIL_CHECK.
Referenced by Pscf::Prdc::Cuda::RField< D >::allocate().
RField< D > & Pscf::Prdc::Cuda::RField< D >::operator= | ( | const RField< D > & | other | ) |
Assignment operator, assignment from another RField<D>.
Performs a deep copy, by copying all elements of the RHS RField<D> from device memory to device memory, and copying the meshDimensions.
The RHS RField<D> must be allocated on entry. If this LHS object is not allocated, allocate with the required capacity. If the LHS and RHS arrays are both allocated, capacity values must be equal.
other | the RHS RField |
RField< D > & Pscf::Prdc::Cuda::RField< D >::operator= | ( | const HostDArray< cudaReal > & | other | ) |
Assignment operator, assignment from a HostDArray<cudaReal>.
Performs a deep copy, by copying all elements of the RHS RField<D> from host memory to device memory.
The RHS HostDArray<cudaReal> and LHS RField<D> must both be allocated with equal capacity values on entry.
other | the RHS HostDArray<cudaReal> |
Definition at line 99 of file cuda/RField.tpp.
References Util::Array< Data >::capacity(), Util::DArray< T >::isAllocated(), Pscf::DeviceArray< Data >::operator=(), and UTIL_THROW.
IntVec< D > const & Pscf::Prdc::Cuda::RField< D >::meshDimensions | ( | ) | const |
Return mesh dimensions by constant reference.
void Pscf::Prdc::Cuda::RField< D >::serialize | ( | Archive & | ar, |
const unsigned int | version ) |
Serialize a Field to/from an Archive.
ar | archive |
version | archive version id |