PSCF v1.4.0
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.
virtual ~DeviceArray ()
 Destructor.
void allocate (int capacity)
 Allocate the underlying C array on the device.
void deallocate ()
 Dellocate the underlying C array.
void associate (DeviceArray< cudaReal > &arr, int beginId, int capacity)
 Associate this object with a slice of a different DeviceArray.
void dissociate ()
 Dissociate this object from an externally owned memory block.
void addReference (CountedReference &reference)
 Associate a reference with reference counter for this container.
virtual DeviceArray< cudaReal > & operator= (const DeviceArray< cudaReal > &other)
 Assignment operator, assign from another DeviceArray<Data> array.
int capacity () const
 Return array capacity.
bool isAllocated () const
 Return true if the array has allocated data, false otherwise.
bool isOwner () const
 Does this container own an allocated memory block?
bool isAssociated () const
 Is this container associated with a memory block it does not own?
cudaRealcArray ()
 Return pointer to underlying C array.

Additional Inherited Members

Public Types inherited from Pscf::DeviceArray< cudaReal >
typedef cudaReal ValueType
 Data type of each element.
Protected Attributes inherited from Pscf::DeviceArray< cudaReal >
cudaRealdataPtr_
 Pointer to a C array of Data elements on the GPU device.
int capacity_
 Allocated size (capacity) of the array.
ReferenceCounter refCounter_
 Counter for any arrays that use data owned by this.
CountedReference ref_
 Reference to another array that owns memory used by this one.

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 32 of file cuda/RField.h.

Constructor & Destructor Documentation

◆ RField() [1/3]

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

Default constructor.

Definition at line 24 of file cuda/RField.tpp.

References Pscf::DeviceArray< cudaReal >::DeviceArray().

Referenced by operator=(), operator=(), and RField().

◆ 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 allocate(), Pscf::DeviceArray< cudaReal >::DeviceArray(), and 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.

Definition at line 40 of file cuda/RField.tpp.

References Pscf::DeviceArray< cudaReal >::DeviceArray(), and RField().

◆ ~RField()

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

Destructor.

Deletes underlying C array, if allocated previously.

Definition at line 49 of file cuda/RField.tpp.

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

Definition at line 56 of file cuda/RField.tpp.

References Pscf::DeviceArray< Data >::allocate(), meshDimensions(), and UTIL_CHECK.

Referenced by Pscf::Rpg::FilmFieldGenMask< D >::compute(), RField(), serialize(), and Pscf::Rpg::FilmFieldGenMask< D >::stress().

◆ 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(), Pscf::DeviceArray< cudaReal >::DeviceArray(), meshDimensions(), and UTIL_CHECK.

Referenced by Pscf::Rpg::Block< D >::stepThread().

◆ 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

Definition at line 87 of file cuda/RField.tpp.

References Pscf::DeviceArray< Data >::operator=(), and 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(), Pscf::DeviceArray< cudaReal >::capacity_, Pscf::DeviceArray< cudaReal >::isAllocated(), Util::DArray< Data >::isAllocated(), Pscf::DeviceArray< Data >::operator=(), RField(), and UTIL_THROW.

◆ meshDimensions()

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

Return mesh dimensions by constant reference.

Definition at line 150 of file cuda/RField.h.

Referenced by allocate(), associate(), Pscf::Prdc::Cuda::FFT< D >::inverseTransformUnsafe(), RField(), and Pscf::Rpg::FieldIo< D >::writeFieldRGrid().

◆ 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

Definition at line 158 of file cuda/RField.h.

References allocate(), Pscf::DeviceArray< cudaReal >::capacity(), Pscf::DeviceArray< cudaReal >::capacity_, Pscf::DeviceArray< cudaReal >::isAllocated(), and UTIL_THROW.


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