NAMD
Public Member Functions | Protected Attributes | List of all members
FFTCompute Class Referenceabstract

#include <PmeSolverUtil.h>

Inheritance diagram for FFTCompute:
CudaFFTCompute

Public Member Functions

 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 ()
 
virtual void forward ()=0
 
virtual void backward ()=0
 
float * getDataSrc ()
 
float * getDataDst ()
 

Protected Attributes

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 125 of file PmeSolverUtil.h.

Constructor & Destructor Documentation

FFTCompute::FFTCompute ( )
inline

Definition at line 127 of file PmeSolverUtil.h.

References dataDst, dataDstAllocated, dataDstSize, dataSrc, dataSrcAllocated, and dataSrcSize.

127  {
128  dataSrc = NULL;
129  dataSrcSize = 0;
130  dataSrcAllocated = false;
131  dataDst = NULL;
132  dataDstSize = 0;
133  dataDstAllocated = false;
134  }
bool dataDstAllocated
bool dataSrcAllocated
float * dataDst
float * dataSrc
virtual FFTCompute::~FFTCompute ( )
inlinevirtual

Definition at line 213 of file PmeSolverUtil.h.

213 {}

Member Function Documentation

virtual void FFTCompute::backward ( )
pure virtual

Implemented in CudaFFTCompute.

virtual void FFTCompute::forward ( )
pure virtual

Implemented in CudaFFTCompute.

float* FFTCompute::getDataDst ( )
inline

Definition at line 217 of file PmeSolverUtil.h.

References dataDst.

217 {return dataDst;}
float * dataDst
float* FFTCompute::getDataSrc ( )
inline

Definition at line 216 of file PmeSolverUtil.h.

References dataSrc.

216 {return dataSrc;}
float * dataSrc
void FFTCompute::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 
)
inline

Definition at line 135 of file PmeSolverUtil.h.

References dataDst, dataDstAllocated, dataDstSize, dataSrc, dataSrcAllocated, dataSrcSize, getPencilDim(), PmeGrid::K1, PmeGrid::K2, PmeGrid::K3, NAMD_bug(), Perm_cX_Y_Z, Perm_X_Y_Z, Perm_Y_Z_cX, Perm_Z_cX_Y, PmeGrid::xBlocks, PmeGrid::yBlocks, and PmeGrid::zBlocks.

139  {
140 
141  if (dataSrc_in != NULL && dataSrc_in == dataDst_in)
142  NAMD_bug("FFTCompute::init, only out-of-place FFTs supported");
143 
144  int permutationDst = permutation;
145  if (permutation == Perm_X_Y_Z) {
146  permutationDst = Perm_cX_Y_Z;
147  }
148 
149  if (dataSrc_in == NULL) {
150  // Sets data and dataSize
151  dataSrcSize = getDataSizeRequired(permutation, pmeGrid, jblock, kblock);
152  dataSrc = allocateData(dataSrcSize);
153  dataSrcAllocated = true;
154  } else {
155  if (dataSrcSize_in < getDataSizeRequired(permutation, pmeGrid, jblock, kblock))
156  NAMD_bug("FFTCompute::init, invalid dataSrcSize_in");
157  dataSrcSize = dataSrcSize_in;
158  dataSrc = dataSrc_in;
159  dataSrcAllocated = false;
160  }
161 
162  if (dataDst_in == NULL) {
163  // Sets data and dataSize
164  dataDstSize = getDataSizeRequired(permutationDst, pmeGrid, jblock, kblock);
165  dataDst = allocateData(dataDstSize);
166  dataDstAllocated = true;
167  } else {
168  if (dataDstSize_in < getDataSizeRequired(permutationDst, pmeGrid, jblock, kblock))
169  NAMD_bug("FFTCompute::init, invalid dataDstSize_in");
170  dataDstSize = dataDstSize_in;
171  dataDst = dataDst_in;
172  dataDstAllocated = false;
173  }
174 
175  // Final sanity check
176  if (dataDst == NULL || dataSrc == NULL ||
177  dataDstSize < getDataSizeRequired(permutationDst, pmeGrid, jblock, kblock) ||
178  dataSrcSize < getDataSizeRequired(permutation, pmeGrid, jblock, kblock))
179  NAMD_bug("FFTCompute::init, error setting up data buffers");
180 
181  // Now "data" is pointer to grid data with at least size getDataSizeRequired(...)
182  if (pmePencilType == 3) {
183  // 3D FFT
184  if (pmeGrid.xBlocks != 1 || pmeGrid.yBlocks != 1 || pmeGrid.zBlocks != 1)
185  NAMD_bug("FFTCompute::init, 3D FFT requires a single pencil");
186  int n[3] = {pmeGrid.K1, pmeGrid.K2, pmeGrid.K3};
187  plan3D(n, flags);
188  } else if (pmePencilType == 1) {
189  int i0, i1, j0, j1, k0, k1;
190  getPencilDim(pmeGrid, permutation, jblock, kblock, i0, i1, j0, j1, k0, k1);
191  int n[1] = {i1-i0+1};
192  int howmany = (j1-j0+1)*(k1-k0+1);
193  if (permutation == Perm_X_Y_Z) {
194  plan1DX(n, howmany, flags);
195  } else if (permutation == Perm_Y_Z_cX) {
196  plan1DY(n, howmany, flags);
197  } else if (permutation == Perm_Z_cX_Y) {
198  plan1DZ(n, howmany, flags);
199  } else {
200  NAMD_bug("FFTCompute::init, invalid permutation");
201  }
202  } else if (pmePencilType == 2) {
203  // 2D FFTs of xy planes
204  int i0, i1, j0, j1, k0, k1;
205  getPencilDim(pmeGrid, permutation, 0, kblock, i0, i1, j0, j1, k0, k1);
206  int n[2] = {pmeGrid.K1, pmeGrid.K2};
207  int howmany = k1-k0+1;
208  plan2D(n, howmany, flags);
209  } else {
210  NAMD_bug("FFTCompute::init, invalid pmePencilType");
211  }
212  }
int zBlocks
Definition: PmeBase.h:22
int K2
Definition: PmeBase.h:18
int K1
Definition: PmeBase.h:18
static void getPencilDim(const PmeGrid &pmeGrid, const int permutation, const int jblock, const int kblock, int &i0, int &i1, int &j0, int &j1, int &k0, int &k1)
Definition: PmeSolverUtil.h:29
bool dataDstAllocated
int yBlocks
Definition: PmeBase.h:22
void NAMD_bug(const char *err_msg)
Definition: common.C:129
bool dataSrcAllocated
int K3
Definition: PmeBase.h:18
float * dataDst
int xBlocks
Definition: PmeBase.h:22
float * dataSrc

Member Data Documentation

float* FFTCompute::dataDst
protected
bool FFTCompute::dataDstAllocated
protected

Definition at line 229 of file PmeSolverUtil.h.

Referenced by FFTCompute(), init(), and CudaFFTCompute::~CudaFFTCompute().

int FFTCompute::dataDstSize
protected

Definition at line 226 of file PmeSolverUtil.h.

Referenced by FFTCompute(), and init().

float* FFTCompute::dataSrc
protected
bool FFTCompute::dataSrcAllocated
protected

Definition at line 228 of file PmeSolverUtil.h.

Referenced by FFTCompute(), init(), and CudaFFTCompute::~CudaFFTCompute().

int FFTCompute::dataSrcSize
protected

Definition at line 225 of file PmeSolverUtil.h.

Referenced by FFTCompute(), and init().

int FFTCompute::isize
protected

Definition at line 220 of file PmeSolverUtil.h.

int FFTCompute::jblock
protected

Definition at line 219 of file PmeSolverUtil.h.

int FFTCompute::jsize
protected

Definition at line 220 of file PmeSolverUtil.h.

int FFTCompute::kblock
protected

Definition at line 219 of file PmeSolverUtil.h.

int FFTCompute::ksize
protected

Definition at line 220 of file PmeSolverUtil.h.


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