1#ifndef AMREX_FFT_LOCAL_R2C_H_
2#define AMREX_FFT_LOCAL_R2C_H_
3#include <AMReX_Config.H>
27 int M = AMREX_SPACEDIM>
54 bool cache_plan =
true);
56 bool cache_plan =
false);
105 return m_spectral_size;
113 T* m_p_fwd =
nullptr;
116#if defined(AMREX_USE_SYCL)
123 bool m_cache_plan =
false;
126template <
typename T, FFT::Direction D,
int M>
131 m_real_size(fft_size),
132 m_spectral_size(fft_size)
133#if defined(AMREX_USE_GPU)
134 , m_cache_plan(cache_plan)
137#if !defined(AMREX_USE_GPU)
142 m_spectral_size[0] = m_real_size[0]/2 + 1;
144#if defined(AMREX_USE_SYCL)
152 auto* pf = (
void*)m_p_fwd;
153 auto* pb = (
void*)m_p_bwd;
156 m_fft_fwd.template init_r2c<Direction::forward,M>(m_real_size, pf, pb, m_cache_plan);
157 m_fft_bwd = m_fft_fwd;
160 m_fft_fwd.template init_r2c<Direction::forward,M>(m_real_size, pf, pb, m_cache_plan);
163 m_fft_bwd.template init_r2c<Direction::backward,M>(m_real_size, pf, pb, m_cache_plan);
167#if defined(AMREX_USE_SYCL)
172template <
typename T, FFT::Direction D,
int M>
176 if (m_fft_bwd.plan != m_fft_fwd.plan) {
186template <
typename T, FFT::Direction D,
int M>
189 static_assert(M >= 1 && M <= 3);
193template <
typename T, FFT::Direction D,
int M>
195 : m_p_fwd(rhs.m_p_fwd),
196 m_p_bwd(rhs.m_p_bwd),
197 m_fft_fwd(rhs.m_fft_fwd),
198 m_fft_bwd(rhs.m_fft_bwd),
199#if defined(AMREX_USE_SYCL)
200 m_gpu_stream(rhs.m_gpu_stream),
202 m_real_size(rhs.m_real_size),
203 m_spectral_size(rhs.m_spectral_size),
204 m_cache_plan(rhs.m_cache_plan)
206 rhs.m_cache_plan =
true;
209template <
typename T, FFT::Direction D,
int M>
212 if (
this == &rhs) {
return *
this; }
216 m_p_fwd = rhs.m_p_fwd;
217 m_p_bwd = rhs.m_p_bwd;
218 m_fft_fwd = rhs.m_fft_fwd;
219 m_fft_bwd = rhs.m_fft_bwd;
220#if defined(AMREX_USE_SYCL)
221 m_gpu_stream = rhs.m_gpu_stream;
223 m_real_size = rhs.m_real_size;
224 m_spectral_size = rhs.m_spectral_size;
225 m_cache_plan = rhs.m_cache_plan;
227 rhs.m_cache_plan =
true;
232template <
typename T, FFT::Direction D,
int M>
239#if defined(AMREX_USE_GPU)
241 m_fft_fwd.set_ptrs((
void*)indata, (
void*)outdata);
243#if defined(AMREX_USE_SYCL)
245 if (current_stream != m_gpu_stream) {
253 if (((T*)indata != m_p_fwd) || (outdata != m_p_bwd)) {
254 m_p_fwd = (T*)indata;
256 auto* pf = (
void*)m_p_fwd;
257 auto* pb = (
void*)m_p_bwd;
259 m_fft_fwd.template init_r2c<Direction::forward,M>(m_real_size, pf, pb,
false);
262 m_fft_bwd.template init_r2c<Direction::backward,M>(m_real_size, pf, pb,
false);
268 m_fft_fwd.template compute_r2c<Direction::forward>();
270#if defined(AMREX_USE_SYCL)
271 if (current_stream != m_gpu_stream) {
277template <
typename T, FFT::Direction D,
int M>
284#if defined(AMREX_USE_GPU)
286 m_fft_bwd.set_ptrs((
void*)outdata, (
void*)indata);
288#if defined(AMREX_USE_SYCL)
290 if (current_stream != m_gpu_stream) {
298 if (((
GpuComplex<T>*)indata != m_p_bwd) || (outdata != m_p_fwd)) {
301 auto* pf = (
void*)m_p_fwd;
302 auto* pb = (
void*)m_p_bwd;
304 m_fft_bwd.template init_r2c<Direction::backward,M>(m_real_size, pf, pb,
false);
307 m_fft_fwd.template init_r2c<Direction::forward,M>(m_real_size, pf, pb,
false);
313 m_fft_bwd.template compute_r2c<Direction::backward>();
315#if defined(AMREX_USE_SYCL)
316 if (current_stream != m_gpu_stream) {
322template <
typename T, FFT::Direction D,
int M>
326 for (
auto s : m_real_size) {
#define BL_PROFILE(a)
Definition AMReX_BLProfiler.H:551
Local Discrete Fourier Transform.
Definition AMReX_FFT_LocalR2C.H:29
void backward(GpuComplex< T > const *indata, T *outdata)
Backward transform.
Definition AMReX_FFT_LocalR2C.H:280
T scalingFactor() const
Definition AMReX_FFT_LocalR2C.H:323
void forward(T const *indata, GpuComplex< T > *outdata)
Forward transform.
Definition AMReX_FFT_LocalR2C.H:235
void clear()
Definition AMReX_FFT_LocalR2C.H:173
LocalR2C & operator=(LocalR2C &&) noexcept
Definition AMReX_FFT_LocalR2C.H:210
~LocalR2C()
Definition AMReX_FFT_LocalR2C.H:187
IntVectND< M > const & spectralSize() const
Spectral domain size.
Definition AMReX_FFT_LocalR2C.H:104
static gpuStream_t setStream(gpuStream_t s) noexcept
Definition AMReX_GpuDevice.cpp:731
static void resetStreamIndex() noexcept
Definition AMReX_GpuDevice.H:96
An Integer Vector in dim-Dimensional Space.
Definition AMReX_IntVect.H:57
Definition AMReX_FFT_Helper.H:46
Direction
Definition AMReX_FFT_Helper.H:48
void streamSynchronize() noexcept
Definition AMReX_GpuDevice.H:263
gpuStream_t gpuStream() noexcept
Definition AMReX_GpuDevice.H:244
__host__ __device__ void ignore_unused(const Ts &...)
This shuts up the compiler about unused variables.
Definition AMReX.H:138
cudaStream_t gpuStream_t
Definition AMReX_GpuControl.H:83
Definition AMReX_FFT_Helper.H:134
A host / device complex number type, because std::complex doesn't work in device code with Cuda yet.
Definition AMReX_GpuComplex.H:30