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

Constructor & Destructor Documentation

◆ FFTCompute()

FFTCompute::FFTCompute ( )
inline

Definition at line 130 of file PmeSolverUtil.h.

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

130  {
131  dataSrc = NULL;
132  dataSrcSize = 0;
133  dataSrcAllocated = false;
134  dataDst = NULL;
135  dataDstSize = 0;
136  dataDstAllocated = false;
137  }
bool dataDstAllocated
bool dataSrcAllocated
float * dataDst
float * dataSrc

◆ ~FFTCompute()

virtual FFTCompute::~FFTCompute ( )
inlinevirtual

Definition at line 216 of file PmeSolverUtil.h.

216 {}

Member Function Documentation

◆ backward()

virtual void FFTCompute::backward ( )
pure virtual

Implemented in CudaFFTCompute.

◆ forward()

virtual void FFTCompute::forward ( )
pure virtual

Implemented in CudaFFTCompute.

◆ getDataDst()

float* FFTCompute::getDataDst ( )
inline

Definition at line 220 of file PmeSolverUtil.h.

References dataDst.

220 {return dataDst;}
float * dataDst

◆ getDataSrc()

float* FFTCompute::getDataSrc ( )
inline

Definition at line 219 of file PmeSolverUtil.h.

References dataSrc.

219 {return dataSrc;}
float * dataSrc

◆ init()

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

References dataDst, dataDstAllocated, dataDstSize, dataSrc, dataSrcAllocated, dataSrcSize, getPencilDim(), jblock, PmeGrid::K1, PmeGrid::K2, PmeGrid::K3, kblock, 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.

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

Member Data Documentation

◆ dataDst

float* FFTCompute::dataDst
protected

◆ dataDstAllocated

bool FFTCompute::dataDstAllocated
protected

Definition at line 232 of file PmeSolverUtil.h.

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

◆ dataDstSize

int FFTCompute::dataDstSize
protected

Definition at line 229 of file PmeSolverUtil.h.

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

◆ dataSrc

float* FFTCompute::dataSrc
protected

◆ dataSrcAllocated

bool FFTCompute::dataSrcAllocated
protected

Definition at line 231 of file PmeSolverUtil.h.

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

◆ dataSrcSize

int FFTCompute::dataSrcSize
protected

Definition at line 228 of file PmeSolverUtil.h.

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

◆ isize

int FFTCompute::isize
protected

Definition at line 223 of file PmeSolverUtil.h.

◆ jblock

int FFTCompute::jblock
protected

Definition at line 222 of file PmeSolverUtil.h.

Referenced by init().

◆ jsize

int FFTCompute::jsize
protected

Definition at line 223 of file PmeSolverUtil.h.

◆ kblock

int FFTCompute::kblock
protected

Definition at line 222 of file PmeSolverUtil.h.

Referenced by init().

◆ ksize

int FFTCompute::ksize
protected

Definition at line 223 of file PmeSolverUtil.h.


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