#include <OptPme.h>
Inheritance diagram for OptPmeCompute:

Public Member Functions | |
| OptPmeCompute (ComputeID c) | |
| virtual | ~OptPmeCompute () |
| void | doWork () |
| void | doWorkOnPeer () |
| void | sendPencils () |
| void | copyPencils (OptPmeGridMsg *) |
| void | ungridForces_init () |
| void | ungridForces_compute (int istart, int iend) |
| void | ungridForces_finalize () |
| void | setMgr (OptPmeMgr *mgr) |
| int | getNumLocalAtoms () |
Public Attributes | |
| double * | zline_storage |
| float * | sp_zstorage |
|
|
Definition at line 613 of file OptPme.C. References SimParameters::accelMDOn, DebugM, Node::Object(), ReductionMgr::Object(), REDUCTIONS_AMD, REDUCTIONS_BASIC, Node::simParameters, simParams, and ReductionMgr::willSubmit(). 00613 : 00614 ComputeHomePatches(c) 00615 { 00616 DebugM(4,"OptPmeCompute created.\n"); 00617 00618 CProxy_OptPmeMgr::ckLocalBranch( 00619 CkpvAccess(BOCclass_group).computePmeMgr)->setCompute(this); 00620 00621 _initialized = false; 00622 00623 useAvgPositions = 1; 00624 localResults = NULL; 00625 00626 reduction = ReductionMgr::Object()->willSubmit(REDUCTIONS_BASIC); 00627 SimParameters *simParams = Node::Object()->simParameters; 00628 if (simParams->accelMDOn) { 00629 amd_reduction = ReductionMgr::Object()->willSubmit(REDUCTIONS_AMD); 00630 } else { 00631 amd_reduction = NULL; 00632 } 00633 }
|
|
|
Definition at line 835 of file OptPme.C. 00836 {
00837 delete [] zline_storage;
00838 delete [] sp_zstorage;
00839 delete [] q_arr;
00840 }
|
|
|
Definition at line 1017 of file OptPme.C. References PmeGrid::dim2, OptPmeGridMsg::qgrid, OptPmeGridMsg::xlen, OptPmeGridMsg::xstart, OptPmeGridMsg::ylen, and OptPmeGridMsg::ystart. Referenced by OptPmeMgr::recvUngrid(). 01017 {
01018
01019 if (!_initialized) initializeOptPmeCompute();
01020
01021 int ibegin = msg->xstart;
01022 int iend = msg->xstart + msg->xlen;
01023 int jbegin = msg->ystart;
01024 int jend = msg->ylen;
01025 int fcount = zlen * msg->xlen * msg->ylen;
01026
01027 float *qmsg = msg->qgrid;
01028 double *data = q_arr[ibegin * myGrid.dim2 + jbegin];
01029
01030 #pragma disjoint (*qmsg, *data)
01031 #pragma unroll(8)
01032 for ( int k=0; k<fcount; ++k )
01033 data[k] = *(qmsg++);
01034 }
|
|
|
Reimplemented from Compute. Definition at line 843 of file OptPme.C. References OptPmeMgr::_iter, ResizeArrayIter< T >::begin(), BigReal, PmeParticle::cg, DebugM, OptPmeSubComputeMsg::dest, doWorkOnPeer(), ResizeArrayIter< T >::end(), PmeGrid::order, scale_n_copy_coordinates(), OptPmeMgr::subcompute_msgs, SubmitReduction::submit(), and TRACE_COMPOBJ_IDOFFSET. 00844 {
00845 DebugM(4,"Entering OptPmeCompute::doWork().\n");
00846
00847 #ifdef TRACE_COMPUTE_OBJECTS
00848 double traceObjStartTime = CmiWallTimer();
00849 #endif
00850
00851 if (!_initialized) initializeOptPmeCompute();
00852
00853 ResizeArrayIter<PatchElem> ap(patchList);
00854
00855 // Skip computations if nothing to do.
00856 if ( ! patchList[0].p->flags.doFullElectrostatics )
00857 {
00858 for (ap = ap.begin(); ap != ap.end(); ap++) {
00859 CompAtom *x = (*ap).positionBox->open();
00860 Results *r = (*ap).forceBox->open();
00861 (*ap).positionBox->close(&x);
00862 (*ap).forceBox->close(&r);
00863 }
00864 reduction->submit();
00865 if (amd_reduction) amd_reduction->submit();
00866 return;
00867 }
00868
00869 myMgr->_iter ++; //this is a pme step
00870
00871 // allocate storage
00872 numLocalAtoms = 0;
00873 for (ap = ap.begin(); ap != ap.end(); ap++) {
00874 numLocalAtoms += (*ap).p->getNumAtoms();
00875 }
00876
00877 Lattice &lattice = patchList[0].p->flags.lattice;
00878
00879 localData = new PmeParticle[numLocalAtoms];
00880 // get positions and charges
00881 PmeParticle * data_ptr = localData;
00882
00883 int natoms = 0;
00884 // if (myMgr->constant_pressure)
00885 //resetPatchCoordinates(lattice); //Update patch coordinates with new lattice
00886
00887 for (ap = ap.begin(); ap != ap.end(); ap++) {
00888 #ifdef NETWORK_PROGRESS
00889 CmiNetworkProgress();
00890 #endif
00891
00892 CompAtom *x = (*ap).positionBox->open();
00893 if ( patchList[0].p->flags.doMolly ) {
00894 (*ap).positionBox->close(&x);
00895 x = (*ap).avgPositionBox->open();
00896 }
00897 int numAtoms = (*ap).p->getNumAtoms();
00898 int order_1 = myGrid.order - 1;
00899 scale_n_copy_coordinates(x, localData, numAtoms,
00900 lattice, myGrid,
00901 xstart + order_1, xlen - order_1,
00902 ystart + order_1, ylen - order_1,
00903 zstart + order_1, zlen - order_1,
00904 strayChargeErrors);
00905 natoms += numAtoms;
00906
00907 if ( patchList[0].p->flags.doMolly ) { (*ap).avgPositionBox->close(&x); }
00908 else { (*ap).positionBox->close(&x); }
00909 }
00910
00911 numLocalAtoms = natoms; //Exclude all atoms out of range
00912
00913 // calculate self energy
00914 BigReal ewaldcof = ComputeNonbondedUtil::ewaldcof;
00915 evir = 0;
00916 BigReal selfEnergy = 0;
00917 data_ptr = localData;
00918 int i;
00919 for(i=0; i<numLocalAtoms; ++i)
00920 {
00921 selfEnergy += data_ptr->cg * data_ptr->cg;
00922 ++data_ptr;
00923 }
00924 selfEnergy *= -1. * ewaldcof / SQRT_PI;
00925 evir[0] += selfEnergy;
00926
00927 #if 0
00928 if (myMgr->_iter > many_to_many_start) {
00929 OptPmeSubComputeMsg *smsg = myMgr->subcompute_msgs[1]; //not self
00930 CProxy_OptPmeMgr pmeProxy (CkpvAccess(BOCclass_group).computePmeMgr);
00931 pmeProxy[CmiNodeFirst(CmiMyNode())+smsg->dest].doWorkOnPeer(smsg);
00932 }
00933 else
00934 #endif
00935 doWorkOnPeer();
00936
00937 #ifdef TRACE_COMPUTE_OBJECTS
00938 traceUserBracketEvent(TRACE_COMPOBJ_IDOFFSET+this->cid, traceObjStartTime, CmiWallTimer());
00939 #endif
00940
00941 }
|
|
|
Definition at line 943 of file OptPme.C. References OptPmeMgr::_iter, OptPmeMgr::constant_pressure, OptPmeRealSpace::fill_charges(), OptPmeMgr::handle, PHASE_GR, pme_d2f(), sendPencils(), sp_zstorage, OptPmeMgr::xPencil, and zline_storage. Referenced by doWork(), and OptPmeMgr::doWorkOnPeer(). 00944 {
00945 Lattice &lattice = patchList[0].p->flags.lattice;
00946 double **q = q_arr;
00947 memset( (void*) zline_storage, 0, zlen * nzlines * sizeof(double) );
00948
00949 myRealSpace = new OptPmeRealSpace(myGrid,numLocalAtoms);
00950 if (!strayChargeErrors)
00951 myRealSpace->fill_charges(q, localData, zstart, zlen);
00952
00953 if (myMgr->constant_pressure && patchList[0].patchID == 0)
00954 myMgr->xPencil.recvLattice (lattice);
00955
00956 if (myMgr->_iter <= many_to_many_start)
00957 sendPencils();
00958 #if CHARM_VERSION > 60000
00959 else {
00960 pme_d2f (sp_zstorage, zline_storage, nzlines * zlen);
00961 CmiDirect_manytomany_start (myMgr->handle, PHASE_GR);
00962 }
00963 #endif
00964 }
|
|
|
Definition at line 66 of file OptPme.h. Referenced by OptPmeMgr::ungridCalc(). 00066 { return numLocalAtoms; }
|
|
|
Definition at line 968 of file OptPme.C. References PmeGrid::block1, PmeGrid::block2, PmeGrid::dim2, PmeGrid::dim3, PmeGrid::K1, PmeGrid::K2, OptPmeGridMsg::patchID, OptPmeGridMsg::qgrid, ResizeArray< Elem >::size(), OptPmeGridMsg::sourceNode, PmeGrid::xBlocks, OptPmeGridMsg::xlen, OptPmeGridMsg::xstart, PmeGrid::yBlocks, OptPmeGridMsg::ylen, OptPmeGridMsg::ystart, PmeGrid::zBlocks, OptPmeGridMsg::zlen, OptPmeMgr::zPencil, and OptPmeGridMsg::zstart. Referenced by doWorkOnPeer(). 00968 {
00969
00970 //iout << iPE << " Sending charge grid for " << numLocalAtoms << " atoms to FFT with " << myMgr->numPencilsActive << " messages" <<".\n" << endi;
00971
00972 int xBlocks = myGrid.xBlocks;
00973 int yBlocks = myGrid.yBlocks;
00974 int zBlocks = myGrid.zBlocks;
00975
00976 int K1 = myGrid.K1;
00977 int K2 = myGrid.K2;
00978 int dim2 = myGrid.dim2;
00979 int dim3 = myGrid.dim3;
00980 int block1 = myGrid.block1;
00981 int block2 = myGrid.block2;
00982
00983 //Lattice lattice = patchList[0].p->flags.lattice;
00984
00985 int nactive = 0;
00986 for (int idx = 0; idx < pencilVec.size(); idx++) {
00987 int xstart = pencilVec[idx].xmin;
00988 int ystart = pencilVec[idx].ymin;
00989 int xlen = pencilVec[idx].xmax - pencilVec[idx].xmin + 1;
00990 int ylen = pencilVec[idx].ymax - pencilVec[idx].ymin + 1;
00991 int ib = pencilVec[idx].ib;
00992 int jb = pencilVec[idx].jb;
00993 double *data = pencilVec[idx].data;
00994
00995 int fcount = xlen * ylen * zlen;
00996 OptPmeGridMsg *msg = new (fcount, PRIORITY_SIZE) OptPmeGridMsg;
00997 msg->zstart = zstart;
00998 msg->zlen = zlen;
00999 msg->xstart = xstart;
01000 msg->xlen = xlen;
01001 msg->ystart = ystart;
01002 msg->ylen = ylen;
01003 msg->sourceNode = CkMyPe();
01004 msg->patchID = patchList[0].patchID;
01005
01006 float *qmsg = msg->qgrid;
01007 #pragma disjoint (*data, *qmsg)
01008 #pragma unroll(8)
01009 for ( int k=0; k< fcount; ++k )
01010 *(qmsg++) = data[k];
01011
01012 myMgr->zPencil(ib,jb,0).recvGrid(msg);
01013 }
01014 }
|
|
|
Definition at line 64 of file OptPme.h. Referenced by OptPmeMgr::setCompute(). 00064 { myMgr = mgr; }
|
|
||||||||||||
|
Definition at line 1047 of file OptPme.C. References SimParameters::commOnly, OptPmeRealSpace::compute_forces(), Node::Object(), scale_forces(), Node::simParameters, and simParams. Referenced by OptPmeMgr::ungridCalc(), and OptPmeMgr::ungridCalc_subcompute(). 01049 {
01050 Vector *gridResults;
01051 gridResults = localResults;
01052
01053 if (iend == 0)
01054 iend = numLocalAtoms;
01055
01056 SimParameters *simParams = Node::Object()->simParameters;
01057 Vector pairForce = 0.;
01058 Lattice &lattice = patchList[0].p->flags.lattice;
01059 if(!simParams->commOnly) {
01060 #ifdef NETWORK_PROGRESS
01061 CmiNetworkProgress();
01062 #endif
01063 if (!strayChargeErrors) {
01064 myRealSpace->compute_forces(q_arr, localData, gridResults,
01065 zstart, zlen, istart, iend);
01066 scale_forces(gridResults + istart, iend - istart, lattice);
01067 }
01068 }
01069 }
|
|
|
Definition at line 1071 of file OptPme.C. References ResizeArrayIter< T >::begin(), SimParameters::commOnly, ResizeArrayIter< T >::end(), Results::f, Force, SubmitReduction::item(), Node::Object(), REDUCTION_ELECT_ENERGY_SLOW, REDUCTION_STRAY_CHARGE_ERRORS, Node::simParameters, simParams, SubmitReduction::submit(), Vector::x, Vector::y, and Vector::z. Referenced by OptPmeMgr::ungridCalc(), and OptPmeMgr::ungridCalc_subcompute_done(). 01071 {
01072 SimParameters *simParams = Node::Object()->simParameters;
01073 delete myRealSpace;
01074
01075 delete [] localData;
01076 // delete [] localPartition;
01077
01078 Vector *results_ptr = localResults;
01079 ResizeArrayIter<PatchElem> ap(patchList);
01080
01081 // add in forces
01082 for (ap = ap.begin(); ap != ap.end(); ap++) {
01083 Results *r = (*ap).forceBox->open();
01084 Force *f = r->f[Results::slow];
01085 int numAtoms = (*ap).p->getNumAtoms();
01086
01087 if ( ! strayChargeErrors && ! simParams->commOnly ) {
01088 for(int i=0; i<numAtoms; ++i) {
01089 f[i].x += results_ptr->x;
01090 f[i].y += results_ptr->y;
01091 f[i].z += results_ptr->z;
01092 ++results_ptr;
01093 }
01094 }
01095
01096 (*ap).forceBox->close(&r);
01097 }
01098
01099 delete [] localResults;
01100
01101 double scale = 1.;
01102
01103 reduction->item(REDUCTION_ELECT_ENERGY_SLOW) += evir[0] * scale;
01104 reduction->item(REDUCTION_STRAY_CHARGE_ERRORS) += strayChargeErrors;
01105 strayChargeErrors = 0;
01106 reduction->submit();
01107 if (amd_reduction) {
01108 amd_reduction->item(REDUCTION_ELECT_ENERGY_SLOW) += evir[0] * scale;
01109 amd_reduction->submit();
01110 }
01111 }
|
|
|
Definition at line 1036 of file OptPme.C. References OptPmeMgr::_iter, pme_f2d(), sp_zstorage, and zline_storage. Referenced by OptPmeMgr::ungridCalc(). 01036 {
01037
01038 //printf ("%d: In OptPMECompute::ungridforces_init\n", CkMyPe());
01039
01040 if (myMgr->_iter > many_to_many_start)
01041 pme_f2d (zline_storage, sp_zstorage, nzlines * zlen);
01042
01043 localResults = new Vector[numLocalAtoms];
01044 //memset (localResults, 0, sizeof (Vector) * numLocalAtoms);
01045 }
|
|
|
Definition at line 69 of file OptPme.h. Referenced by doWorkOnPeer(), and ungridForces_init(). |
|
|
Definition at line 68 of file OptPme.h. Referenced by doWorkOnPeer(), and ungridForces_init(). |
1.3.9.1