NAMD
Classes | Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
WorkDistrib Class Reference

#include <WorkDistrib.h>

Inheritance diagram for WorkDistrib:

Classes

struct  pe_sortop_compact
 
struct  pe_sortop_diffuse
 

Public Member Functions

 WorkDistrib ()
 
 ~WorkDistrib (void)
 
void enqueueWork (LocalWorkMsg *msg)
 
void enqueueExcls (LocalWorkMsg *msg)
 
void enqueueBonds (LocalWorkMsg *msg)
 
void enqueueAngles (LocalWorkMsg *msg)
 
void enqueueDihedrals (LocalWorkMsg *msg)
 
void enqueueImpropers (LocalWorkMsg *msg)
 
void enqueueThole (LocalWorkMsg *msg)
 
void enqueueAniso (LocalWorkMsg *msg)
 
void enqueueCrossterms (LocalWorkMsg *msg)
 
void enqueueOneFourNbThole (LocalWorkMsg *msg)
 
void enqueueGromacsPair (LocalWorkMsg *msg)
 
void enqueuePme (LocalWorkMsg *msg)
 
void enqueueSelfA1 (LocalWorkMsg *msg)
 
void enqueueSelfA2 (LocalWorkMsg *msg)
 
void enqueueSelfA3 (LocalWorkMsg *msg)
 
void enqueueSelfB1 (LocalWorkMsg *msg)
 
void enqueueSelfB2 (LocalWorkMsg *msg)
 
void enqueueSelfB3 (LocalWorkMsg *msg)
 
void enqueueWorkA1 (LocalWorkMsg *msg)
 
void enqueueWorkA2 (LocalWorkMsg *msg)
 
void enqueueWorkA3 (LocalWorkMsg *msg)
 
void enqueueWorkB1 (LocalWorkMsg *msg)
 
void enqueueWorkB2 (LocalWorkMsg *msg)
 
void enqueueWorkB3 (LocalWorkMsg *msg)
 
void enqueueWorkC (LocalWorkMsg *msg)
 
void enqueueCUDA (LocalWorkMsg *msg)
 
void enqueueCUDAP2 (LocalWorkMsg *msg)
 
void enqueueCUDAP3 (LocalWorkMsg *msg)
 
void finishCUDAPatch (FinishWorkMsg *msg)
 
void finishCUDA (LocalWorkMsg *msg)
 
void finishCUDAP2 (LocalWorkMsg *msg)
 
void finishCUDAP3 (LocalWorkMsg *msg)
 
void enqueueMIC (LocalWorkMsg *msg)
 
void finishMIC (LocalWorkMsg *msg)
 
void enqueueLCPO (LocalWorkMsg *msg)
 
void mapComputes (void)
 
void sendPatchMap (void)
 
void sendComputeMap (void)
 
void saveComputeMapChanges (int, CkGroupID)
 
void recvComputeMapChanges (ComputeMapChangeMsg *)
 
void doneSaveComputeMap (CkReductionMsg *)
 
FullAtomListcreateAtomLists (const char *basename=0)
 
void createHomePatches (void)
 
void distributeHomePatches (void)
 
void reinitAtoms (const char *basename=0)
 
void patchMapInit (void)
 
void assignNodeToPatch (void)
 
void savePatchMap (PatchMapMsg *msg)
 
void setPatchMapArrived (bool s)
 
void initHostDeviceLDB ()
 
void contributeHostDeviceLDB (int peSetLen, int *peSet)
 
void setDeviceLDBParams (int dt, int hs, int sp1, int pp1, int pp2)
 

Static Public Member Functions

static void messageEnqueueWork (Compute *)
 
static void messageFinishCUDA (Compute *)
 
static void messageFinishMIC (Compute *)
 
static void sortPmePes (int *pmepes, int xdim, int ydim)
 
static void peOrderingReady ()
 
static void send_initHostDeviceLDB ()
 
static void send_contributeHostDeviceLDB (int peSetLen, int *peSet)
 
static void send_setDeviceLDBParams (int dt, int hs, int sp1, int pp1, int pp2)
 
static void buildNodeAwarePeOrdering (void)
 

Static Public Attributes

static int peOrderingInit
 
static int * peDiffuseOrdering
 
static int * peDiffuseOrderingIndex
 
static int * peCompactOrdering
 
static int * peCompactOrderingIndex
 

Detailed Description

Definition at line 42 of file WorkDistrib.h.

Constructor & Destructor Documentation

◆ WorkDistrib()

WorkDistrib::WorkDistrib ( )

Definition at line 108 of file WorkDistrib.C.

References eventMachineProgress, and NAMD_bug().

109 {
110  CkpvAccess(BOCclass_group).workDistrib = thisgroup;
111  patchMapArrived = false;
112  computeMapArrived = false;
113 
114 #if CMK_SMP
115 #define MACHINE_PROGRESS
116 #else
117 #define MACHINE_PROGRESS { traceUserEvent(eventMachineProgress); CmiMachineProgressImpl(); }
118  if ( CkMyNodeSize() > 1 ) NAMD_bug("CkMyNodeSize() > 1 for non-smp build");
119  eventMachineProgress = traceRegisterUserEvent("CmiMachineProgressImpl",233);
120 #endif
121 }
void NAMD_bug(const char *err_msg)
Definition: common.C:195
static int eventMachineProgress
Definition: WorkDistrib.C:103

◆ ~WorkDistrib()

WorkDistrib::~WorkDistrib ( void  )

Definition at line 124 of file WorkDistrib.C.

125 { }

Member Function Documentation

◆ assignNodeToPatch()

void WorkDistrib::assignNodeToPatch ( void  )

Definition at line 1456 of file WorkDistrib.C.

References endi(), Patch::getNumAtoms(), iINFO(), iout, Node::molecule, NAMD_die(), PatchMap::node(), Molecule::numAtoms, Node::numNodes(), PatchMap::numPatches(), PatchMap::Object(), Node::Object(), PatchMap::patch(), Node::simParameters, SimParameters::simulatedPEs, and SimParameters::simulateInitialMapping.

Referenced by Node::startup().

1457 {
1458  PatchMap *patchMap = PatchMap::Object();
1459  int nNodes = Node::Object()->numNodes();
1460  SimParameters *simparam = Node::Object()->simParameters;
1461  if(simparam->simulateInitialMapping) {
1462  nNodes = simparam->simulatedPEs;
1463  }
1464 
1465 #if (CMK_BLUEGENEP | CMK_BLUEGENEL) && USE_TOPOMAP
1466  TopoManager tmgr;
1467  int numPes = tmgr.getDimNX() * tmgr.getDimNY() * tmgr.getDimNZ();
1468  if (numPes > patchMap->numPatches() && (assignPatchesTopoGridRecBisection() > 0)) {
1469  CkPrintf ("Blue Gene/L topology partitioner finished successfully \n");
1470  }
1471  else
1472 #endif
1473  assignPatchesSpaceFillingCurve();
1474 
1475  int *nAtoms = new int[nNodes];
1476  int numAtoms=0;
1477  int i;
1478  for(i=0; i < nNodes; i++)
1479  nAtoms[i] = 0;
1480 
1481  for(i=0; i < patchMap->numPatches(); i++)
1482  {
1483  // iout << iINFO << "Patch " << i << " has "
1484  // << patchMap->patch(i)->getNumAtoms() << " atoms and "
1485  // << patchMap->patch(i)->getNumAtoms() *
1486  // patchMap->patch(i)->getNumAtoms()
1487  // << " pairs.\n" << endi;
1488 #ifdef MEM_OPT_VERSION
1489  numAtoms += patchMap->numAtoms(i);
1490  nAtoms[patchMap->node(i)] += patchMap->numAtoms(i);
1491 #else
1492  if (patchMap->patch(i)) {
1493  numAtoms += patchMap->patch(i)->getNumAtoms();
1494  nAtoms[patchMap->node(i)] += patchMap->patch(i)->getNumAtoms();
1495  }
1496 #endif
1497  }
1498 
1499  if ( numAtoms != Node::Object()->molecule->numAtoms ) {
1500  for(i=0; i < nNodes; i++)
1501  iout << iINFO << nAtoms[i] << " atoms assigned to node " << i << "\n" << endi;
1502  iout << iINFO << "Assigned " << numAtoms << " atoms but expected " << Node::Object()->molecule->numAtoms << "\n" << endi;
1503  NAMD_die("Incorrect atom count in WorkDistrib::assignNodeToPatch\n");
1504  }
1505 
1506  delete [] nAtoms;
1507 
1508  // PatchMap::Object()->printPatchMap();
1509 }
static Node * Object()
Definition: Node.h:86
std::ostream & iINFO(std::ostream &s)
Definition: InfoStream.C:81
Bool simulateInitialMapping
int getNumAtoms() const
Definition: Patch.h:105
static PatchMap * Object()
Definition: PatchMap.h:27
SimParameters * simParameters
Definition: Node.h:181
std::ostream & endi(std::ostream &s)
Definition: InfoStream.C:54
#define iout
Definition: InfoStream.h:51
Patch * patch(PatchID pid)
Definition: PatchMap.h:244
int numNodes()
Definition: Node.h:192
int numPatches(void) const
Definition: PatchMap.h:59
int numAtoms
Definition: Molecule.h:586
void NAMD_die(const char *err_msg)
Definition: common.C:147
int node(int pid) const
Definition: PatchMap.h:114
Molecule * molecule
Definition: Node.h:179

◆ buildNodeAwarePeOrdering()

void WorkDistrib::buildNodeAwarePeOrdering ( void  )
static

Definition at line 183 of file WorkDistrib.C.

References ResizeArray< Elem >::begin(), endi(), iout, iWARN(), peCompactOrdering, peCompactOrderingIndex, peDiffuseOrdering, peDiffuseOrderingIndex, peOrderingInit, peOrderingReady(), randtopo, and Random::reorder().

Referenced by build_ordering().

183  {
184 
185  CmiMemLock();
186  if ( ! peOrderingInit ) {
187  //CkPrintf("WorkDistrib::buildNodeAwarePeOrdering on pe %d\n", CkMyPe());
188 
189  const int numPhys = CmiNumPhysicalNodes();
190  const int numNode = CmiNumNodes();
191  const int numPe = CmiNumPes();
192  ResizeArray<int> numNodeInPhys(numPhys);
193  ResizeArray<int> rankInPhysOfNode(numNode);
194 
195  peDiffuseOrdering = new int[numPe];
196  peDiffuseOrderingIndex = new int[numPe];
197  peCompactOrdering = new int[numPe];
198  peCompactOrderingIndex = new int[numPe];
199 
200  int k = 0;
201  for ( int ph=0; ph<numPhys; ++ph ) {
202  int *pes, npes;
203  CmiGetPesOnPhysicalNode(ph, &pes, &npes);
204  for ( int i=0; i<npes; ++i, ++k ) {
205  peCompactOrdering[k] = pes[i];
206  }
207  numNodeInPhys[ph] = 0;
208  for ( int i=0, j=0; i<npes; i += CmiNodeSize(CmiNodeOf(pes[i])), ++j ) {
209  rankInPhysOfNode[CmiNodeOf(pes[i])] = j;
210  numNodeInPhys[ph] += 1;
211  }
212  }
213 
214  if ( randtopo && numPhys > 2 ) {
215  if ( ! CkMyNode() ) {
216  iout << iWARN << "RANDOMIZING PHYSICAL NODE ORDERING\n" << endi;
217  }
218  ResizeArray<int> randPhysOrder(numPhys);
219  for ( int j=0; j<numPhys; ++j ) {
220  randPhysOrder[j] = j;
221  }
222  Random(314159265).reorder(randPhysOrder.begin()+2, numPhys-2);
223  for ( int j=0, k=0; j<numPhys; ++j ) {
224  const int ph = randPhysOrder[j];
225  int *pes, npes;
226  CmiGetPesOnPhysicalNode(ph, &pes, &npes);
227  for ( int i=0; i<npes; ++i, ++k ) {
228  peCompactOrdering[k] = pes[i];
229  }
230  }
231  }
232 
233  for ( int i=0; i<numPe; ++i ) {
234  peDiffuseOrdering[i] = i;
235  }
236  std::sort(peDiffuseOrdering, peDiffuseOrdering+numPe,
237  pe_sortop_bit_reversed(rankInPhysOfNode.begin()));
238 
239  for ( int i=0; i<numPe; ++i ) {
242  }
243 
244  if ( 0 && CmiMyNode() == 0 ) for ( int i=0; i<numPe; ++i ) {
245  CkPrintf("order %5d %5d %5d %5d %5d\n", i,
250  }
251 
252  peOrderingInit = 1;
253  }
254  CmiMemUnlock();
255  peOrderingReady();
256 
257 }
static int * peCompactOrdering
Definition: WorkDistrib.h:118
std::ostream & endi(std::ostream &s)
Definition: InfoStream.C:54
static void peOrderingReady()
Definition: WorkDistrib.C:173
std::ostream & iWARN(std::ostream &s)
Definition: InfoStream.C:82
#define iout
Definition: InfoStream.h:51
void reorder(Elem *a, int n)
Definition: Random.h:234
Definition: Random.h:37
static int * peDiffuseOrderingIndex
Definition: WorkDistrib.h:117
static int * peDiffuseOrdering
Definition: WorkDistrib.h:116
static int peOrderingInit
Definition: WorkDistrib.h:115
static int * peCompactOrderingIndex
Definition: WorkDistrib.h:119
static int randtopo
Definition: WorkDistrib.C:87

◆ contributeHostDeviceLDB()

void WorkDistrib::contributeHostDeviceLDB ( int  peSetLen,
int *  peSet 
)

Definition at line 3539 of file WorkDistrib.C.

3539  {
3540  #if defined(NAMD_MIC)
3541  mic_contributeHostDeviceLDB(peSetLen, peSet);
3542  #endif
3543 }

◆ createAtomLists()

FullAtomList * WorkDistrib::createAtomLists ( const char *  basename = 0)

Definition at line 654 of file WorkDistrib.C.

References ResizeArray< Elem >::add(), SimParameters::alchOn, Lattice::apply_transform(), PatchMap::assignToPatch(), Molecule::atomcharge(), CompAtomExt::atomFixed, HydrogenGroupID::atomID, Molecule::atommass(), HydrogenGroupID::atomsInGroup, HydrogenGroupID::atomsInMigrationGroup, Molecule::atomvdwtype(), ResizeArray< Elem >::begin(), SimParameters::binaryOutput, CompAtom::charge, SimParameters::comMove, Node::configList, StringList::data, CompAtomExt::dispcoef, endi(), FALSE, ConfigList::find(), SimParameters::fixedAtomsOn, FullAtom::fixedPosition, PDB::get_all_positions(), Molecule::get_fep_type(), Parameters::get_vdw_params(), Molecule::getAtoms(), getWaterModelGroupSize(), PatchMap::gridsize_a(), PatchMap::gridsize_b(), PatchMap::gridsize_c(), CompAtomExt::groupFixed, Molecule::hydrogenGroup, CompAtom::hydrogenGroupSize, CompAtomExt::id, PatchMap::index_a(), PatchMap::index_b(), PatchMap::index_c(), SimParameters::initialTemp, iout, Molecule::is_atom_fixed(), HydrogenGroupID::isGP, HydrogenGroupID::isMP, CompAtom::isWater, Molecule::langevin_param(), FullAtom::langevinParam, SimParameters::lattice, SimParameters::lesOn, SimParameters::LJPMEOn, FullAtom::mass, PatchMap::max_a(), PatchMap::max_b(), PatchMap::max_c(), FullAtom::migrationGroupSize, PatchMap::min_a(), PatchMap::min_b(), PatchMap::min_c(), Node::molecule, NAMD_bug(), NAMD_die(), Lattice::nearest(), CompAtom::nonbondedGroupSize, SimParameters::nonbondedScaling, PDB::num_atoms(), PatchMap::numPatches(), PatchMap::Object(), order, SimParameters::outputPatchDetails, SimParameters::pairInteractionOn, CompAtom::partition, Node::pdb, CompAtom::position, SimParameters::pressureProfileAtomTypes, read_binary_file(), FullAtom::recipMass, Molecule::rigid_bond_length(), RIGID_NONE, FullAtom::rigidBondLength, SimParameters::rigidBonds, Node::simParameters, ResizeArray< Elem >::size(), sortAtomsForPatches(), SimParameters::staticAtomAssignment, atom_constants::status, FullAtom::status, FullAtom::transform, TRUE, SimParameters::useSettle, CompAtom::vdwType, FullAtom::velocity, and SimParameters::watmodel.

Referenced by createHomePatches(), and reinitAtoms().

655 {
656  int i;
657  StringList *current; // Pointer used to retrieve configuration items
658  CProxy_Node nd(CkpvAccess(BOCclass_group).node);
659  Node *node = nd.ckLocalBranch();
660  PatchMap *patchMap = PatchMap::Object();
661  CProxy_PatchMgr pm(CkpvAccess(BOCclass_group).patchMgr);
662  PatchMgr *patchMgr = pm.ckLocalBranch();
663  SimParameters *params = node->simParameters;
664  Molecule *molecule = node->molecule;
665  PDB *pdb = node->pdb;
666 
667  int numPatches = patchMap->numPatches();
668  int numAtoms = pdb->num_atoms();
669 
670  Vector *positions = new Position[numAtoms];
671  Vector *velocities = new Velocity[numAtoms];
672 
673  if ( basename ) {
674  if ( params->binaryOutput ) {
675  read_binary_file((std::string(basename)+".coor").c_str(), positions, numAtoms);
676  read_binary_file((std::string(basename)+".vel").c_str(), velocities, numAtoms);
677  } else {
678  PDB coorpdb((std::string(basename)+".coor").c_str());
679  if ( coorpdb.num_atoms() != numAtoms ) {
680  NAMD_die("Incorrect atom count in coordinate pdb file");
681  }
682  coorpdb.get_all_positions(positions);
683  velocities_from_PDB((std::string(basename)+".vel").c_str(), velocities, numAtoms);
684  }
685  } else {
686  pdb->get_all_positions(positions);
687 
688  if ( params->initialTemp < 0.0 ) {
689  Bool binvels=FALSE;
690 
691  // Reading the veolcities from a PDB
692  current = node->configList->find("velocities");
693 
694  if (current == NULL) {
695  current = node->configList->find("binvelocities");
696  binvels = TRUE;
697  }
698 
699  if (!binvels) {
700  velocities_from_PDB(current->data, velocities, numAtoms);
701  }
702  else {
703  velocities_from_binfile(current->data, velocities, numAtoms);
704  }
705  }
706  else {
707  // Random velocities for a given temperature
708  random_velocities(params->initialTemp, molecule, velocities, numAtoms);
709  }
710  }
711 
712  // If COMMotion == no, remove center of mass motion
713  if (!(params->comMove)) {
714  remove_com_motion(velocities, molecule, numAtoms);
715  }
716 
717  FullAtomList *atoms = new FullAtomList[numPatches];
718 
719  const Lattice lattice = params->lattice;
720 
721  if ( params->staticAtomAssignment ) {
722  FullAtomList sortAtoms;
723  for ( i=0; i < numAtoms; i++ ) {
724  HydrogenGroupID &h = molecule->hydrogenGroup[i];
725  if ( ! h.isMP ) continue;
726  FullAtom a;
727  a.id = i;
729  a.position = positions[h.atomID];
730  sortAtoms.add(a);
731  }
732  int *order = new int[sortAtoms.size()];
733  for ( i=0; i < sortAtoms.size(); i++ ) {
734  order[i] = i;
735  }
736  int *breaks = new int[numPatches];
737  sortAtomsForPatches(order,breaks,sortAtoms.begin(),
738  sortAtoms.size(),numAtoms,
739  patchMap->gridsize_c(),
740  patchMap->gridsize_b(),
741  patchMap->gridsize_a());
742 
743  i = 0;
744  for ( int pid = 0; pid < numPatches; ++pid ) {
745  int iend = breaks[pid];
746  for ( ; i<iend; ++i ) {
747  FullAtom &sa = sortAtoms[order[i]];
748  int mgs = sa.migrationGroupSize;
749 /*
750 CkPrintf("patch %d (%d %d %d) has group %d atom %d size %d at %.2f %.2f %.2f\n",
751  pid, patchMap->index_a(pid), patchMap->index_b(pid),
752  patchMap->index_c(pid), order[i], sa.id, mgs,
753  sa.position.x, sa.position.y, sa.position.z);
754 */
755  for ( int k=0; k<mgs; ++k ) {
756  HydrogenGroupID &h = molecule->hydrogenGroup[sa.id + k];
757  int aid = h.atomID;
758  FullAtom a;
759  a.id = aid;
760  a.position = positions[aid];
761  a.velocity = velocities[aid];
762  a.vdwType = molecule->atomvdwtype(aid);
763  a.status = molecule->getAtoms()[aid].status;
764  a.langevinParam = molecule->langevin_param(aid);
765  a.hydrogenGroupSize = h.isGP ? h.atomsInGroup : 0;
767  if(params->rigidBonds != RIGID_NONE) {
768  a.rigidBondLength = molecule->rigid_bond_length(aid);
769  }else{
770  a.rigidBondLength = 0.0;
771  }
772  atoms[pid].add(a);
773  }
774  }
775 CkPrintf("patch %d (%d %d %d) has %d atoms\n",
776  pid, patchMap->index_a(pid), patchMap->index_b(pid),
777  patchMap->index_c(pid), atoms[pid].size());
778  }
779  delete [] order;
780  delete [] breaks;
781  } else
782  {
783  // split atoms into patches based on migration group and position
784  int aid, pid=0;
785  for(i=0; i < numAtoms; i++)
786  {
787  // Assign atoms to patches without splitting hydrogen groups.
788  // We know that the hydrogenGroup array is sorted with group parents
789  // listed first. Thus, only change the pid if an atom is a group parent.
790  HydrogenGroupID &h = molecule->hydrogenGroup[i];
791  aid = h.atomID;
792  FullAtom a;
793  a.id = aid;
794  a.position = positions[aid];
795  a.velocity = velocities[aid];
796  a.vdwType = molecule->atomvdwtype(aid);
797  a.status = molecule->getAtoms()[aid].status;
798  a.langevinParam = molecule->langevin_param(aid);
799  a.hydrogenGroupSize = h.isGP ? h.atomsInGroup : 0;
801  if(params->rigidBonds != RIGID_NONE) {
802  a.rigidBondLength = molecule->rigid_bond_length(aid);
803  }else{
804  a.rigidBondLength = 0.0;
805  }
806  if (h.isMP) {
807  pid = patchMap->assignToPatch(positions[aid],lattice);
808  } // else: don't change pid
809  atoms[pid].add(a);
810  }
811  }
812 
813  delete [] positions;
814  delete [] velocities;
815 
816  for(i=0; i < numPatches; i++)
817  {
818  ScaledPosition center(0.5*(patchMap->min_a(i)+patchMap->max_a(i)),
819  0.5*(patchMap->min_b(i)+patchMap->max_b(i)),
820  0.5*(patchMap->min_c(i)+patchMap->max_c(i)));
821 
822  int n = atoms[i].size();
823  FullAtom *a = atoms[i].begin();
824  int j;
825 //Modifications for alchemical fep
826  Bool alchOn = params->alchOn;
827 //fepe
828  Bool lesOn = params->lesOn;
829 
830  Bool pairInteractionOn = params->pairInteractionOn;
831 
832  Bool pressureProfileTypes = (params->pressureProfileAtomTypes > 1);
833 
834  Transform mother_transform;
835  for(j=0; j < n; j++)
836  {
837  int aid = a[j].id;
838 
839  a[j].nonbondedGroupSize = 0; // must be set based on coordinates
840 
841  a[j].atomFixed = molecule->is_atom_fixed(aid) ? 1 : 0;
842  a[j].fixedPosition = a[j].position;
843 
844  if ( a[j].migrationGroupSize ) {
845  if ( a[j].migrationGroupSize != a[j].hydrogenGroupSize ) {
846  Position pos = a[j].position;
847  int mgs = a[j].migrationGroupSize;
848  int c = 1;
849  for ( int k=a[j].hydrogenGroupSize; k<mgs;
850  k+=a[j+k].hydrogenGroupSize ) {
851  pos += a[j+k].position;
852  ++c;
853  }
854  pos *= 1./c;
855  mother_transform = a[j].transform; // should be 0,0,0
856  pos = lattice.nearest(pos,center,&mother_transform);
857  a[j].position = lattice.apply_transform(a[j].position,mother_transform);
858  a[j].transform = mother_transform;
859  } else {
860  a[j].position = lattice.nearest(
861  a[j].position, center, &(a[j].transform));
862  mother_transform = a[j].transform;
863  }
864  } else {
865  a[j].position = lattice.apply_transform(a[j].position,mother_transform);
866  a[j].transform = mother_transform;
867  }
868 
869  a[j].mass = molecule->atommass(aid);
870  // Using double precision division for reciprocal mass.
871  a[j].recipMass = ( a[j].mass > 0 ? (1. / a[j].mass) : 0 );
872  a[j].charge = molecule->atomcharge(aid);
873  if ( params->LJPMEOn ) {
874  const int index = a[j].vdwType;
875  const float scaling = params->nonbondedScaling;
876  float sigma, epsilon, sigma14, epsilon14;
877  molecule->params->get_vdw_params(&sigma, &epsilon, &sigma14, &epsilon14, index);
878  a[j].dispcoef = 2*sigma*sigma*sigma*sqrt(scaling * epsilon);
879  }
880  else {
881  a[j].dispcoef = 0;
882  }
883 
884 //Modifications for alchemical fep
885  if ( alchOn || lesOn || pairInteractionOn || pressureProfileTypes) {
886  a[j].partition = molecule->get_fep_type(aid);
887  }
888  else {
889  a[j].partition = 0;
890  }
891 //fepe
892 
893  }
894 
895 #if 0
896  int size, allfixed, k;
897  for(j=0; j < n; j+=size) {
898  size = a[j].hydrogenGroupSize;
899  if ( ! size ) {
900  NAMD_bug("Mother atom with hydrogenGroupSize of 0!");
901  }
902  allfixed = 1;
903  for ( k = 0; k < size; ++k ) {
904  allfixed = ( allfixed && (a[j+k].atomFixed) );
905  }
906  for ( k = 0; k < size; ++k ) {
907  a[j+k].groupFixed = allfixed ? 1 : 0;
908  }
909  // DH - set isWater flag
910  // based on same condition as used for determining Settle:
911  // The rigidBondLength of the FIRST water atom is set greater than 0.
912  if (a[j].rigidBondLength > 0) {
913  for (k = 0; k < size; k++) {
914  a[j+k].isWater = 1;
915  }
916  }
917  }
918 #else
919  // DH - promote water checking to take place before simulation
920  // Flag the Settle water molecules.
921  int size, allfixed;
922  const WaterModel watmodel = params->watmodel;
923  const int wathgsize = getWaterModelGroupSize(watmodel);
924  const int fixedAtomsOn = params->fixedAtomsOn;
925  const int useSettle = params->useSettle;
926  for(int j=0; j < n; j+=size) {
927  size = a[j].hydrogenGroupSize;
928  if ( ! size ) {
929  NAMD_bug("Mother atom with hydrogenGroupSize of 0!");
930  }
931  allfixed = 1;
932  for (int k = 0; k < size; ++k ) {
933  allfixed = ( allfixed && (a[j+k].atomFixed) );
934  }
935  for (int k = 0; k < size; ++k ) {
936  a[j+k].groupFixed = allfixed ? 1 : 0;
937  }
938  // DH - Set isWater flag for SETTLE water molecules,
939  // based on same condition as used in HomePatch::buildRattleList():
940  // The rigidBondLength of the FIRST water atom is set greater than 0.
941  if (a[j].rigidBondLength > 0) {
942  if (size != wathgsize) {
943  char errmsg[256];
944  sprintf(errmsg,
945  "Water molecule starting with atom %d contains %d atoms "
946  "but the specified water model requires %d atoms.\n",
947  a[j].id+1, size, wathgsize
948  );
949  NAMD_die(errmsg);
950  }
951  int anyfixed = 0;
952  for (int k = 0; k < size; k++) {
953  anyfixed += ( fixedAtomsOn && a[j+k].atomFixed );
954  }
955  if (useSettle && !anyfixed) {
956  for (int k = 0; k < size; k++) {
957  a[j+k].isWater = 1;
958  }
959  }
960  }
961  }
962 #endif
963 
964  if ( params->outputPatchDetails ) {
965  int patchId = i;
966  int numAtomsInPatch = n;
967  int numFixedAtomsInPatch = 0;
968  int numAtomsInFixedGroupsInPatch = 0;
969  for(j=0; j < n; j++) {
970  numFixedAtomsInPatch += ( a[j].atomFixed ? 1 : 0 );
971  numAtomsInFixedGroupsInPatch += ( a[j].groupFixed ? 1 : 0 );
972  }
973  iout << "PATCH_DETAILS:"
974  << " patch " << patchId
975  << " atoms " << numAtomsInPatch
976  << " fixed_atoms " << numFixedAtomsInPatch
977  << " fixed_groups " << numAtomsInFixedGroupsInPatch
978  << "\n" << endi;
979  }
980  }
981 
982  return atoms;
983 
984 }
Real atomcharge(int anum) const
Definition: Molecule.h:1124
Real langevinParam
Definition: NamdTypes.h:220
Definition: PDB.h:36
int size(void) const
Definition: ResizeArray.h:131
PatchID assignToPatch(Position p, const Lattice &l)
Definition: PatchMap.inl:14
Definition: Node.h:78
BigReal max_a(int pid) const
Definition: PatchMap.h:92
Position fixedPosition
Definition: NamdTypes.h:212
static PatchMap * Object()
Definition: PatchMap.h:27
Definition: Vector.h:72
SimParameters * simParameters
Definition: Node.h:181
BigReal nonbondedScaling
DispCoef dispcoef
Definition: NamdTypes.h:151
std::ostream & endi(std::ostream &s)
Definition: InfoStream.C:54
#define FALSE
Definition: common.h:127
Position position
Definition: NamdTypes.h:78
int index_a(int pid) const
Definition: PatchMap.h:86
#define iout
Definition: InfoStream.h:51
Velocity velocity
Definition: NamdTypes.h:211
int num_atoms(void)
Definition: PDB.C:323
uint32 groupFixed
Definition: NamdTypes.h:163
int add(const Elem &elem)
Definition: ResizeArray.h:101
Bool pairInteractionOn
Molecule stores the structural information for the system.
Definition: Molecule.h:174
int atomsInGroup
Definition: Hydrogen.h:19
WaterModel watmodel
int gridsize_c(void) const
Definition: PatchMap.h:66
uint32 id
Definition: NamdTypes.h:160
Charge charge
Definition: NamdTypes.h:79
HydrogenGroup hydrogenGroup
Definition: Molecule.h:676
void read_binary_file(const char *fname, Vector *data, int n)
Definition: NamdOneTools.C:52
constexpr int getWaterModelGroupSize(const WaterModel &watmodel)
Definition: common.h:228
int gridsize_a(void) const
Definition: PatchMap.h:64
#define order
Definition: PmeRealSpace.C:235
int numPatches(void) const
Definition: PatchMap.h:59
NAMD_HOST_DEVICE Position apply_transform(Position data, const Transform &t) const
Definition: Lattice.h:137
void NAMD_bug(const char *err_msg)
Definition: common.C:195
BigReal min_c(int pid) const
Definition: PatchMap.h:95
int32 migrationGroupSize
Definition: NamdTypes.h:230
AtomID atomID
Definition: Hydrogen.h:16
Real langevin_param(int atomnum) const
Definition: Molecule.h:1388
Index atomvdwtype(int anum) const
Definition: Molecule.h:1134
int16 vdwType
Definition: NamdTypes.h:80
int index_b(int pid) const
Definition: PatchMap.h:87
Bool staticAtomAssignment
int Bool
Definition: common.h:142
uint8 partition
Definition: NamdTypes.h:81
uint8 hydrogenGroupSize
Definition: NamdTypes.h:89
NAMD_HOST_DEVICE Position nearest(Position data, ScaledPosition ref) const
Definition: Lattice.h:95
void NAMD_die(const char *err_msg)
Definition: common.C:147
PDB * pdb
Definition: Node.h:183
BigReal min_a(int pid) const
Definition: PatchMap.h:91
Real atommass(int anum) const
Definition: Molecule.h:1114
ConfigList * configList
Definition: Node.h:182
int index_c(int pid) const
Definition: PatchMap.h:88
unsigned char get_fep_type(int anum) const
Definition: Molecule.h:1437
int32 status
Atom status bit fields defined in structures.h.
Definition: NamdTypes.h:227
uint8 nonbondedGroupSize
Definition: NamdTypes.h:82
Atom * getAtoms() const
Definition: Molecule.h:520
BigReal initialTemp
Real rigidBondLength
Definition: NamdTypes.h:231
int pressureProfileAtomTypes
int atomsInMigrationGroup
Definition: Hydrogen.h:29
iterator begin(void)
Definition: ResizeArray.h:36
BigReal max_b(int pid) const
Definition: PatchMap.h:94
char * data
Definition: ConfigList.h:48
uint8 isWater
Definition: NamdTypes.h:90
Mass mass
Definition: NamdTypes.h:218
BigReal max_c(int pid) const
Definition: PatchMap.h:96
int gridsize_b(void) const
Definition: PatchMap.h:65
Bool is_atom_fixed(int atomnum) const
Definition: Molecule.h:1504
StringList * find(const char *name) const
Definition: ConfigList.C:341
#define RIGID_NONE
Definition: SimParameters.h:80
uint32 atomFixed
Definition: NamdTypes.h:162
void get_vdw_params(Real *sigma, Real *epsilon, Real *sigma14, Real *epsilon14, Index index)
Definition: Parameters.h:568
Real rigid_bond_length(int atomnum) const
Definition: Molecule.h:1550
double recipMass
Definition: NamdTypes.h:213
void get_all_positions(Vector *)
Definition: PDB.C:365
BigReal min_b(int pid) const
Definition: PatchMap.h:93
WaterModel
Definition: common.h:221
Molecule * molecule
Definition: Node.h:179
#define TRUE
Definition: common.h:128
void sortAtomsForPatches(int *order, int *breaks, const FullAtom *atoms, int nmgrps, int natoms, int ni, int nj, int nk)
Definition: SortAtoms.C:135
Transform transform
Definition: NamdTypes.h:229

◆ createHomePatches()

void WorkDistrib::createHomePatches ( void  )

Definition at line 989 of file WorkDistrib.C.

References createAtomLists(), PatchMgr::createHomePatch(), DebugM, endi(), iINFO(), iout, PatchMap::numPatches(), PatchMap::Object(), and ResizeArray< Elem >::size().

Referenced by Node::startup().

990 {
991  int i;
992  PatchMap *patchMap = PatchMap::Object();
993  CProxy_PatchMgr pm(CkpvAccess(BOCclass_group).patchMgr);
994  PatchMgr *patchMgr = pm.ckLocalBranch();
995 
996  int numPatches = patchMap->numPatches();
997 
998  FullAtomList *atoms = createAtomLists();
999 
1000 #ifdef MEM_OPT_VERSION
1001 /* CProxy_Node nd(CkpvAccess(BOCclass_group).node);
1002  Node *node = nd.ckLocalBranch();
1003  node->molecule->delEachAtomSigs();
1004  node->molecule->delMassChargeSpace();
1005 */
1006 #endif
1007 
1008  int maxAtoms = -1;
1009  int maxPatch = -1;
1010  for(i=0; i < numPatches; i++) {
1011  int numAtoms = atoms[i].size();
1012  if ( numAtoms > maxAtoms ) { maxAtoms = numAtoms; maxPatch = i; }
1013  }
1014  iout << iINFO << "LARGEST PATCH (" << maxPatch <<
1015  ") HAS " << maxAtoms << " ATOMS\n" << endi;
1016 
1017 #ifdef SHOW_HISTOGRAM_HGROUP_SIZES
1018  // histogram hydrogen group sizes
1019  int hgroupsize[9] = { 0 };
1020  int numhgroups = 0;
1021  int numwaters = 0;
1022  int maxhgroupsize = 0;
1023  for (i = 0; i < numPatches; i++) {
1024  const FullAtomList& a = atoms[i];
1025  int numAtoms = a.size();
1026  int hgs = 1; // init to something sane
1027  for (int j = 0; j < numAtoms; j += hgs) {
1028  hgs = a[j].hydrogenGroupSize;
1029  int histndx = ( hgs > 8 ? 8 : hgs );
1030  hgroupsize[ histndx ]++;
1031  numhgroups++;
1032  if (a[j].isWater) numwaters++;
1033  if (maxhgroupsize < hgs) maxhgroupsize = hgs;
1034  }
1035  }
1036  int hgslast = ( maxhgroupsize > 8 ? 8 : maxhgroupsize );
1037  printf("Number of hydrogen groups: %7d\n", numhgroups);
1038  printf("Number of settle water molecules: %7d\n", numwaters);
1039  printf("Number of remaining hydrogen groups: %7d\n", numhgroups - numwaters);
1040  printf("Largest hydrogen group size: %7d\n", maxhgroupsize);
1041  printf("Histogram of hydrogen group sizes:\n");
1042  int hgstotal = 0;
1043  for (i = 0; i <= hgslast; i++) {
1044  printf(" size %d count %d\n", i, hgroupsize[i]);
1045  hgstotal += hgroupsize[i];
1046  }
1047  printf("Checksum over hydrogen group sizes: %7d\n", hgstotal);
1048 #endif
1049 
1050  for(i=0; i < numPatches; i++)
1051  {
1052  if ( ! ( i % 100 ) )
1053  {
1054  DebugM(3,"Created " << i << " patches so far.\n");
1055  }
1056 
1057  patchMgr->createHomePatch(i,atoms[i]);
1058  }
1059 
1060  delete [] atoms;
1061 }
std::ostream & iINFO(std::ostream &s)
Definition: InfoStream.C:81
int size(void) const
Definition: ResizeArray.h:131
static PatchMap * Object()
Definition: PatchMap.h:27
void createHomePatch(PatchID pid, FullAtomList &a)
Definition: PatchMgr.C:74
#define DebugM(x, y)
Definition: Debug.h:75
std::ostream & endi(std::ostream &s)
Definition: InfoStream.C:54
#define iout
Definition: InfoStream.h:51
int numPatches(void) const
Definition: PatchMap.h:59
FullAtomList * createAtomLists(const char *basename=0)
Definition: WorkDistrib.C:654

◆ distributeHomePatches()

void WorkDistrib::distributeHomePatches ( void  )

Definition at line 1063 of file WorkDistrib.C.

References DebugM, PatchMgr::movePatch(), Node::myid(), PatchMap::node(), PatchMap::numPatches(), PatchMap::Object(), and PatchMgr::sendMovePatches().

Referenced by Node::startup().

1063  {
1064  // ref BOC
1065  CProxy_Node nd(CkpvAccess(BOCclass_group).node);
1066  Node *node = nd.ckLocalBranch();
1067  CProxy_PatchMgr pm(CkpvAccess(BOCclass_group).patchMgr);
1068  PatchMgr *patchMgr = pm.ckLocalBranch();
1069  // ref singleton
1070  PatchMap *patchMap = PatchMap::Object();
1071 
1072  // Move patches to the proper node
1073  for(int i=0;i < patchMap->numPatches(); i++)
1074  {
1075  if (patchMap->node(i) != node->myid() )
1076  {
1077  DebugM(3,"patchMgr->movePatch("
1078  << i << "," << patchMap->node(i) << ")\n");
1079  patchMgr->movePatch(i,patchMap->node(i));
1080  }
1081  }
1082  patchMgr->sendMovePatches();
1083 }
Definition: Node.h:78
static PatchMap * Object()
Definition: PatchMap.h:27
#define DebugM(x, y)
Definition: Debug.h:75
void movePatch(PatchID, NodeID)
Definition: PatchMgr.C:84
int numPatches(void) const
Definition: PatchMap.h:59
void sendMovePatches()
Definition: PatchMgr.C:110
int myid()
Definition: Node.h:191
int node(int pid) const
Definition: PatchMap.h:114

◆ doneSaveComputeMap()

void WorkDistrib::doneSaveComputeMap ( CkReductionMsg *  msg)

Definition at line 430 of file WorkDistrib.C.

430  {
431  delete msg;
432 
433  CkSendMsgBranch(saveComputeMapReturnEP, CkAllocMsg(0,0,0), 0, saveComputeMapReturnChareID);
434 }

◆ enqueueAngles()

void WorkDistrib::enqueueAngles ( LocalWorkMsg msg)

Definition at line 3110 of file WorkDistrib.C.

References LocalWorkMsg::compute, Compute::doWork(), Compute::localWorkMsg, MACHINE_PROGRESS, and NAMD_bug().

3110  {
3112  if ( msg->compute->localWorkMsg != msg )
3113  NAMD_bug("WorkDistrib LocalWorkMsg recycling failed!");
3114 }
LocalWorkMsg *const localWorkMsg
Definition: Compute.h:46
#define MACHINE_PROGRESS
virtual void doWork()
Definition: Compute.C:120
Compute * compute
Definition: WorkDistrib.h:27
void NAMD_bug(const char *err_msg)
Definition: common.C:195

◆ enqueueAniso()

void WorkDistrib::enqueueAniso ( LocalWorkMsg msg)

Definition at line 3134 of file WorkDistrib.C.

References LocalWorkMsg::compute, Compute::doWork(), Compute::localWorkMsg, MACHINE_PROGRESS, and NAMD_bug().

3134  {
3136  if ( msg->compute->localWorkMsg != msg )
3137  NAMD_bug("WorkDistrib LocalWorkMsg recycling failed!");
3138 }
LocalWorkMsg *const localWorkMsg
Definition: Compute.h:46
#define MACHINE_PROGRESS
virtual void doWork()
Definition: Compute.C:120
Compute * compute
Definition: WorkDistrib.h:27
void NAMD_bug(const char *err_msg)
Definition: common.C:195

◆ enqueueBonds()

void WorkDistrib::enqueueBonds ( LocalWorkMsg msg)

Definition at line 3104 of file WorkDistrib.C.

References LocalWorkMsg::compute, Compute::doWork(), Compute::localWorkMsg, MACHINE_PROGRESS, and NAMD_bug().

3104  {
3106  if ( msg->compute->localWorkMsg != msg )
3107  NAMD_bug("WorkDistrib LocalWorkMsg recycling failed!");
3108 }
LocalWorkMsg *const localWorkMsg
Definition: Compute.h:46
#define MACHINE_PROGRESS
virtual void doWork()
Definition: Compute.C:120
Compute * compute
Definition: WorkDistrib.h:27
void NAMD_bug(const char *err_msg)
Definition: common.C:195

◆ enqueueCrossterms()

void WorkDistrib::enqueueCrossterms ( LocalWorkMsg msg)

Definition at line 3140 of file WorkDistrib.C.

References LocalWorkMsg::compute, Compute::doWork(), Compute::localWorkMsg, MACHINE_PROGRESS, and NAMD_bug().

3140  {
3142  if ( msg->compute->localWorkMsg != msg )
3143  NAMD_bug("WorkDistrib LocalWorkMsg recycling failed!");
3144 }
LocalWorkMsg *const localWorkMsg
Definition: Compute.h:46
#define MACHINE_PROGRESS
virtual void doWork()
Definition: Compute.C:120
Compute * compute
Definition: WorkDistrib.h:27
void NAMD_bug(const char *err_msg)
Definition: common.C:195

◆ enqueueCUDA()

void WorkDistrib::enqueueCUDA ( LocalWorkMsg msg)

Definition at line 3244 of file WorkDistrib.C.

References LocalWorkMsg::compute, Compute::doWork(), and MACHINE_PROGRESS.

3244  {
3246 }
#define MACHINE_PROGRESS
virtual void doWork()
Definition: Compute.C:120
Compute * compute
Definition: WorkDistrib.h:27

◆ enqueueCUDAP2()

void WorkDistrib::enqueueCUDAP2 ( LocalWorkMsg msg)

Definition at line 3247 of file WorkDistrib.C.

References LocalWorkMsg::compute, Compute::doWork(), and MACHINE_PROGRESS.

3247  {
3249 }
#define MACHINE_PROGRESS
virtual void doWork()
Definition: Compute.C:120
Compute * compute
Definition: WorkDistrib.h:27

◆ enqueueCUDAP3()

void WorkDistrib::enqueueCUDAP3 ( LocalWorkMsg msg)

Definition at line 3250 of file WorkDistrib.C.

References LocalWorkMsg::compute, Compute::doWork(), and MACHINE_PROGRESS.

3250  {
3252 }
#define MACHINE_PROGRESS
virtual void doWork()
Definition: Compute.C:120
Compute * compute
Definition: WorkDistrib.h:27

◆ enqueueDihedrals()

void WorkDistrib::enqueueDihedrals ( LocalWorkMsg msg)

Definition at line 3116 of file WorkDistrib.C.

References LocalWorkMsg::compute, Compute::doWork(), Compute::localWorkMsg, MACHINE_PROGRESS, and NAMD_bug().

3116  {
3118  if ( msg->compute->localWorkMsg != msg )
3119  NAMD_bug("WorkDistrib LocalWorkMsg recycling failed!");
3120 }
LocalWorkMsg *const localWorkMsg
Definition: Compute.h:46
#define MACHINE_PROGRESS
virtual void doWork()
Definition: Compute.C:120
Compute * compute
Definition: WorkDistrib.h:27
void NAMD_bug(const char *err_msg)
Definition: common.C:195

◆ enqueueExcls()

void WorkDistrib::enqueueExcls ( LocalWorkMsg msg)

Definition at line 3098 of file WorkDistrib.C.

References LocalWorkMsg::compute, Compute::doWork(), Compute::localWorkMsg, MACHINE_PROGRESS, and NAMD_bug().

3098  {
3100  if ( msg->compute->localWorkMsg != msg )
3101  NAMD_bug("WorkDistrib LocalWorkMsg recycling failed!");
3102 }
LocalWorkMsg *const localWorkMsg
Definition: Compute.h:46
#define MACHINE_PROGRESS
virtual void doWork()
Definition: Compute.C:120
Compute * compute
Definition: WorkDistrib.h:27
void NAMD_bug(const char *err_msg)
Definition: common.C:195

◆ enqueueGromacsPair()

void WorkDistrib::enqueueGromacsPair ( LocalWorkMsg msg)

Definition at line 3153 of file WorkDistrib.C.

References LocalWorkMsg::compute, Compute::doWork(), Compute::localWorkMsg, MACHINE_PROGRESS, and NAMD_bug().

3153  {
3154  msg->compute->doWork();
3156  if ( msg->compute->localWorkMsg != msg )
3157  NAMD_bug("\nWorkDistrib LocalWorkMsg recycling failed! Check enqueueGromacsPair from WorkDistrib.C\n");
3158 }
LocalWorkMsg *const localWorkMsg
Definition: Compute.h:46
#define MACHINE_PROGRESS
virtual void doWork()
Definition: Compute.C:120
Compute * compute
Definition: WorkDistrib.h:27
void NAMD_bug(const char *err_msg)
Definition: common.C:195

◆ enqueueImpropers()

void WorkDistrib::enqueueImpropers ( LocalWorkMsg msg)

Definition at line 3122 of file WorkDistrib.C.

References LocalWorkMsg::compute, Compute::doWork(), Compute::localWorkMsg, MACHINE_PROGRESS, and NAMD_bug().

3122  {
3124  if ( msg->compute->localWorkMsg != msg )
3125  NAMD_bug("WorkDistrib LocalWorkMsg recycling failed!");
3126 }
LocalWorkMsg *const localWorkMsg
Definition: Compute.h:46
#define MACHINE_PROGRESS
virtual void doWork()
Definition: Compute.C:120
Compute * compute
Definition: WorkDistrib.h:27
void NAMD_bug(const char *err_msg)
Definition: common.C:195

◆ enqueueLCPO()

void WorkDistrib::enqueueLCPO ( LocalWorkMsg msg)

Definition at line 3167 of file WorkDistrib.C.

References LocalWorkMsg::compute, Compute::doWork(), Compute::localWorkMsg, and NAMD_bug().

3167  {
3168  msg->compute->doWork();
3169  if ( msg->compute->localWorkMsg != msg )
3170  NAMD_bug("WorkDistrib LocalWorkMsg recycling failed!");
3171 }
LocalWorkMsg *const localWorkMsg
Definition: Compute.h:46
virtual void doWork()
Definition: Compute.C:120
Compute * compute
Definition: WorkDistrib.h:27
void NAMD_bug(const char *err_msg)
Definition: common.C:195

◆ enqueueMIC()

void WorkDistrib::enqueueMIC ( LocalWorkMsg msg)

Definition at line 3268 of file WorkDistrib.C.

References LocalWorkMsg::compute, Compute::doWork(), and MACHINE_PROGRESS.

3268  {
3270 }
#define MACHINE_PROGRESS
virtual void doWork()
Definition: Compute.C:120
Compute * compute
Definition: WorkDistrib.h:27

◆ enqueueOneFourNbThole()

void WorkDistrib::enqueueOneFourNbThole ( LocalWorkMsg msg)

Definition at line 3146 of file WorkDistrib.C.

References LocalWorkMsg::compute, Compute::doWork(), Compute::localWorkMsg, MACHINE_PROGRESS, and NAMD_bug().

3146  {
3148  if ( msg->compute->localWorkMsg != msg )
3149  NAMD_bug("WorkDistrib LocalWorkMsg recycling failed!");
3150 }
LocalWorkMsg *const localWorkMsg
Definition: Compute.h:46
#define MACHINE_PROGRESS
virtual void doWork()
Definition: Compute.C:120
Compute * compute
Definition: WorkDistrib.h:27
void NAMD_bug(const char *err_msg)
Definition: common.C:195

◆ enqueuePme()

void WorkDistrib::enqueuePme ( LocalWorkMsg msg)

Definition at line 3161 of file WorkDistrib.C.

References LocalWorkMsg::compute, Compute::doWork(), Compute::localWorkMsg, MACHINE_PROGRESS, and NAMD_bug().

3161  {
3163  if ( msg->compute->localWorkMsg != msg )
3164  NAMD_bug("WorkDistrib LocalWorkMsg recycling failed!");
3165 }
LocalWorkMsg *const localWorkMsg
Definition: Compute.h:46
#define MACHINE_PROGRESS
virtual void doWork()
Definition: Compute.C:120
Compute * compute
Definition: WorkDistrib.h:27
void NAMD_bug(const char *err_msg)
Definition: common.C:195

◆ enqueueSelfA1()

void WorkDistrib::enqueueSelfA1 ( LocalWorkMsg msg)

Definition at line 3172 of file WorkDistrib.C.

References LocalWorkMsg::compute, Compute::doWork(), Compute::localWorkMsg, MACHINE_PROGRESS, and NAMD_bug().

3172  {
3174  if ( msg->compute->localWorkMsg != msg )
3175  NAMD_bug("WorkDistrib LocalWorkMsg recycling failed!");
3176 }
LocalWorkMsg *const localWorkMsg
Definition: Compute.h:46
#define MACHINE_PROGRESS
virtual void doWork()
Definition: Compute.C:120
Compute * compute
Definition: WorkDistrib.h:27
void NAMD_bug(const char *err_msg)
Definition: common.C:195

◆ enqueueSelfA2()

void WorkDistrib::enqueueSelfA2 ( LocalWorkMsg msg)

Definition at line 3177 of file WorkDistrib.C.

References LocalWorkMsg::compute, Compute::doWork(), Compute::localWorkMsg, MACHINE_PROGRESS, and NAMD_bug().

3177  {
3179  if ( msg->compute->localWorkMsg != msg )
3180  NAMD_bug("WorkDistrib LocalWorkMsg recycling failed!");
3181 }
LocalWorkMsg *const localWorkMsg
Definition: Compute.h:46
#define MACHINE_PROGRESS
virtual void doWork()
Definition: Compute.C:120
Compute * compute
Definition: WorkDistrib.h:27
void NAMD_bug(const char *err_msg)
Definition: common.C:195

◆ enqueueSelfA3()

void WorkDistrib::enqueueSelfA3 ( LocalWorkMsg msg)

Definition at line 3182 of file WorkDistrib.C.

References LocalWorkMsg::compute, Compute::doWork(), Compute::localWorkMsg, MACHINE_PROGRESS, and NAMD_bug().

3182  {
3184  if ( msg->compute->localWorkMsg != msg )
3185  NAMD_bug("WorkDistrib LocalWorkMsg recycling failed!");
3186 }
LocalWorkMsg *const localWorkMsg
Definition: Compute.h:46
#define MACHINE_PROGRESS
virtual void doWork()
Definition: Compute.C:120
Compute * compute
Definition: WorkDistrib.h:27
void NAMD_bug(const char *err_msg)
Definition: common.C:195

◆ enqueueSelfB1()

void WorkDistrib::enqueueSelfB1 ( LocalWorkMsg msg)

Definition at line 3188 of file WorkDistrib.C.

References LocalWorkMsg::compute, Compute::doWork(), Compute::localWorkMsg, MACHINE_PROGRESS, and NAMD_bug().

3188  {
3190  if ( msg->compute->localWorkMsg != msg )
3191  NAMD_bug("WorkDistrib LocalWorkMsg recycling failed!");
3192 }
LocalWorkMsg *const localWorkMsg
Definition: Compute.h:46
#define MACHINE_PROGRESS
virtual void doWork()
Definition: Compute.C:120
Compute * compute
Definition: WorkDistrib.h:27
void NAMD_bug(const char *err_msg)
Definition: common.C:195

◆ enqueueSelfB2()

void WorkDistrib::enqueueSelfB2 ( LocalWorkMsg msg)

Definition at line 3193 of file WorkDistrib.C.

References LocalWorkMsg::compute, Compute::doWork(), Compute::localWorkMsg, MACHINE_PROGRESS, and NAMD_bug().

3193  {
3195  if ( msg->compute->localWorkMsg != msg )
3196  NAMD_bug("WorkDistrib LocalWorkMsg recycling failed!");
3197 }
LocalWorkMsg *const localWorkMsg
Definition: Compute.h:46
#define MACHINE_PROGRESS
virtual void doWork()
Definition: Compute.C:120
Compute * compute
Definition: WorkDistrib.h:27
void NAMD_bug(const char *err_msg)
Definition: common.C:195

◆ enqueueSelfB3()

void WorkDistrib::enqueueSelfB3 ( LocalWorkMsg msg)

Definition at line 3198 of file WorkDistrib.C.

References LocalWorkMsg::compute, Compute::doWork(), Compute::localWorkMsg, MACHINE_PROGRESS, and NAMD_bug().

3198  {
3200  if ( msg->compute->localWorkMsg != msg )
3201  NAMD_bug("WorkDistrib LocalWorkMsg recycling failed!");
3202 }
LocalWorkMsg *const localWorkMsg
Definition: Compute.h:46
#define MACHINE_PROGRESS
virtual void doWork()
Definition: Compute.C:120
Compute * compute
Definition: WorkDistrib.h:27
void NAMD_bug(const char *err_msg)
Definition: common.C:195

◆ enqueueThole()

void WorkDistrib::enqueueThole ( LocalWorkMsg msg)

Definition at line 3128 of file WorkDistrib.C.

References LocalWorkMsg::compute, Compute::doWork(), Compute::localWorkMsg, MACHINE_PROGRESS, and NAMD_bug().

3128  {
3130  if ( msg->compute->localWorkMsg != msg )
3131  NAMD_bug("WorkDistrib LocalWorkMsg recycling failed!");
3132 }
LocalWorkMsg *const localWorkMsg
Definition: Compute.h:46
#define MACHINE_PROGRESS
virtual void doWork()
Definition: Compute.C:120
Compute * compute
Definition: WorkDistrib.h:27
void NAMD_bug(const char *err_msg)
Definition: common.C:195

◆ enqueueWork()

void WorkDistrib::enqueueWork ( LocalWorkMsg msg)

Definition at line 3092 of file WorkDistrib.C.

References LocalWorkMsg::compute, Compute::doWork(), Compute::localWorkMsg, MACHINE_PROGRESS, and NAMD_bug().

3092  {
3094  if ( msg->compute->localWorkMsg != msg )
3095  NAMD_bug("WorkDistrib LocalWorkMsg recycling failed!");
3096 }
LocalWorkMsg *const localWorkMsg
Definition: Compute.h:46
#define MACHINE_PROGRESS
virtual void doWork()
Definition: Compute.C:120
Compute * compute
Definition: WorkDistrib.h:27
void NAMD_bug(const char *err_msg)
Definition: common.C:195

◆ enqueueWorkA1()

void WorkDistrib::enqueueWorkA1 ( LocalWorkMsg msg)

Definition at line 3204 of file WorkDistrib.C.

References LocalWorkMsg::compute, Compute::doWork(), Compute::localWorkMsg, MACHINE_PROGRESS, and NAMD_bug().

3204  {
3206  if ( msg->compute->localWorkMsg != msg )
3207  NAMD_bug("WorkDistrib LocalWorkMsg recycling failed!");
3208 }
LocalWorkMsg *const localWorkMsg
Definition: Compute.h:46
#define MACHINE_PROGRESS
virtual void doWork()
Definition: Compute.C:120
Compute * compute
Definition: WorkDistrib.h:27
void NAMD_bug(const char *err_msg)
Definition: common.C:195

◆ enqueueWorkA2()

void WorkDistrib::enqueueWorkA2 ( LocalWorkMsg msg)

Definition at line 3209 of file WorkDistrib.C.

References LocalWorkMsg::compute, Compute::doWork(), Compute::localWorkMsg, MACHINE_PROGRESS, and NAMD_bug().

3209  {
3211  if ( msg->compute->localWorkMsg != msg )
3212  NAMD_bug("WorkDistrib LocalWorkMsg recycling failed!");
3213 }
LocalWorkMsg *const localWorkMsg
Definition: Compute.h:46
#define MACHINE_PROGRESS
virtual void doWork()
Definition: Compute.C:120
Compute * compute
Definition: WorkDistrib.h:27
void NAMD_bug(const char *err_msg)
Definition: common.C:195

◆ enqueueWorkA3()

void WorkDistrib::enqueueWorkA3 ( LocalWorkMsg msg)

Definition at line 3214 of file WorkDistrib.C.

References LocalWorkMsg::compute, Compute::doWork(), Compute::localWorkMsg, MACHINE_PROGRESS, and NAMD_bug().

3214  {
3216  if ( msg->compute->localWorkMsg != msg )
3217  NAMD_bug("WorkDistrib LocalWorkMsg recycling failed!");
3218 }
LocalWorkMsg *const localWorkMsg
Definition: Compute.h:46
#define MACHINE_PROGRESS
virtual void doWork()
Definition: Compute.C:120
Compute * compute
Definition: WorkDistrib.h:27
void NAMD_bug(const char *err_msg)
Definition: common.C:195

◆ enqueueWorkB1()

void WorkDistrib::enqueueWorkB1 ( LocalWorkMsg msg)

Definition at line 3220 of file WorkDistrib.C.

References LocalWorkMsg::compute, Compute::doWork(), Compute::localWorkMsg, MACHINE_PROGRESS, and NAMD_bug().

3220  {
3222  if ( msg->compute->localWorkMsg != msg )
3223  NAMD_bug("WorkDistrib LocalWorkMsg recycling failed!");
3224 }
LocalWorkMsg *const localWorkMsg
Definition: Compute.h:46
#define MACHINE_PROGRESS
virtual void doWork()
Definition: Compute.C:120
Compute * compute
Definition: WorkDistrib.h:27
void NAMD_bug(const char *err_msg)
Definition: common.C:195

◆ enqueueWorkB2()

void WorkDistrib::enqueueWorkB2 ( LocalWorkMsg msg)

Definition at line 3225 of file WorkDistrib.C.

References LocalWorkMsg::compute, Compute::doWork(), Compute::localWorkMsg, MACHINE_PROGRESS, and NAMD_bug().

3225  {
3227  if ( msg->compute->localWorkMsg != msg )
3228  NAMD_bug("WorkDistrib LocalWorkMsg recycling failed!");
3229 }
LocalWorkMsg *const localWorkMsg
Definition: Compute.h:46
#define MACHINE_PROGRESS
virtual void doWork()
Definition: Compute.C:120
Compute * compute
Definition: WorkDistrib.h:27
void NAMD_bug(const char *err_msg)
Definition: common.C:195

◆ enqueueWorkB3()

void WorkDistrib::enqueueWorkB3 ( LocalWorkMsg msg)

Definition at line 3230 of file WorkDistrib.C.

References LocalWorkMsg::compute, Compute::doWork(), Compute::localWorkMsg, MACHINE_PROGRESS, and NAMD_bug().

3230  {
3232  if ( msg->compute->localWorkMsg != msg )
3233  NAMD_bug("WorkDistrib LocalWorkMsg recycling failed!");
3234 }
LocalWorkMsg *const localWorkMsg
Definition: Compute.h:46
#define MACHINE_PROGRESS
virtual void doWork()
Definition: Compute.C:120
Compute * compute
Definition: WorkDistrib.h:27
void NAMD_bug(const char *err_msg)
Definition: common.C:195

◆ enqueueWorkC()

void WorkDistrib::enqueueWorkC ( LocalWorkMsg msg)

Definition at line 3238 of file WorkDistrib.C.

References LocalWorkMsg::compute, Compute::doWork(), Compute::localWorkMsg, MACHINE_PROGRESS, and NAMD_bug().

3238  {
3240  if ( msg->compute->localWorkMsg != msg )
3241  NAMD_bug("WorkDistrib LocalWorkMsg recycling failed!");
3242 }
LocalWorkMsg *const localWorkMsg
Definition: Compute.h:46
#define MACHINE_PROGRESS
virtual void doWork()
Definition: Compute.C:120
Compute * compute
Definition: WorkDistrib.h:27
void NAMD_bug(const char *err_msg)
Definition: common.C:195

◆ finishCUDA()

void WorkDistrib::finishCUDA ( LocalWorkMsg msg)

Definition at line 3258 of file WorkDistrib.C.

References LocalWorkMsg::compute, Compute::doWork(), and MACHINE_PROGRESS.

3258  {
3260 }
#define MACHINE_PROGRESS
virtual void doWork()
Definition: Compute.C:120
Compute * compute
Definition: WorkDistrib.h:27

◆ finishCUDAP2()

void WorkDistrib::finishCUDAP2 ( LocalWorkMsg msg)

Definition at line 3261 of file WorkDistrib.C.

References LocalWorkMsg::compute, Compute::doWork(), and MACHINE_PROGRESS.

3261  {
3263 }
#define MACHINE_PROGRESS
virtual void doWork()
Definition: Compute.C:120
Compute * compute
Definition: WorkDistrib.h:27

◆ finishCUDAP3()

void WorkDistrib::finishCUDAP3 ( LocalWorkMsg msg)

Definition at line 3264 of file WorkDistrib.C.

References LocalWorkMsg::compute, Compute::doWork(), and MACHINE_PROGRESS.

3264  {
3266 }
#define MACHINE_PROGRESS
virtual void doWork()
Definition: Compute.C:120
Compute * compute
Definition: WorkDistrib.h:27

◆ finishCUDAPatch()

void WorkDistrib::finishCUDAPatch ( FinishWorkMsg msg)

Definition at line 3254 of file WorkDistrib.C.

References FinishWorkMsg::compute, FinishWorkMsg::data, and Compute::finishPatch().

3254  {
3255  msg->compute->finishPatch(msg->data);
3256 }
Compute * compute
Definition: WorkDistrib.h:33
virtual void finishPatch(int)
Definition: Compute.C:124

◆ finishMIC()

void WorkDistrib::finishMIC ( LocalWorkMsg msg)

Definition at line 3271 of file WorkDistrib.C.

References LocalWorkMsg::compute, Compute::doWork(), and MACHINE_PROGRESS.

3271  {
3273 }
#define MACHINE_PROGRESS
virtual void doWork()
Definition: Compute.C:120
Compute * compute
Definition: WorkDistrib.h:27

◆ initHostDeviceLDB()

void WorkDistrib::initHostDeviceLDB ( )

Definition at line 3526 of file WorkDistrib.C.

3526  {
3527  #if defined(NAMD_MIC)
3528  mic_hostDeviceLDB();
3529  #endif
3530 }

◆ mapComputes()

void WorkDistrib::mapComputes ( void  )

Definition at line 2407 of file WorkDistrib.C.

References ComputeMap::allocateCids(), SimParameters::bondedCUDA, computeAnglesType, computeAnisoType, computeBondsType, computeConsForceType, computeConsTorqueType, computeCrosstermsType, computeCylindricalBCType, computeDihedralsType, computeEFieldType, computeEwaldType, computeExclsType, computeExtType, computeFmmType, computeFullDirectType, computeGBISserType, computeGlobalType, computeGridForceType, computeGromacsPairType, computeImpropersType, computeLjPmeSerialType, computeMsmMsaType, computeMsmSerialType, computeMsmType, computeNonbondedCUDA2Type, computeNonbondedMICType, computeOneFourNbTholeType, computePmeCUDAType, computePmeType, computeQMType, computeRestraintsType, computeSelfAnglesType, computeSelfAnisoType, computeSelfBondsType, computeSelfCrosstermsType, computeSelfDihedralsType, computeSelfExclsType, computeSelfGromacsPairType, computeSelfImpropersType, computeSelfOneFourNbTholeType, computeSelfTholeType, computeSphericalBCType, computeStirType, computeTclBCType, computeTholeType, SimParameters::consForceOn, SimParameters::consTorqueOn, SimParameters::constraintsOn, SimParameters::cylindricalBCOn, DebugM, SimParameters::drudeOn, SimParameters::eFieldOn, SimParameters::extForcesOn, SimParameters::FMAOn, SimParameters::FMMOn, SimParameters::fullDirectOn, SimParameters::GBISserOn, SimParameters::globalForcesOn, SimParameters::goGroPair, SimParameters::LCPOOn, SimParameters::LJPMEOn, ComputeMap::loadComputeMap(), SimParameters::mgridforceOn, SimParameters::MSMOn, SimParameters::MsmSerialOn, NAMD_die(), PatchMap::Object(), Node::Object(), ComputeMap::Object(), SimParameters::pairInteractionOn, SimParameters::pairInteractionSelf, SimParameters::PMEOn, SimParameters::pressureProfileEwaldOn, SimParameters::qmForcesOn, ComputeMap::saveComputeMap(), Node::simParameters, simParams, SimParameters::sphericalBCOn, SimParameters::stirOn, SimParameters::tclBCOn, SimParameters::useDPME, and SimParameters::usePMECUDA.

Referenced by Node::startup().

2408 {
2409  PatchMap *patchMap = PatchMap::Object();
2410  ComputeMap *computeMap = ComputeMap::Object();
2411  CProxy_Node nd(CkpvAccess(BOCclass_group).node);
2412  Node *node = nd.ckLocalBranch();
2413 
2414  DebugM(3,"Mapping computes\n");
2415 
2416  computeMap->allocateCids();
2417 
2418  // Handle full electrostatics
2419  if ( node->simParameters->fullDirectOn )
2420  mapComputeHomePatches(computeFullDirectType);
2421  if ( node->simParameters->FMAOn )
2422 #ifdef DPMTA
2423  mapComputeHomePatches(computeDPMTAType);
2424 #else
2425  NAMD_die("This binary does not include DPMTA (FMA).");
2426 #endif
2427  if ( node->simParameters->PMEOn ) {
2428 #ifdef DPME
2429  if ( node->simParameters->useDPME )
2430  mapComputeHomePatches(computeDPMEType);
2431  else {
2432  mapComputeHomePatches(computePmeType);
2434  mapComputeHomePatches(computeEwaldType);
2435  }
2436 #else
2437 #if defined(NAMD_CUDA) || defined(NAMD_HIP)
2438  if (node->simParameters->usePMECUDA) {
2439  mapComputePatch(computePmeCUDAType);
2440  } else
2441 #endif
2442  {
2443  mapComputePatch(computePmeType);
2444  }
2446  mapComputeHomePatches(computeEwaldType);
2447 #endif
2448  }
2449 
2450  if ( node->simParameters->globalForcesOn ) {
2451  DebugM(2,"adding ComputeGlobal\n");
2452  mapComputeHomePatches(computeGlobalType);
2453  }
2454 
2455  if ( node->simParameters->extForcesOn )
2456  mapComputeHomePatches(computeExtType);
2457 
2458  if ( node->simParameters->qmForcesOn )
2459  mapComputeHomePatches(computeQMType);
2460 
2461  if ( node->simParameters->GBISserOn )
2462  mapComputeHomePatches(computeGBISserType);
2463 
2464  if ( node->simParameters->MsmSerialOn )
2465  mapComputeHomePatches(computeMsmSerialType);
2466 
2467  if ( node->simParameters->LJPMEOn )
2468  mapComputeHomePatches(computeLjPmeSerialType);
2469 #ifdef CHARM_HAS_MSA
2470  else if ( node->simParameters->MSMOn )
2471  mapComputeHomePatches(computeMsmMsaType);
2472 #else
2473  else if ( node->simParameters->MSMOn )
2474  mapComputeHomePatches(computeMsmType);
2475 #endif
2476 
2477  if ( node->simParameters->FMMOn )
2478  mapComputeHomePatches(computeFmmType);
2479 
2480 #if defined(NAMD_CUDA) || defined(NAMD_HIP)
2481 #ifdef BONDED_CUDA
2482  if (node->simParameters->bondedCUDA) {
2483  mapComputeNode(computeBondedCUDAType);
2484  }
2485 #endif
2486 #endif
2487 
2488 #if defined(NAMD_CUDA) || defined(NAMD_HIP)
2489  mapComputeNode(computeNonbondedCUDA2Type);
2490  mapComputeHomeTuples(computeExclsType);
2491  mapComputePatch(computeSelfExclsType);
2492 #endif
2493 
2494 #ifdef NAMD_MIC
2495  mapComputeNode(computeNonbondedMICType);
2496 #endif
2497 
2498  mapComputeNonbonded();
2499 
2500  if ( node->simParameters->LCPOOn ) {
2501  mapComputeLCPO();
2502  }
2503 
2504  // If we're doing true pair interactions, no need for bonded terms.
2505  // But if we're doing within-group interactions, we do need them.
2506  if ( !node->simParameters->pairInteractionOn ||
2508  mapComputeHomeTuples(computeBondsType);
2509  mapComputeHomeTuples(computeAnglesType);
2510  mapComputeHomeTuples(computeDihedralsType);
2511  mapComputeHomeTuples(computeImpropersType);
2512  mapComputeHomeTuples(computeCrosstermsType);
2513  mapComputePatch(computeSelfBondsType);
2514  mapComputePatch(computeSelfAnglesType);
2515  mapComputePatch(computeSelfDihedralsType);
2516  mapComputePatch(computeSelfImpropersType);
2517  mapComputePatch(computeSelfCrosstermsType);
2518  }
2519 
2520  if ( node->simParameters->goGroPair ) {
2521  // JLai
2522  mapComputeHomeTuples(computeGromacsPairType);
2523  mapComputePatch(computeSelfGromacsPairType);
2524  // End of JLai
2525  }
2526 
2527  if ( node->simParameters->drudeOn ) {
2528  mapComputeHomeTuples(computeTholeType);
2529  mapComputePatch(computeSelfTholeType);
2530  mapComputeHomeTuples(computeAnisoType);
2531  mapComputePatch(computeSelfAnisoType);
2532  mapComputeHomeTuples(computeOneFourNbTholeType);
2533  mapComputePatch(computeSelfOneFourNbTholeType);
2534  }
2535 
2536  if ( node->simParameters->eFieldOn )
2537  mapComputePatch(computeEFieldType);
2538  /* BEGIN gf */
2539  if ( node->simParameters->mgridforceOn )
2540  mapComputePatch(computeGridForceType);
2541  /* END gf */
2542  if ( node->simParameters->stirOn )
2543  mapComputePatch(computeStirType);
2544  if ( node->simParameters->sphericalBCOn )
2545  mapComputePatch(computeSphericalBCType);
2546  if ( node->simParameters->cylindricalBCOn )
2547  mapComputePatch(computeCylindricalBCType);
2548  if ( node->simParameters->tclBCOn ) {
2549  mapComputeHomePatches(computeTclBCType);
2550  }
2551  if ( node->simParameters->constraintsOn )
2552  mapComputePatch(computeRestraintsType);
2553  if ( node->simParameters->consForceOn )
2554  mapComputePatch(computeConsForceType);
2555  if ( node->simParameters->consTorqueOn )
2556  mapComputePatch(computeConsTorqueType);
2557 
2558  // store the latest compute map
2560  if (simParams->storeComputeMap) {
2561  computeMap->saveComputeMap(simParams->computeMapFilename);
2562  }
2563  // override mapping decision
2564  if (simParams->loadComputeMap) {
2565  computeMap->loadComputeMap(simParams->computeMapFilename);
2566  CkPrintf("ComputeMap has been loaded from %s.\n", simParams->computeMapFilename);
2567  }
2568 }
static Node * Object()
Definition: Node.h:86
void saveComputeMap(const char *fname)
Definition: ComputeMap.C:260
Definition: Node.h:78
static PatchMap * Object()
Definition: PatchMap.h:27
SimParameters * simParameters
Definition: Node.h:181
void loadComputeMap(const char *fname)
Definition: ComputeMap.C:276
#define DebugM(x, y)
Definition: Debug.h:75
Bool pairInteractionOn
int allocateCids()
Definition: ComputeMap.C:141
void NAMD_die(const char *err_msg)
Definition: common.C:147
Bool pressureProfileEwaldOn
#define simParams
Definition: Output.C:131
static ComputeMap * Object()
Definition: ComputeMap.h:91
Bool pairInteractionSelf

◆ messageEnqueueWork()

void WorkDistrib::messageEnqueueWork ( Compute compute)
static

Definition at line 2866 of file WorkDistrib.C.

References Compute::cid, LocalWorkMsg::compute, computeAnglesType, computeAnisoType, computeBondsType, computeCrosstermsType, computeDihedralsType, computeExclsType, computeGromacsPairType, computeImpropersType, computeLCPOType, computeNonbondedCUDA2Type, computeNonbondedMICType, computeNonbondedPairType, computeNonbondedSelfType, computeOneFourNbTholeType, computePmeCUDAType, computePmeType, computeSelfAnglesType, computeSelfAnisoType, computeSelfBondsType, computeSelfCrosstermsType, computeSelfDihedralsType, computeSelfExclsType, computeSelfGromacsPairType, computeSelfImpropersType, computeSelfOneFourNbTholeType, computeSelfTholeType, computeTholeType, Compute::doWork(), Compute::getGBISPhase(), Compute::localWorkMsg, MACHINE_PROGRESS, NAMD_bug(), Compute::priority(), Compute::sequence(), SET_PRIORITY, and Compute::type().

Referenced by cuda_check_pme_forces(), Compute::enqueueWork(), CudaComputeNonbonded::messageEnqueueWork(), ComputePmeMgr::submitReductions(), and ComputePmeMgr::ungridCalc().

2866  {
2867  LocalWorkMsg *msg = compute->localWorkMsg;
2868  int seq = compute->sequence();
2869  int gbisPhase = compute->getGBISPhase();
2870 
2871  if ( seq < 0 ) {
2872  NAMD_bug("compute->sequence() < 0 in WorkDistrib::messageEnqueueWork");
2873  } else {
2874  SET_PRIORITY(msg,seq,compute->priority());
2875  }
2876 
2877  msg->compute = compute; // pointer is valid since send is to local Pe
2878  int type = compute->type();
2879  int cid = compute->cid;
2880 
2881  CProxy_WorkDistrib wdProxy(CkpvAccess(BOCclass_group).workDistrib);
2882  switch ( type ) {
2883  case computeExclsType:
2884  case computeSelfExclsType:
2885  wdProxy[CkMyPe()].enqueueExcls(msg);
2886  break;
2887  case computeBondsType:
2888  case computeSelfBondsType:
2889  wdProxy[CkMyPe()].enqueueBonds(msg);
2890  break;
2891  case computeAnglesType:
2892  case computeSelfAnglesType:
2893  wdProxy[CkMyPe()].enqueueAngles(msg);
2894  break;
2895  case computeDihedralsType:
2897  wdProxy[CkMyPe()].enqueueDihedrals(msg);
2898  break;
2899  case computeImpropersType:
2901  wdProxy[CkMyPe()].enqueueImpropers(msg);
2902  break;
2903  case computeTholeType:
2904  case computeSelfTholeType:
2905  wdProxy[CkMyPe()].enqueueThole(msg);
2906  break;
2907  case computeAnisoType:
2908  case computeSelfAnisoType:
2909  wdProxy[CkMyPe()].enqueueAniso(msg);
2910  break;
2911  case computeCrosstermsType:
2913  wdProxy[CkMyPe()].enqueueCrossterms(msg);
2914  break;
2917  wdProxy[CkMyPe()].enqueueOneFourNbThole(msg);
2918  break;
2919  // JLai
2922  wdProxy[CkMyPe()].enqueueGromacsPair(msg);
2923  break;
2924  // End of JLai
2925  case computeLCPOType:
2926  wdProxy[CkMyPe()].enqueueLCPO(msg);
2927  break;
2929  switch ( seq % 2 ) {
2930  case 0:
2931  //wdProxy[CkMyPe()].enqueueSelfA(msg);
2932  switch ( gbisPhase ) {
2933  case 1:
2934  wdProxy[CkMyPe()].enqueueSelfA1(msg);
2935  break;
2936  case 2:
2937  wdProxy[CkMyPe()].enqueueSelfA2(msg);
2938  break;
2939  case 3:
2940  wdProxy[CkMyPe()].enqueueSelfA3(msg);
2941  break;
2942  }
2943  break;
2944  case 1:
2945  //wdProxy[CkMyPe()].enqueueSelfB(msg);
2946  switch ( gbisPhase ) {
2947  case 1:
2948  wdProxy[CkMyPe()].enqueueSelfB1(msg);
2949  break;
2950  case 2:
2951  wdProxy[CkMyPe()].enqueueSelfB2(msg);
2952  break;
2953  case 3:
2954  wdProxy[CkMyPe()].enqueueSelfB3(msg);
2955  break;
2956  }
2957  break;
2958  default:
2959  NAMD_bug("WorkDistrib::messageEnqueueSelf case statement error!");
2960  }
2961  break;
2963  switch ( seq % 2 ) {
2964  case 0:
2965  //wdProxy[CkMyPe()].enqueueWorkA(msg);
2966  switch ( gbisPhase ) {
2967  case 1:
2968  wdProxy[CkMyPe()].enqueueWorkA1(msg);
2969  break;
2970  case 2:
2971  wdProxy[CkMyPe()].enqueueWorkA2(msg);
2972  break;
2973  case 3:
2974  wdProxy[CkMyPe()].enqueueWorkA3(msg);
2975  break;
2976  }
2977  break;
2978  case 1:
2979  //wdProxy[CkMyPe()].enqueueWorkB(msg);
2980  switch ( gbisPhase ) {
2981  case 1:
2982  wdProxy[CkMyPe()].enqueueWorkB1(msg);
2983  break;
2984  case 2:
2985  wdProxy[CkMyPe()].enqueueWorkB2(msg);
2986  break;
2987  case 3:
2988  wdProxy[CkMyPe()].enqueueWorkB3(msg);
2989  break;
2990  }
2991  break;
2992  case 2:
2993  wdProxy[CkMyPe()].enqueueWorkC(msg);
2994  break;
2995  default:
2996  NAMD_bug("WorkDistrib::messageEnqueueWork case statement error!");
2997  }
2998  break;
2999 #if defined(NAMD_CUDA) || defined(NAMD_HIP)
3001 // CkPrintf("WorkDistrib[%d]::CUDA seq=%d phase=%d\n", CkMyPe(), seq, gbisPhase);
3002  //wdProxy[CkMyPe()].enqueueCUDA(msg);
3003  switch ( gbisPhase ) {
3004  case 1:
3005  wdProxy[CkMyPe()].enqueueCUDA(msg);
3006  break;
3007  case 2:
3008  wdProxy[CkMyPe()].enqueueCUDAP2(msg);
3009  break;
3010  case 3:
3011  wdProxy[CkMyPe()].enqueueCUDAP3(msg);
3012  break;
3013  }
3014 #else
3016 #endif
3017  break;
3019 #ifdef NAMD_MIC
3020  wdProxy[CkMyPe()].enqueueMIC(msg);
3021 #endif
3022  break;
3023  case computePmeType:
3024  // CkPrintf("PME %d %d %x\n", CkMyPe(), seq, compute->priority());
3025  wdProxy[CkMyPe()].enqueuePme(msg);
3026  break;
3027 #if defined(NAMD_CUDA) || defined(NAMD_HIP)
3028  case computePmeCUDAType:
3029  wdProxy[CkMyPe()].enqueuePme(msg);
3030  break;
3031 #endif
3032  default:
3033  wdProxy[CkMyPe()].enqueueWork(msg);
3034  }
3035 }
int sequence(void)
Definition: Compute.h:64
int getGBISPhase(void)
Definition: Compute.h:66
LocalWorkMsg *const localWorkMsg
Definition: Compute.h:46
#define MACHINE_PROGRESS
virtual void doWork()
Definition: Compute.C:120
Compute * compute
Definition: WorkDistrib.h:27
void NAMD_bug(const char *err_msg)
Definition: common.C:195
int priority(void)
Definition: Compute.h:65
int type()
Definition: Compute.h:48
#define SET_PRIORITY(MSG, SEQ, PRIO)
Definition: Priorities.h:18
const ComputeID cid
Definition: Compute.h:43

◆ messageFinishCUDA()

void WorkDistrib::messageFinishCUDA ( Compute compute)
static

Definition at line 3038 of file WorkDistrib.C.

References LocalWorkMsg::compute, Compute::doWork(), Compute::getGBISPhase(), Compute::localWorkMsg, MACHINE_PROGRESS, NAMD_bug(), Compute::priority(), Compute::sequence(), and SET_PRIORITY.

3038  {
3039  LocalWorkMsg *msg = compute->localWorkMsg;
3040  int seq = compute->sequence();
3041  int gbisPhase = compute->getGBISPhase();
3042 
3043  if ( seq < 0 ) {
3044  NAMD_bug("compute->sequence() < 0 in WorkDistrib::messageEnqueueWork");
3045  } else {
3046  SET_PRIORITY(msg,seq,compute->priority());
3047  }
3048 
3049  msg->compute = compute; // pointer is valid since send is to local Pe
3050  CProxy_WorkDistrib wdProxy(CkpvAccess(BOCclass_group).workDistrib);
3051 
3052 #if defined(NAMD_CUDA) || defined(NAMD_HIP)
3053  //wdProxy[CkMyPe()].finishCUDA(msg);
3054  switch ( gbisPhase ) {
3055  case 1:
3056  wdProxy[CkMyPe()].finishCUDA(msg);
3057  break;
3058  case 2:
3059  wdProxy[CkMyPe()].finishCUDAP2(msg);
3060  break;
3061  case 3:
3062  wdProxy[CkMyPe()].finishCUDAP3(msg);
3063  break;
3064  }
3065 #else
3067 #endif
3068 }
int sequence(void)
Definition: Compute.h:64
int getGBISPhase(void)
Definition: Compute.h:66
LocalWorkMsg *const localWorkMsg
Definition: Compute.h:46
#define MACHINE_PROGRESS
virtual void doWork()
Definition: Compute.C:120
Compute * compute
Definition: WorkDistrib.h:27
void NAMD_bug(const char *err_msg)
Definition: common.C:195
int priority(void)
Definition: Compute.h:65
#define SET_PRIORITY(MSG, SEQ, PRIO)
Definition: Priorities.h:18

◆ messageFinishMIC()

void WorkDistrib::messageFinishMIC ( Compute compute)
static

Definition at line 3071 of file WorkDistrib.C.

References LocalWorkMsg::compute, Compute::doWork(), Compute::getGBISPhase(), Compute::localWorkMsg, MACHINE_PROGRESS, NAMD_bug(), Compute::priority(), Compute::sequence(), and SET_PRIORITY.

3071  {
3072  LocalWorkMsg *msg = compute->localWorkMsg;
3073  int seq = compute->sequence();
3074  int gbisPhase = compute->getGBISPhase();
3075 
3076  if ( seq < 0 ) {
3077  NAMD_bug("compute->sequence() < 0 in WorkDistrib::messageFinishMIC");
3078  } else {
3079  SET_PRIORITY(msg,seq,compute->priority());
3080  }
3081 
3082  msg->compute = compute; // pointer is valid since send is to local Pe
3083  CProxy_WorkDistrib wdProxy(CkpvAccess(BOCclass_group).workDistrib);
3084 
3085 #ifdef NAMD_MIC
3086  wdProxy[CkMyPe()].finishMIC(msg);
3087 #else
3089 #endif
3090 }
int sequence(void)
Definition: Compute.h:64
int getGBISPhase(void)
Definition: Compute.h:66
LocalWorkMsg *const localWorkMsg
Definition: Compute.h:46
#define MACHINE_PROGRESS
virtual void doWork()
Definition: Compute.C:120
Compute * compute
Definition: WorkDistrib.h:27
void NAMD_bug(const char *err_msg)
Definition: common.C:195
int priority(void)
Definition: Compute.h:65
#define SET_PRIORITY(MSG, SEQ, PRIO)
Definition: Priorities.h:18

◆ patchMapInit()

void WorkDistrib::patchMapInit ( void  )

Definition at line 1238 of file WorkDistrib.C.

References Lattice::a_p(), Lattice::a_r(), Lattice::b_p(), Lattice::b_r(), Lattice::c_p(), Lattice::c_r(), SimParameters::CUDASOAintegrateMode, DebugM, endi(), PDB::find_extremes(), SimParameters::FMAOn, SimParameters::FMMOn, PDB::get_extremes(), iINFO(), iout, isOutputProcessor(), iWARN(), SimParameters::lattice, SimParameters::LCPOOn, PatchMap::makePatches(), SimParameters::maxPatches, SimParameters::minAtomsPerPatch, Node::molecule, SimParameters::MSMOn, NAMD_die(), SimParameters::noPatchesOnOne, SimParameters::noPatchesOnOutputPEs, SimParameters::noPatchesOnZero, PDB::num_atoms(), Molecule::numAtoms, SimParameters::numoutputprocs, PatchMap::Object(), Node::Object(), Lattice::origin(), SimParameters::patchDimension, Node::pdb, SimParameters::replicaUniformPatchGrids, Node::simParameters, SimParameters::simulatedPEs, SimParameters::simulateInitialMapping, PatchMap::sizeGrid(), SimParameters::staticAtomAssignment, SimParameters::twoAwayX, SimParameters::twoAwayY, SimParameters::twoAwayZ, Vector::x, Vector::y, and Vector::z.

Referenced by Node::startup().

1239 {
1240  PatchMap *patchMap = PatchMap::Object();
1241  CProxy_Node nd(CkpvAccess(BOCclass_group).node);
1242  Node *node = nd.ckLocalBranch();
1243  SimParameters *params = node->simParameters;
1244  Lattice lattice = params->lattice;
1245 
1246  BigReal patchSize = params->patchDimension;
1247 
1248 #ifndef MEM_OPT_VERSION
1249  const int totalAtoms = node->pdb->num_atoms();
1250 #else
1251  const int totalAtoms = node->molecule->numAtoms;
1252 #endif
1253 
1254  ScaledPosition xmin, xmax;
1255 
1256  double maxNumPatches = 1.e9; // need to adjust fractional values
1257  if ( params->minAtomsPerPatch > 0 )
1258  maxNumPatches = totalAtoms / params->minAtomsPerPatch;
1259 
1260  DebugM(3,"Mapping patches\n");
1261  if ( lattice.a_p() && lattice.b_p() && lattice.c_p() ) {
1262  xmin = 0.; xmax = 0.;
1263  }
1264  else if ( params->FMAOn || params->MSMOn || params->FMMOn ) {
1265  // Need to use full box for FMA to match NAMD 1.X results.
1266 #if 0
1267  node->pdb->find_extremes(&(xmin.x),&(xmax.x),lattice.a_r());
1268  node->pdb->find_extremes(&(xmin.y),&(xmax.y),lattice.b_r());
1269  node->pdb->find_extremes(&(xmin.z),&(xmax.z),lattice.c_r());
1270 #endif
1271  node->pdb->find_extremes(lattice);
1272  node->pdb->get_extremes(xmin, xmax);
1273 #if 0
1274  printf("+++ center=%.4f %.4f %.4f\n",
1275  lattice.origin().x, lattice.origin().y, lattice.origin().z);
1276  printf("+++ xmin=%.4f xmax=%.4f\n", xmin.x, xmax.x);
1277  printf("+++ ymin=%.4f ymax=%.4f\n", xmin.y, xmax.y);
1278  printf("+++ zmin=%.4f zmax=%.4f\n", xmin.z, xmax.z);
1279 #endif
1280  // Otherwise, this allows a small number of stray atoms.
1281  }
1282  else {
1283 #if 0
1284  node->pdb->find_extremes(&(xmin.x),&(xmax.x),lattice.a_r(),0.9);
1285  node->pdb->find_extremes(&(xmin.y),&(xmax.y),lattice.b_r(),0.9);
1286  node->pdb->find_extremes(&(xmin.z),&(xmax.z),lattice.c_r(),0.9);
1287 #endif
1288  node->pdb->find_extremes(lattice, 1.0);
1289  node->pdb->get_extremes(xmin, xmax);
1290  iout << iINFO << "ORIGINAL ATOMS MINMAX IS " << xmin << " " << xmax << "\n" << endi;
1291  double frac = ( (double)totalAtoms - 10000. ) / (double)totalAtoms;
1292  if ( frac < 0.9 ) { frac = 0.9; }
1293  node->pdb->find_extremes(lattice, frac);
1294  node->pdb->get_extremes(xmin, xmax);
1295  iout << iINFO << "ADJUSTED ATOMS MINMAX IS " << xmin << " " << xmax << "\n" << endi;
1296  }
1297 
1298 #if 0
1299  BigReal origin_shift;
1300  origin_shift = lattice.a_r() * lattice.origin();
1301  xmin.x -= origin_shift;
1302  xmax.x -= origin_shift;
1303  origin_shift = lattice.b_r() * lattice.origin();
1304  xmin.y -= origin_shift;
1305  xmax.y -= origin_shift;
1306  origin_shift = lattice.c_r() * lattice.origin();
1307  xmin.z -= origin_shift;
1308  xmax.z -= origin_shift;
1309 #endif
1310 
1311  // SimParameters default is -1 for unset
1312  int twoAwayX = params->twoAwayX;
1313  int twoAwayY = params->twoAwayY;
1314  int twoAwayZ = params->twoAwayZ;
1315 
1316  // SASA implementation is not compatible with twoAway patches
1317  if (params->LCPOOn && patchSize < 32.4) {
1318  if ( twoAwayX > 0 || twoAwayY > 0 || twoAwayZ > 0 ) {
1319  iout << iWARN << "Ignoring twoAway[XYZ] due to LCPO SASA implementation.\n" << endi;
1320  }
1321  twoAwayX = twoAwayY = twoAwayZ = 0;
1322  }
1323 
1324  // if you think you know what you're doing go right ahead
1325  if ( twoAwayX > 0 ) maxNumPatches = 1.e9;
1326  if ( twoAwayY > 0 ) maxNumPatches = 1.e9;
1327  if ( twoAwayZ > 0 ) maxNumPatches = 1.e9;
1328  if ( params->maxPatches > 0 ) {
1329  maxNumPatches = params->maxPatches;
1330  iout << iINFO << "LIMITING NUMBER OF PATCHES TO " <<
1331  maxNumPatches << "\n" << endi;
1332  }
1333 
1334  int numpes = CkNumPes();
1335  SimParameters *simparam = Node::Object()->simParameters;
1336  if(simparam->simulateInitialMapping) {
1337  numpes = simparam->simulatedPEs;
1338  delete [] patchMap->nPatchesOnNode;
1339  patchMap->nPatchesOnNode = new int[numpes];
1340  memset(patchMap->nPatchesOnNode, 0, numpes*sizeof(int));
1341  }
1342 
1343 #if defined(NAMD_CUDA) || defined(NAMD_HIP) || defined(NAMD_MIC)
1344  // for CUDA be sure there are more patches than pes
1345 
1346  int numPatches = patchMap->sizeGrid(
1347  xmin,xmax,lattice,patchSize,maxNumPatches,params->staticAtomAssignment,
1348  twoAwayX>0 ? 2 : 1, twoAwayY>0 ? 2 : 1, twoAwayZ>0 ? 2 : 1);
1349  if ( numPatches < numpes && twoAwayX < 0 ) {
1350  twoAwayX = 1;
1351  numPatches = patchMap->sizeGrid(
1352  xmin,xmax,lattice,patchSize,maxNumPatches,params->staticAtomAssignment,
1353  twoAwayX>0 ? 2 : 1, twoAwayY>0 ? 2 : 1, twoAwayZ>0 ? 2 : 1);
1354  }
1355  if ( numPatches < numpes && twoAwayY < 0 ) {
1356  twoAwayY = 1;
1357  numPatches = patchMap->sizeGrid(
1358  xmin,xmax,lattice,patchSize,maxNumPatches,params->staticAtomAssignment,
1359  twoAwayX>0 ? 2 : 1, twoAwayY>0 ? 2 : 1, twoAwayZ>0 ? 2 : 1);
1360  }
1361  if ( numPatches < numpes && twoAwayZ < 0 ) {
1362  twoAwayZ = 1;
1363  numPatches = patchMap->sizeGrid(
1364  xmin,xmax,lattice,patchSize,maxNumPatches,params->staticAtomAssignment,
1365  twoAwayX>0 ? 2 : 1, twoAwayY>0 ? 2 : 1, twoAwayZ>0 ? 2 : 1);
1366  }
1367  if ( numPatches < numpes ) {
1368  #if defined(NAMD_MIC)
1369  NAMD_die("MIC-enabled NAMD requires at least one patch per thread.");
1370  #else
1371  if (simparam->CUDASOAintegrateMode) {
1372  NAMD_die("GPU-resident NAMD requires at least one patch per thread.");
1373  }
1374  #endif
1375  }
1376  if ( numPatches % numpes && numPatches <= 1.4 * numpes ) {
1377  int exactFit = numPatches - numPatches % numpes;
1378  int newNumPatches = patchMap->sizeGrid(
1379  xmin,xmax,lattice,patchSize,exactFit,params->staticAtomAssignment,
1380  twoAwayX>0 ? 2 : 1, twoAwayY>0 ? 2 : 1, twoAwayZ>0 ? 2 : 1);
1381  if ( newNumPatches == exactFit ) {
1382  iout << iINFO << "REDUCING NUMBER OF PATCHES TO IMPROVE LOAD BALANCE\n" << endi;
1383  maxNumPatches = exactFit;
1384  }
1385  }
1386 
1387  patchMap->makePatches(xmin,xmax,lattice,patchSize,maxNumPatches,
1388  params->staticAtomAssignment, params->replicaUniformPatchGrids, params->LCPOOn,
1389  twoAwayX>0 ? 2 : 1, twoAwayY>0 ? 2 : 1, twoAwayZ>0 ? 2 : 1);
1390 
1391 #else
1392 
1393  int availPes = numpes;
1394  if ( params->noPatchesOnZero && numpes > 1 ) {
1395  availPes -= 1;
1396  if(params->noPatchesOnOne && numpes > 2)
1397  availPes -= 1;
1398  }
1399 #ifdef MEM_OPT_VERSION
1400  if(params->noPatchesOnOutputPEs && numpes - params->numoutputprocs >2)
1401  {
1402  availPes -= params->numoutputprocs;
1403  if ( params->noPatchesOnZero && numpes > 1 && isOutputProcessor(0)){
1404  availPes++;
1405  }
1406  if ( params->noPatchesOnOne && numpes > 2 && isOutputProcessor(1)){
1407  availPes++;
1408  }
1409  }
1410 #endif
1411 
1412  int numPatches = patchMap->sizeGrid(
1413  xmin,xmax,lattice,patchSize,1.e9,params->staticAtomAssignment,
1414  twoAwayX ? 2 : 1, twoAwayY ? 2 : 1, twoAwayZ ? 2 : 1);
1415  if ( ( numPatches > (0.3*availPes) || numPatches > maxNumPatches
1416  ) && twoAwayZ < 0 ) {
1417  twoAwayZ = 0;
1418  numPatches = patchMap->sizeGrid(
1419  xmin,xmax,lattice,patchSize,1.e9,params->staticAtomAssignment,
1420  twoAwayX ? 2 : 1, twoAwayY ? 2 : 1, twoAwayZ ? 2 : 1);
1421  }
1422  if ( ( numPatches > (0.6*availPes) || numPatches > maxNumPatches
1423  ) && twoAwayY < 0 ) {
1424  twoAwayY = 0;
1425  numPatches = patchMap->sizeGrid(
1426  xmin,xmax,lattice,patchSize,1.e9,params->staticAtomAssignment,
1427  twoAwayX ? 2 : 1, twoAwayY ? 2 : 1, twoAwayZ ? 2 : 1);
1428  }
1429  if ( ( numPatches > availPes || numPatches > maxNumPatches
1430  ) && twoAwayX < 0 ) {
1431  twoAwayX = 0;
1432  numPatches = patchMap->sizeGrid(
1433  xmin,xmax,lattice,patchSize,1.e9,params->staticAtomAssignment,
1434  twoAwayX ? 2 : 1, twoAwayY ? 2 : 1, twoAwayZ ? 2 : 1);
1435  }
1436  if ( numPatches > availPes && numPatches <= (1.4*availPes) && availPes <= maxNumPatches ) {
1437  int newNumPatches = patchMap->sizeGrid(
1438  xmin,xmax,lattice,patchSize,availPes,params->staticAtomAssignment,
1439  twoAwayX ? 2 : 1, twoAwayY ? 2 : 1, twoAwayZ ? 2 : 1);
1440  if ( newNumPatches <= availPes && numPatches <= (1.4*newNumPatches) ) {
1441  iout << iINFO << "REDUCING NUMBER OF PATCHES TO IMPROVE LOAD BALANCE\n" << endi;
1442  maxNumPatches = availPes;
1443  }
1444  }
1445 
1446  patchMap->makePatches(xmin,xmax,lattice,patchSize,maxNumPatches,
1447  params->staticAtomAssignment, params->replicaUniformPatchGrids, params->LCPOOn,
1448  twoAwayX ? 2 : 1, twoAwayY ? 2 : 1, twoAwayZ ? 2 : 1);
1449 
1450 #endif
1451 
1452 }
static Node * Object()
Definition: Node.h:86
std::ostream & iINFO(std::ostream &s)
Definition: InfoStream.C:81
Bool simulateInitialMapping
NAMD_HOST_DEVICE int c_p() const
Definition: Lattice.h:291
Definition: Node.h:78
static PatchMap * Object()
Definition: PatchMap.h:27
Definition: Vector.h:72
SimParameters * simParameters
Definition: Node.h:181
Bool CUDASOAintegrateMode
#define DebugM(x, y)
Definition: Debug.h:75
std::ostream & endi(std::ostream &s)
Definition: InfoStream.C:54
BigReal z
Definition: Vector.h:74
std::ostream & iWARN(std::ostream &s)
Definition: InfoStream.C:82
#define iout
Definition: InfoStream.h:51
int sizeGrid(ScaledPosition xmin, ScaledPosition xmax, const Lattice &lattice, BigReal patchSize, double maxNumPatches, int staticAtomAssignment, int asplit, int bsplit, int csplit)
Definition: PatchMap.C:62
int num_atoms(void)
Definition: PDB.C:323
NAMD_HOST_DEVICE int b_p() const
Definition: Lattice.h:290
Bool staticAtomAssignment
Bool replicaUniformPatchGrids
BigReal x
Definition: Vector.h:74
void get_extremes(ScaledPosition &xmin, ScaledPosition &xmax) const
Definition: PDB.h:104
NAMD_HOST_DEVICE int a_p() const
Definition: Lattice.h:289
NAMD_HOST_DEVICE Vector a_r() const
Definition: Lattice.h:284
NAMD_HOST_DEVICE Vector b_r() const
Definition: Lattice.h:285
int numAtoms
Definition: Molecule.h:586
void NAMD_die(const char *err_msg)
Definition: common.C:147
PDB * pdb
Definition: Node.h:183
NAMD_HOST_DEVICE Vector c_r() const
Definition: Lattice.h:286
void makePatches(ScaledPosition xmin, ScaledPosition xmax, const Lattice &lattice, BigReal patchSize, double maxNumPatches, int staticAtomAssignment, int replicaUniformPatchGrids, int lcpo, int asplit, int bsplit, int csplit)
Definition: PatchMap.C:171
void find_extremes(const Lattice &, BigReal frac=1.0)
Definition: PDB.C:437
BigReal y
Definition: Vector.h:74
BigReal patchDimension
int isOutputProcessor(int pe)
Molecule * molecule
Definition: Node.h:179
NAMD_HOST_DEVICE Vector origin() const
Definition: Lattice.h:278
Bool noPatchesOnOutputPEs
double BigReal
Definition: common.h:123

◆ peOrderingReady()

void WorkDistrib::peOrderingReady ( )
static

Definition at line 173 of file WorkDistrib.C.

References cuda_initialize(), and mic_initialize().

Referenced by buildNodeAwarePeOrdering().

173  {
174  //CkPrintf("WorkDistrib::peOrderingReady on %d\n", CkMyPe());
175 #if defined(NAMD_CUDA) || defined(NAMD_HIP)
176  cuda_initialize();
177 #endif
178 #ifdef NAMD_MIC
179  mic_initialize();
180 #endif
181 }
void cuda_initialize()
Definition: DeviceCUDA.C:27
void mic_initialize()

◆ recvComputeMapChanges()

void WorkDistrib::recvComputeMapChanges ( ComputeMapChangeMsg msg)

Definition at line 377 of file WorkDistrib.C.

References ALLBUTME, BUFSIZE, COMPUTEMAPTAG, MOStream::end(), MIStream::get(), NAMD_bug(), ComputeMap::newNode(), ComputeMap::newNumPartitions(), ComputeMap::numComputes(), ComputeMap::Object(), MOStream::put(), ComputeMap::setNewNode(), and ComputeMap::setNewNumPartitions().

377  {
378 
379  delete msg;
380 
381  ComputeMap *computeMap = ComputeMap::Object();
382 
383  int i;
384  int nc = computeMap->numComputes();
385 
386  if ( ! CkMyPe() ) { // send
387  // CkPrintf("At %f on %d WorkDistrib::recvComputeMapChanges %d\n", CmiWallTimer(), CkMyPe(), nc);
388  MOStream *msg = CkpvAccess(comm)->newOutputStream(ALLBUTME, COMPUTEMAPTAG, BUFSIZE);
389  msg->put(nc);
390  for (i=0; i<nc; i++) {
391  int data = computeMap->newNode(i);
392  msg->put(data);
393  }
394  msg->put(nc);
395  for (i=0; i<nc; i++) {
396  char data = computeMap->newNumPartitions(i);
397  msg->put(data);
398  }
399  msg->put(nc);
400  msg->end();
401  delete msg;
402  // CkPrintf("At %f on %d done WorkDistrib::recvComputeMapChanges %d\n", CmiWallTimer(), CkMyPe(), nc);
403  } else if ( ! CkMyRank() ) { // receive
404  // if ( CkMyNode() == 1 ) CkPrintf("At %f on %d WorkDistrib::recvComputeMapChanges %d\n", CmiWallTimer(), CkMyPe(), nc);
405  MIStream *msg = CkpvAccess(comm)->newInputStream(0, COMPUTEMAPTAG);
406  msg->get(i);
407  if ( i != nc ) NAMD_bug("WorkDistrib::recvComputeMapChanges check 1 failed\n");
408  for (i=0; i<nc; i++) {
409  int data;
410  msg->get(data);
411  computeMap->setNewNode(i,data);
412  }
413  msg->get(i);
414  if ( i != nc ) NAMD_bug("WorkDistrib::recvComputeMapChanges check 2 failed\n");
415  for (i=0; i<nc; i++) {
416  char data;
417  msg->get(data);
418  computeMap->setNewNumPartitions(i,data);
419  }
420  msg->get(i);
421  if ( i != nc ) NAMD_bug("WorkDistrib::recvComputeMapChanges check 3 failed\n");
422  delete msg;
423  // if ( CkMyNode() == 1 ) CkPrintf("At %f on %d done WorkDistrib::recvComputeMapChanges %d\n", CmiWallTimer(), CkMyPe(), nc);
424  }
425 
426  CkCallback cb(CkIndex_WorkDistrib::doneSaveComputeMap(NULL), 0, thisgroup);
427  contribute(0, NULL, CkReduction::random, cb);
428 }
void end(void)
Definition: MStream.C:176
void setNewNumPartitions(ComputeID cid, char numPartitions)
Definition: ComputeMap.h:146
int numComputes(void)
Definition: ComputeMap.h:103
#define ALLBUTME
Definition: Communicate.h:14
MIStream * get(char &data)
Definition: MStream.h:29
char newNumPartitions(ComputeID cid)
Definition: ComputeMap.h:143
void NAMD_bug(const char *err_msg)
Definition: common.C:195
#define COMPUTEMAPTAG
Definition: common.h:184
void setNewNode(ComputeID cid, NodeID node)
Definition: ComputeMap.h:122
#define BUFSIZE
Definition: Communicate.h:15
static ComputeMap * Object()
Definition: ComputeMap.h:91
MOStream * put(char data)
Definition: MStream.h:112
NodeID newNode(ComputeID cid)
Definition: ComputeMap.h:118

◆ reinitAtoms()

void WorkDistrib::reinitAtoms ( const char *  basename = 0)

Definition at line 1085 of file WorkDistrib.C.

References createAtomLists(), PatchMap::numPatches(), PatchMap::Object(), and PatchMgr::sendAtoms().

1085  {
1086 
1087  PatchMap *patchMap = PatchMap::Object();
1088  CProxy_PatchMgr pm(CkpvAccess(BOCclass_group).patchMgr);
1089  PatchMgr *patchMgr = pm.ckLocalBranch();
1090 
1091  int numPatches = patchMap->numPatches();
1092 
1093  FullAtomList *atoms = createAtomLists(basename);
1094 
1095  for(int i=0; i < numPatches; i++) {
1096  patchMgr->sendAtoms(i,atoms[i]);
1097  }
1098 
1099  delete [] atoms;
1100 
1101 }
static PatchMap * Object()
Definition: PatchMap.h:27
void sendAtoms(PatchID pid, FullAtomList &a)
Definition: PatchMgr.C:157
int numPatches(void) const
Definition: PatchMap.h:59
FullAtomList * createAtomLists(const char *basename=0)
Definition: WorkDistrib.C:654

◆ saveComputeMapChanges()

void WorkDistrib::saveComputeMapChanges ( int  ep,
CkGroupID  chareID 
)

Definition at line 359 of file WorkDistrib.C.

Referenced by ComputeMgr::updateComputes2().

360 {
361  saveComputeMapReturnEP = ep;
362  saveComputeMapReturnChareID = chareID;
363 
364  ComputeMapChangeMsg *mapMsg = new (0, 0, 0) ComputeMapChangeMsg;
365  CProxy_WorkDistrib(thisgroup).recvComputeMapChanges(mapMsg);
366 
367 /*
368  // store the latest compute map
369  SimParameters *simParams = Node::Object()->simParameters;
370  if (simParams->storeComputeMap) {
371  computeMap->saveComputeMap(simParams->computeMapFilename);
372  CkPrintf("ComputeMap has been stored in %s.\n", simParams->computeMapFilename);
373  }
374 */
375 }

◆ savePatchMap()

void WorkDistrib::savePatchMap ( PatchMapMsg msg)

Definition at line 1147 of file WorkDistrib.C.

References SimParameters::isRecvSpanningTreeUnset(), SimParameters::isSendSpanningTreeUnset(), PatchMap::Object(), ProxyMgr::Object(), PatchMapMsg::patchMapData, ProxyMgr::setRecvSpanning(), ProxyMgr::setSendSpanning(), Node::simParameters, split(), and PatchMap::unpack().

1148 {
1149  // Use a resend to forward messages before processing. Otherwise the
1150  // map distribution is slow on many CPUs. We need to use a tree
1151  // rather than a broadcast because some implementations of broadcast
1152  // generate a copy of the message on the sender for each recipient.
1153  // This is because MPI doesn't allow re-use of an outstanding buffer.
1154 
1155  if ( CkMyRank() ) patchMapArrived = true;
1156 
1157  if ( patchMapArrived && CkMyPe() ) {
1159 
1160  //Automatically enable spanning tree
1161  CProxy_Node nd(CkpvAccess(BOCclass_group).node);
1162  Node *node = nd.ckLocalBranch();
1163  SimParameters *params = node->simParameters;
1164  if( ( PatchMap::Object()->numPatches() <= CkNumPes()/4
1165 #ifdef NODEAWARE_PROXY_SPANNINGTREE
1166  || CkNumPes() > CkNumNodes()
1167  ) && ( CkNumNodes() > 1
1168 #endif
1169  ) && params->isSendSpanningTreeUnset() )
1171 
1172 #ifdef NODEAWARE_PROXY_SPANNINGTREE
1173  if ( CkNumPes() > CkNumNodes() && CkNumNodes() > 1
1174  && params->isRecvSpanningTreeUnset() )
1176 #endif
1177  }
1178 
1179  if ( patchMapArrived ) {
1180  if ( CkMyRank() + 1 < CkNodeSize(CkMyNode()) ) {
1181  ((CProxy_WorkDistrib(thisgroup))[CkMyPe()+1]).savePatchMap(msg);
1182  } else {
1183  delete msg;
1184  }
1185  return;
1186  }
1187 
1188  patchMapArrived = true;
1189 
1190  int self = CkMyNode();
1191  int range_begin = 0;
1192  int range_end = CkNumNodes();
1193  while ( self != range_begin ) {
1194  ++range_begin;
1195  int split = range_begin + ( range_end - range_begin ) / 2;
1196  if ( self < split ) { range_end = split; }
1197  else { range_begin = split; }
1198  }
1199  int send_near = self + 1;
1200  int send_far = send_near + ( range_end - send_near ) / 2;
1201 
1202  int pids[3];
1203  int npid = 0;
1204  if ( send_far < range_end ) pids[npid++] = CkNodeFirst(send_far);
1205  if ( send_near < send_far ) pids[npid++] = CkNodeFirst(send_near);
1206  pids[npid++] = CkMyPe(); // always send the message to ourselves
1207  CProxy_WorkDistrib(thisgroup).savePatchMap(msg,npid,pids);
1208 }
int isSendSpanningTreeUnset()
void setRecvSpanning()
Definition: ProxyMgr.C:370
static ProxyMgr * Object()
Definition: ProxyMgr.h:394
Definition: Node.h:78
int isRecvSpanningTreeUnset()
static PatchMap * Object()
Definition: PatchMap.h:27
SimParameters * simParameters
Definition: Node.h:181
void setSendSpanning()
Definition: ProxyMgr.C:361
char * patchMapData
Definition: WorkDistrib.C:1108
void unpack(char *buf)
Definition: PatchMap.C:365
std::vector< std::string > split(const std::string &text, std::string delimiter)
Definition: MoleculeQM.C:74
void savePatchMap(PatchMapMsg *msg)
Definition: WorkDistrib.C:1147

◆ send_contributeHostDeviceLDB()

void WorkDistrib::send_contributeHostDeviceLDB ( int  peSetLen,
int *  peSet 
)
static

Definition at line 3532 of file WorkDistrib.C.

3532  {
3533  #if defined(NAMD_MIC)
3534  CProxy_WorkDistrib wdProxy(CkpvAccess(BOCclass_group).workDistrib);
3535  wdProxy[0].contributeHostDeviceLDB(peSetLen, peSet);
3536  #endif
3537 }

◆ send_initHostDeviceLDB()

void WorkDistrib::send_initHostDeviceLDB ( )
static

Definition at line 3519 of file WorkDistrib.C.

3519  {
3520  #if defined(NAMD_MIC)
3521  CProxy_WorkDistrib wdProxy(CkpvAccess(BOCclass_group).workDistrib);
3522  wdProxy.initHostDeviceLDB();
3523  #endif
3524 }

◆ send_setDeviceLDBParams()

void WorkDistrib::send_setDeviceLDBParams ( int  dt,
int  hs,
int  sp1,
int  pp1,
int  pp2 
)
static

Definition at line 3545 of file WorkDistrib.C.

3545  {
3546  #if defined(NAMD_MIC)
3547  CProxy_WorkDistrib wdProxy(CkpvAccess(BOCclass_group).workDistrib);
3548  wdProxy.setDeviceLDBParams(dt, hs, sp1, pp1, pp2);
3549  #endif
3550 }

◆ sendComputeMap()

void WorkDistrib::sendComputeMap ( void  )

Definition at line 1211 of file WorkDistrib.C.

References ALLBUTME, BUFSIZE, COMPUTEMAPTAG, MOStream::end(), ComputeMap::initPtrs(), ComputeMap::Object(), ComputeMap::pack(), and ComputeMap::unpack().

Referenced by Node::startup().

1212 {
1213  if ( CkMyRank() ) return;
1214 
1215  if ( CkNumNodes() == 1 ) {
1216  computeMapArrived = true;
1218  return;
1219  }
1220 
1221  if ( ! CkMyPe() ) { // send
1222  MOStream *msg = CkpvAccess(comm)->newOutputStream(ALLBUTME, COMPUTEMAPTAG, BUFSIZE);
1223  ComputeMap::Object()->pack(msg);
1224  msg->end();
1225  delete msg;
1226  } else if ( ! CkMyRank() ) { // receive
1227  MIStream *msg = CkpvAccess(comm)->newInputStream(0, COMPUTEMAPTAG);
1228  ComputeMap::Object()->unpack(msg);
1229  delete msg;
1230  }
1231 
1232  computeMapArrived = true;
1234 }
void end(void)
Definition: MStream.C:176
void initPtrs()
Definition: ComputeMap.C:80
#define ALLBUTME
Definition: Communicate.h:14
void pack(MOStream *msg)
Definition: ComputeMap.C:61
#define COMPUTEMAPTAG
Definition: common.h:184
#define BUFSIZE
Definition: Communicate.h:15
static ComputeMap * Object()
Definition: ComputeMap.h:91
void unpack(MIStream *msg)
Definition: ComputeMap.C:68

◆ sendPatchMap()

void WorkDistrib::sendPatchMap ( void  )

Definition at line 1111 of file WorkDistrib.C.

References SimParameters::isRecvSpanningTreeUnset(), SimParameters::isSendSpanningTreeUnset(), PatchMap::Object(), ProxyMgr::Object(), PatchMap::pack(), PatchMap::packSize(), PatchMapMsg::patchMapData, ProxyMgr::setRecvSpanning(), ProxyMgr::setSendSpanning(), and Node::simParameters.

Referenced by Node::startup().

1112 {
1113  if ( CkNumPes() == 1 ) {
1114  patchMapArrived = true;
1115  return;
1116  }
1117 
1118  //Automatically enable spanning tree
1119  CProxy_Node nd(CkpvAccess(BOCclass_group).node);
1120  Node *node = nd.ckLocalBranch();
1121  SimParameters *params = node->simParameters;
1122  if( ( PatchMap::Object()->numPatches() <= CkNumPes()/4
1123 #ifdef NODEAWARE_PROXY_SPANNINGTREE
1124  || CkNumPes() > CkNumNodes()
1125  ) && ( CkNumNodes() > 1
1126 #endif
1127  ) && params->isSendSpanningTreeUnset() )
1129 
1130 #ifdef NODEAWARE_PROXY_SPANNINGTREE
1131  if ( CkNumPes() > CkNumNodes() && CkNumNodes() > 1
1132  && params->isRecvSpanningTreeUnset() )
1134 #endif
1135 
1136  int size = PatchMap::Object()->packSize();
1137 
1138  PatchMapMsg *mapMsg = new (size, 0) PatchMapMsg;
1139 
1140  PatchMap::Object()->pack(mapMsg->patchMapData, size);
1141 
1142  CProxy_WorkDistrib workProxy(thisgroup);
1143  workProxy[0].savePatchMap(mapMsg);
1144 }
int isSendSpanningTreeUnset()
void setRecvSpanning()
Definition: ProxyMgr.C:370
static ProxyMgr * Object()
Definition: ProxyMgr.h:394
Definition: Node.h:78
int isRecvSpanningTreeUnset()
static PatchMap * Object()
Definition: PatchMap.h:27
SimParameters * simParameters
Definition: Node.h:181
void setSendSpanning()
Definition: ProxyMgr.C:361
int packSize(void)
Definition: PatchMap.C:314
char * patchMapData
Definition: WorkDistrib.C:1108
void pack(char *buf, int size)
Definition: PatchMap.C:328

◆ setDeviceLDBParams()

void WorkDistrib::setDeviceLDBParams ( int  dt,
int  hs,
int  sp1,
int  pp1,
int  pp2 
)

Definition at line 3552 of file WorkDistrib.C.

3552  {
3553  #if defined(NAMD_MIC)
3554  mic_setDeviceLDBParams(dt, hs, sp1, pp1, pp2);
3555  #endif
3556 }

◆ setPatchMapArrived()

void WorkDistrib::setPatchMapArrived ( bool  s)
inline

Definition at line 108 of file WorkDistrib.h.

Referenced by Node::startup().

108 {patchMapArrived=s;}

◆ sortPmePes()

void WorkDistrib::sortPmePes ( int *  pmepes,
int  xdim,
int  ydim 
)
static

Definition at line 307 of file WorkDistrib.C.

References ResizeArray< Elem >::begin(), PatchMap::center(), PatchMap::node(), PatchMap::numPatches(), PatchMap::Object(), and recursive_bisect_coord().

Referenced by ComputePmeMgr::initialize().

307  {
308  int numpes = CkNumPes();
309  ResizeArray<int> count(numpes);
310  ResizeArray<ScaledPosition> sumPos(numpes);
311  ResizeArray<ScaledPosition> avgPos(numpes);
312  for ( int i=0; i<numpes; ++i ) {
313  count[i] = 0;
314  sumPos[i] = 0;
315  avgPos[i] = 0;
316  }
317  PatchMap *patchMap = PatchMap::Object();
318  for ( int i=0, npatches=patchMap->numPatches(); i<npatches; ++i ) {
319  int pe = patchMap->node(i);
320  count[pe] += 1;
321  sumPos[pe] += patchMap->center(i);
322  }
323  const int npmepes = xdim*ydim;
324  ResizeArray<int> sortpes(npmepes);
325  for ( int i=0; i<npmepes; ++i ) {
326  int pe = sortpes[i] = pmepes[i];
327  int cnt = count[pe];
328  ScaledPosition sum = sumPos[pe];
329  if ( cnt == 0 ) {
330  // average over node
331  int node = CkNodeOf(pe);
332  int nsize = CkNodeSize(node);
333  int pe2 = CkNodeFirst(node);
334  for ( int j=0; j<nsize; ++j, ++pe2 ) {
335  cnt += count[pe2];
336  sum += sumPos[pe2];
337  }
338  }
339  if ( cnt == 0 ) {
340  // average over physical node
341  int node = CmiPhysicalNodeID(pe);
342  int nsize, *nlist;
343  CmiGetPesOnPhysicalNode(node, &nlist, &nsize);
344  for ( int j=0; j<nsize; ++j ) {
345  int pe2 = nlist[j];
346  cnt += count[pe2];
347  sum += sumPos[pe2];
348  }
349  }
350  if ( cnt ) {
351  avgPos[pe] = sum / cnt;
352  }
353  }
354  recursive_bisect_coord(0, xdim, 0, ydim, sortpes.begin(), avgPos.begin(), pmepes, ydim);
355 }
ScaledPosition center(int pid) const
Definition: PatchMap.h:99
static PatchMap * Object()
Definition: PatchMap.h:27
Definition: Vector.h:72
static void recursive_bisect_coord(int x_begin, int x_end, int y_begin, int y_end, int *pe_begin, ScaledPosition *coord, int *result, int ydim)
Definition: WorkDistrib.C:275
int numPatches(void) const
Definition: PatchMap.h:59
int node(int pid) const
Definition: PatchMap.h:114

Member Data Documentation

◆ peCompactOrdering

int * WorkDistrib::peCompactOrdering
static

Definition at line 118 of file WorkDistrib.h.

Referenced by buildNodeAwarePeOrdering().

◆ peCompactOrderingIndex

int * WorkDistrib::peCompactOrderingIndex
static

◆ peDiffuseOrdering

int * WorkDistrib::peDiffuseOrdering
static

◆ peDiffuseOrderingIndex

int * WorkDistrib::peDiffuseOrderingIndex
static

◆ peOrderingInit

int WorkDistrib::peOrderingInit
static

Definition at line 115 of file WorkDistrib.h.

Referenced by buildNodeAwarePeOrdering().


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