PSCF v1.5.0
Pscf::FFTBatched< D > Class Template Reference

Batched Fourier transform wrapper for real data. More...

#include <FFTBatched.h>

Public Member Functions

 FFTBatched ()
 Default constructor.
virtual ~FFTBatched ()
 Destructor.
void setup (IntVec< D > const &meshDimensions, int batchSize)
 Set up FFT calculation (get grid dimensions and make FFT plan).
void resetBatchSize (int batchSize)
 Set the batch size to a new value.
void forwardTransform (BackendArray< cudaReal, CUT > const &rFields, BackendArray< cudaComplex, CUT > &kFields) const
 Compute batched forward (real-to-complex) DFTs.
void inverseTransformUnsafe (BackendArray< cudaComplex, CUT > &kFields, BackendArray< cudaReal, CUT > &rFields) const
 Compute inverse (complex-to-real) Fourier transform.
const IntVec< D > & meshDimensions () const
 Return the dimensions of the grid for which this was allocated.
bool isSetup () const
 Has the setup method been called?

Detailed Description

template<int D>
class Pscf::FFTBatched< D >

Batched Fourier transform wrapper for real data.

Definition at line 28 of file FFTBatched.h.

Constructor & Destructor Documentation

◆ FFTBatched()

template<int D>
Pscf::FFTBatched< D >::FFTBatched ( )

Default constructor.

Definition at line 64 of file FFTBatched.tpp.

◆ ~FFTBatched()

template<int D>
Pscf::FFTBatched< D >::~FFTBatched ( )
virtual

Destructor.

Definition at line 78 of file FFTBatched.tpp.

Member Function Documentation

◆ setup()

template<int D>
void Pscf::FFTBatched< D >::setup ( IntVec< D > const & meshDimensions,
int batchSize )

Set up FFT calculation (get grid dimensions and make FFT plan).

This function may only be called once, and isSetup() = true after it is called. It sets the grid dimensions, which are immutable thereafter, sets and initial batch size, and makes FFT plans for forward and inverse batched transformations.

Exceptions
Exceptionif isSetup() == false
Parameters
meshDimensionsdimensions of real-space grid
batchSizenumber of simultaneous FFTs to perform

Definition at line 85 of file FFTBatched.tpp.

References meshDimensions(), and UTIL_CHECK.

◆ resetBatchSize()

template<int D>
void Pscf::FFTBatched< D >::resetBatchSize ( int batchSize)

Set the batch size to a new value.

This function must be called after setup.

Exceptions
Exceptionif isSetup() == false
Parameters
batchSizenew batch size.

Definition at line 115 of file FFTBatched.tpp.

References UTIL_CHECK.

◆ forwardTransform()

template<int D>
void Pscf::FFTBatched< D >::forwardTransform ( BackendArray< cudaReal, CUT > const & rFields,
BackendArray< cudaComplex, CUT > & kFields ) const

Compute batched forward (real-to-complex) DFTs.

The resulting complex array is the output of cuFFT's batched forward transform method scaled by a factor of 1/N (where N is the number of grid points). The scaling ensures that a round-trip Fourier transform (forward + inverse) reproduces the original input array.

The number of Fourier transforms performed per batch, known as the batch size, is initialized by the setup() function and may be reset by the resetBatchSize() function.

This transform is inherently "safe", meaning that the input array will not be modified during the DFT.

Parameters
rFieldsreal values on r-grid (input, gpu mem)
kFieldscomplex values on k-grid (output, gpu mem)

Definition at line 128 of file FFTBatched.tpp.

References Pscf::VecOp::mulEqS(), UTIL_CHECK, and UTIL_THROW.

◆ inverseTransformUnsafe()

template<int D>
void Pscf::FFTBatched< D >::inverseTransformUnsafe ( BackendArray< cudaComplex, CUT > & kFields,
BackendArray< cudaReal, CUT > & rFields ) const

Compute inverse (complex-to-real) Fourier transform.

The resulting real array is the unaltered output of cuFFT's inverse transform function.

This transform is inherently "unsafe", meaning that the input array will be overwritten during the DFT. Accordingly, the input array is not const, as it is for safe transform methods.

Parameters
kFieldscomplex values on k-grid (input, gpu mem)
rFieldsreal values on r-grid (output, gpu mem)

Definition at line 163 of file FFTBatched.tpp.

References UTIL_CHECK, and UTIL_THROW.

◆ meshDimensions()

template<int D>
const IntVec< D > & Pscf::FFTBatched< D >::meshDimensions ( ) const
inline

Return the dimensions of the grid for which this was allocated.

Definition at line 164 of file FFTBatched.h.

Referenced by setup().

◆ isSetup()

template<int D>
bool Pscf::FFTBatched< D >::isSetup ( ) const
inline

Has the setup method been called?

Definition at line 169 of file FFTBatched.h.


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