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

Generated on Thu Nov 23 01:17:14 2017 for NAMD by  doxygen 1.4.7