PSCF v1.5.0
Pscf::RField< D, CUT > Class Template Reference

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

#include <RField.h>

Inheritance diagram for Pscf::RField< D, CUT >:
Pscf::BackendArray< cudaReal, CUT >

Public Member Functions

 RField ()
 Default constructor.
 RField (IntVec< D > const &meshDimensions)
 Allocating constructor.
 RField (RField< D, CUT > const &other)
 Copy constructor.
virtual ~RField ()
 Destructor.
void allocate (IntVec< D > const &meshDimensions)
 Allocate the underlying array for data on a regular mesh.
void deallocate ()
 Deallocate the underlying array.
void associate (BackendArray< cudaReal, CUT > &arr, int beginId, IntVec< D > const &meshDimensions)
 Associate this object with a slice of another BackendArray.
RField< D, CUT > & operator= (RField< D, CUT > const &other)
 Assignment operator, assignment from another RField.
RField< D, CUT > & operator= (HostSendArray< cudaReal, CUT > const &other)
 Assignment from a HostSendArray<cudaReal,CUT>.
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.

Detailed Description

template<int D>
class Pscf::RField< D, CUT >

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

Constructor & Destructor Documentation

◆ RField() [1/3]

template<int D>
Pscf::RField< D, CUT >::RField ( )

Default constructor.

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

References RField().

Referenced by allocate(), associate(), deallocate(), meshDimensions(), operator=(), operator=(), RField(), RField(), RField(), serialize(), and ~RField().

◆ RField() [2/3]

template<int D>
Pscf::RField< D, CUT >::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 30 of file cuda/RField.tpp.

References allocate(), meshDimensions(), and RField().

◆ RField() [3/3]

template<int D>
Pscf::RField< D, CUT >::RField ( RField< D, CUT > const & other)

Copy constructor.

Allocates new memory and copies all elements by value.

Parameters
otherthe RField to be copied.

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

References RField().

◆ ~RField()

template<int D>
Pscf::RField< D, CUT >::~RField ( )
virtual

Destructor.

Deletes underlying C array, if allocated previously.

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

References RField().

Member Function Documentation

◆ allocate()

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

Allocate the underlying 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 54 of file cuda/RField.tpp.

References meshDimensions(), RField(), and UTIL_CHECK.

Referenced by RField(), and serialize().

◆ deallocate()

template<int D>
void Pscf::RField< D, CUT >::deallocate ( )

Deallocate the underlying array.

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

References RField().

◆ associate()

template<int D>
void Pscf::RField< D, CUT >::associate ( BackendArray< cudaReal, CUT > & arr,
int beginId,
IntVec< D > const & meshDimensions )

Associate this object with a slice of another BackendArray.

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 81 of file cuda/RField.tpp.

References meshDimensions(), RField(), and UTIL_CHECK.

◆ operator=() [1/2]

template<int D>
RField< D, CUT > & Pscf::RField< D, CUT >::operator= ( RField< D, CUT > const & other)

Assignment operator, assignment from another RField.

Performs a deep copy, by copying all elements of the RHS RField from device memory to device memory, and copying the meshDimensions.

The RHS RField 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 99 of file cuda/RField.tpp.

References RField().

◆ operator=() [2/2]

template<int D>
RField< D, CUT > & Pscf::RField< D, CUT >::operator= ( HostSendArray< cudaReal, CUT > const & other)

Assignment from a HostSendArray<cudaReal,CUT>.

Performs a deep copy, by copying all elements of the RHS RField from host memory to device memory.

The RHS HostSendArray<cudaReal,CUT> and LHS RField must both be allocated with equal capacity values on entry.

Parameters
otherthe RHS HostSendArray<cudaReal,CUT>

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

References RField(), and UTIL_CHECK.

◆ meshDimensions()

template<int D>
IntVec< D > const & Pscf::RField< D, CUT >::meshDimensions ( ) const
inline

Return mesh dimensions by constant reference.

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

References RField().

Referenced by allocate(), associate(), and RField().

◆ serialize()

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

Serialize a Field to/from an Archive.

Parameters
ararchive
versionarchive version id

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

References allocate(), RField(), and UTIL_THROW.


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