PSCF v1.4.0
FFTBatched.h
1#ifndef PRDC_CUDA_FFT_BATCHED_H
2#define PRDC_CUDA_FFT_BATCHED_H
3
4/*
5* PSCF - Polymer Self-Consistent Field
6*
7* Copyright 2015 - 2025, The Regents of the University of Minnesota
8* Distributed under the terms of the GNU General Public License.
9*/
10
11//#include "RField.h"
12//#include "RFieldDft.h"
13#include <pscf/cuda/cudaTypes.h>
14#include <pscf/cuda/DeviceArray.h>
15#include <pscf/math/IntVec.h>
16#include <util/global.h>
17
18#include <cufft.h>
19
20namespace Pscf {
21namespace Prdc {
22namespace Cuda {
23
24 using namespace Util;
25
31 template <int D>
33 {
34
35 public:
36
40 FFTBatched();
41
45 virtual ~FFTBatched();
46
53 void setup(IntVec<D> const & meshDimensions, int batchSize);
54
73 void forwardTransform(DeviceArray<cudaReal> const & rFields,
74 DeviceArray<cudaComplex>& kFields) const;
75
90 DeviceArray<cudaReal>& rFields) const;
91
95 const IntVec<D>& meshDimensions() const;
96
102 void resetBatchSize(int batchSize);
103
107 bool isSetup() const;
108
109 private:
110
112 IntVec<D> meshDimensions_;
113
115 IntVec<D> kMeshDimensions_;
116
118 int batchSize_;
119
121 int rSize_;
122
124 int kSize_;
125
127 cufftHandle fPlan_;
128
130 cufftHandle iPlan_;
131
133 bool isSetup_;
134
140 void makePlans(int batchSize);
141
142 };
143
144 // Return the dimensions of the grid for which this was allocated.
145 template <int D>
147 { return meshDimensions_; }
148
149 // Has the setup method been called?
150 template <int D>
151 inline bool FFTBatched<D>::isSetup() const
152 { return isSetup_; }
153
154 #ifndef PRDC_CUDA_FFT_BATCHED_TPP
155 // Explicit instantiation declarations
156 extern template class FFTBatched<1>;
157 extern template class FFTBatched<2>;
158 extern template class FFTBatched<3>;
159 #endif
160
161}
162}
163}
164
165#endif
Dynamic array on the GPU device with aligned data.
Definition DeviceArray.h:96
An IntVec<D, T> is a D-component vector of elements of integer type T.
Definition IntVec.h:27
Batched Fourier transform wrapper for real data.
Definition FFTBatched.h:33
virtual ~FFTBatched()
Destructor.
void forwardTransform(DeviceArray< cudaReal > const &rFields, DeviceArray< cudaComplex > &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:146
void inverseTransformUnsafe(DeviceArray< cudaComplex > &kFields, DeviceArray< cudaReal > &rFields) const
Compute inverse (complex-to-real) Fourier transform.
void setup(IntVec< D > const &meshDimensions, int batchSize)
Set up FFT calculation (get grid dimensions and make FFT plan)
FFTBatched()
Default constructor.
bool isSetup() const
Has the setup method been called?
Definition FFTBatched.h:151
void resetBatchSize(int batchSize)
Set the batch size to a new value.
File containing preprocessor macros for error handling.
Fields, FFTs, and utilities for periodic boundary conditions (CUDA).
Definition CField.cu:12
Periodic fields and crystallography.
Definition complex.cpp:11
PSCF package top-level namespace.