14#include <pscf/backend/cuda/VecOp.h>
84 cufftDestroy(rcfPlan_);
87 cufftDestroy(criPlan_);
90 cufftDestroy(ccPlan_);
106 for (
int i = 0; i < D; ++i) {
118 if (kFieldCopy_.isAllocated()) {
119 if (kFieldCopy_.capacity() != kSize_) {
120 kFieldCopy_.deallocate();
146 #ifdef SINGLE_PRECISION
147 result = cufftExecR2C(rcfPlan_,
const_cast<cudaReal*
>(rField.cArray()),
150 result = cufftExecD2Z(rcfPlan_,
const_cast<cudaReal*
>(rField.cArray()),
153 if (result != CUFFT_SUCCESS) {
154 UTIL_THROW(
"Failure in cufft real-to-complex forward transform");
173 UTIL_CHECK(rField.meshDimensions() == meshDimensions_);
174 UTIL_CHECK(kField.meshDimensions() == meshDimensions_);
177 #ifdef SINGLE_PRECISION
178 result = cufftExecC2R(criPlan_, kField.cArray(), rField.cArray());
180 result = cufftExecZ2D(criPlan_, kField.cArray(), rField.cArray());
182 if (result != CUFFT_SUCCESS) {
183 UTIL_THROW(
"Failure in cufft complex-to-real inverse transform");
196 if (kFieldCopy_.isAllocated()) {
198 UTIL_CHECK(kFieldCopy_.meshDimensions() == meshDimensions_);
202 kFieldCopy_ = kField;
221 UTIL_CHECK(rField.meshDimensions() == meshDimensions_);
222 UTIL_CHECK(kField.meshDimensions() == meshDimensions_);
227 #ifdef SINGLE_PRECISION
228 result = cufftExecC2C(ccPlan_,
const_cast<cudaComplex*
>(rField.cArray()),
229 kField.cArray(), CUFFT_FORWARD);
231 result = cufftExecZ2Z(ccPlan_,
const_cast<cudaComplex*
>(rField.cArray()),
232 kField.cArray(), CUFFT_FORWARD);
234 if (result != CUFFT_SUCCESS) {
235 UTIL_THROW(
"Failure in cufft complex-to-complex forward transform");
254 UTIL_CHECK(rField.meshDimensions() == meshDimensions_);
255 UTIL_CHECK(kField.meshDimensions() == meshDimensions_);
260 #ifdef SINGLE_PRECISION
261 result = cufftExecC2C(ccPlan_,
const_cast<cudaComplex*
>(kField.cArray()),
262 rField.cArray(), CUFFT_INVERSE);
264 result = cufftExecZ2Z(ccPlan_,
const_cast<cudaComplex*
>(kField.cArray()),
265 rField.cArray(), CUFFT_INVERSE);
267 if (result != CUFFT_SUCCESS) {
268 UTIL_THROW(
"Failure in cufft complex-to-complex inverse transform");
284 for (
int i = 0; i < D; ++i) {
286 kMeshDimensions[i] = rMeshDimensions[i];
288 kMeshDimensions[i] = rMeshDimensions[i]/2 + 1;
290 kSize *= kMeshDimensions[i];
void inverseTransformUnsafe(RFieldDft< D, CUT > &kField, RField< D, CUT > &rField) const
Compute inverse (complex-to-real) DFT, overwriting the input.
const IntVec< D > & meshDimensions() const
Return the dimensions of the grid for which this was allocated.
FFT()
Default constructor.
An IntVec<D, T> is a D-component vector of elements of integer type T.
File containing preprocessor macros for error handling.
#define UTIL_CHECK(condition)
Assertion macro suitable for serial or parallel production code.
#define UTIL_THROW(msg)
Macro for throwing an Exception, reporting function, file and line number.
void mulEqS(Array< double > &a, double b)
Vector-scalar in-place multiplication, a[i] *= b (real).
PSCF package top-level namespace.
cufftDoubleComplex cudaComplex
Complex number type used in CPU code that uses FFTW.
cufftDoubleReal cudaReal
Real number type used in CPU code that uses FFTW.