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 6057 of file ComputeMsm.C.

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

6057  : ComputeHomePatches(c)
6058 {
6059  CProxy_ComputeMsmMgr::ckLocalBranch(
6060  CkpvAccess(BOCclass_group).computeMsmMgr)->setCompute(this);
6062  qscaling = sqrtf(COULOMB / simParams->dielectric);
6064 #ifdef DEBUG_MSM_VERBOSE
6065  printf("ComputeMsm: (constructor) PE=%d\n", CkMyPe());
6066 #endif
6067 }
static Node * Object()
Definition: Node.h:86
SimParameters * simParameters
Definition: Node.h:178
#define COULOMB
Definition: common.h:46
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 6069 of file ComputeMsm.C.

6070 {
6071  // free memory
6072 #ifdef DEBUG_MSM_VERBOSE
6073  printf("ComputeMsm: (destructor) PE=%d\n", CkMyPe());
6074 #endif
6075 }

Member Function Documentation

void ComputeMsm::doWork ( void  )
virtual

Reimplemented from Compute.

Definition at line 6077 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.

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

Definition at line 6161 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().

6162 {
6163  if (++cntLocalPatches != numLocalPatches) return;
6164 
6165  // NAMD patches
6167 #ifdef DEBUG_MSM
6168  for (ap = ap.begin(); ap != ap.end(); ap++) {
6169  int patchID = (*ap).patchID;
6170  ASSERT(myMgr->patchPtrArray()[patchID]->cntRecvs ==
6171  myMgr->mapData().patchList[patchID].numRecvs);
6172  }
6173 #endif
6174 
6175  // get results from ComputeMsmMgr
6176  msm::PatchPtrArray& patchPtr = myMgr->patchPtrArray();
6177 
6178 #ifdef DEBUG_MSM_VERBOSE
6179  printf("ComputeMsm: saveResults() PE=%d\n", CkMyPe());
6180 #endif
6181  // store force updates
6182  // submit reductions
6183 
6184  // add in forces
6185  int cnt=0, n;
6186  for (ap = ap.begin(); ap != ap.end(); ap++) {
6187  Results *r = (*ap).forceBox->open();
6188  Force *f = r->f[Results::slow];
6189  int numAtoms = (*ap).p->getNumAtoms();
6190  int patchID = (*ap).patchID;
6191  if (patchPtr[patchID] == NULL) {
6192  char msg[100];
6193  snprintf(msg, sizeof(msg), "Expecting patch %d to exist on PE %d",
6194  patchID, CkMyPe());
6195  NAMD_die(msg);
6196  }
6197  msm::PatchData& patch = *(patchPtr[patchID]);
6198  ASSERT(numAtoms == patch.force.len() );
6199  for (n = 0; n < numAtoms; n++) {
6200  f[n] += patch.force[n];
6201  }
6202  (*ap).forceBox->close(&r);
6203 
6204  reduction->item(REDUCTION_ELECT_ENERGY_SLOW) += patch.energy;
6205 // reduction->item(REDUCTION_VIRIAL_SLOW_XX) += patch.virial[0][0];
6206 // reduction->item(REDUCTION_VIRIAL_SLOW_XY) += patch.virial[0][1];
6207 // reduction->item(REDUCTION_VIRIAL_SLOW_XZ) += patch.virial[0][2];
6208 // reduction->item(REDUCTION_VIRIAL_SLOW_YX) += patch.virial[1][0];
6209 // reduction->item(REDUCTION_VIRIAL_SLOW_YY) += patch.virial[1][1];
6210 // reduction->item(REDUCTION_VIRIAL_SLOW_YZ) += patch.virial[1][2];
6211 // reduction->item(REDUCTION_VIRIAL_SLOW_ZX) += patch.virial[2][0];
6212 // reduction->item(REDUCTION_VIRIAL_SLOW_ZY) += patch.virial[2][1];
6213 // reduction->item(REDUCTION_VIRIAL_SLOW_ZZ) += patch.virial[2][2];
6214  Float *virial = myMgr->virial;
6215  reduction->item(REDUCTION_VIRIAL_SLOW_XX) += virial[ComputeMsmMgr::VXX];
6216  reduction->item(REDUCTION_VIRIAL_SLOW_XY) += virial[ComputeMsmMgr::VXY];
6217  reduction->item(REDUCTION_VIRIAL_SLOW_XZ) += virial[ComputeMsmMgr::VXZ];
6218  reduction->item(REDUCTION_VIRIAL_SLOW_YX) += virial[ComputeMsmMgr::VXY];
6219  reduction->item(REDUCTION_VIRIAL_SLOW_YY) += virial[ComputeMsmMgr::VYY];
6220  reduction->item(REDUCTION_VIRIAL_SLOW_YZ) += virial[ComputeMsmMgr::VYZ];
6221  reduction->item(REDUCTION_VIRIAL_SLOW_ZX) += virial[ComputeMsmMgr::VXZ];
6222  reduction->item(REDUCTION_VIRIAL_SLOW_ZY) += virial[ComputeMsmMgr::VYZ];
6223  reduction->item(REDUCTION_VIRIAL_SLOW_ZZ) += virial[ComputeMsmMgr::VZZ];
6224  }
6225  reduction->submit();
6226 }
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:85
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: