Loading [MathJax]/extensions/TeX/AMSsymbols.js
PSCF v1.2
Pscf::Prdc::Cuda::RField< D > Class Template Reference

Field of real values on a regular mesh, allocated on a GPU device. More...

#include <RField.h>

Inheritance diagram for Pscf::Prdc::Cuda::RField< D >:
Pscf::DeviceArray< cudaReal >

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.
 
- Public Member Functions inherited from Pscf::DeviceArray< cudaReal >
 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

- Public Types inherited from Pscf::DeviceArray< cudaReal >
typedef cudaReal ElementType
 Data type of each element.
 
- Protected Attributes inherited from Pscf::DeviceArray< cudaReal >
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.
 

Detailed Description

template<int D>
class Pscf::Prdc::Cuda::RField< D >

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.

Constructor & Destructor Documentation

◆ RField() [1/3]

template<int D>
Pscf::Prdc::Cuda::RField< D >::RField ( )

Default constructor.

◆ RField() [2/3]

template<int D>
Pscf::Prdc::Cuda::RField< D >::RField ( IntVec< D > const & meshDimensions)

Allocating constructor.

Allocates memory by calling allocate(meshDimensions) internally.

Parameters
meshDimensionsnumber 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().

◆ RField() [3/3]

template<int D>
Pscf::Prdc::Cuda::RField< D >::RField ( RField< D > const & other)

Copy constructor.

Allocates new memory and copies all elements by value.

Parameters
otherthe RField to be copied.

◆ ~RField()

template<int D>
virtual Pscf::Prdc::Cuda::RField< D >::~RField ( )
virtual

Destructor.

Deletes underlying C array, if allocated previously.

Member Function Documentation

◆ allocate()

template<int D>
void Pscf::Prdc::Cuda::RField< D >::allocate ( IntVec< D > const & meshDimensions)

Allocate the underlying C array for data on a regular mesh.

Exceptions
Exceptionif the RField is already allocated.
Parameters
meshDimensionsnumber of grid points in each dimension

References Pscf::Prdc::Cuda::RField< D >::associate().

◆ associate()

template<int D>
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.

Exceptions
Exceptionif the array is already allocated.
Parameters
arrparent array that owns the data
beginIdindex in the parent array at which this array starts
meshDimensionsnumber 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().

◆ operator=() [1/2]

template<int D>
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.

Parameters
otherthe RHS RField

◆ operator=() [2/2]

template<int D>
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.

Parameters
otherthe 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.

◆ meshDimensions()

template<int D>
IntVec< D > const & Pscf::Prdc::Cuda::RField< D >::meshDimensions ( ) const

Return mesh dimensions by constant reference.

◆ serialize()

template<int D>
template<class Archive >
void Pscf::Prdc::Cuda::RField< D >::serialize ( Archive & ar,
const unsigned int version )

Serialize a Field to/from an Archive.

Parameters
ararchive
versionarchive version id

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