NAMD
Public Member Functions | List of all members
ComputeMsm Class Reference

#include <ComputeMsm.h>

Inheritance diagram for ComputeMsm:
ComputeHomePatches Compute

Public Member Functions

 ComputeMsm (ComputeID c)
 
virtual ~ComputeMsm ()
 
void doWork ()
 
void saveResults ()
 
void setMgr (ComputeMsmMgr *mgr)
 
- Public Member Functions inherited from ComputeHomePatches
 ComputeHomePatches (ComputeID c)
 
virtual ~ComputeHomePatches ()
 
virtual void initialize ()
 
virtual void atomUpdate ()
 
FlagsgetFlags (void)
 
- Public Member Functions inherited from Compute
 Compute (ComputeID)
 
int type ()
 
virtual ~Compute ()
 
void setNumPatches (int n)
 
int getNumPatches ()
 
virtual void patchReady (PatchID, int doneMigration, int seq)
 
virtual int noWork ()
 
virtual void finishPatch (int)
 
int sequence (void)
 
int priority (void)
 
int getGBISPhase (void)
 
virtual void gbisP2PatchReady (PatchID, int seq)
 
virtual void gbisP3PatchReady (PatchID, int seq)
 

Additional Inherited Members

- Public Attributes inherited from Compute
const ComputeID cid
 
LDObjHandle ldObjHandle
 
LocalWorkMsg *const localWorkMsg
 
- Protected Member Functions inherited from Compute
void enqueueWork ()
 
- Protected Attributes inherited from ComputeHomePatches
int useAvgPositions
 
int hasPatchZero
 
ComputeHomePatchList patchList
 
PatchMappatchMap
 
- Protected Attributes inherited from Compute
int computeType
 
int basePriority
 
int gbisPhase
 
int gbisPhasePriority [3]
 

Detailed Description

Definition at line 25 of file ComputeMsm.h.

Constructor & Destructor Documentation

ComputeMsm::ComputeMsm ( ComputeID  c)

Definition at line 6053 of file ComputeMsm.C.

References COULOMB, SimParameters::dielectric, Node::Object(), ReductionMgr::Object(), REDUCTIONS_BASIC, Node::simParameters, and ReductionMgr::willSubmit().

6053  : ComputeHomePatches(c)
6054 {
6055  CProxy_ComputeMsmMgr::ckLocalBranch(
6056  CkpvAccess(BOCclass_group).computeMsmMgr)->setCompute(this);
6058  qscaling = sqrtf(COULOMB / simParams->dielectric);
6060 #ifdef DEBUG_MSM_VERBOSE
6061  printf("ComputeMsm: (constructor) PE=%d\n", CkMyPe());
6062 #endif
6063 }
static Node * Object()
Definition: Node.h:86
SimParameters * simParameters
Definition: Node.h:178
#define COULOMB
Definition: common.h:44
SubmitReduction * willSubmit(int setID, int size=-1)
Definition: ReductionMgr.C:365
static ReductionMgr * Object(void)
Definition: ReductionMgr.h:278
ComputeHomePatches(ComputeID c)
#define simParams
Definition: Output.C:127
BigReal dielectric
ComputeMsm::~ComputeMsm ( )
virtual

Definition at line 6065 of file ComputeMsm.C.

6066 {
6067  // free memory
6068 #ifdef DEBUG_MSM_VERBOSE
6069  printf("ComputeMsm: (destructor) PE=%d\n", CkMyPe());
6070 #endif
6071 }

Member Function Documentation

void ComputeMsm::doWork ( void  )
virtual

Reimplemented from Compute.

Definition at line 6073 of file ComputeMsm.C.

References msm::Array< T >::append(), ASSERT, ResizeArrayIter< Type >::begin(), CompAtom::charge, ComputeMsmMgr::compute(), msm::PatchData::coordArray(), ResizeArrayIter< Type >::end(), CompAtomExt::id, msm::PatchData::init(), msm::Array< T >::len(), ComputeMsmMgr::mapData(), ComputeHomePatches::patchList, ComputeMsmMgr::patchPtrArray(), CompAtom::position, msm::Array< T >::resize(), Compute::sequence(), msm::PatchData::sequence, ResizeArray< T >::size(), SubmitReduction::submit(), and x.

6074 {
6075  // for each patch do stuff
6076 #ifdef DEBUG_MSM_VERBOSE
6077  printf("ComputeMsm: doWork() PE=%d\n", CkMyPe());
6078 #endif
6079 
6080 #if 0
6081 #ifdef MSM_TIMING
6082  myMgr->initTiming();
6083 #endif
6084 #ifdef MSM_PROFILING
6085  myMgr->initProfiling();
6086 #endif
6087 #endif
6088 
6089  // patchList is inherited from ComputeHomePatches
6091  numLocalPatches = patchList.size();
6092  cntLocalPatches = 0;
6093  ASSERT(cntLocalPatches < numLocalPatches);
6094 
6095 #ifdef DEBUG_MSM_VERBOSE
6096  printf("patchList size = %d\n", patchList.size() );
6097 #endif
6098 
6099  // Skip computations if nothing to do.
6100  if ( ! patchList[0].p->flags.doFullElectrostatics ) {
6101  for (ap = ap.begin(); ap != ap.end(); ap++) {
6102  CompAtom *x = (*ap).positionBox->open();
6103  Results *r = (*ap).forceBox->open();
6104  (*ap).positionBox->close(&x);
6105  (*ap).forceBox->close(&r);
6106  }
6107  reduction->submit();
6108  return;
6109  }
6110  msm::Map& map = myMgr->mapData();
6111  // This is the patchPtr array for MSM; any local patch will be set up
6112  // with a non-NULL pointer to its supporting data structure.
6113  msm::PatchPtrArray& patchPtr = myMgr->patchPtrArray();
6114  // also store just a list of IDs for the local patches
6115  msm::Array<int> patchIDList(numLocalPatches);
6116  patchIDList.resize(0); // to use append on pre-allocated array buffer
6117  int cnt=0, n;
6118  for (ap = ap.begin(); ap != ap.end(); ap++) {
6119  CompAtom *x = (*ap).positionBox->open();
6120  CompAtomExt *xExt = (*ap).p->getCompAtomExtInfo();
6121  if ( patchList[0].p->flags.doMolly ) {
6122  (*ap).positionBox->close(&x);
6123  x = (*ap).avgPositionBox->open();
6124  }
6125  int numAtoms = (*ap).p->getNumAtoms();
6126  int patchID = (*ap).patchID;
6127  patchIDList.append(patchID);
6128  if (patchPtr[patchID] == NULL) {
6129  // create PatchData if it doesn't exist for this patchID
6130  patchPtr[patchID] = new msm::PatchData(myMgr, patchID);
6131 #ifdef DEBUG_MSM_VERBOSE
6132  printf("Creating new PatchData: patchID=%d PE=%d\n",
6133  patchID, CkMyPe());
6134 #endif
6135  }
6136  msm::PatchData& patch = *(patchPtr[patchID]);
6137  patch.init(numAtoms);
6138  msm::AtomCoordArray& coord = patch.coordArray();
6139  ASSERT(coord.len() == numAtoms);
6140  for (n = 0; n < numAtoms; n++) {
6141  coord[n].position = x[n].position;
6142  coord[n].charge = qscaling * x[n].charge;
6143  coord[n].id = xExt[n].id;
6144  }
6145  if ( patchList[0].p->flags.doMolly ) {
6146  (*ap).avgPositionBox->close(&x);
6147  }
6148  else {
6149  (*ap).positionBox->close(&x);
6150  }
6151  patch.sequence = sequence();
6152  }
6153 
6154  myMgr->compute(patchIDList);
6155 }
msm::Map & mapData()
Definition: ComputeMsm.C:447
int len() const
Definition: MsmMap.h:218
int sequence(void)
Definition: Compute.h:64
ComputeHomePatchList patchList
Position position
Definition: NamdTypes.h:53
void compute(msm::Array< int > &patchIDList)
Definition: ComputeMsm.C:5986
Charge charge
Definition: NamdTypes.h:54
#define ASSERT(E)
AtomCoordArray & coordArray()
Definition: ComputeMsm.C:1756
msm::PatchPtrArray & patchPtrArray()
Definition: ComputeMsm.C:445
void submit(void)
Definition: ReductionMgr.h:323
int size(void) const
Definition: ResizeArray.h:127
gridSize x
void init(int natoms)
Definition: ComputeMsm.C:6248
void ComputeMsm::saveResults ( )

Definition at line 6157 of file ComputeMsm.C.

References ASSERT, ResizeArrayIter< Type >::begin(), ResizeArrayIter< Type >::end(), msm::PatchData::energy, Results::f, msm::PatchData::force, SubmitReduction::item(), msm::Array< T >::len(), ComputeMsmMgr::mapData(), NAMD_die(), ComputeHomePatches::patchList, msm::Map::patchList, ComputeMsmMgr::patchPtrArray(), REDUCTION_ELECT_ENERGY_SLOW, Results::slow, SubmitReduction::submit(), ComputeMsmMgr::virial, ComputeMsmMgr::VXX, ComputeMsmMgr::VXY, ComputeMsmMgr::VXZ, ComputeMsmMgr::VYY, ComputeMsmMgr::VYZ, and ComputeMsmMgr::VZZ.

Referenced by ComputeMsmMgr::doneCompute().

6158 {
6159  if (++cntLocalPatches != numLocalPatches) return;
6160 
6161  // NAMD patches
6163 #ifdef DEBUG_MSM
6164  for (ap = ap.begin(); ap != ap.end(); ap++) {
6165  int patchID = (*ap).patchID;
6166  ASSERT(myMgr->patchPtrArray()[patchID]->cntRecvs ==
6167  myMgr->mapData().patchList[patchID].numRecvs);
6168  }
6169 #endif
6170 
6171  // get results from ComputeMsmMgr
6172  msm::PatchPtrArray& patchPtr = myMgr->patchPtrArray();
6173 
6174 #ifdef DEBUG_MSM_VERBOSE
6175  printf("ComputeMsm: saveResults() PE=%d\n", CkMyPe());
6176 #endif
6177  // store force updates
6178  // submit reductions
6179 
6180  // add in forces
6181  int cnt=0, n;
6182  for (ap = ap.begin(); ap != ap.end(); ap++) {
6183  Results *r = (*ap).forceBox->open();
6184  Force *f = r->f[Results::slow];
6185  int numAtoms = (*ap).p->getNumAtoms();
6186  int patchID = (*ap).patchID;
6187  if (patchPtr[patchID] == NULL) {
6188  char msg[100];
6189  snprintf(msg, sizeof(msg), "Expecting patch %d to exist on PE %d",
6190  patchID, CkMyPe());
6191  NAMD_die(msg);
6192  }
6193  msm::PatchData& patch = *(patchPtr[patchID]);
6194  ASSERT(numAtoms == patch.force.len() );
6195  for (n = 0; n < numAtoms; n++) {
6196  f[n] += patch.force[n];
6197  }
6198  (*ap).forceBox->close(&r);
6199 
6200  reduction->item(REDUCTION_ELECT_ENERGY_SLOW) += patch.energy;
6201 // reduction->item(REDUCTION_VIRIAL_SLOW_XX) += patch.virial[0][0];
6202 // reduction->item(REDUCTION_VIRIAL_SLOW_XY) += patch.virial[0][1];
6203 // reduction->item(REDUCTION_VIRIAL_SLOW_XZ) += patch.virial[0][2];
6204 // reduction->item(REDUCTION_VIRIAL_SLOW_YX) += patch.virial[1][0];
6205 // reduction->item(REDUCTION_VIRIAL_SLOW_YY) += patch.virial[1][1];
6206 // reduction->item(REDUCTION_VIRIAL_SLOW_YZ) += patch.virial[1][2];
6207 // reduction->item(REDUCTION_VIRIAL_SLOW_ZX) += patch.virial[2][0];
6208 // reduction->item(REDUCTION_VIRIAL_SLOW_ZY) += patch.virial[2][1];
6209 // reduction->item(REDUCTION_VIRIAL_SLOW_ZZ) += patch.virial[2][2];
6210  Float *virial = myMgr->virial;
6211  reduction->item(REDUCTION_VIRIAL_SLOW_XX) += virial[ComputeMsmMgr::VXX];
6212  reduction->item(REDUCTION_VIRIAL_SLOW_XY) += virial[ComputeMsmMgr::VXY];
6213  reduction->item(REDUCTION_VIRIAL_SLOW_XZ) += virial[ComputeMsmMgr::VXZ];
6214  reduction->item(REDUCTION_VIRIAL_SLOW_YX) += virial[ComputeMsmMgr::VXY];
6215  reduction->item(REDUCTION_VIRIAL_SLOW_YY) += virial[ComputeMsmMgr::VYY];
6216  reduction->item(REDUCTION_VIRIAL_SLOW_YZ) += virial[ComputeMsmMgr::VYZ];
6217  reduction->item(REDUCTION_VIRIAL_SLOW_ZX) += virial[ComputeMsmMgr::VXZ];
6218  reduction->item(REDUCTION_VIRIAL_SLOW_ZY) += virial[ComputeMsmMgr::VYZ];
6219  reduction->item(REDUCTION_VIRIAL_SLOW_ZZ) += virial[ComputeMsmMgr::VZZ];
6220  }
6221  reduction->submit();
6222 }
Array< PatchDiagram > patchList
Definition: MsmMap.h:955
msm::Map & mapData()
Definition: ComputeMsm.C:447
int len() const
Definition: MsmMap.h:218
Definition: Vector.h:64
ComputeHomePatchList patchList
BigReal & item(int i)
Definition: ReductionMgr.h:312
BigReal energy
Definition: ComputeMsm.C:1750
#define ASSERT(E)
Float virial[VMAX]
Definition: ComputeMsm.C:527
Force * f[maxNumForces]
Definition: PatchTypes.h:67
void NAMD_die(const char *err_msg)
Definition: common.C:83
ForceArray force
Definition: ComputeMsm.C:1743
float Float
Definition: MsmMap.h:74
msm::PatchPtrArray & patchPtrArray()
Definition: ComputeMsm.C:445
void submit(void)
Definition: ReductionMgr.h:323
void ComputeMsm::setMgr ( ComputeMsmMgr mgr)
inline

Definition at line 32 of file ComputeMsm.h.

Referenced by ComputeMsmMgr::setCompute().

32 { myMgr = mgr; }

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