NAMD
PmeSolver.C
Go to the documentation of this file.
1 #include <stdio.h>
2 #include "Priorities.h"
3 struct float2 {float x,y;};
4 #include "PmeSolver.h"
5 
6 //
7 // Data flow for PmePencilXYZ
8 //
9 // dataSrc [xyz] dataDst
10 //
11 // dataDst [solve] dataDst
12 //
13 // dataDst [xyz] dataSrc
14 //
15 // dataSrc [force]
16 //
17 
19  __sdag_init();
20  setMigratable(false);
21  fftCompute = NULL;
22  pmeKSpaceCompute = NULL;
24  doEnergy = false;
25  doVirial = false;
26 }
27 
28 PmePencilXYZ::PmePencilXYZ(CkMigrateMessage *m) {
29  NAMD_bug("PmePencilXYZ cannot be migrated");
30  //__sdag_init();
31  // setMigratable(false);
32  // fftCompute = NULL;
33  // pmeKSpaceCompute = NULL;
34  // reduction = ReductionMgr::Object()->willSubmit(REDUCTIONS_BASIC);
35 }
36 
38  if (fftCompute != NULL) delete fftCompute;
39  if (pmeKSpaceCompute != NULL) delete pmeKSpaceCompute;
40  delete reduction;
41 }
42 
43 void PmePencilXYZ::initFFT(PmeStartMsg *msg) {
44  if (fftCompute == NULL)
45  NAMD_bug("PmePencilXYZ::initFFT, fftCompute not initialized");
46  fftCompute->init(msg->data, msg->dataSize, NULL, 0, Perm_X_Y_Z, pmeGrid, 3, 0, 0, 0);
47 }
48 
49 void PmePencilXYZ::forwardFFT() {
50  if (fftCompute == NULL)
51  NAMD_bug("PmePencilXYZ::forwardFFT, fftCompute not initialized");
53 }
54 
55 void PmePencilXYZ::backwardFFT() {
56  if (fftCompute == NULL)
57  NAMD_bug("PmePencilXYZ::backwardFFT, fftCompute not initialized");
59 }
60 
61 void PmePencilXYZ::forwardDone() {
62  if (pmeKSpaceCompute == NULL)
63  NAMD_bug("PmePencilXYZ::forwardDone, pmeKSpaceCompute not initialized");
65 }
66 
68  NAMD_bug("PmePencilXYZ::backwardDone(), base class method called");
69 }
70 
72  if (pmeKSpaceCompute == NULL)
73  NAMD_bug("PmePencilXYZ::submitReductions, pmeKSpaceCompute not initialized");
74  double virial[9];
75  double energy = pmeKSpaceCompute->getEnergy();
76  pmeKSpaceCompute->getVirial(virial);
77  reduction->item(REDUCTION_ELECT_ENERGY_SLOW) += energy;
78  reduction->item(REDUCTION_VIRIAL_SLOW_XX) += virial[0];
79  reduction->item(REDUCTION_VIRIAL_SLOW_XY) += virial[1];
80  reduction->item(REDUCTION_VIRIAL_SLOW_XZ) += virial[2];
81  reduction->item(REDUCTION_VIRIAL_SLOW_YX) += virial[3];
82  reduction->item(REDUCTION_VIRIAL_SLOW_YY) += virial[4];
83  reduction->item(REDUCTION_VIRIAL_SLOW_YZ) += virial[5];
84  reduction->item(REDUCTION_VIRIAL_SLOW_ZX) += virial[6];
85  reduction->item(REDUCTION_VIRIAL_SLOW_ZY) += virial[7];
86  reduction->item(REDUCTION_VIRIAL_SLOW_ZZ) += virial[8];
88  reduction->submit();
89 }
90 
92  reduction->submit();
93 }
94 
95 //###########################################################################
96 //###########################################################################
97 //###########################################################################
98 
99 //
100 // Data flow for PmePencilXY & PmePencilZ
101 //
102 // dataSrc(XY) [xy] dataDst(XY)
103 //
104 // dataDst(XY) [transp] dataSrc(Z)
105 //---------------------------------
106 //
107 // dataSrc(Z) [z] dataDst(Z)
108 //
109 // dataDst(Z) [solve] dataDst(Z)
110 //
111 // dataDst(Z) [z] dataSrc(Z)
112 //
113 // dataSrc(Z) [transp] dataDst(XY)
114 //---------------------------------
115 //
116 // dataDst(XY) [xy] dataSrc(XY)
117 //
118 // dataSrc(XY) [force]
119 //
120 
122  __sdag_init();
123  setMigratable(false);
124  fftCompute = NULL;
125  pmeTranspose = NULL;
126 }
127 
128 PmePencilXY::PmePencilXY(CkMigrateMessage *m) {
129  NAMD_bug("PmePencilXY cannot be migrated");
130 //__sdag_init();
131  // setMigratable(false);
132  // fftCompute = NULL;
133  // pmeTranspose = NULL;
134 }
135 
137  if (fftCompute != NULL) delete fftCompute;
138  if (pmeTranspose != NULL) delete pmeTranspose;
139 }
140 
141 void PmePencilXY::initFFT(PmeStartMsg *msg) {
142  if (fftCompute == NULL)
143  NAMD_bug("PmePencilXY::initFFT, fftCompute not initialized");
144  fftCompute->init(msg->data, msg->dataSize, NULL, 0, Perm_X_Y_Z, pmeGrid, 2, 0, thisIndex.z, 0);
145 }
146 
147 void PmePencilXY::forwardFFT() {
148  if (fftCompute == NULL)
149  NAMD_bug("PmePencilXY::forwardFFT, fftCompute not initialized");
150  fftCompute->forward();
151 }
152 
153 void PmePencilXY::backwardFFT() {
154  if (fftCompute == NULL)
155  NAMD_bug("PmePencilXY::backwardFFT, fftCompute not initialized");
156  fftCompute->backward();
157 }
158 
160  blockSizes.resize(pmeGrid.xBlocks);
161  for (int x=0;x < pmeGrid.xBlocks;x++) {
162  int i0, i1, j0, j1, k0, k1;
163  getBlockDim(pmeGrid, Perm_cX_Y_Z, x, 0, thisIndex.z,
164  i0, i1, j0, j1, k0, k1);
165  int size = (i1-i0+1)*(j1-j0+1)*(k1-k0+1);
166  blockSizes[x] = size;
167  }
168 }
169 
170 void PmePencilXY::forwardDone() {
171  NAMD_bug("PmePencilXY::forwardDone(), base class method called");
172 }
173 
174 void PmePencilXY::backwardDone() {
175  NAMD_bug("PmePencilXY::backwardDone(), base class method called");
176 }
177 
178 void PmePencilXY::recvDataFromZ(PmeBlockMsg *msg) {
179  NAMD_bug("PmePencilXY::recvDataFromZ(), base class method called");
180 }
181 
182 void PmePencilXY::start(const CkCallback &) {
183  NAMD_bug("PmePencilXY::start(), base class method called");
184 }
185 
186 //###########################################################################
187 //###########################################################################
188 //###########################################################################
189 
190 //
191 // Data flow for PmePencilX & PmePencilX & PmePencilZ
192 //
193 // dataSrc(X) [x] dataDst(X)
194 //
195 // dataDst(X) [transp] dataSrc(Y)
196 //---------------------------------
197 //
198 // dataSrc(Y) [y] dataDst(Y)
199 //
200 // dataDst(Y) [transp] dataSrc(Z)
201 //---------------------------------
202 //
203 // dataSrc(Z) [z] dataDst(Z)
204 //
205 // dataDst(Z) [solve] dataDst(Z)
206 //
207 // dataDst(Z) [z] dataSrc(Z)
208 //
209 // dataSrc(Z) [transp] dataDst(Y)
210 //---------------------------------
211 //
212 // dataDst(Y) [y] dataSrc(Y)
213 //
214 // dataSrc(Y) [transp] dataDst(X)
215 //---------------------------------
216 //
217 // dataDst(X) [x] dataSrc(X)
218 //
219 // dataSrc(X) [force]
220 //
221 
223  __sdag_init();
224  setMigratable(false);
225  fftCompute = NULL;
226  pmeTranspose = NULL;
227  numStrayAtoms = 0;
228 }
229 
230 PmePencilX::PmePencilX(CkMigrateMessage *m) {
231  NAMD_bug("PmePencilX cannot be migrated");
232 //__sdag_init();
233  // setMigratable(false);
234  // fftCompute = NULL;
235  // pmeTranspose = NULL;
236 }
237 
239  if (fftCompute != NULL) delete fftCompute;
240  if (pmeTranspose != NULL) delete pmeTranspose;
241 }
242 
243 void PmePencilX::initFFT(PmeStartMsg *msg) {
244  if (fftCompute == NULL)
245  NAMD_bug("PmePencilX::initFFT, fftCompute not initialized");
246  fftCompute->init(msg->data, msg->dataSize, NULL, 0, Perm_X_Y_Z, pmeGrid, 1, thisIndex.y, thisIndex.z, 0);
247 }
248 
249 void PmePencilX::forwardFFT() {
250  if (fftCompute == NULL)
251  NAMD_bug("PmePencilX::forwardFFT, fftCompute not initialized");
252  fftCompute->forward();
253 }
254 
255 void PmePencilX::backwardFFT() {
256  if (fftCompute == NULL)
257  NAMD_bug("PmePencilX::backwardFFT, fftCompute not initialized");
258  fftCompute->backward();
259 }
260 
262  blockSizes.resize(pmeGrid.xBlocks);
263  for (int x=0;x < pmeGrid.xBlocks;x++) {
264  int i0, i1, j0, j1, k0, k1;
265  getBlockDim(pmeGrid, Perm_cX_Y_Z, x, thisIndex.y, thisIndex.z,
266  i0, i1, j0, j1, k0, k1);
267  int size = (i1-i0+1)*(j1-j0+1)*(k1-k0+1);
268  blockSizes[x] = size;
269  }
270 }
271 
272 void PmePencilX::forwardDone() {
273  NAMD_bug("PmePencilX::forwardDone(), base class method called");
274 }
275 
276 void PmePencilX::backwardDone() {
277  NAMD_bug("PmePencilX::backwardDone(), base class method called");
278 }
279 
280 void PmePencilX::recvDataFromY(PmeBlockMsg *msg) {
281  NAMD_bug("PmePencilX::recvDataFromY(), base class method called");
282 }
283 
284 void PmePencilX::start(const CkCallback &) {
285  NAMD_bug("PmePencilX::start(), base class method called");
286 }
287 
288 //###########################################################################
289 //###########################################################################
290 //###########################################################################
291 
293  __sdag_init();
294  setMigratable(false);
295  fftCompute = NULL;
296  pmeTranspose = NULL;
297  numStrayAtoms = 0;
298 }
299 
300 PmePencilY::PmePencilY(CkMigrateMessage *m) {
301  NAMD_bug("PmePencilY cannot be migrated");
302  // __sdag_init();
303  // setMigratable(false);
304  // fftCompute = NULL;
305  // pmeTranspose = NULL;
306 }
307 
309  if (fftCompute != NULL) delete fftCompute;
310  if (pmeTranspose != NULL) delete pmeTranspose;
311 }
312 
313 void PmePencilY::initFFT(PmeStartMsg *msg) {
314  if (fftCompute == NULL)
315  NAMD_bug("PmePencilY::initFFT, fftCompute not initialized");
316  fftCompute->init(msg->data, msg->dataSize, NULL, 0, Perm_Y_Z_cX, pmeGrid, 1, thisIndex.z, thisIndex.x, 0);
317 }
318 
319 void PmePencilY::forwardFFT() {
320  if (fftCompute == NULL)
321  NAMD_bug("PmePencilY::forwardFFT, fftCompute not initialized");
322  fftCompute->forward();
323 }
324 
325 void PmePencilY::backwardFFT() {
326  if (fftCompute == NULL)
327  NAMD_bug("PmePencilY::backwardFFT, fftCompute not initialized");
328  fftCompute->backward();
329 }
330 
332  blockSizes.resize(pmeGrid.yBlocks);
333  for (int y=0;y < pmeGrid.yBlocks;y++) {
334  int i0, i1, j0, j1, k0, k1;
335  getBlockDim(pmeGrid, Perm_Y_Z_cX, y, thisIndex.z, thisIndex.x,
336  i0, i1, j0, j1, k0, k1);
337  int size = (i1-i0+1)*(j1-j0+1)*(k1-k0+1);
338  blockSizes[y] = size;
339  }
340 }
341 
342 void PmePencilY::forwardDone() {
343  NAMD_bug("PmePencilY::forwardDone(), base class method called");
344 }
345 
346 void PmePencilY::backwardDone() {
347  NAMD_bug("PmePencilY::backwardDone(), base class method called");
348 }
349 
350 void PmePencilY::recvDataFromX(PmeBlockMsg *msg) {
351  NAMD_bug("PmePencilY::recvDataFromX(), base class method called");
352 }
353 
354 void PmePencilY::recvDataFromZ(PmeBlockMsg *msg) {
355  NAMD_bug("PmePencilY::recvDataFromZ(), base class method called");
356 }
357 
358 void PmePencilY::start(const CkCallback &) {
359  NAMD_bug("PmePencilY::start(), base class method called");
360 }
361 
362 //###########################################################################
363 //###########################################################################
364 //###########################################################################
365 
367  __sdag_init();
368  setMigratable(false);
369  fftCompute = NULL;
370  pmeTranspose = NULL;
371  pmeKSpaceCompute = NULL;
373  doEnergy = false;
374  doVirial = false;
375  numStrayAtoms = 0;
376 }
377 
378 PmePencilZ::PmePencilZ(CkMigrateMessage *m) {
379  NAMD_bug("PmePencilZ cannot be migrated");
380  //__sdag_init();
381  // setMigratable(false);
382  // fftCompute = NULL;
383  // pmeTranspose = NULL;
384 }
385 
387  if (fftCompute != NULL) delete fftCompute;
388  if (pmeTranspose != NULL) delete pmeTranspose;
389  if (pmeKSpaceCompute != NULL) delete pmeKSpaceCompute;
390  delete reduction;
391 }
392 
393 void PmePencilZ::initFFT(PmeStartMsg *msg) {
394  if (fftCompute == NULL)
395  NAMD_bug("PmePencilZ::initFFT, fftCompute not initialized");
396  fftCompute->init(msg->data, msg->dataSize, NULL, 0, Perm_Z_cX_Y, pmeGrid, 1, thisIndex.x, thisIndex.y, 0);
397 }
398 
399 void PmePencilZ::forwardFFT() {
400  if (fftCompute == NULL)
401  NAMD_bug("PmePencilZ::forwardFFT, fftCompute not initialized");
402  fftCompute->forward();
403 }
404 
405 void PmePencilZ::backwardFFT() {
406  if (fftCompute == NULL)
407  NAMD_bug("PmePencilZ::backwardFFT, fftCompute not initialized");
408  fftCompute->backward();
409 }
410 
412  blockSizes.resize(pmeGrid.zBlocks);
413  for (int z=0;z < pmeGrid.zBlocks;z++) {
414  int i0, i1, j0, j1, k0, k1;
415  getBlockDim(pmeGrid, Perm_Z_cX_Y, z, thisIndex.x, thisIndex.y,
416  i0, i1, j0, j1, k0, k1);
417  int size = (i1-i0+1)*(j1-j0+1)*(k1-k0+1);
418  blockSizes[z] = size;
419  }
420 }
421 
422 void PmePencilZ::forwardDone() {
423  if (pmeKSpaceCompute == NULL)
424  NAMD_bug("PmePencilZ::forwardDone, pmeKSpaceCompute not initialized");
426 }
427 
429  if (pmeKSpaceCompute == NULL)
430  NAMD_bug("PmePencilZ::submitReductions, pmeKSpaceCompute not initialized");
431  double virial[9];
432  double energy = pmeKSpaceCompute->getEnergy();
433  // fprintf(stderr, "PmePencilZ::submitReductions(), numStrayAtoms %d\n", numStrayAtoms);
434  pmeKSpaceCompute->getVirial(virial);
435  reduction->item(REDUCTION_ELECT_ENERGY_SLOW) += energy;
436  reduction->item(REDUCTION_VIRIAL_SLOW_XX) += virial[0];
437  reduction->item(REDUCTION_VIRIAL_SLOW_XY) += virial[1];
438  reduction->item(REDUCTION_VIRIAL_SLOW_XZ) += virial[2];
439  reduction->item(REDUCTION_VIRIAL_SLOW_YX) += virial[3];
440  reduction->item(REDUCTION_VIRIAL_SLOW_YY) += virial[4];
441  reduction->item(REDUCTION_VIRIAL_SLOW_YZ) += virial[5];
442  reduction->item(REDUCTION_VIRIAL_SLOW_ZX) += virial[6];
443  reduction->item(REDUCTION_VIRIAL_SLOW_ZY) += virial[7];
444  reduction->item(REDUCTION_VIRIAL_SLOW_ZZ) += virial[8];
446  reduction->submit();
447  numStrayAtoms = 0;
448 }
449 
450 void PmePencilZ::backwardDone() {
451  NAMD_bug("PmePencilZ::backwardDone(), base class method called");
452 }
453 
454 void PmePencilZ::recvDataFromY(PmeBlockMsg *msg) {
455  NAMD_bug("PmePencilY::recvDataFromY(), base class method called");
456 }
457 
458 void PmePencilZ::start(const CkCallback &) {
459  NAMD_bug("PmePencilZ::start(), base class method called");
460 }
461 
463  reduction->submit();
464 }
465 
466 #include "PmeSolver.def.h"
FFTCompute * fftCompute
Definition: PmeSolver.h:141
virtual ~PmePencilXYZ()
Definition: PmeSolver.C:37
int zBlocks
Definition: PmeBase.h:22
Lattice lattice
Definition: PmeSolver.h:253
bool doEnergy
Definition: PmeSolver.h:248
FFTCompute * fftCompute
Definition: PmeSolver.h:193
std::vector< int > blockSizes
Definition: PmeSolver.h:252
virtual void solve(Lattice &lattice, const bool doEnergy, const bool doVirial, float *data)=0
float x
Definition: PmeSolver.C:3
virtual ~PmePencilXY()
Definition: PmeSolver.C:136
void submitReductions()
Definition: PmeSolver.C:71
virtual void backwardDone()
Definition: PmeSolver.C:67
PmeTranspose * pmeTranspose
Definition: PmeSolver.h:167
virtual void backward()=0
BigReal & item(int i)
Definition: ReductionMgr.h:312
PmeKSpaceCompute * pmeKSpaceCompute
Definition: PmeSolver.h:251
SubmitReduction * willSubmit(int setID, int size=-1)
Definition: ReductionMgr.C:365
Lattice lattice
Definition: PmeSolver.h:143
PmePencilX_SDAG_CODE PmePencilX()
Definition: PmeSolver.C:222
static ReductionMgr * Object(void)
Definition: ReductionMgr.h:278
int numStrayAtoms
Definition: PmeSolver.h:144
std::vector< int > blockSizes
Definition: PmeSolver.h:222
PmeGrid pmeGrid
Definition: PmeSolver.h:164
bool doVirial
Definition: PmeSolver.h:248
PmeTranspose * pmeTranspose
Definition: PmeSolver.h:250
std::vector< int > blockSizes
Definition: PmeSolver.h:195
virtual ~PmePencilY()
Definition: PmeSolver.C:308
PmeTranspose * pmeTranspose
Definition: PmeSolver.h:221
int yBlocks
Definition: PmeBase.h:22
bool doVirial
Definition: PmeSolver.h:140
void initBlockSizes()
Definition: PmeSolver.C:261
float y
Definition: PmeSolver.C:3
int numStrayAtoms
Definition: PmeSolver.h:224
PmeGrid pmeGrid
Definition: PmeSolver.h:247
PmeGrid pmeGrid
Definition: PmeSolver.h:139
void NAMD_bug(const char *err_msg)
Definition: common.C:123
void initBlockSizes()
Definition: PmeSolver.C:331
PmePencilXY_SDAG_CODE PmePencilXY()
Definition: PmeSolver.C:121
PmeKSpaceCompute * pmeKSpaceCompute
Definition: PmeSolver.h:142
FFTCompute * fftCompute
Definition: PmeSolver.h:166
std::vector< int > blockSizes
Definition: PmeSolver.h:168
gridSize z
PmePencilXYZ_SDAG_CODE PmePencilXYZ()
Definition: PmeSolver.C:18
bool doEnergy
Definition: PmeSolver.h:140
int dataSize
Definition: PmeSolver.h:104
virtual void getVirial(double *virial)=0
PmePencilZ_SDAG_CODE PmePencilZ()
Definition: PmeSolver.C:366
float * getDataDst()
FFTCompute * fftCompute
Definition: PmeSolver.h:220
int numStrayAtoms
Definition: PmeSolver.h:254
FFTCompute * fftCompute
Definition: PmeSolver.h:249
void skip()
Definition: PmeSolver.C:91
virtual ~PmePencilX()
Definition: PmeSolver.C:238
float * data
Definition: PmeSolver.h:103
static void getBlockDim(const PmeGrid &pmeGrid, const int permutation, const int iblock, const int jblock, const int kblock, int &i0, int &i1, int &j0, int &j1, int &k0, int &k1)
Definition: PmeSolverUtil.h:86
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)
gridSize y
virtual void forward()=0
void initBlockSizes()
Definition: PmeSolver.C:411
PmeTranspose * pmeTranspose
Definition: PmeSolver.h:194
void submit(void)
Definition: ReductionMgr.h:323
void submitReductions()
Definition: PmeSolver.C:428
int xBlocks
Definition: PmeBase.h:22
void initBlockSizes()
Definition: PmeSolver.C:159
gridSize x
PmePencilY_SDAG_CODE PmePencilY()
Definition: PmeSolver.C:292
virtual ~PmePencilZ()
Definition: PmeSolver.C:386
PmeGrid pmeGrid
Definition: PmeSolver.h:218
PmeGrid pmeGrid
Definition: PmeSolver.h:191
virtual double getEnergy()=0
int numStrayAtoms
Definition: PmeSolver.h:197
void skip()
Definition: PmeSolver.C:462