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 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 106 of file WorkDistrib.C.

References eventMachineProgress, and NAMD_bug().

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

◆ ~WorkDistrib()

WorkDistrib::~WorkDistrib ( void  )

Definition at line 122 of file WorkDistrib.C.

123 { }

Member Function Documentation

◆ assignNodeToPatch()

void WorkDistrib::assignNodeToPatch ( void  )

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

1445 {
1446  PatchMap *patchMap = PatchMap::Object();
1447  int nNodes = Node::Object()->numNodes();
1448  SimParameters *simparam = Node::Object()->simParameters;
1449  if(simparam->simulateInitialMapping) {
1450  nNodes = simparam->simulatedPEs;
1451  }
1452 
1453 #if (CMK_BLUEGENEP | CMK_BLUEGENEL) && USE_TOPOMAP
1454  TopoManager tmgr;
1455  int numPes = tmgr.getDimNX() * tmgr.getDimNY() * tmgr.getDimNZ();
1456  if (numPes > patchMap->numPatches() && (assignPatchesTopoGridRecBisection() > 0)) {
1457  CkPrintf ("Blue Gene/L topology partitioner finished successfully \n");
1458  }
1459  else
1460 #endif
1461  assignPatchesSpaceFillingCurve();
1462 
1463  int *nAtoms = new int[nNodes];
1464  int numAtoms=0;
1465  int i;
1466  for(i=0; i < nNodes; i++)
1467  nAtoms[i] = 0;
1468 
1469  for(i=0; i < patchMap->numPatches(); i++)
1470  {
1471  // iout << iINFO << "Patch " << i << " has "
1472  // << patchMap->patch(i)->getNumAtoms() << " atoms and "
1473  // << patchMap->patch(i)->getNumAtoms() *
1474  // patchMap->patch(i)->getNumAtoms()
1475  // << " pairs.\n" << endi;
1476 #ifdef MEM_OPT_VERSION
1477  numAtoms += patchMap->numAtoms(i);
1478  nAtoms[patchMap->node(i)] += patchMap->numAtoms(i);
1479 #else
1480  if (patchMap->patch(i)) {
1481  numAtoms += patchMap->patch(i)->getNumAtoms();
1482  nAtoms[patchMap->node(i)] += patchMap->patch(i)->getNumAtoms();
1483  }
1484 #endif
1485  }
1486 
1487  if ( numAtoms != Node::Object()->molecule->numAtoms ) {
1488  for(i=0; i < nNodes; i++)
1489  iout << iINFO << nAtoms[i] << " atoms assigned to node " << i << "\n" << endi;
1490  iout << iINFO << "Assigned " << numAtoms << " atoms but expected " << Node::Object()->molecule->numAtoms << "\n" << endi;
1491  NAMD_die("Incorrect atom count in WorkDistrib::assignNodeToPatch\n");
1492  }
1493 
1494  delete [] nAtoms;
1495 
1496  // PatchMap::Object()->printPatchMap();
1497 }
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:585
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 181 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().

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

◆ contributeHostDeviceLDB()

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

Definition at line 3515 of file WorkDistrib.C.

3515  {
3516  #if defined(NAMD_MIC)
3517  mic_contributeHostDeviceLDB(peSetLen, peSet);
3518  #endif
3519 }

◆ createAtomLists()

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

Definition at line 652 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, endi(), FALSE, ConfigList::find(), SimParameters::fixedAtomsOn, FullAtom::fixedPosition, PDB::get_all_positions(), Molecule::get_fep_type(), 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, 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, 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().

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

◆ createHomePatches()

void WorkDistrib::createHomePatches ( void  )

Definition at line 977 of file WorkDistrib.C.

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

Referenced by Node::startup().

978 {
979  int i;
980  PatchMap *patchMap = PatchMap::Object();
981  CProxy_PatchMgr pm(CkpvAccess(BOCclass_group).patchMgr);
982  PatchMgr *patchMgr = pm.ckLocalBranch();
983 
984  int numPatches = patchMap->numPatches();
985 
986  FullAtomList *atoms = createAtomLists();
987 
988 #ifdef MEM_OPT_VERSION
989 /* CProxy_Node nd(CkpvAccess(BOCclass_group).node);
990  Node *node = nd.ckLocalBranch();
991  node->molecule->delEachAtomSigs();
992  node->molecule->delMassChargeSpace();
993 */
994 #endif
995 
996  int maxAtoms = -1;
997  int maxPatch = -1;
998  for(i=0; i < numPatches; i++) {
999  int numAtoms = atoms[i].size();
1000  if ( numAtoms > maxAtoms ) { maxAtoms = numAtoms; maxPatch = i; }
1001  }
1002  iout << iINFO << "LARGEST PATCH (" << maxPatch <<
1003  ") HAS " << maxAtoms << " ATOMS\n" << endi;
1004 
1005 #ifdef SHOW_HISTOGRAM_HGROUP_SIZES
1006  // histogram hydrogen group sizes
1007  int hgroupsize[9] = { 0 };
1008  int numhgroups = 0;
1009  int numwaters = 0;
1010  int maxhgroupsize = 0;
1011  for (i = 0; i < numPatches; i++) {
1012  const FullAtomList& a = atoms[i];
1013  int numAtoms = a.size();
1014  int hgs = 1; // init to something sane
1015  for (int j = 0; j < numAtoms; j += hgs) {
1016  hgs = a[j].hydrogenGroupSize;
1017  int histndx = ( hgs > 8 ? 8 : hgs );
1018  hgroupsize[ histndx ]++;
1019  numhgroups++;
1020  if (a[j].isWater) numwaters++;
1021  if (maxhgroupsize < hgs) maxhgroupsize = hgs;
1022  }
1023  }
1024  int hgslast = ( maxhgroupsize > 8 ? 8 : maxhgroupsize );
1025  printf("Number of hydrogen groups: %7d\n", numhgroups);
1026  printf("Number of settle water molecules: %7d\n", numwaters);
1027  printf("Number of remaining hydrogen groups: %7d\n", numhgroups - numwaters);
1028  printf("Largest hydrogen group size: %7d\n", maxhgroupsize);
1029  printf("Histogram of hydrogen group sizes:\n");
1030  int hgstotal = 0;
1031  for (i = 0; i <= hgslast; i++) {
1032  printf(" size %d count %d\n", i, hgroupsize[i]);
1033  hgstotal += hgroupsize[i];
1034  }
1035  printf("Checksum over hydrogen group sizes: %7d\n", hgstotal);
1036 #endif
1037 
1038  for(i=0; i < numPatches; i++)
1039  {
1040  if ( ! ( i % 100 ) )
1041  {
1042  DebugM(3,"Created " << i << " patches so far.\n");
1043  }
1044 
1045  patchMgr->createHomePatch(i,atoms[i]);
1046  }
1047 
1048  delete [] atoms;
1049 }
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:652

◆ distributeHomePatches()

void WorkDistrib::distributeHomePatches ( void  )

Definition at line 1051 of file WorkDistrib.C.

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

Referenced by Node::startup().

1051  {
1052  // ref BOC
1053  CProxy_Node nd(CkpvAccess(BOCclass_group).node);
1054  Node *node = nd.ckLocalBranch();
1055  CProxy_PatchMgr pm(CkpvAccess(BOCclass_group).patchMgr);
1056  PatchMgr *patchMgr = pm.ckLocalBranch();
1057  // ref singleton
1058  PatchMap *patchMap = PatchMap::Object();
1059 
1060  // Move patches to the proper node
1061  for(int i=0;i < patchMap->numPatches(); i++)
1062  {
1063  if (patchMap->node(i) != node->myid() )
1064  {
1065  DebugM(3,"patchMgr->movePatch("
1066  << i << "," << patchMap->node(i) << ")\n");
1067  patchMgr->movePatch(i,patchMap->node(i));
1068  }
1069  }
1070  patchMgr->sendMovePatches();
1071 }
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 428 of file WorkDistrib.C.

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

◆ enqueueAngles()

void WorkDistrib::enqueueAngles ( 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

◆ enqueueAniso()

void WorkDistrib::enqueueAniso ( 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

◆ enqueueBonds()

void WorkDistrib::enqueueBonds ( LocalWorkMsg msg)

Definition at line 3086 of file WorkDistrib.C.

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

3086  {
3088  if ( msg->compute->localWorkMsg != msg )
3089  NAMD_bug("WorkDistrib LocalWorkMsg recycling failed!");
3090 }
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 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

◆ enqueueCUDA()

void WorkDistrib::enqueueCUDA ( LocalWorkMsg msg)

Definition at line 3220 of file WorkDistrib.C.

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

3220  {
3222 }
#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 3223 of file WorkDistrib.C.

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

3223  {
3225 }
#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 3226 of file WorkDistrib.C.

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

3226  {
3228 }
#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 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

◆ enqueueExcls()

void WorkDistrib::enqueueExcls ( LocalWorkMsg msg)

Definition at line 3080 of file WorkDistrib.C.

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

3080  {
3082  if ( msg->compute->localWorkMsg != msg )
3083  NAMD_bug("WorkDistrib LocalWorkMsg recycling failed!");
3084 }
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 3129 of file WorkDistrib.C.

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

3129  {
3130  msg->compute->doWork();
3132  if ( msg->compute->localWorkMsg != msg )
3133  NAMD_bug("\nWorkDistrib LocalWorkMsg recycling failed! Check enqueueGromacsPair from WorkDistrib.C\n");
3134 }
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 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

◆ enqueueLCPO()

void WorkDistrib::enqueueLCPO ( LocalWorkMsg msg)

Definition at line 3143 of file WorkDistrib.C.

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

3143  {
3144  msg->compute->doWork();
3145  if ( msg->compute->localWorkMsg != msg )
3146  NAMD_bug("WorkDistrib LocalWorkMsg recycling failed!");
3147 }
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 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

◆ enqueuePme()

void WorkDistrib::enqueuePme ( LocalWorkMsg msg)

Definition at line 3137 of file WorkDistrib.C.

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

3137  {
3139  if ( msg->compute->localWorkMsg != msg )
3140  NAMD_bug("WorkDistrib LocalWorkMsg recycling failed!");
3141 }
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 3148 of file WorkDistrib.C.

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

3148  {
3150  if ( msg->compute->localWorkMsg != msg )
3151  NAMD_bug("WorkDistrib LocalWorkMsg recycling failed!");
3152 }
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 3153 of file WorkDistrib.C.

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

3153  {
3155  if ( msg->compute->localWorkMsg != msg )
3156  NAMD_bug("WorkDistrib LocalWorkMsg recycling failed!");
3157 }
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 3158 of file WorkDistrib.C.

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

3158  {
3160  if ( msg->compute->localWorkMsg != msg )
3161  NAMD_bug("WorkDistrib LocalWorkMsg recycling failed!");
3162 }
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 3164 of file WorkDistrib.C.

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

3164  {
3166  if ( msg->compute->localWorkMsg != msg )
3167  NAMD_bug("WorkDistrib LocalWorkMsg recycling failed!");
3168 }
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 3169 of file WorkDistrib.C.

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

3169  {
3171  if ( msg->compute->localWorkMsg != msg )
3172  NAMD_bug("WorkDistrib LocalWorkMsg recycling failed!");
3173 }
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 3174 of file WorkDistrib.C.

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

3174  {
3176  if ( msg->compute->localWorkMsg != msg )
3177  NAMD_bug("WorkDistrib LocalWorkMsg recycling failed!");
3178 }
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 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

◆ enqueueWork()

void WorkDistrib::enqueueWork ( LocalWorkMsg msg)

Definition at line 3074 of file WorkDistrib.C.

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

3074  {
3076  if ( msg->compute->localWorkMsg != msg )
3077  NAMD_bug("WorkDistrib LocalWorkMsg recycling failed!");
3078 }
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 3180 of file WorkDistrib.C.

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

3180  {
3182  if ( msg->compute->localWorkMsg != msg )
3183  NAMD_bug("WorkDistrib LocalWorkMsg recycling failed!");
3184 }
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 3185 of file WorkDistrib.C.

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

3185  {
3187  if ( msg->compute->localWorkMsg != msg )
3188  NAMD_bug("WorkDistrib LocalWorkMsg recycling failed!");
3189 }
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 3190 of file WorkDistrib.C.

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

3190  {
3192  if ( msg->compute->localWorkMsg != msg )
3193  NAMD_bug("WorkDistrib LocalWorkMsg recycling failed!");
3194 }
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 3196 of file WorkDistrib.C.

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

3196  {
3198  if ( msg->compute->localWorkMsg != msg )
3199  NAMD_bug("WorkDistrib LocalWorkMsg recycling failed!");
3200 }
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 3201 of file WorkDistrib.C.

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

3201  {
3203  if ( msg->compute->localWorkMsg != msg )
3204  NAMD_bug("WorkDistrib LocalWorkMsg recycling failed!");
3205 }
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 3206 of file WorkDistrib.C.

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

3206  {
3208  if ( msg->compute->localWorkMsg != msg )
3209  NAMD_bug("WorkDistrib LocalWorkMsg recycling failed!");
3210 }
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 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

◆ finishCUDA()

void WorkDistrib::finishCUDA ( LocalWorkMsg msg)

Definition at line 3234 of file WorkDistrib.C.

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

3234  {
3236 }
#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 3237 of file WorkDistrib.C.

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

3237  {
3239 }
#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 3240 of file WorkDistrib.C.

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

3240  {
3242 }
#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 3230 of file WorkDistrib.C.

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

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

◆ finishMIC()

void WorkDistrib::finishMIC ( 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

◆ initHostDeviceLDB()

void WorkDistrib::initHostDeviceLDB ( )

Definition at line 3502 of file WorkDistrib.C.

3502  {
3503  #if defined(NAMD_MIC)
3504  mic_hostDeviceLDB();
3505  #endif
3506 }

◆ mapComputes()

void WorkDistrib::mapComputes ( void  )

Definition at line 2395 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, computePmeCUDAType, computePmeType, computeQMType, computeRestraintsType, computeSelfAnglesType, computeSelfAnisoType, computeSelfBondsType, computeSelfCrosstermsType, computeSelfDihedralsType, computeSelfExclsType, computeSelfGromacsPairType, computeSelfImpropersType, 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().

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

◆ messageEnqueueWork()

void WorkDistrib::messageEnqueueWork ( Compute compute)
static

Definition at line 2852 of file WorkDistrib.C.

References Compute::cid, LocalWorkMsg::compute, computeAnglesType, computeAnisoType, computeBondsType, computeCrosstermsType, computeDihedralsType, computeExclsType, computeGromacsPairType, computeImpropersType, computeLCPOType, computeNonbondedCUDA2Type, computeNonbondedMICType, computeNonbondedPairType, computeNonbondedSelfType, computePmeCUDAType, computePmeType, computeSelfAnglesType, computeSelfAnisoType, computeSelfBondsType, computeSelfCrosstermsType, computeSelfDihedralsType, computeSelfExclsType, computeSelfGromacsPairType, computeSelfImpropersType, 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().

2852  {
2853  LocalWorkMsg *msg = compute->localWorkMsg;
2854  int seq = compute->sequence();
2855  int gbisPhase = compute->getGBISPhase();
2856 
2857  if ( seq < 0 ) {
2858  NAMD_bug("compute->sequence() < 0 in WorkDistrib::messageEnqueueWork");
2859  } else {
2860  SET_PRIORITY(msg,seq,compute->priority());
2861  }
2862 
2863  msg->compute = compute; // pointer is valid since send is to local Pe
2864  int type = compute->type();
2865  int cid = compute->cid;
2866 
2867  CProxy_WorkDistrib wdProxy(CkpvAccess(BOCclass_group).workDistrib);
2868  switch ( type ) {
2869  case computeExclsType:
2870  case computeSelfExclsType:
2871  wdProxy[CkMyPe()].enqueueExcls(msg);
2872  break;
2873  case computeBondsType:
2874  case computeSelfBondsType:
2875  wdProxy[CkMyPe()].enqueueBonds(msg);
2876  break;
2877  case computeAnglesType:
2878  case computeSelfAnglesType:
2879  wdProxy[CkMyPe()].enqueueAngles(msg);
2880  break;
2881  case computeDihedralsType:
2883  wdProxy[CkMyPe()].enqueueDihedrals(msg);
2884  break;
2885  case computeImpropersType:
2887  wdProxy[CkMyPe()].enqueueImpropers(msg);
2888  break;
2889  case computeTholeType:
2890  case computeSelfTholeType:
2891  wdProxy[CkMyPe()].enqueueThole(msg);
2892  break;
2893  case computeAnisoType:
2894  case computeSelfAnisoType:
2895  wdProxy[CkMyPe()].enqueueAniso(msg);
2896  break;
2897  case computeCrosstermsType:
2899  wdProxy[CkMyPe()].enqueueCrossterms(msg);
2900  break;
2901  // JLai
2904  wdProxy[CkMyPe()].enqueueGromacsPair(msg);
2905  break;
2906  // End of JLai
2907  case computeLCPOType:
2908  wdProxy[CkMyPe()].enqueueLCPO(msg);
2909  break;
2911  switch ( seq % 2 ) {
2912  case 0:
2913  //wdProxy[CkMyPe()].enqueueSelfA(msg);
2914  switch ( gbisPhase ) {
2915  case 1:
2916  wdProxy[CkMyPe()].enqueueSelfA1(msg);
2917  break;
2918  case 2:
2919  wdProxy[CkMyPe()].enqueueSelfA2(msg);
2920  break;
2921  case 3:
2922  wdProxy[CkMyPe()].enqueueSelfA3(msg);
2923  break;
2924  }
2925  break;
2926  case 1:
2927  //wdProxy[CkMyPe()].enqueueSelfB(msg);
2928  switch ( gbisPhase ) {
2929  case 1:
2930  wdProxy[CkMyPe()].enqueueSelfB1(msg);
2931  break;
2932  case 2:
2933  wdProxy[CkMyPe()].enqueueSelfB2(msg);
2934  break;
2935  case 3:
2936  wdProxy[CkMyPe()].enqueueSelfB3(msg);
2937  break;
2938  }
2939  break;
2940  default:
2941  NAMD_bug("WorkDistrib::messageEnqueueSelf case statement error!");
2942  }
2943  break;
2945  switch ( seq % 2 ) {
2946  case 0:
2947  //wdProxy[CkMyPe()].enqueueWorkA(msg);
2948  switch ( gbisPhase ) {
2949  case 1:
2950  wdProxy[CkMyPe()].enqueueWorkA1(msg);
2951  break;
2952  case 2:
2953  wdProxy[CkMyPe()].enqueueWorkA2(msg);
2954  break;
2955  case 3:
2956  wdProxy[CkMyPe()].enqueueWorkA3(msg);
2957  break;
2958  }
2959  break;
2960  case 1:
2961  //wdProxy[CkMyPe()].enqueueWorkB(msg);
2962  switch ( gbisPhase ) {
2963  case 1:
2964  wdProxy[CkMyPe()].enqueueWorkB1(msg);
2965  break;
2966  case 2:
2967  wdProxy[CkMyPe()].enqueueWorkB2(msg);
2968  break;
2969  case 3:
2970  wdProxy[CkMyPe()].enqueueWorkB3(msg);
2971  break;
2972  }
2973  break;
2974  case 2:
2975  wdProxy[CkMyPe()].enqueueWorkC(msg);
2976  break;
2977  default:
2978  NAMD_bug("WorkDistrib::messageEnqueueWork case statement error!");
2979  }
2980  break;
2981 #if defined(NAMD_CUDA) || defined(NAMD_HIP)
2983 // CkPrintf("WorkDistrib[%d]::CUDA seq=%d phase=%d\n", CkMyPe(), seq, gbisPhase);
2984  //wdProxy[CkMyPe()].enqueueCUDA(msg);
2985  switch ( gbisPhase ) {
2986  case 1:
2987  wdProxy[CkMyPe()].enqueueCUDA(msg);
2988  break;
2989  case 2:
2990  wdProxy[CkMyPe()].enqueueCUDAP2(msg);
2991  break;
2992  case 3:
2993  wdProxy[CkMyPe()].enqueueCUDAP3(msg);
2994  break;
2995  }
2996 #else
2998 #endif
2999  break;
3001 #ifdef NAMD_MIC
3002  wdProxy[CkMyPe()].enqueueMIC(msg);
3003 #endif
3004  break;
3005  case computePmeType:
3006  // CkPrintf("PME %d %d %x\n", CkMyPe(), seq, compute->priority());
3007  wdProxy[CkMyPe()].enqueuePme(msg);
3008  break;
3009 #if defined(NAMD_CUDA) || defined(NAMD_HIP)
3010  case computePmeCUDAType:
3011  wdProxy[CkMyPe()].enqueuePme(msg);
3012  break;
3013 #endif
3014  default:
3015  wdProxy[CkMyPe()].enqueueWork(msg);
3016  }
3017 }
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 3020 of file WorkDistrib.C.

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

3020  {
3021  LocalWorkMsg *msg = compute->localWorkMsg;
3022  int seq = compute->sequence();
3023  int gbisPhase = compute->getGBISPhase();
3024 
3025  if ( seq < 0 ) {
3026  NAMD_bug("compute->sequence() < 0 in WorkDistrib::messageEnqueueWork");
3027  } else {
3028  SET_PRIORITY(msg,seq,compute->priority());
3029  }
3030 
3031  msg->compute = compute; // pointer is valid since send is to local Pe
3032  CProxy_WorkDistrib wdProxy(CkpvAccess(BOCclass_group).workDistrib);
3033 
3034 #if defined(NAMD_CUDA) || defined(NAMD_HIP)
3035  //wdProxy[CkMyPe()].finishCUDA(msg);
3036  switch ( gbisPhase ) {
3037  case 1:
3038  wdProxy[CkMyPe()].finishCUDA(msg);
3039  break;
3040  case 2:
3041  wdProxy[CkMyPe()].finishCUDAP2(msg);
3042  break;
3043  case 3:
3044  wdProxy[CkMyPe()].finishCUDAP3(msg);
3045  break;
3046  }
3047 #else
3049 #endif
3050 }
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 3053 of file WorkDistrib.C.

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

3053  {
3054  LocalWorkMsg *msg = compute->localWorkMsg;
3055  int seq = compute->sequence();
3056  int gbisPhase = compute->getGBISPhase();
3057 
3058  if ( seq < 0 ) {
3059  NAMD_bug("compute->sequence() < 0 in WorkDistrib::messageFinishMIC");
3060  } else {
3061  SET_PRIORITY(msg,seq,compute->priority());
3062  }
3063 
3064  msg->compute = compute; // pointer is valid since send is to local Pe
3065  CProxy_WorkDistrib wdProxy(CkpvAccess(BOCclass_group).workDistrib);
3066 
3067 #ifdef NAMD_MIC
3068  wdProxy[CkMyPe()].finishMIC(msg);
3069 #else
3071 #endif
3072 }
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 1226 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().

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

References cuda_initialize(), and mic_initialize().

Referenced by buildNodeAwarePeOrdering().

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

◆ recvComputeMapChanges()

void WorkDistrib::recvComputeMapChanges ( ComputeMapChangeMsg msg)

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

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

◆ reinitAtoms()

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

Definition at line 1073 of file WorkDistrib.C.

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

1073  {
1074 
1075  PatchMap *patchMap = PatchMap::Object();
1076  CProxy_PatchMgr pm(CkpvAccess(BOCclass_group).patchMgr);
1077  PatchMgr *patchMgr = pm.ckLocalBranch();
1078 
1079  int numPatches = patchMap->numPatches();
1080 
1081  FullAtomList *atoms = createAtomLists(basename);
1082 
1083  for(int i=0; i < numPatches; i++) {
1084  patchMgr->sendAtoms(i,atoms[i]);
1085  }
1086 
1087  delete [] atoms;
1088 
1089 }
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:652

◆ saveComputeMapChanges()

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

Definition at line 357 of file WorkDistrib.C.

Referenced by ComputeMgr::updateComputes2().

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

◆ savePatchMap()

void WorkDistrib::savePatchMap ( PatchMapMsg msg)

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

1136 {
1137  // Use a resend to forward messages before processing. Otherwise the
1138  // map distribution is slow on many CPUs. We need to use a tree
1139  // rather than a broadcast because some implementations of broadcast
1140  // generate a copy of the message on the sender for each recipient.
1141  // This is because MPI doesn't allow re-use of an outstanding buffer.
1142 
1143  if ( CkMyRank() ) patchMapArrived = true;
1144 
1145  if ( patchMapArrived && CkMyPe() ) {
1147 
1148  //Automatically enable spanning tree
1149  CProxy_Node nd(CkpvAccess(BOCclass_group).node);
1150  Node *node = nd.ckLocalBranch();
1151  SimParameters *params = node->simParameters;
1152  if( ( PatchMap::Object()->numPatches() <= CkNumPes()/4
1153 #ifdef NODEAWARE_PROXY_SPANNINGTREE
1154  || CkNumPes() > CkNumNodes()
1155  ) && ( CkNumNodes() > 1
1156 #endif
1157  ) && params->isSendSpanningTreeUnset() )
1159 
1160 #ifdef NODEAWARE_PROXY_SPANNINGTREE
1161  if ( CkNumPes() > CkNumNodes() && CkNumNodes() > 1
1162  && params->isRecvSpanningTreeUnset() )
1164 #endif
1165  }
1166 
1167  if ( patchMapArrived ) {
1168  if ( CkMyRank() + 1 < CkNodeSize(CkMyNode()) ) {
1169  ((CProxy_WorkDistrib(thisgroup))[CkMyPe()+1]).savePatchMap(msg);
1170  } else {
1171  delete msg;
1172  }
1173  return;
1174  }
1175 
1176  patchMapArrived = true;
1177 
1178  int self = CkMyNode();
1179  int range_begin = 0;
1180  int range_end = CkNumNodes();
1181  while ( self != range_begin ) {
1182  ++range_begin;
1183  int split = range_begin + ( range_end - range_begin ) / 2;
1184  if ( self < split ) { range_end = split; }
1185  else { range_begin = split; }
1186  }
1187  int send_near = self + 1;
1188  int send_far = send_near + ( range_end - send_near ) / 2;
1189 
1190  int pids[3];
1191  int npid = 0;
1192  if ( send_far < range_end ) pids[npid++] = CkNodeFirst(send_far);
1193  if ( send_near < send_far ) pids[npid++] = CkNodeFirst(send_near);
1194  pids[npid++] = CkMyPe(); // always send the message to ourselves
1195  CProxy_WorkDistrib(thisgroup).savePatchMap(msg,npid,pids);
1196 }
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:1096
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:1135

◆ send_contributeHostDeviceLDB()

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

Definition at line 3508 of file WorkDistrib.C.

3508  {
3509  #if defined(NAMD_MIC)
3510  CProxy_WorkDistrib wdProxy(CkpvAccess(BOCclass_group).workDistrib);
3511  wdProxy[0].contributeHostDeviceLDB(peSetLen, peSet);
3512  #endif
3513 }

◆ send_initHostDeviceLDB()

void WorkDistrib::send_initHostDeviceLDB ( )
static

Definition at line 3495 of file WorkDistrib.C.

3495  {
3496  #if defined(NAMD_MIC)
3497  CProxy_WorkDistrib wdProxy(CkpvAccess(BOCclass_group).workDistrib);
3498  wdProxy.initHostDeviceLDB();
3499  #endif
3500 }

◆ send_setDeviceLDBParams()

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

Definition at line 3521 of file WorkDistrib.C.

3521  {
3522  #if defined(NAMD_MIC)
3523  CProxy_WorkDistrib wdProxy(CkpvAccess(BOCclass_group).workDistrib);
3524  wdProxy.setDeviceLDBParams(dt, hs, sp1, pp1, pp2);
3525  #endif
3526 }

◆ sendComputeMap()

void WorkDistrib::sendComputeMap ( void  )

Definition at line 1199 of file WorkDistrib.C.

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

Referenced by Node::startup().

1200 {
1201  if ( CkMyRank() ) return;
1202 
1203  if ( CkNumNodes() == 1 ) {
1204  computeMapArrived = true;
1206  return;
1207  }
1208 
1209  if ( ! CkMyPe() ) { // send
1210  MOStream *msg = CkpvAccess(comm)->newOutputStream(ALLBUTME, COMPUTEMAPTAG, BUFSIZE);
1211  ComputeMap::Object()->pack(msg);
1212  msg->end();
1213  delete msg;
1214  } else if ( ! CkMyRank() ) { // receive
1215  MIStream *msg = CkpvAccess(comm)->newInputStream(0, COMPUTEMAPTAG);
1216  ComputeMap::Object()->unpack(msg);
1217  delete msg;
1218  }
1219 
1220  computeMapArrived = true;
1222 }
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:89
void unpack(MIStream *msg)
Definition: ComputeMap.C:68

◆ sendPatchMap()

void WorkDistrib::sendPatchMap ( void  )

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

1100 {
1101  if ( CkNumPes() == 1 ) {
1102  patchMapArrived = true;
1103  return;
1104  }
1105 
1106  //Automatically enable spanning tree
1107  CProxy_Node nd(CkpvAccess(BOCclass_group).node);
1108  Node *node = nd.ckLocalBranch();
1109  SimParameters *params = node->simParameters;
1110  if( ( PatchMap::Object()->numPatches() <= CkNumPes()/4
1111 #ifdef NODEAWARE_PROXY_SPANNINGTREE
1112  || CkNumPes() > CkNumNodes()
1113  ) && ( CkNumNodes() > 1
1114 #endif
1115  ) && params->isSendSpanningTreeUnset() )
1117 
1118 #ifdef NODEAWARE_PROXY_SPANNINGTREE
1119  if ( CkNumPes() > CkNumNodes() && CkNumNodes() > 1
1120  && params->isRecvSpanningTreeUnset() )
1122 #endif
1123 
1124  int size = PatchMap::Object()->packSize();
1125 
1126  PatchMapMsg *mapMsg = new (size, 0) PatchMapMsg;
1127 
1128  PatchMap::Object()->pack(mapMsg->patchMapData, size);
1129 
1130  CProxy_WorkDistrib workProxy(thisgroup);
1131  workProxy[0].savePatchMap(mapMsg);
1132 }
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:1096
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 3528 of file WorkDistrib.C.

3528  {
3529  #if defined(NAMD_MIC)
3530  mic_setDeviceLDBParams(dt, hs, sp1, pp1, pp2);
3531  #endif
3532 }

◆ setPatchMapArrived()

void WorkDistrib::setPatchMapArrived ( bool  s)
inline

Definition at line 107 of file WorkDistrib.h.

Referenced by Node::startup().

107 {patchMapArrived=s;}

◆ sortPmePes()

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

Definition at line 305 of file WorkDistrib.C.

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

Referenced by ComputePmeMgr::initialize().

305  {
306  int numpes = CkNumPes();
307  ResizeArray<int> count(numpes);
308  ResizeArray<ScaledPosition> sumPos(numpes);
309  ResizeArray<ScaledPosition> avgPos(numpes);
310  for ( int i=0; i<numpes; ++i ) {
311  count[i] = 0;
312  sumPos[i] = 0;
313  avgPos[i] = 0;
314  }
315  PatchMap *patchMap = PatchMap::Object();
316  for ( int i=0, npatches=patchMap->numPatches(); i<npatches; ++i ) {
317  int pe = patchMap->node(i);
318  count[pe] += 1;
319  sumPos[pe] += patchMap->center(i);
320  }
321  const int npmepes = xdim*ydim;
322  ResizeArray<int> sortpes(npmepes);
323  for ( int i=0; i<npmepes; ++i ) {
324  int pe = sortpes[i] = pmepes[i];
325  int cnt = count[pe];
326  ScaledPosition sum = sumPos[pe];
327  if ( cnt == 0 ) {
328  // average over node
329  int node = CkNodeOf(pe);
330  int nsize = CkNodeSize(node);
331  int pe2 = CkNodeFirst(node);
332  for ( int j=0; j<nsize; ++j, ++pe2 ) {
333  cnt += count[pe2];
334  sum += sumPos[pe2];
335  }
336  }
337  if ( cnt == 0 ) {
338  // average over physical node
339  int node = CmiPhysicalNodeID(pe);
340  int nsize, *nlist;
341  CmiGetPesOnPhysicalNode(node, &nlist, &nsize);
342  for ( int j=0; j<nsize; ++j ) {
343  int pe2 = nlist[j];
344  cnt += count[pe2];
345  sum += sumPos[pe2];
346  }
347  }
348  if ( cnt ) {
349  avgPos[pe] = sum / cnt;
350  }
351  }
352  recursive_bisect_coord(0, xdim, 0, ydim, sortpes.begin(), avgPos.begin(), pmepes, ydim);
353 }
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:273
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 117 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 114 of file WorkDistrib.h.

Referenced by buildNodeAwarePeOrdering().


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