1 #ifndef AMREX_FFT_LOCAL_R2C_H_
2 #define AMREX_FFT_LOCAL_R2C_H_
3 #include <AMReX_Config.H>
26 int M = AMREX_SPACEDIM>
53 bool cache_plan =
true);
55 bool cache_plan =
false);
115 #if defined(AMREX_USE_SYCL)
125 template <
typename T, FFT::Direction D,
int M>
130 m_real_size(fft_size),
131 m_spectral_size(fft_size)
132 #
if defined(AMREX_USE_GPU)
133 , m_cache_plan(cache_plan)
136 #if !defined(AMREX_USE_GPU)
143 #if defined(AMREX_USE_SYCL)
154 #ifdef AMREX_USE_SYCL
166 #if defined(AMREX_USE_SYCL)
171 template <
typename T, FFT::Direction D,
int M>
175 if (m_fft_bwd.plan != m_fft_fwd.plan) {
185 template <
typename T, FFT::Direction D,
int M>
188 static_assert(
M >= 1 &&
M <= 3);
192 template <
typename T, FFT::Direction D,
int M>
194 : m_p_fwd(rhs.m_p_fwd),
195 m_p_bwd(rhs.m_p_bwd),
196 m_fft_fwd(rhs.m_fft_fwd),
197 m_fft_bwd(rhs.m_fft_bwd),
198 #if defined(AMREX_USE_SYCL)
199 m_gpu_stream(rhs.m_gpu_stream),
201 m_real_size(rhs.m_real_size),
202 m_spectral_size(rhs.m_spectral_size),
203 m_cache_plan(rhs.m_cache_plan)
205 rhs.m_cache_plan =
true;
208 template <
typename T, FFT::Direction D,
int M>
211 if (
this == &rhs) {
return *
this; }
215 m_p_fwd = rhs.m_p_fwd;
216 m_p_bwd = rhs.m_p_bwd;
217 m_fft_fwd = rhs.m_fft_fwd;
218 m_fft_bwd = rhs.m_fft_bwd;
219 #if defined(AMREX_USE_SYCL)
220 m_gpu_stream = rhs.m_gpu_stream;
222 m_real_size = rhs.m_real_size;
223 m_spectral_size = rhs.m_spectral_size;
224 m_cache_plan = rhs.m_cache_plan;
226 rhs.m_cache_plan =
true;
231 template <
typename T, FFT::Direction D,
int M>
238 #if defined(AMREX_USE_GPU)
240 m_fft_fwd.set_ptrs((
void*)indata, (
void*)outdata);
242 #if defined(AMREX_USE_SYCL)
244 if (current_stream != m_gpu_stream) {
252 if (((T*)indata != m_p_fwd) || (outdata != m_p_bwd)) {
253 m_p_fwd = (T*)indata;
255 auto* pf = (
void*)m_p_fwd;
256 auto* pb = (
void*)m_p_bwd;
258 m_fft_fwd.template init_r2c<Direction::forward,M>(m_real_size, pf, pb,
false);
261 m_fft_bwd.template init_r2c<Direction::backward,M>(m_real_size, pf, pb,
false);
267 m_fft_fwd.template compute_r2c<Direction::forward>();
269 #if defined(AMREX_USE_SYCL)
270 if (current_stream != m_gpu_stream) {
276 template <
typename T, FFT::Direction D,
int M>
283 #if defined(AMREX_USE_GPU)
285 m_fft_bwd.set_ptrs((
void*)outdata, (
void*)indata);
287 #if defined(AMREX_USE_SYCL)
289 if (current_stream != m_gpu_stream) {
297 if (((
GpuComplex<T>*)indata != m_p_bwd) || (outdata != m_p_fwd)) {
300 auto* pf = (
void*)m_p_fwd;
301 auto* pb = (
void*)m_p_bwd;
303 m_fft_bwd.template init_r2c<Direction::backward,M>(m_real_size, pf, pb,
false);
306 m_fft_fwd.template init_r2c<Direction::forward,M>(m_real_size, pf, pb,
false);
312 m_fft_bwd.template compute_r2c<Direction::backward>();
314 #if defined(AMREX_USE_SYCL)
315 if (current_stream != m_gpu_stream) {
321 template <
typename T, FFT::Direction D,
int M>
325 for (
auto s : m_real_size) {
#define BL_PROFILE(a)
Definition: AMReX_BLProfiler.H:551
if(!(yy_init))
Definition: amrex_iparser.lex.nolint.H:935
Local Discrete Fourier Transform.
Definition: AMReX_FFT_LocalR2C.H:28
void backward(GpuComplex< T > const *indata, T *outdata)
Backward transform.
Definition: AMReX_FFT_LocalR2C.H:279
T scalingFactor() const
Definition: AMReX_FFT_LocalR2C.H:322
void forward(T const *indata, GpuComplex< T > *outdata)
Forward transform.
Definition: AMReX_FFT_LocalR2C.H:234
Plan< T > m_fft_bwd
Definition: AMReX_FFT_LocalR2C.H:110
void clear()
Definition: AMReX_FFT_LocalR2C.H:172
LocalR2C & operator=(LocalR2C &&) noexcept
Definition: AMReX_FFT_LocalR2C.H:209
GpuComplex< T > * m_p_bwd
Definition: AMReX_FFT_LocalR2C.H:113
Plan< T > m_fft_fwd
Definition: AMReX_FFT_LocalR2C.H:109
bool m_cache_plan
Definition: AMReX_FFT_LocalR2C.H:122
IntVectND< M > m_spectral_size
Definition: AMReX_FFT_LocalR2C.H:120
T * m_p_fwd
Definition: AMReX_FFT_LocalR2C.H:112
~LocalR2C()
Definition: AMReX_FFT_LocalR2C.H:186
IntVectND< M > m_real_size
Definition: AMReX_FFT_LocalR2C.H:119
IntVectND< M > const & spectralSize() const
Spectral domain size.
Definition: AMReX_FFT_LocalR2C.H:103
static gpuStream_t setStream(gpuStream_t s) noexcept
Definition: AMReX_GpuDevice.cpp:615
static void resetStreamIndex() noexcept
Definition: AMReX_GpuDevice.H:76
Definition: AMReX_IntVect.H:48
Definition: AMReX_FFT.cpp:7
Direction
Definition: AMReX_FFT_Helper.H:48
void streamSynchronize() noexcept
Definition: AMReX_GpuDevice.H:237
gpuStream_t gpuStream() noexcept
Definition: AMReX_GpuDevice.H:218
static constexpr int M
Definition: AMReX_OpenBC.H:13
cudaStream_t gpuStream_t
Definition: AMReX_GpuControl.H:77
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void ignore_unused(const Ts &...)
This shuts up the compiler about unused variables.
Definition: AMReX.H:111
Definition: AMReX_FFT_Helper.H:113
A host / device complex number type, because std::complex doesn't work in device code with Cuda yet.
Definition: AMReX_GpuComplex.H:29