PmeSolver.C

Go to the documentation of this file.
00001 #include <stdio.h>
00002 #include "Priorities.h"
00003 struct float2 {float x,y;};
00004 #include "PmeSolver.h"
00005 
00006 //
00007 // Data flow for PmePencilXYZ
00008 //
00009 // dataSrc [xyz]   dataDst
00010 //
00011 // dataDst [solve] dataDst
00012 //
00013 // dataDst [xyz]   dataSrc
00014 //
00015 // dataSrc [force]
00016 //
00017 
00018 PmePencilXYZ::PmePencilXYZ() {
00019   __sdag_init();
00020   setMigratable(false);
00021   fftCompute = NULL;
00022   pmeKSpaceCompute = NULL;
00023   reduction = ReductionMgr::Object()->willSubmit(REDUCTIONS_BASIC);
00024   doEnergy = false;
00025   doVirial = false;
00026 }
00027 
00028 PmePencilXYZ::PmePencilXYZ(CkMigrateMessage *m) {
00029   NAMD_bug("PmePencilXYZ cannot be migrated");
00030   //__sdag_init();
00031   // setMigratable(false);
00032   // fftCompute = NULL;
00033   // pmeKSpaceCompute = NULL;
00034   // reduction = ReductionMgr::Object()->willSubmit(REDUCTIONS_BASIC);
00035 }
00036 
00037 PmePencilXYZ::~PmePencilXYZ() {
00038   if (fftCompute != NULL) delete fftCompute;
00039   if (pmeKSpaceCompute != NULL) delete pmeKSpaceCompute;
00040   delete reduction;
00041 }
00042 
00043 void PmePencilXYZ::initFFT(PmeStartMsg *msg) {
00044   if (fftCompute == NULL)
00045     NAMD_bug("PmePencilXYZ::initFFT, fftCompute not initialized");
00046   fftCompute->init(msg->data, msg->dataSize, NULL, 0, Perm_X_Y_Z, pmeGrid, 3, 0, 0, 0);
00047 }
00048 
00049 void PmePencilXYZ::forwardFFT() {
00050   if (fftCompute == NULL)
00051     NAMD_bug("PmePencilXYZ::forwardFFT, fftCompute not initialized");
00052   fftCompute->forward();
00053 }
00054 
00055 void PmePencilXYZ::backwardFFT() {
00056   if (fftCompute == NULL)
00057     NAMD_bug("PmePencilXYZ::backwardFFT, fftCompute not initialized");
00058   fftCompute->backward();
00059 }
00060 
00061 void PmePencilXYZ::forwardDone() {
00062   if (pmeKSpaceCompute == NULL)
00063     NAMD_bug("PmePencilXYZ::forwardDone, pmeKSpaceCompute not initialized");
00064   pmeKSpaceCompute->solve(lattice, doEnergy, doVirial, fftCompute->getDataDst());
00065 }
00066 
00067 void PmePencilXYZ::backwardDone() {
00068   NAMD_bug("PmePencilXYZ::backwardDone(), base class method called");
00069 }
00070 
00071 void PmePencilXYZ::submitReductions() {
00072   if (pmeKSpaceCompute == NULL)
00073     NAMD_bug("PmePencilXYZ::submitReductions, pmeKSpaceCompute not initialized");
00074   double virial[9];
00075   double energy = pmeKSpaceCompute->getEnergy();
00076   pmeKSpaceCompute->getVirial(virial);
00077   reduction->item(REDUCTION_ELECT_ENERGY_SLOW) += energy;
00078   reduction->item(REDUCTION_VIRIAL_SLOW_XX) += virial[0];
00079   reduction->item(REDUCTION_VIRIAL_SLOW_XY) += virial[1];
00080   reduction->item(REDUCTION_VIRIAL_SLOW_XZ) += virial[2];
00081   reduction->item(REDUCTION_VIRIAL_SLOW_YX) += virial[3];
00082   reduction->item(REDUCTION_VIRIAL_SLOW_YY) += virial[4];
00083   reduction->item(REDUCTION_VIRIAL_SLOW_YZ) += virial[5];
00084   reduction->item(REDUCTION_VIRIAL_SLOW_ZX) += virial[6];
00085   reduction->item(REDUCTION_VIRIAL_SLOW_ZY) += virial[7];
00086   reduction->item(REDUCTION_VIRIAL_SLOW_ZZ) += virial[8];
00087   reduction->item(REDUCTION_STRAY_CHARGE_ERRORS) += numStrayAtoms;
00088   reduction->submit();
00089 }
00090 
00091 void PmePencilXYZ::skip() {
00092   reduction->submit();  
00093 }
00094 
00095 //###########################################################################
00096 //###########################################################################
00097 //###########################################################################
00098 
00099 //
00100 // Data flow for PmePencilXY & PmePencilZ
00101 //
00102 // dataSrc(XY) [xy]     dataDst(XY)
00103 //
00104 // dataDst(XY) [transp] dataSrc(Z)
00105 //---------------------------------
00106 //
00107 // dataSrc(Z)  [z]      dataDst(Z)
00108 //
00109 // dataDst(Z)  [solve]  dataDst(Z)
00110 //
00111 // dataDst(Z)  [z]      dataSrc(Z)
00112 //
00113 // dataSrc(Z)  [transp] dataDst(XY)
00114 //---------------------------------
00115 //
00116 // dataDst(XY) [xy]     dataSrc(XY)
00117 //
00118 // dataSrc(XY) [force]
00119 //
00120 
00121 PmePencilXY::PmePencilXY() {
00122   __sdag_init();
00123   setMigratable(false);
00124   fftCompute = NULL;
00125   pmeTranspose = NULL;
00126 }
00127 
00128 PmePencilXY::PmePencilXY(CkMigrateMessage *m) {
00129   NAMD_bug("PmePencilXY cannot be migrated");
00130 //__sdag_init();
00131   // setMigratable(false);
00132   // fftCompute = NULL;
00133   // pmeTranspose = NULL;
00134 }
00135 
00136 PmePencilXY::~PmePencilXY() {
00137   if (fftCompute != NULL) delete fftCompute;
00138   if (pmeTranspose != NULL) delete pmeTranspose;
00139 }
00140 
00141 void PmePencilXY::initFFT(PmeStartMsg *msg) {
00142   if (fftCompute == NULL)
00143     NAMD_bug("PmePencilXY::initFFT, fftCompute not initialized");
00144   fftCompute->init(msg->data, msg->dataSize,  NULL, 0, Perm_X_Y_Z, pmeGrid, 2, 0, thisIndex.z, 0);
00145 }
00146 
00147 void PmePencilXY::forwardFFT() {
00148   if (fftCompute == NULL)
00149     NAMD_bug("PmePencilXY::forwardFFT, fftCompute not initialized");
00150   fftCompute->forward();
00151 }
00152 
00153 void PmePencilXY::backwardFFT() {
00154   if (fftCompute == NULL)
00155     NAMD_bug("PmePencilXY::backwardFFT, fftCompute not initialized");
00156   fftCompute->backward();
00157 }
00158 
00159 void PmePencilXY::initBlockSizes() {
00160   blockSizes.resize(pmeGrid.xBlocks);
00161   for (int x=0;x < pmeGrid.xBlocks;x++) {
00162     int i0, i1, j0, j1, k0, k1;
00163     getBlockDim(pmeGrid, Perm_cX_Y_Z, x, 0, thisIndex.z,
00164       i0, i1, j0, j1, k0, k1);
00165     int size = (i1-i0+1)*(j1-j0+1)*(k1-k0+1);
00166     blockSizes[x] = size;
00167   }
00168 }
00169 
00170 void PmePencilXY::forwardDone() {
00171   NAMD_bug("PmePencilXY::forwardDone(), base class method called");
00172 }
00173 
00174 void PmePencilXY::backwardDone() {
00175   NAMD_bug("PmePencilXY::backwardDone(), base class method called");
00176 }
00177 
00178 void PmePencilXY::recvDataFromZ(PmeBlockMsg *msg) {
00179   NAMD_bug("PmePencilXY::recvDataFromZ(), base class method called");
00180 }
00181 
00182 void PmePencilXY::start() {
00183   NAMD_bug("PmePencilXY::start(), base class method called");
00184 }
00185 
00186 //###########################################################################
00187 //###########################################################################
00188 //###########################################################################
00189 
00190 //
00191 // Data flow for PmePencilX & PmePencilX & PmePencilZ
00192 //
00193 // dataSrc(X) [x]     dataDst(X)
00194 //
00195 // dataDst(X) [transp] dataSrc(Y)
00196 //---------------------------------
00197 //
00198 // dataSrc(Y) [y]      dataDst(Y)
00199 //
00200 // dataDst(Y) [transp] dataSrc(Z)
00201 //---------------------------------
00202 //
00203 // dataSrc(Z) [z]      dataDst(Z)
00204 //
00205 // dataDst(Z) [solve]  dataDst(Z)
00206 //
00207 // dataDst(Z) [z]      dataSrc(Z)
00208 //
00209 // dataSrc(Z) [transp] dataDst(Y)
00210 //---------------------------------
00211 //
00212 // dataDst(Y) [y]      dataSrc(Y)
00213 //
00214 // dataSrc(Y) [transp] dataDst(X)
00215 //---------------------------------
00216 //
00217 // dataDst(X) [x]      dataSrc(X)
00218 //
00219 // dataSrc(X) [force]
00220 //
00221 
00222 PmePencilX::PmePencilX() {
00223   __sdag_init();
00224   setMigratable(false);
00225   fftCompute = NULL;
00226   pmeTranspose = NULL;
00227   numStrayAtoms = 0;
00228 }
00229 
00230 PmePencilX::PmePencilX(CkMigrateMessage *m) {
00231   NAMD_bug("PmePencilX cannot be migrated");
00232 //__sdag_init();
00233   // setMigratable(false);
00234   // fftCompute = NULL;
00235   // pmeTranspose = NULL;
00236 }
00237 
00238 PmePencilX::~PmePencilX() {
00239   if (fftCompute != NULL) delete fftCompute;
00240   if (pmeTranspose != NULL) delete pmeTranspose;
00241 }
00242 
00243 void PmePencilX::initFFT(PmeStartMsg *msg) {
00244   if (fftCompute == NULL)
00245     NAMD_bug("PmePencilX::initFFT, fftCompute not initialized");
00246   fftCompute->init(msg->data, msg->dataSize,  NULL, 0, Perm_X_Y_Z, pmeGrid, 1, thisIndex.y, thisIndex.z, 0);
00247 }
00248 
00249 void PmePencilX::forwardFFT() {
00250   if (fftCompute == NULL)
00251     NAMD_bug("PmePencilX::forwardFFT, fftCompute not initialized");
00252   fftCompute->forward();
00253 }
00254 
00255 void PmePencilX::backwardFFT() {
00256   if (fftCompute == NULL)
00257     NAMD_bug("PmePencilX::backwardFFT, fftCompute not initialized");
00258   fftCompute->backward();
00259 }
00260 
00261 void PmePencilX::initBlockSizes() {
00262   blockSizes.resize(pmeGrid.xBlocks);
00263   for (int x=0;x < pmeGrid.xBlocks;x++) {
00264     int i0, i1, j0, j1, k0, k1;
00265     getBlockDim(pmeGrid, Perm_cX_Y_Z, x, thisIndex.y, thisIndex.z,
00266       i0, i1, j0, j1, k0, k1);
00267     int size = (i1-i0+1)*(j1-j0+1)*(k1-k0+1);
00268     blockSizes[x] = size;
00269   }
00270 }
00271 
00272 void PmePencilX::forwardDone() {
00273   NAMD_bug("PmePencilX::forwardDone(), base class method called");
00274 }
00275 
00276 void PmePencilX::backwardDone() {
00277   NAMD_bug("PmePencilX::backwardDone(), base class method called");
00278 }
00279 
00280 void PmePencilX::recvDataFromY(PmeBlockMsg *msg) {
00281   NAMD_bug("PmePencilX::recvDataFromY(), base class method called");
00282 }
00283 
00284 void PmePencilX::start() {
00285   NAMD_bug("PmePencilX::start(), base class method called");
00286 }
00287 
00288 //###########################################################################
00289 //###########################################################################
00290 //###########################################################################
00291 
00292 PmePencilY::PmePencilY() {
00293   __sdag_init();
00294   setMigratable(false);
00295   fftCompute = NULL;
00296   pmeTranspose = NULL;
00297   numStrayAtoms = 0;
00298 }
00299 
00300 PmePencilY::PmePencilY(CkMigrateMessage *m) {
00301   NAMD_bug("PmePencilY cannot be migrated");
00302   // __sdag_init();
00303   // setMigratable(false);
00304   // fftCompute = NULL;
00305   // pmeTranspose = NULL;
00306 }
00307 
00308 PmePencilY::~PmePencilY() {
00309   if (fftCompute != NULL) delete fftCompute;
00310   if (pmeTranspose != NULL) delete pmeTranspose;
00311 }
00312 
00313 void PmePencilY::initFFT(PmeStartMsg *msg) {
00314   if (fftCompute == NULL)
00315     NAMD_bug("PmePencilY::initFFT, fftCompute not initialized");
00316   fftCompute->init(msg->data, msg->dataSize,  NULL, 0, Perm_Y_Z_cX, pmeGrid, 1, thisIndex.z, thisIndex.x, 0);
00317 }
00318 
00319 void PmePencilY::forwardFFT() {
00320   if (fftCompute == NULL)
00321     NAMD_bug("PmePencilY::forwardFFT, fftCompute not initialized");
00322   fftCompute->forward();
00323 }
00324 
00325 void PmePencilY::backwardFFT() {
00326   if (fftCompute == NULL)
00327     NAMD_bug("PmePencilY::backwardFFT, fftCompute not initialized");
00328   fftCompute->backward();
00329 }
00330 
00331 void PmePencilY::initBlockSizes() {
00332   blockSizes.resize(pmeGrid.yBlocks);
00333   for (int y=0;y < pmeGrid.yBlocks;y++) {
00334     int i0, i1, j0, j1, k0, k1;
00335     getBlockDim(pmeGrid, Perm_Y_Z_cX, y, thisIndex.z, thisIndex.x,
00336       i0, i1, j0, j1, k0, k1);
00337     int size = (i1-i0+1)*(j1-j0+1)*(k1-k0+1);
00338     blockSizes[y] = size;
00339   }
00340 }
00341 
00342 void PmePencilY::forwardDone() {
00343   NAMD_bug("PmePencilY::forwardDone(), base class method called");
00344 }
00345 
00346 void PmePencilY::backwardDone() {
00347   NAMD_bug("PmePencilY::backwardDone(), base class method called");
00348 }
00349 
00350 void PmePencilY::recvDataFromX(PmeBlockMsg *msg) {
00351   NAMD_bug("PmePencilY::recvDataFromX(), base class method called");
00352 }
00353 
00354 void PmePencilY::recvDataFromZ(PmeBlockMsg *msg) {
00355   NAMD_bug("PmePencilY::recvDataFromZ(), base class method called");
00356 }
00357 
00358 void PmePencilY::start() {
00359   NAMD_bug("PmePencilY::start(), base class method called");
00360 }
00361 
00362 //###########################################################################
00363 //###########################################################################
00364 //###########################################################################
00365 
00366 PmePencilZ::PmePencilZ() {
00367   __sdag_init();
00368   setMigratable(false);
00369   fftCompute = NULL;
00370   pmeTranspose = NULL;
00371   pmeKSpaceCompute = NULL;
00372   reduction = ReductionMgr::Object()->willSubmit(REDUCTIONS_BASIC);
00373   doEnergy = false;
00374   doVirial = false;
00375   numStrayAtoms = 0;
00376 }
00377 
00378 PmePencilZ::PmePencilZ(CkMigrateMessage *m) {
00379   NAMD_bug("PmePencilZ cannot be migrated");
00380   //__sdag_init();
00381   // setMigratable(false);
00382   // fftCompute = NULL;
00383   // pmeTranspose = NULL;
00384 }
00385 
00386 PmePencilZ::~PmePencilZ() {
00387   if (fftCompute != NULL) delete fftCompute;
00388   if (pmeTranspose != NULL) delete pmeTranspose;
00389   if (pmeKSpaceCompute != NULL) delete pmeKSpaceCompute;
00390   delete reduction;
00391 }
00392 
00393 void PmePencilZ::initFFT(PmeStartMsg *msg) {
00394   if (fftCompute == NULL)
00395     NAMD_bug("PmePencilZ::initFFT, fftCompute not initialized");
00396   fftCompute->init(msg->data, msg->dataSize,  NULL, 0, Perm_Z_cX_Y, pmeGrid, 1, thisIndex.x, thisIndex.y, 0); 
00397 }
00398 
00399 void PmePencilZ::forwardFFT() {
00400   if (fftCompute == NULL)
00401     NAMD_bug("PmePencilZ::forwardFFT, fftCompute not initialized");
00402   fftCompute->forward();
00403 }
00404 
00405 void PmePencilZ::backwardFFT() {
00406   if (fftCompute == NULL)
00407     NAMD_bug("PmePencilZ::backwardFFT, fftCompute not initialized");
00408   fftCompute->backward();
00409 }
00410 
00411 void PmePencilZ::initBlockSizes() {
00412   blockSizes.resize(pmeGrid.zBlocks);
00413   for (int z=0;z < pmeGrid.zBlocks;z++) {
00414     int i0, i1, j0, j1, k0, k1;
00415     getBlockDim(pmeGrid, Perm_Z_cX_Y, z, thisIndex.x, thisIndex.y,
00416       i0, i1, j0, j1, k0, k1);
00417     int size = (i1-i0+1)*(j1-j0+1)*(k1-k0+1);
00418     blockSizes[z] = size;
00419   }
00420 }
00421 
00422 void PmePencilZ::forwardDone() {
00423   if (pmeKSpaceCompute == NULL)
00424     NAMD_bug("PmePencilZ::forwardDone, pmeKSpaceCompute not initialized");
00425   pmeKSpaceCompute->solve(lattice, doEnergy, doVirial, fftCompute->getDataDst());
00426 }
00427 
00428 void PmePencilZ::submitReductions() {
00429   if (pmeKSpaceCompute == NULL)
00430     NAMD_bug("PmePencilZ::submitReductions, pmeKSpaceCompute not initialized");
00431   double virial[9];
00432   double energy = pmeKSpaceCompute->getEnergy();
00433   // fprintf(stderr, "PmePencilZ::submitReductions(), numStrayAtoms %d\n", numStrayAtoms);
00434   pmeKSpaceCompute->getVirial(virial);
00435   reduction->item(REDUCTION_ELECT_ENERGY_SLOW) += energy;
00436   reduction->item(REDUCTION_VIRIAL_SLOW_XX) += virial[0];
00437   reduction->item(REDUCTION_VIRIAL_SLOW_XY) += virial[1];
00438   reduction->item(REDUCTION_VIRIAL_SLOW_XZ) += virial[2];
00439   reduction->item(REDUCTION_VIRIAL_SLOW_YX) += virial[3];
00440   reduction->item(REDUCTION_VIRIAL_SLOW_YY) += virial[4];
00441   reduction->item(REDUCTION_VIRIAL_SLOW_YZ) += virial[5];
00442   reduction->item(REDUCTION_VIRIAL_SLOW_ZX) += virial[6];
00443   reduction->item(REDUCTION_VIRIAL_SLOW_ZY) += virial[7];
00444   reduction->item(REDUCTION_VIRIAL_SLOW_ZZ) += virial[8];
00445   reduction->item(REDUCTION_STRAY_CHARGE_ERRORS) += numStrayAtoms;
00446   reduction->submit();
00447   numStrayAtoms = 0;
00448 }
00449 
00450 void PmePencilZ::backwardDone() {
00451   NAMD_bug("PmePencilZ::backwardDone(), base class method called");
00452 }
00453 
00454 void PmePencilZ::recvDataFromY(PmeBlockMsg *msg) {
00455   NAMD_bug("PmePencilY::recvDataFromY(), base class method called");
00456 }
00457 
00458 void PmePencilZ::start() {
00459   NAMD_bug("PmePencilZ::start(), base class method called");
00460 }
00461 
00462 void PmePencilZ::skip() {
00463   reduction->submit();  
00464 }
00465 
00466 #include "PmeSolver.def.h"

Generated on Thu Oct 18 01:17:15 2018 for NAMD by  doxygen 1.4.7