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 46 of file CudaPmeSolverUtil.h.

Constructor & Destructor Documentation

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

Definition at line 74 of file CudaPmeSolverUtil.h.

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

Definition at line 101 of file CudaPmeSolverUtil.C.

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

101  {
102  cudaCheck(cudaSetDevice(deviceID));
103  cufftCheck(cufftDestroy(forwardPlan));
104  cufftCheck(cufftDestroy(backwardPlan));
105  if (dataSrcAllocated) deallocate_device<float>(&dataSrc);
106  if (dataDstAllocated) deallocate_device<float>(&dataDst);
107 }
#define cufftCheck(stmt)
bool dataDstAllocated
bool dataSrcAllocated
float * dataDst
#define cudaCheck(stmt)
Definition: CudaUtils.h:95
float * dataSrc

Member Function Documentation

void CudaFFTCompute::backward ( )
virtual

Implements FFTCompute.

Definition at line 153 of file CudaPmeSolverUtil.C.

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

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

Implements FFTCompute.

Definition at line 118 of file CudaPmeSolverUtil.C.

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

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

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