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

Discrete Fourier Transform (DFT) of a real field, allocated on a GPU. More...

#include <RFieldDft.h>

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

Public Member Functions

 RFieldDft ()
 Default constructor.
 RFieldDft (IntVec< D > const &meshDimensions)
 Allocating constructor.
 RFieldDft (RFieldDft< D > const &other)
 Copy constructor.
virtual ~RFieldDft ()
 Destructor.
RFieldDft< D > & operator= (RFieldDft< D > const &other)
 Assignment operator, assignment from another RFieldDft<D>.
RFieldDft< 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 an FFT grid.
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 vector of real-space mesh dimensions by constant reference.
IntVec< D > const & dftDimensions () const
 Return vector of dft (Fourier) grid dimensions by const 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::RFieldDft< D >

Discrete Fourier Transform (DFT) of a real field, allocated on a GPU.

The DFT is stored internally as a C array of cudaComplex elements located in global GPU memory. All member functions are C++ functions that can be called from the host CPU.

Definition at line 33 of file cuda/RFieldDft.h.

Constructor & Destructor Documentation

◆ RFieldDft() [1/3]

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

Default constructor.

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

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

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

◆ RFieldDft() [2/3]

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

Allocating constructor.

Calls allocate(meshDimensions) internally.

Parameters
meshDimensionsdimensions of asssociated r-grid mesh

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

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

◆ RFieldDft() [3/3]

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

Copy constructor.

Allocates new memory and copies all elements by value.

Parameters
otherthe RFieldDft to be copied.

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

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

◆ ~RFieldDft()

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

Destructor.

Deletes underlying C array, if allocated previously.

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

Member Function Documentation

◆ operator=() [1/2]

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

Assignment operator, assignment from another RFieldDft<D>.

If this Field is not allocated, allocates and copies all elements.

If this and the other Field are both allocated, the capacities must be exactly equal. If so, this method copies all elements.

Parameters
otherthe RHS Field

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

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

◆ operator=() [2/2]

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

Assignment operator, assignment from a HostDArray<cudaComplex>.

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

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

Parameters
otherthe RHS HostDArray<cudaComplex>

Definition at line 75 of file cuda/RFieldDft.tpp.

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

◆ allocate()

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

Allocate the underlying C array for an FFT grid.

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

Definition at line 98 of file cuda/RFieldDft.tpp.

References Pscf::DeviceArray< Data >::allocate(), Pscf::Prdc::Cuda::FFT< D >::computeKMesh(), meshDimensions(), and UTIL_CHECK.

Referenced by RFieldDft(), and serialize().

◆ associate()

template<int D>
void Pscf::Prdc::Cuda::RFieldDft< 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 118 of file cuda/RFieldDft.tpp.

References Pscf::DeviceArray< Data >::associate(), Pscf::Prdc::Cuda::FFT< D >::computeKMesh(), Pscf::DeviceArray< cudaComplex >::DeviceArray(), meshDimensions(), and UTIL_CHECK.

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

◆ meshDimensions()

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

◆ dftDimensions()

template<int D>
const IntVec< D > & Pscf::Prdc::Cuda::RFieldDft< D >::dftDimensions ( ) const
inline

Return vector of dft (Fourier) grid dimensions by const reference.

The last element of dftDimensions() and meshDimensions() differ by about a factor of two: dftDimensions()[D-1] = meshDimensions()/2 + 1. For D > 1, other elements are equal.

Definition at line 170 of file cuda/RFieldDft.h.

Referenced by Pscf::Rpg::FieldIo< D >::convertBasisToKGrid(), Pscf::Rpg::FieldIo< D >::convertKGridToBasis(), and Pscf::Rpg::FieldIo< D >::hasSymmetry().

◆ serialize()

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

Serialize a Field to/from an Archive.

Parameters
ararchive
versionarchive version id

Definition at line 178 of file cuda/RFieldDft.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: