PSCF v1.4.0
Pscf::Prdc::Cuda::CField< D > Class Template Reference

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

#include <CField.h>

Inheritance diagram for Pscf::Prdc::Cuda::CField< D >:
Pscf::DeviceArray< cudaComplex >

Public Member Functions

 CField ()
 Default constructor.
 CField (IntVec< D > const &meshDimensions)
 Allocating constructor.
 CField (CField const &other)
 Copy constructor.
virtual ~CField ()
 Destructor.
CField< D > & operator= (CField< D > const &other)
 Assignment operator, assignment from another CField<D>.
CField< D > & operator= (HostDArray< cudaComplex > const &other)
 Assignment operator, assignment from a HostDArray<cudaComplex>.
void allocate (IntVec< D > const &meshDimensions)
 Allocate the underlying C array for data on a regular mesh.
void associate (DeviceArray< cudaComplex > &arr, int beginId, IntVec< D > const &meshDimensions)
 Associate this object with a slice of another DeviceArray.
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< cudaComplex >
 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< cudaComplex > &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< cudaComplex > & operator= (const DeviceArray< cudaComplex > &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?
cudaComplexcArray ()
 Return pointer to underlying C array.

Additional Inherited Members

Public Types inherited from Pscf::DeviceArray< cudaComplex >
typedef cudaComplex ValueType
 Data type of each element.
Protected Attributes inherited from Pscf::DeviceArray< cudaComplex >
cudaComplexdataPtr_
 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::CField< D >

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

Definition at line 30 of file cuda/CField.h.

Constructor & Destructor Documentation

◆ CField() [1/3]

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

Default constructor.

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

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

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

◆ CField() [2/3]

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

Allocating constructor.

Calls allocate(meshDimension) internally.

Parameters
meshDimensionsnumbers of grid points in each dimension

Definition at line 32 of file cuda/CField.tpp.

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

◆ CField() [3/3]

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

Copy constructor.

Allocates new memory and copies all elements by value.

Parameters
otherthe CField to be copied.

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

References CField(), and Pscf::DeviceArray< cudaComplex >::DeviceArray().

◆ ~CField()

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

Destructor.

Deletes underlying C array, if allocated previously.

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

Member Function Documentation

◆ operator=() [1/2]

template<int D>
CField< D > & Pscf::Prdc::Cuda::CField< D >::operator= ( CField< D > const & other)

Assignment operator, assignment from another CField<D>.

Performs a deep copy, by copying all elements of the RHS CField<D> from device memory to device memory.

The RHS CField must be allocated. If this LHS CField is not allocated on entry, allocate it before copying elements. If both LHS and RHS objects are allocated on entry, the capacities must be equal.

Parameters
otherthe RHS CField<D>

Definition at line 58 of file cuda/CField.tpp.

References CField(), and Pscf::DeviceArray< Data >::operator=().

◆ operator=() [2/2]

template<int D>
CField< D > & Pscf::Prdc::Cuda::CField< D >::operator= ( HostDArray< cudaComplex > const & other)

Assignment operator, assignment from a HostDArray<cudaComplex>.

Performs a deep copy, by copying all elements of the RHS CField<D> from host memory to device memory.

The RHS HostDArray<cudaComplex> and LHS CField<D> must both be allocated with equal capacity values on entry.

Parameters
otherthe RHS HostDArray<cudaComplex>

Definition at line 70 of file cuda/CField.tpp.

References Util::Array< Data >::capacity(), Pscf::DeviceArray< cudaComplex >::capacity_, CField(), Pscf::DeviceArray< cudaComplex >::isAllocated(), Util::DArray< Data >::isAllocated(), Pscf::DeviceArray< Data >::operator=(), and UTIL_THROW.

◆ allocate()

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

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

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

Definition at line 93 of file cuda/CField.tpp.

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

Referenced by CField(), and serialize().

◆ associate()

template<int D>
void Pscf::Prdc::Cuda::CField< D >::associate ( DeviceArray< cudaComplex > & 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 108 of file cuda/CField.tpp.

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

◆ meshDimensions()

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

Return mesh dimensions by constant reference.

Definition at line 148 of file cuda/CField.h.

Referenced by allocate(), associate(), CField(), Pscf::Prdc::Cuda::FFT< D >::forwardTransform(), and Pscf::Prdc::Cuda::FFT< D >::inverseTransform().

◆ serialize()

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

Serialize a Field to/from an Archive.

Parameters
ararchive
versionarchive version id

Definition at line 156 of file cuda/CField.h.

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


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