NAMD
Public Member Functions | List of all members
CudaFFTCompute Class Reference

#include <CudaPmeSolverUtil.h>

Inheritance diagram for CudaFFTCompute:
FFTCompute

Public Member Functions

 CudaFFTCompute (int deviceID, cudaStream_t stream)
 
 ~CudaFFTCompute ()
 
void forward ()
 
void backward ()
 
- Public Member Functions inherited from FFTCompute
 FFTCompute ()
 
void init (float *dataSrc_in, int dataSrcSize_in, float *dataDst_in, int dataDstSize_in, int permutation, PmeGrid pmeGrid, int pmePencilType, int jblock, int kblock, int flags)
 
virtual ~FFTCompute ()
 
float * getDataSrc ()
 
float * getDataDst ()
 

Additional Inherited Members

- Protected Attributes inherited from FFTCompute
int jblock
 
int kblock
 
int isize
 
int jsize
 
int ksize
 
float * dataSrc
 
float * dataDst
 
int dataSrcSize
 
int dataDstSize
 
bool dataSrcAllocated
 
bool dataDstAllocated
 

Detailed Description

Definition at line 29 of file CudaPmeSolverUtil.h.

Constructor & Destructor Documentation

CudaFFTCompute::CudaFFTCompute ( int  deviceID,
cudaStream_t  stream 
)
inline

Definition at line 47 of file CudaPmeSolverUtil.h.

47 : deviceID(deviceID), stream(stream) {}
__thread cudaStream_t stream
CudaFFTCompute::~CudaFFTCompute ( )

Definition at line 96 of file CudaPmeSolverUtil.C.

References cudaCheck, cufftCheck, FFTCompute::dataDst, FFTCompute::dataDstAllocated, FFTCompute::dataSrc, and FFTCompute::dataSrcAllocated.

96  {
97  cudaCheck(cudaSetDevice(deviceID));
98  cufftCheck(cufftDestroy(forwardPlan));
99  cufftCheck(cufftDestroy(backwardPlan));
100  if (dataSrcAllocated) deallocate_device<float>(&dataSrc);
101  if (dataDstAllocated) deallocate_device<float>(&dataDst);
102 }
#define cufftCheck(stmt)
bool dataDstAllocated
bool dataSrcAllocated
float * dataDst
#define cudaCheck(stmt)
Definition: CudaUtils.h:79
float * dataSrc

Member Function Documentation

void CudaFFTCompute::backward ( )
virtual

Implements FFTCompute.

Definition at line 148 of file CudaPmeSolverUtil.C.

References cudaCheck, cudaNAMD_bug(), cufftCheck, FFTCompute::dataDst, and FFTCompute::dataSrc.

148  {
149  cudaCheck(cudaSetDevice(deviceID));
150  if (backwardType == CUFFT_C2R) {
151  // if (ncall == 1) {
152  // if (plantype == 1)
153  // writeComplexToDisk((float2 *)data, 33*64*64, "data_fx_by_bz.txt");
154  // else
155  // writeComplexToDisk((float2 *)data, 33*64*64, "data_fx_fy_fz_2.txt");
156  // }
157 
158  cufftCheck(cufftExecC2R(backwardPlan, (cufftComplex *)dataDst, (cufftReal *)dataSrc));
159 
160  // if (ncall == 1)
161  // if (plantype == 1)
162  // writeRealToDisk(data, 64*64*64, "data_bx_by_bz_1D.txt");
163  // else
164  // writeRealToDisk(data, 64*64*64, "data_bx_by_bz_3D.txt");
165  } else if (backwardType == CUFFT_C2C) {
166  // nc2cb++;
167  // if (ncall == 1 && nc2cb == 1)
168  // writeComplexToDisk((float2 *)data, 33*64*64, "data_fz_fx_fy_2.txt");
169  // else if (ncall == 1 && nc2cb == 2)
170  // writeComplexToDisk((float2 *)data, 33*64*64, "data_fy_bz_fx.txt");
171  cufftCheck(cufftExecC2C(backwardPlan, (cufftComplex *)dataDst, (cufftComplex *)dataSrc, CUFFT_INVERSE));
172  // if (ncall == 1 && nc2cb == 1)
173  // writeComplexToDisk((float2 *)data, 33*64*64, "data_bz_fx_fy.txt");
174  // else if (ncall == 1 && nc2cb == 2)
175  // writeComplexToDisk((float2 *)data, 33*64*64, "data_by_bz_fx.txt");
176  } else {
177  cudaNAMD_bug("CudaFFTCompute::backward(), unsupported FFT type");
178  }
179 }
#define cufftCheck(stmt)
void cudaNAMD_bug(const char *msg)
Definition: CudaUtils.C:31
float * dataDst
#define cudaCheck(stmt)
Definition: CudaUtils.h:79
float * dataSrc
void CudaFFTCompute::forward ( )
virtual

Implements FFTCompute.

Definition at line 113 of file CudaPmeSolverUtil.C.

References cudaCheck, cudaNAMD_bug(), cufftCheck, FFTCompute::dataDst, and FFTCompute::dataSrc.

113  {
114  cudaCheck(cudaSetDevice(deviceID));
115  // ncall++;
116  if (forwardType == CUFFT_R2C) {
117 
118  cufftCheck(cufftExecR2C(forwardPlan, (cufftReal *)dataSrc, (cufftComplex *)dataDst));
119 
120  // if (ncall == 1) {
121  // writeComplexToDisk((float2 *)dataSrc, (isize/2+1)*jsize*ksize, "dataSrc.txt", stream);
122  // }
123 
124  // if (ncall == 1 && plantype == 2) {
125  // writeComplexToDisk((float2 *)data, (isize/2+1)*jsize*ksize, "data_fx_fy_z.txt", stream);
126  // }
127 
128  } else if (forwardType == CUFFT_C2C) {
129  // nc2cf++;
130  // if (ncall == 1 && nc2cf == 1)
131  // writeComplexToDisk((float2 *)data, 33*64*64, "data_y_z_fx.txt");
132  // else if (ncall == 1 && nc2cf == 2)
133  // writeComplexToDisk((float2 *)data, 33*64*64, "data_z_fx_fy.txt");
134  cufftCheck(cufftExecC2C(forwardPlan, (cufftComplex *)dataSrc, (cufftComplex *)dataDst, CUFFT_FORWARD));
135  // fprintf(stderr, "ncall %d plantype %d\n", ncall, plantype);
136  // if (ncall == 1 && plantype == 1 && isize == 62) {
137  // writeComplexToDisk((float2 *)data, isize*jsize*(ksize/2+1), "data_fy_z_fx.txt", stream);
138  // }
139  // if (ncall == 1 && nc2cf == 1)
140  // writeComplexToDisk((float2 *)data, 33*64*64, "data_fy_z_fx.txt");
141  // else if (ncall == 1 && nc2cf == 2)
142  // writeComplexToDisk((float2 *)data, 33*64*64, "data_fz_fx_fy.txt");
143  } else {
144  cudaNAMD_bug("CudaFFTCompute::forward(), unsupported FFT type");
145  }
146 }
#define cufftCheck(stmt)
void cudaNAMD_bug(const char *msg)
Definition: CudaUtils.C:31
float * dataDst
#define cudaCheck(stmt)
Definition: CudaUtils.h:79
float * dataSrc

The documentation for this class was generated from the following files: