Block-Structured AMR Software Framework
Loading...
Searching...
No Matches
amrex::FFT::Plan< T > Struct Template Reference

#include <AMReX_FFT_Helper.H>

Public Types

using VendorPlan = cufftHandle
 
using VendorComplex = std::conditional_t< std::is_same_v< float, T >, cuComplex, cuDoubleComplex >
 

Public Member Functions

void set_ptrs (void *p0, void *p1)
 Register device pointers used by the forward/backward executions.
 
void destroy ()
 Release any vendor FFT plan objects owned by this Plan.
 
template<Direction D>
void init_r2c (Box const &box, T *pr, VendorComplex *pc, bool is_2d_transform=false, int ncomp=1)
 Initialize a 1-D or 2-D real-to-complex plan over the supplied Box.
 
template<Direction D, int M>
void init_r2c (IntVectND< M > const &fft_size, void *pbf, void *pbb, bool cache, int ncomp=1)
 Initialize an M-dimensional batched real-to-complex plan.
 
template<Direction D>
void init_c2c (Box const &box, VendorComplex *p, int ncomp=1, int ndims=1)
 Initialize a complex-to-complex plan across 1/2/3 dimensions.
 
template<Direction D>
Kind get_r2r_kind (std::pair< Boundary, Boundary > const &bc)
 Map boundary conditions to the Plan Kind for real-to-real transforms.
 
template<Direction D>
void init_r2r (Box const &box, T *p, std::pair< Boundary, Boundary > const &bc, int howmany_initval=1)
 Initialize a real-to-real (cosine/sine) plan that operates on real buffers.
 
template<Direction D>
void init_r2r (Box const &box, VendorComplex *pc, std::pair< Boundary, Boundary > const &bc)
 Initialize a real-to-real plan that reads/writes complex storage.
 
template<Direction D>
void compute_r2c ()
 Execute the previously initialized real-to-complex plan.
 
template<Direction D>
void compute_c2c ()
 Execute the complex-to-complex plan in place.
 
void * alloc_scratch_space () const
 Allocate GPU scratch space large enough to hold packed R2R data.
 
void pack_r2r_buffer (void *pbuf, T const *psrc) const
 Expand the real R2R input into the symmetry-extended buffer expected by CUFFT/rocFFT.
 
void unpack_r2r_buffer (T *pdst, void const *pbuf) const
 Collapse the spectral R2R result back into the original real layout.
 
template<Direction D>
void compute_r2r ()
 Execute the real-to-real plan, including GPU packing/unpacking.
 

Static Public Member Functions

static void free_scratch_space (void *p)
 Release GPU scratch allocated via alloc_scratch_space().
 
static void destroy_vendor_plan (VendorPlan plan)
 Helper that destroys a vendor plan of the appropriate backend type.
 

Public Attributes

int n = 0
 
int howmany = 0
 
Kind kind = Kind::none
 
bool r2r_data_is_complex = false
 
bool defined = false
 
bool defined2 = false
 
VendorPlan plan {}
 
VendorPlan plan2 {}
 
void * pf = nullptr
 
void * pb = nullptr
 

Member Typedef Documentation

◆ VendorComplex

template<typename T >
using amrex::FFT::Plan< T >::VendorComplex = std::conditional_t<std::is_same_v<float,T>, cuComplex, cuDoubleComplex>

◆ VendorPlan

template<typename T >
using amrex::FFT::Plan< T >::VendorPlan = cufftHandle

Member Function Documentation

◆ alloc_scratch_space()

template<typename T >
void * amrex::FFT::Plan< T >::alloc_scratch_space ( ) const
inline

Allocate GPU scratch space large enough to hold packed R2R data.

Returns
Device pointer owned by The_Arena().

◆ compute_c2c()

template<typename T >
template<Direction D>
void amrex::FFT::Plan< T >::compute_c2c ( )
inline

Execute the complex-to-complex plan in place.

◆ compute_r2c()

template<typename T >
template<Direction D>
void amrex::FFT::Plan< T >::compute_r2c ( )
inline

Execute the previously initialized real-to-complex plan.

The direction is determined by the template parameter.

◆ compute_r2r()

template<typename T >
template<Direction D>
void amrex::FFT::Plan< T >::compute_r2r ( )
inline

Execute the real-to-real plan, including GPU packing/unpacking.

◆ destroy()

template<typename T >
void amrex::FFT::Plan< T >::destroy ( )
inline

Release any vendor FFT plan objects owned by this Plan.

◆ destroy_vendor_plan()

template<typename T >
static void amrex::FFT::Plan< T >::destroy_vendor_plan ( VendorPlan< T >  plan)
inlinestatic

Helper that destroys a vendor plan of the appropriate backend type.

◆ free_scratch_space()

template<typename T >
static void amrex::FFT::Plan< T >::free_scratch_space ( void *  p)
inlinestatic

Release GPU scratch allocated via alloc_scratch_space().

◆ get_r2r_kind()

template<typename T >
template<Direction D>
Kind amrex::FFT::Plan< T >::get_r2r_kind ( std::pair< Boundary, Boundary > const &  bc)
inline

Map boundary conditions to the Plan Kind for real-to-real transforms.

Parameters
bcPair denoting (low, high) boundary type.
Returns
Corresponding Kind enum (sine/cosine variants).

◆ init_c2c()

template<typename T >
template<Direction D>
void amrex::FFT::Plan< T >::init_c2c ( Box const &  box,
VendorComplex p,
int  ncomp = 1,
int  ndims = 1 
)
inline

Initialize a complex-to-complex plan across 1/2/3 dimensions.

The batch size equals the number of components ncomp multiplied by the cell counts along directions that are not transformed. For example, in a 3-D build with ndims = 1 we perform an x-line transform batched over every y–z cell, so the batch count becomes ncomp * box.length(1) * box.length(2). Likewise, a 2-D transform in a 3-D build batches along the remaining z slices.

Parameters
boxBox describing the logical FFT extents.
pPointer to the in-place complex buffer.
ncompNumber of independent components per cell.
ndimsDimensionality of the transform (1, 2, or 3).

◆ init_r2c() [1/2]

template<typename T >
template<Direction D>
void amrex::FFT::Plan< T >::init_r2c ( Box const &  box,
T *  pr,
VendorComplex pc,
bool  is_2d_transform = false,
int  ncomp = 1 
)
inline

Initialize a 1-D or 2-D real-to-complex plan over the supplied Box.

Parameters
boxReal-space domain
prPointer to the real data buffer.
pcPointer to the complex data buffer.
is_2d_transformTrue for 2d tranfrom.
ncompNumber of real components packed into the buffer.

◆ init_r2c() [2/2]

template<typename T >
template<Direction D, int M>
void amrex::FFT::Plan< T >::init_r2c ( IntVectND< M > const &  fft_size,
void *  pbf,
void *  pbb,
bool  cache,
int  ncomp = 1 
)

Initialize an M-dimensional batched real-to-complex plan.

Parameters
fft_sizeLogical FFT extent per dimension.
pbfForward (real) buffer pointer.
pbbBackward (complex) buffer pointer.
cacheWhether to cache vendor plans (GPU backends only).
ncompNumber of transforms sharing the same plan.

◆ init_r2r() [1/2]

template<typename T >
template<Direction D>
void amrex::FFT::Plan< T >::init_r2r ( Box const &  box,
T *  p,
std::pair< Boundary, Boundary > const &  bc,
int  howmany_initval = 1 
)
inline

Initialize a real-to-real (cosine/sine) plan that operates on real buffers.

Parameters
boxBox describing the transform size.
pPointer to the real input/output buffer.
bcBoundary-condition pair.
howmany_initvalNumber of transforms batched together.

◆ init_r2r() [2/2]

template<typename T >
template<Direction D>
void amrex::FFT::Plan< T >::init_r2r ( Box const &  box,
VendorComplex pc,
std::pair< Boundary, Boundary > const &  bc 
)
inline

Initialize a real-to-real plan that reads/writes complex storage.

Parameters
box1-D Box describing the transform size.
pcPointer to the complex buffer (two real components interleaved).
bcBoundary-condition pair.

◆ pack_r2r_buffer()

template<typename T >
void amrex::FFT::Plan< T >::pack_r2r_buffer ( void *  pbuf,
T const *  psrc 
) const
inline

Expand the real R2R input into the symmetry-extended buffer expected by CUFFT/rocFFT.

Parameters
pbufDestination buffer (scratch).
psrcSource real data.

◆ set_ptrs()

template<typename T >
void amrex::FFT::Plan< T >::set_ptrs ( void *  p0,
void *  p1 
)
inline

Register device pointers used by the forward/backward executions.

Parameters
p0Forward buffer pointer.
p1Backward buffer pointer.

◆ unpack_r2r_buffer()

template<typename T >
void amrex::FFT::Plan< T >::unpack_r2r_buffer ( T *  pdst,
void const *  pbuf 
) const
inline

Collapse the spectral R2R result back into the original real layout.

Parameters
pdstDestination real buffer.
pbufScratch buffer holding the spectral data.

Member Data Documentation

◆ defined

template<typename T >
bool amrex::FFT::Plan< T >::defined = false

◆ defined2

template<typename T >
bool amrex::FFT::Plan< T >::defined2 = false

◆ howmany

template<typename T >
int amrex::FFT::Plan< T >::howmany = 0

◆ kind

template<typename T >
Kind amrex::FFT::Plan< T >::kind = Kind::none

◆ n

template<typename T >
int amrex::FFT::Plan< T >::n = 0

◆ pb

template<typename T >
void* amrex::FFT::Plan< T >::pb = nullptr

◆ pf

template<typename T >
void* amrex::FFT::Plan< T >::pf = nullptr

◆ plan

template<typename T >
VendorPlan amrex::FFT::Plan< T >::plan {}

◆ plan2

template<typename T >
VendorPlan amrex::FFT::Plan< T >::plan2 {}

◆ r2r_data_is_complex

template<typename T >
bool amrex::FFT::Plan< T >::r2r_data_is_complex = false

The documentation for this struct was generated from the following file: