PSCF v1.5.0
FFTBatched.h
1#ifndef PSCF_FFT_BATCHED_CU_H
2#define PSCF_FFT_BATCHED_CU_H
3
4/*
5* PSCF - Polymer Self-Consistent Field
6*
7* Copyright 2015 - 2026, David Morse (morse012@um.edu) and co-authors
8* Distributed under the terms of the GNU General Public License.
9*/
10
11#include <pscf/backend/cuda/cudaTypes.h>
12#include <pscf/backend/cuda/BackendArray.h>
13#include <pscf/math/IntVec.h>
14#include <util/global.h>
15
16#include <cufft.h>
17
18namespace Pscf {
19
20 using namespace Util;
21
27 template <int D>
29 {
30
31 public:
32
36 FFTBatched();
37
41 virtual ~FFTBatched();
42
56 void setup(IntVec<D> const & meshDimensions, int batchSize);
57
67 void resetBatchSize(int batchSize);
68
89 BackendArray<cudaComplex,CUT>& kFields) const;
90
106 BackendArray<cudaReal,CUT>& rFields) const;
107
111 const IntVec<D>& meshDimensions() const;
112
116 bool isSetup() const;
117
118 private:
119
121 IntVec<D> meshDimensions_;
122
124 IntVec<D> kMeshDimensions_;
125
127 int batchSize_;
128
130 int rSize_;
131
133 int kSize_;
134
136 cufftHandle fPlan_;
137
139 cufftHandle iPlan_;
140
142 bool isSetup_;
143
144 // Private member functions
145
151 void makePlans(int batchSize);
152
156 void destroyPlans();
157
158 };
159
160 // Inline member functions
161
162 // Return the dimensions of the grid for which this was allocated.
163 template <int D> inline
165 { return meshDimensions_; }
166
167 // Has the setup method been called?
168 template <int D> inline
170 { return isSetup_; }
171
172 // Explicit instantiation declarations
173 extern template class FFTBatched<1>;
174 extern template class FFTBatched<2>;
175 extern template class FFTBatched<3>;
176
177}
178#endif
Batched Fourier transform wrapper for real data.
Definition FFTBatched.h:29
void inverseTransformUnsafe(BackendArray< cudaComplex, CUT > &kFields, BackendArray< cudaReal, CUT > &rFields) const
Compute inverse (complex-to-real) Fourier transform.
FFTBatched()
Default constructor.
void forwardTransform(BackendArray< cudaReal, CUT > const &rFields, BackendArray< cudaComplex, CUT > &kFields) const
Compute batched forward (real-to-complex) DFTs.
const IntVec< D > & meshDimensions() const
Return the dimensions of the grid for which this was allocated.
Definition FFTBatched.h:164
void resetBatchSize(int batchSize)
Set the batch size to a new value.
void setup(IntVec< D > const &meshDimensions, int batchSize)
Set up FFT calculation (get grid dimensions and make FFT plan).
bool isSetup() const
Has the setup method been called?
Definition FFTBatched.h:169
An IntVec<D, T> is a D-component vector of elements of integer type T.
Definition IntVec.h:27
File containing preprocessor macros for error handling.
PSCF package top-level namespace.