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 ( )

Definition at line 105 of file WorkDistrib.C.

References eventMachineProgress, and NAMD_bug().

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

Definition at line 121 of file WorkDistrib.C.

122 { }

Member Function Documentation

void WorkDistrib::assignNodeToPatch ( void  )

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

1324 {
1325  PatchMap *patchMap = PatchMap::Object();
1326  int nNodes = Node::Object()->numNodes();
1327  SimParameters *simparam = Node::Object()->simParameters;
1328  if(simparam->simulateInitialMapping) {
1329  nNodes = simparam->simulatedPEs;
1330  }
1331 
1332 #if (CMK_BLUEGENEP | CMK_BLUEGENEL) && USE_TOPOMAP
1333  TopoManager tmgr;
1334  int numPes = tmgr.getDimNX() * tmgr.getDimNY() * tmgr.getDimNZ();
1335  if (numPes > patchMap->numPatches() && (assignPatchesTopoGridRecBisection() > 0)) {
1336  CkPrintf ("Blue Gene/L topology partitioner finished successfully \n");
1337  }
1338  else
1339 #endif
1340  assignPatchesSpaceFillingCurve();
1341 
1342  int *nAtoms = new int[nNodes];
1343  int numAtoms=0;
1344  int i;
1345  for(i=0; i < nNodes; i++)
1346  nAtoms[i] = 0;
1347 
1348  for(i=0; i < patchMap->numPatches(); i++)
1349  {
1350  // iout << iINFO << "Patch " << i << " has "
1351  // << patchMap->patch(i)->getNumAtoms() << " atoms and "
1352  // << patchMap->patch(i)->getNumAtoms() *
1353  // patchMap->patch(i)->getNumAtoms()
1354  // << " pairs.\n" << endi;
1355 #ifdef MEM_OPT_VERSION
1356  numAtoms += patchMap->numAtoms(i);
1357  nAtoms[patchMap->node(i)] += patchMap->numAtoms(i);
1358 #else
1359  if (patchMap->patch(i)) {
1360  numAtoms += patchMap->patch(i)->getNumAtoms();
1361  nAtoms[patchMap->node(i)] += patchMap->patch(i)->getNumAtoms();
1362  }
1363 #endif
1364  }
1365 
1366  if ( numAtoms != Node::Object()->molecule->numAtoms ) {
1367  for(i=0; i < nNodes; i++)
1368  iout << iINFO << nAtoms[i] << " atoms assigned to node " << i << "\n" << endi;
1369  iout << iINFO << "Assigned " << numAtoms << " atoms but expected " << Node::Object()->molecule->numAtoms << "\n" << endi;
1370  NAMD_die("Incorrect atom count in WorkDistrib::assignNodeToPatch\n");
1371  }
1372 
1373  delete [] nAtoms;
1374 
1375  // PatchMap::Object()->printPatchMap();
1376 }
static Node * Object()
Definition: Node.h:86
std::ostream & iINFO(std::ostream &s)
Definition: InfoStream.C:81
Bool simulateInitialMapping
static PatchMap * Object()
Definition: PatchMap.h:27
SimParameters * simParameters
Definition: Node.h:178
std::ostream & endi(std::ostream &s)
Definition: InfoStream.C:54
#define iout
Definition: InfoStream.h:51
Patch * patch(PatchID pid)
Definition: PatchMap.h:235
int numNodes()
Definition: Node.h:189
int numAtoms
Definition: Molecule.h:557
void NAMD_die(const char *err_msg)
Definition: common.C:85
int numPatches(void) const
Definition: PatchMap.h:59
int node(int pid) const
Definition: PatchMap.h:114
int getNumAtoms()
Definition: Patch.h:105
Molecule * molecule
Definition: Node.h:176
void WorkDistrib::buildNodeAwarePeOrdering ( void  )
static

Definition at line 180 of file WorkDistrib.C.

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

Referenced by build_ordering().

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

Definition at line 3402 of file WorkDistrib.C.

3402  {
3403  #if defined(NAMD_MIC)
3404  mic_contributeHostDeviceLDB(peSetLen, peSet);
3405  #endif
3406 }
FullAtomList * WorkDistrib::createAtomLists ( const char *  basename = 0)

Definition at line 622 of file WorkDistrib.C.

References ResizeArray< T >::add(), SimParameters::alchOn, Lattice::apply_transform(), PatchMap::assignToPatch(), Molecule::atomcharge(), CompAtomExt::atomFixed, HydrogenGroupID::atomID, Molecule::atommass(), atoms, HydrogenGroupID::atomsInGroup, HydrogenGroupID::atomsInMigrationGroup, Molecule::atomvdwtype(), ResizeArray< T >::begin(), SimParameters::binaryOutput, CompAtom::charge, SimParameters::comMove, Node::configList, StringList::data, endi(), FALSE, ConfigList::find(), FullAtom::fixedPosition, PDB::get_all_positions(), Molecule::get_fep_type(), Molecule::getAtoms(), 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, 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(), 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< T >::size(), sortAtomsForPatches(), SimParameters::staticAtomAssignment, atom_constants::status, FullAtom::status, FullAtom::transform, TRUE, CompAtom::vdwType, and FullAtom::velocity.

Referenced by createHomePatches(), and reinitAtoms().

623 {
624  int i;
625  StringList *current; // Pointer used to retrieve configuration items
626  CProxy_Node nd(CkpvAccess(BOCclass_group).node);
627  Node *node = nd.ckLocalBranch();
628  PatchMap *patchMap = PatchMap::Object();
629  CProxy_PatchMgr pm(CkpvAccess(BOCclass_group).patchMgr);
630  PatchMgr *patchMgr = pm.ckLocalBranch();
631  SimParameters *params = node->simParameters;
632  Molecule *molecule = node->molecule;
633  PDB *pdb = node->pdb;
634 
635  int numPatches = patchMap->numPatches();
636  int numAtoms = pdb->num_atoms();
637 
638  Vector *positions = new Position[numAtoms];
639  Vector *velocities = new Velocity[numAtoms];
640 
641  if ( basename ) {
642  if ( params->binaryOutput ) {
643  read_binary_file((std::string(basename)+".coor").c_str(), positions, numAtoms);
644  read_binary_file((std::string(basename)+".vel").c_str(), velocities, numAtoms);
645  } else {
646  PDB coorpdb((std::string(basename)+".coor").c_str());
647  if ( coorpdb.num_atoms() != numAtoms ) {
648  NAMD_die("Incorrect atom count in coordinate pdb file");
649  }
650  coorpdb.get_all_positions(positions);
651  velocities_from_PDB((std::string(basename)+".vel").c_str(), velocities, numAtoms);
652  }
653  } else {
654  pdb->get_all_positions(positions);
655 
656  if ( params->initialTemp < 0.0 ) {
657  Bool binvels=FALSE;
658 
659  // Reading the veolcities from a PDB
660  current = node->configList->find("velocities");
661 
662  if (current == NULL) {
663  current = node->configList->find("binvelocities");
664  binvels = TRUE;
665  }
666 
667  if (!binvels) {
668  velocities_from_PDB(current->data, velocities, numAtoms);
669  }
670  else {
671  velocities_from_binfile(current->data, velocities, numAtoms);
672  }
673  }
674  else {
675  // Random velocities for a given temperature
676  random_velocities(params->initialTemp, molecule, velocities, numAtoms);
677  }
678  }
679 
680  // If COMMotion == no, remove center of mass motion
681  if (!(params->comMove)) {
682  remove_com_motion(velocities, molecule, numAtoms);
683  }
684 
686 
687  const Lattice lattice = params->lattice;
688 
689  if ( params->staticAtomAssignment ) {
690  FullAtomList sortAtoms;
691  for ( i=0; i < numAtoms; i++ ) {
692  HydrogenGroupID &h = molecule->hydrogenGroup[i];
693  if ( ! h.isMP ) continue;
694  FullAtom a;
695  a.id = i;
697  a.position = positions[h.atomID];
698  sortAtoms.add(a);
699  }
700  int *order = new int[sortAtoms.size()];
701  for ( i=0; i < sortAtoms.size(); i++ ) {
702  order[i] = i;
703  }
704  int *breaks = new int[numPatches];
705  sortAtomsForPatches(order,breaks,sortAtoms.begin(),
706  sortAtoms.size(),numAtoms,
707  patchMap->gridsize_c(),
708  patchMap->gridsize_b(),
709  patchMap->gridsize_a());
710 
711  i = 0;
712  for ( int pid = 0; pid < numPatches; ++pid ) {
713  int iend = breaks[pid];
714  for ( ; i<iend; ++i ) {
715  FullAtom &sa = sortAtoms[order[i]];
716  int mgs = sa.migrationGroupSize;
717 /*
718 CkPrintf("patch %d (%d %d %d) has group %d atom %d size %d at %.2f %.2f %.2f\n",
719  pid, patchMap->index_a(pid), patchMap->index_b(pid),
720  patchMap->index_c(pid), order[i], sa.id, mgs,
721  sa.position.x, sa.position.y, sa.position.z);
722 */
723  for ( int k=0; k<mgs; ++k ) {
724  HydrogenGroupID &h = molecule->hydrogenGroup[sa.id + k];
725  int aid = h.atomID;
726  FullAtom a;
727  a.id = aid;
728  a.position = positions[aid];
729  a.velocity = velocities[aid];
730  a.vdwType = molecule->atomvdwtype(aid);
731  a.status = molecule->getAtoms()[aid].status;
732  a.langevinParam = molecule->langevin_param(aid);
733  a.hydrogenGroupSize = h.isGP ? h.atomsInGroup : 0;
735  if(params->rigidBonds != RIGID_NONE) {
736  a.rigidBondLength = molecule->rigid_bond_length(aid);
737  }else{
738  a.rigidBondLength = 0.0;
739  }
740  atoms[pid].add(a);
741  }
742  }
743 CkPrintf("patch %d (%d %d %d) has %d atoms\n",
744  pid, patchMap->index_a(pid), patchMap->index_b(pid),
745  patchMap->index_c(pid), atoms[pid].size());
746  }
747  delete [] order;
748  delete [] breaks;
749  } else
750  {
751  // split atoms into patches based on migration group and position
752  int aid, pid=0;
753  for(i=0; i < numAtoms; i++)
754  {
755  // Assign atoms to patches without splitting hydrogen groups.
756  // We know that the hydrogenGroup array is sorted with group parents
757  // listed first. Thus, only change the pid if an atom is a group parent.
758  HydrogenGroupID &h = molecule->hydrogenGroup[i];
759  aid = h.atomID;
760  FullAtom a;
761  a.id = aid;
762  a.position = positions[aid];
763  a.velocity = velocities[aid];
764  a.vdwType = molecule->atomvdwtype(aid);
765  a.status = molecule->getAtoms()[aid].status;
766  a.langevinParam = molecule->langevin_param(aid);
767  a.hydrogenGroupSize = h.isGP ? h.atomsInGroup : 0;
769  if(params->rigidBonds != RIGID_NONE) {
770  a.rigidBondLength = molecule->rigid_bond_length(aid);
771  }else{
772  a.rigidBondLength = 0.0;
773  }
774  if (h.isMP) {
775  pid = patchMap->assignToPatch(positions[aid],lattice);
776  } // else: don't change pid
777  atoms[pid].add(a);
778  }
779  }
780 
781  delete [] positions;
782  delete [] velocities;
783 
784  for(i=0; i < numPatches; i++)
785  {
786  ScaledPosition center(0.5*(patchMap->min_a(i)+patchMap->max_a(i)),
787  0.5*(patchMap->min_b(i)+patchMap->max_b(i)),
788  0.5*(patchMap->min_c(i)+patchMap->max_c(i)));
789 
790  int n = atoms[i].size();
791  FullAtom *a = atoms[i].begin();
792  int j;
793 //Modifications for alchemical fep
794  Bool alchOn = params->alchOn;
795 //fepe
796  Bool lesOn = params->lesOn;
797 
798  Bool pairInteractionOn = params->pairInteractionOn;
799 
800  Bool pressureProfileTypes = (params->pressureProfileAtomTypes > 1);
801 
802  Transform mother_transform;
803  for(j=0; j < n; j++)
804  {
805  int aid = a[j].id;
806 
807  a[j].nonbondedGroupSize = 0; // must be set based on coordinates
808 
809  a[j].atomFixed = molecule->is_atom_fixed(aid) ? 1 : 0;
810  a[j].fixedPosition = a[j].position;
811 
812  if ( a[j].migrationGroupSize ) {
813  if ( a[j].migrationGroupSize != a[j].hydrogenGroupSize ) {
814  Position pos = a[j].position;
815  int mgs = a[j].migrationGroupSize;
816  int c = 1;
817  for ( int k=a[j].hydrogenGroupSize; k<mgs;
818  k+=a[j+k].hydrogenGroupSize ) {
819  pos += a[j+k].position;
820  ++c;
821  }
822  pos *= 1./c;
823  mother_transform = a[j].transform; // should be 0,0,0
824  pos = lattice.nearest(pos,center,&mother_transform);
825  a[j].position = lattice.apply_transform(a[j].position,mother_transform);
826  a[j].transform = mother_transform;
827  } else {
828  a[j].position = lattice.nearest(
829  a[j].position, center, &(a[j].transform));
830  mother_transform = a[j].transform;
831  }
832  } else {
833  a[j].position = lattice.apply_transform(a[j].position,mother_transform);
834  a[j].transform = mother_transform;
835  }
836 
837  a[j].mass = molecule->atommass(aid);
838  // Using double precision division for reciprocal mass.
839  a[j].recipMass = ( a[j].mass > 0 ? (1. / a[j].mass) : 0 );
840  a[j].charge = molecule->atomcharge(aid);
841 
842 //Modifications for alchemical fep
843  if ( alchOn || lesOn || pairInteractionOn || pressureProfileTypes) {
844  a[j].partition = molecule->get_fep_type(aid);
845  }
846  else {
847  a[j].partition = 0;
848  }
849 //fepe
850 
851  }
852 
853  int size, allfixed, k;
854  for(j=0; j < n; j+=size) {
855  size = a[j].hydrogenGroupSize;
856  if ( ! size ) {
857  NAMD_bug("Mother atom with hydrogenGroupSize of 0!");
858  }
859  allfixed = 1;
860  for ( k = 0; k < size; ++k ) {
861  allfixed = ( allfixed && (a[j+k].atomFixed) );
862  }
863  for ( k = 0; k < size; ++k ) {
864  a[j+k].groupFixed = allfixed ? 1 : 0;
865  }
866  }
867 
868  if ( params->outputPatchDetails ) {
869  int patchId = i;
870  int numAtomsInPatch = n;
871  int numFixedAtomsInPatch = 0;
872  int numAtomsInFixedGroupsInPatch = 0;
873  for(j=0; j < n; j++) {
874  numFixedAtomsInPatch += ( a[j].atomFixed ? 1 : 0 );
875  numAtomsInFixedGroupsInPatch += ( a[j].groupFixed ? 1 : 0 );
876  }
877  iout << "PATCH_DETAILS:"
878  << " patch " << patchId
879  << " atoms " << numAtomsInPatch
880  << " fixed_atoms " << numFixedAtomsInPatch
881  << " fixed_groups " << numAtomsInFixedGroupsInPatch
882  << "\n" << endi;
883  }
884  }
885 
886  return atoms;
887 
888 }
unsigned char partition
Definition: NamdTypes.h:56
Real langevinParam
Definition: NamdTypes.h:110
Real langevin_param(int atomnum) const
Definition: Molecule.h:1300
Definition: PDB.h:36
PatchID assignToPatch(Position p, const Lattice &l)
Definition: PatchMap.inl:14
unsigned int hydrogenGroupSize
Definition: NamdTypes.h:58
Definition: Node.h:78
unsigned int atomFixed
Definition: NamdTypes.h:96
Position fixedPosition
Definition: NamdTypes.h:102
int gridsize_c(void) const
Definition: PatchMap.h:66
static PatchMap * Object()
Definition: PatchMap.h:27
BigReal max_c(int pid) const
Definition: PatchMap.h:96
Definition: Vector.h:64
BigReal min_a(int pid) const
Definition: PatchMap.h:91
SimParameters * simParameters
Definition: Node.h:178
int index_a(int pid) const
Definition: PatchMap.h:86
static __thread atom * atoms
Atom * getAtoms() const
Definition: Molecule.h:491
std::ostream & endi(std::ostream &s)
Definition: InfoStream.C:54
#define FALSE
Definition: common.h:118
Real rigid_bond_length(int atomnum) const
Definition: Molecule.h:1457
Position position
Definition: NamdTypes.h:53
#define iout
Definition: InfoStream.h:51
Velocity velocity
Definition: NamdTypes.h:101
int num_atoms(void)
Definition: PDB.C:323
Position nearest(Position data, ScaledPosition ref) const
Definition: Lattice.h:90
unsigned int groupFixed
Definition: NamdTypes.h:97
Bool pairInteractionOn
BigReal min_b(int pid) const
Definition: PatchMap.h:93
int atomsInGroup
Definition: Hydrogen.h:19
Charge charge
Definition: NamdTypes.h:54
HydrogenGroup hydrogenGroup
Definition: Molecule.h:640
void read_binary_file(const char *fname, Vector *data, int n)
Definition: NamdOneTools.C:52
#define order
Definition: PmeRealSpace.C:235
int gridsize_a(void) const
Definition: PatchMap.h:64
void NAMD_bug(const char *err_msg)
Definition: common.C:129
AtomID atomID
Definition: Hydrogen.h:16
Bool staticAtomAssignment
int Bool
Definition: common.h:133
int index_b(int pid) const
Definition: PatchMap.h:87
__global__ void const int const TileList *__restrict__ TileExcl *__restrict__ const int *__restrict__ const int const float2 *__restrict__ cudaTextureObject_t const int *__restrict__ const float3 const float3 const float3 const float4 *__restrict__ const float cudaTextureObject_t cudaTextureObject_t float const PatchPairRecord *__restrict__ const int *__restrict__ const int2 *__restrict__ const unsigned int *__restrict__ unsigned int *__restrict__ int *__restrict__ int *__restrict__ TileListStat *__restrict__ const BoundingBox *__restrict__ float *__restrict__ float *__restrict__ float *__restrict__ float *__restrict__ float *__restrict__ float *__restrict__ float *__restrict__ float *__restrict__ const int numPatches
void NAMD_die(const char *err_msg)
Definition: common.C:85
PDB * pdb
Definition: Node.h:180
Bool outputPatchDetails
ConfigList * configList
Definition: Node.h:179
unsigned char get_fep_type(int anum) const
Definition: Molecule.h:1349
BigReal max_b(int pid) const
Definition: PatchMap.h:94
int index_c(int pid) const
Definition: PatchMap.h:88
int add(const Elem &elem)
Definition: ResizeArray.h:97
int migrationGroupSize
Definition: NamdTypes.h:117
int32 status
Definition: NamdTypes.h:115
BigReal max_a(int pid) const
Definition: PatchMap.h:92
BigReal initialTemp
Real rigidBondLength
Definition: NamdTypes.h:118
int pressureProfileAtomTypes
short vdwType
Definition: NamdTypes.h:55
int atomsInMigrationGroup
Definition: Hydrogen.h:29
Index atomvdwtype(int anum) const
Definition: Molecule.h:1062
int numPatches(void) const
Definition: PatchMap.h:59
Position apply_transform(Position data, const Transform &t) const
Definition: Lattice.h:132
char * data
Definition: ConfigList.h:48
Real atomcharge(int anum) const
Definition: Molecule.h:1052
Mass mass
Definition: NamdTypes.h:108
StringList * find(const char *name) const
Definition: ConfigList.C:341
Real atommass(int anum) const
Definition: Molecule.h:1042
int size(void) const
Definition: ResizeArray.h:127
unsigned int nonbondedGroupSize
Definition: NamdTypes.h:57
BigReal min_c(int pid) const
Definition: PatchMap.h:95
Bool is_atom_fixed(int atomnum) const
Definition: Molecule.h:1411
#define RIGID_NONE
Definition: SimParameters.h:77
double recipMass
Definition: NamdTypes.h:103
void get_all_positions(Vector *)
Definition: PDB.C:366
Molecule * molecule
Definition: Node.h:176
int gridsize_b(void) const
Definition: PatchMap.h:65
#define TRUE
Definition: common.h:119
void sortAtomsForPatches(int *order, int *breaks, const FullAtom *atoms, int nmgrps, int natoms, int ni, int nj, int nk)
Definition: SortAtoms.C:129
Transform transform
Definition: NamdTypes.h:116
iterator begin(void)
Definition: ResizeArray.h:36
void WorkDistrib::createHomePatches ( void  )

Definition at line 893 of file WorkDistrib.C.

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

Referenced by Node::startup().

894 {
895  int i;
896  PatchMap *patchMap = PatchMap::Object();
897  CProxy_PatchMgr pm(CkpvAccess(BOCclass_group).patchMgr);
898  PatchMgr *patchMgr = pm.ckLocalBranch();
899 
900  int numPatches = patchMap->numPatches();
901 
903 
904 #ifdef MEM_OPT_VERSION
905 /* CProxy_Node nd(CkpvAccess(BOCclass_group).node);
906  Node *node = nd.ckLocalBranch();
907  node->molecule->delEachAtomSigs();
908  node->molecule->delMassChargeSpace();
909 */
910 #endif
911 
912  int maxAtoms = -1;
913  int maxPatch = -1;
914  for(i=0; i < numPatches; i++) {
915  int numAtoms = atoms[i].size();
916  if ( numAtoms > maxAtoms ) { maxAtoms = numAtoms; maxPatch = i; }
917  }
918  iout << iINFO << "LARGEST PATCH (" << maxPatch <<
919  ") HAS " << maxAtoms << " ATOMS\n" << endi;
920 
921  for(i=0; i < numPatches; i++)
922  {
923  if ( ! ( i % 100 ) )
924  {
925  DebugM(3,"Created " << i << " patches so far.\n");
926  }
927 
928  patchMgr->createHomePatch(i,atoms[i]);
929  }
930 
931  delete [] atoms;
932 }
std::ostream & iINFO(std::ostream &s)
Definition: InfoStream.C:81
static PatchMap * Object()
Definition: PatchMap.h:27
static __thread atom * atoms
void createHomePatch(PatchID pid, FullAtomList &a)
Definition: PatchMgr.C:74
#define DebugM(x, y)
Definition: Debug.h:59
std::ostream & endi(std::ostream &s)
Definition: InfoStream.C:54
#define iout
Definition: InfoStream.h:51
__global__ void const int const TileList *__restrict__ TileExcl *__restrict__ const int *__restrict__ const int const float2 *__restrict__ cudaTextureObject_t const int *__restrict__ const float3 const float3 const float3 const float4 *__restrict__ const float cudaTextureObject_t cudaTextureObject_t float const PatchPairRecord *__restrict__ const int *__restrict__ const int2 *__restrict__ const unsigned int *__restrict__ unsigned int *__restrict__ int *__restrict__ int *__restrict__ TileListStat *__restrict__ const BoundingBox *__restrict__ float *__restrict__ float *__restrict__ float *__restrict__ float *__restrict__ float *__restrict__ float *__restrict__ float *__restrict__ float *__restrict__ const int numPatches
int numPatches(void) const
Definition: PatchMap.h:59
FullAtomList * createAtomLists(const char *basename=0)
Definition: WorkDistrib.C:622
int size(void) const
Definition: ResizeArray.h:127
void WorkDistrib::distributeHomePatches ( void  )

Definition at line 934 of file WorkDistrib.C.

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

Referenced by Node::startup().

934  {
935  // ref BOC
936  CProxy_Node nd(CkpvAccess(BOCclass_group).node);
937  Node *node = nd.ckLocalBranch();
938  CProxy_PatchMgr pm(CkpvAccess(BOCclass_group).patchMgr);
939  PatchMgr *patchMgr = pm.ckLocalBranch();
940  // ref singleton
941  PatchMap *patchMap = PatchMap::Object();
942 
943  // Move patches to the proper node
944  for(int i=0;i < patchMap->numPatches(); i++)
945  {
946  if (patchMap->node(i) != node->myid() )
947  {
948  DebugM(3,"patchMgr->movePatch("
949  << i << "," << patchMap->node(i) << ")\n");
950  patchMgr->movePatch(i,patchMap->node(i));
951  }
952  }
953  patchMgr->sendMovePatches();
954 }
Definition: Node.h:78
static PatchMap * Object()
Definition: PatchMap.h:27
#define DebugM(x, y)
Definition: Debug.h:59
void movePatch(PatchID, NodeID)
Definition: PatchMgr.C:84
void sendMovePatches()
Definition: PatchMgr.C:110
int myid()
Definition: Node.h:188
int numPatches(void) const
Definition: PatchMap.h:59
int node(int pid) const
Definition: PatchMap.h:114
void WorkDistrib::doneSaveComputeMap ( CkReductionMsg *  msg)

Definition at line 427 of file WorkDistrib.C.

427  {
428  delete msg;
429 
430  CkSendMsgBranch(saveComputeMapReturnEP, CkAllocMsg(0,0,0), 0, saveComputeMapReturnChareID);
431 }
void WorkDistrib::enqueueAngles ( LocalWorkMsg msg)

Definition at line 2973 of file WorkDistrib.C.

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

2973  {
2975  if ( msg->compute->localWorkMsg != msg )
2976  NAMD_bug("WorkDistrib LocalWorkMsg recycling failed!");
2977 }
LocalWorkMsg *const localWorkMsg
Definition: Compute.h:46
#define MACHINE_PROGRESS
virtual void doWork()
Definition: Compute.C:108
Compute * compute
Definition: WorkDistrib.h:27
void NAMD_bug(const char *err_msg)
Definition: common.C:129
void WorkDistrib::enqueueAniso ( LocalWorkMsg msg)

Definition at line 2997 of file WorkDistrib.C.

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

2997  {
2999  if ( msg->compute->localWorkMsg != msg )
3000  NAMD_bug("WorkDistrib LocalWorkMsg recycling failed!");
3001 }
LocalWorkMsg *const localWorkMsg
Definition: Compute.h:46
#define MACHINE_PROGRESS
virtual void doWork()
Definition: Compute.C:108
Compute * compute
Definition: WorkDistrib.h:27
void NAMD_bug(const char *err_msg)
Definition: common.C:129
void WorkDistrib::enqueueBonds ( LocalWorkMsg msg)

Definition at line 2967 of file WorkDistrib.C.

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

2967  {
2969  if ( msg->compute->localWorkMsg != msg )
2970  NAMD_bug("WorkDistrib LocalWorkMsg recycling failed!");
2971 }
LocalWorkMsg *const localWorkMsg
Definition: Compute.h:46
#define MACHINE_PROGRESS
virtual void doWork()
Definition: Compute.C:108
Compute * compute
Definition: WorkDistrib.h:27
void NAMD_bug(const char *err_msg)
Definition: common.C:129
void WorkDistrib::enqueueCrossterms ( LocalWorkMsg msg)

Definition at line 3003 of file WorkDistrib.C.

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

3003  {
3005  if ( msg->compute->localWorkMsg != msg )
3006  NAMD_bug("WorkDistrib LocalWorkMsg recycling failed!");
3007 }
LocalWorkMsg *const localWorkMsg
Definition: Compute.h:46
#define MACHINE_PROGRESS
virtual void doWork()
Definition: Compute.C:108
Compute * compute
Definition: WorkDistrib.h:27
void NAMD_bug(const char *err_msg)
Definition: common.C:129
void WorkDistrib::enqueueCUDA ( LocalWorkMsg msg)

Definition at line 3101 of file WorkDistrib.C.

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

3101  {
3103  // ComputeNonbondedCUDA *c = msg->compute;
3104  // if ( c->localWorkMsg != msg && c->localWorkMsg2 != msg )
3105  // NAMD_bug("WorkDistrib LocalWorkMsg recycling failed!");
3106 }
#define MACHINE_PROGRESS
virtual void doWork()
Definition: Compute.C:108
Compute * compute
Definition: WorkDistrib.h:27
void WorkDistrib::enqueueCUDAP2 ( LocalWorkMsg msg)

Definition at line 3107 of file WorkDistrib.C.

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

3107  {
3109 }
#define MACHINE_PROGRESS
virtual void doWork()
Definition: Compute.C:108
Compute * compute
Definition: WorkDistrib.h:27
void WorkDistrib::enqueueCUDAP3 ( LocalWorkMsg msg)

Definition at line 3110 of file WorkDistrib.C.

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

3110  {
3112 }
#define MACHINE_PROGRESS
virtual void doWork()
Definition: Compute.C:108
Compute * compute
Definition: WorkDistrib.h:27
void WorkDistrib::enqueueDihedrals ( LocalWorkMsg msg)

Definition at line 2979 of file WorkDistrib.C.

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

2979  {
2981  if ( msg->compute->localWorkMsg != msg )
2982  NAMD_bug("WorkDistrib LocalWorkMsg recycling failed!");
2983 }
LocalWorkMsg *const localWorkMsg
Definition: Compute.h:46
#define MACHINE_PROGRESS
virtual void doWork()
Definition: Compute.C:108
Compute * compute
Definition: WorkDistrib.h:27
void NAMD_bug(const char *err_msg)
Definition: common.C:129
void WorkDistrib::enqueueExcls ( LocalWorkMsg msg)

Definition at line 2961 of file WorkDistrib.C.

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

2961  {
2963  if ( msg->compute->localWorkMsg != msg )
2964  NAMD_bug("WorkDistrib LocalWorkMsg recycling failed!");
2965 }
LocalWorkMsg *const localWorkMsg
Definition: Compute.h:46
#define MACHINE_PROGRESS
virtual void doWork()
Definition: Compute.C:108
Compute * compute
Definition: WorkDistrib.h:27
void NAMD_bug(const char *err_msg)
Definition: common.C:129
void WorkDistrib::enqueueGromacsPair ( LocalWorkMsg msg)

Definition at line 3010 of file WorkDistrib.C.

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

3010  {
3011  msg->compute->doWork();
3013  if ( msg->compute->localWorkMsg != msg )
3014  NAMD_bug("\nWorkDistrib LocalWorkMsg recycling failed! Check enqueueGromacsPair from WorkDistrib.C\n");
3015 }
LocalWorkMsg *const localWorkMsg
Definition: Compute.h:46
#define MACHINE_PROGRESS
virtual void doWork()
Definition: Compute.C:108
Compute * compute
Definition: WorkDistrib.h:27
void NAMD_bug(const char *err_msg)
Definition: common.C:129
void WorkDistrib::enqueueImpropers ( LocalWorkMsg msg)

Definition at line 2985 of file WorkDistrib.C.

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

2985  {
2987  if ( msg->compute->localWorkMsg != msg )
2988  NAMD_bug("WorkDistrib LocalWorkMsg recycling failed!");
2989 }
LocalWorkMsg *const localWorkMsg
Definition: Compute.h:46
#define MACHINE_PROGRESS
virtual void doWork()
Definition: Compute.C:108
Compute * compute
Definition: WorkDistrib.h:27
void NAMD_bug(const char *err_msg)
Definition: common.C:129
void WorkDistrib::enqueueLCPO ( LocalWorkMsg msg)

Definition at line 3024 of file WorkDistrib.C.

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

3024  {
3025  msg->compute->doWork();
3026  if ( msg->compute->localWorkMsg != msg )
3027  NAMD_bug("WorkDistrib LocalWorkMsg recycling failed!");
3028 }
LocalWorkMsg *const localWorkMsg
Definition: Compute.h:46
virtual void doWork()
Definition: Compute.C:108
Compute * compute
Definition: WorkDistrib.h:27
void NAMD_bug(const char *err_msg)
Definition: common.C:129
void WorkDistrib::enqueueMIC ( LocalWorkMsg msg)

Definition at line 3131 of file WorkDistrib.C.

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

3131  {
3133 }
#define MACHINE_PROGRESS
virtual void doWork()
Definition: Compute.C:108
Compute * compute
Definition: WorkDistrib.h:27
void WorkDistrib::enqueuePme ( LocalWorkMsg msg)

Definition at line 3018 of file WorkDistrib.C.

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

3018  {
3020  if ( msg->compute->localWorkMsg != msg )
3021  NAMD_bug("WorkDistrib LocalWorkMsg recycling failed!");
3022 }
LocalWorkMsg *const localWorkMsg
Definition: Compute.h:46
#define MACHINE_PROGRESS
virtual void doWork()
Definition: Compute.C:108
Compute * compute
Definition: WorkDistrib.h:27
void NAMD_bug(const char *err_msg)
Definition: common.C:129
void WorkDistrib::enqueueSelfA1 ( LocalWorkMsg msg)

Definition at line 3029 of file WorkDistrib.C.

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

3029  {
3031  if ( msg->compute->localWorkMsg != msg )
3032  NAMD_bug("WorkDistrib LocalWorkMsg recycling failed!");
3033 }
LocalWorkMsg *const localWorkMsg
Definition: Compute.h:46
#define MACHINE_PROGRESS
virtual void doWork()
Definition: Compute.C:108
Compute * compute
Definition: WorkDistrib.h:27
void NAMD_bug(const char *err_msg)
Definition: common.C:129
void WorkDistrib::enqueueSelfA2 ( LocalWorkMsg msg)

Definition at line 3034 of file WorkDistrib.C.

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

3034  {
3036  if ( msg->compute->localWorkMsg != msg )
3037  NAMD_bug("WorkDistrib LocalWorkMsg recycling failed!");
3038 }
LocalWorkMsg *const localWorkMsg
Definition: Compute.h:46
#define MACHINE_PROGRESS
virtual void doWork()
Definition: Compute.C:108
Compute * compute
Definition: WorkDistrib.h:27
void NAMD_bug(const char *err_msg)
Definition: common.C:129
void WorkDistrib::enqueueSelfA3 ( LocalWorkMsg msg)

Definition at line 3039 of file WorkDistrib.C.

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

3039  {
3041  if ( msg->compute->localWorkMsg != msg )
3042  NAMD_bug("WorkDistrib LocalWorkMsg recycling failed!");
3043 }
LocalWorkMsg *const localWorkMsg
Definition: Compute.h:46
#define MACHINE_PROGRESS
virtual void doWork()
Definition: Compute.C:108
Compute * compute
Definition: WorkDistrib.h:27
void NAMD_bug(const char *err_msg)
Definition: common.C:129
void WorkDistrib::enqueueSelfB1 ( LocalWorkMsg msg)

Definition at line 3045 of file WorkDistrib.C.

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

3045  {
3047  if ( msg->compute->localWorkMsg != msg )
3048  NAMD_bug("WorkDistrib LocalWorkMsg recycling failed!");
3049 }
LocalWorkMsg *const localWorkMsg
Definition: Compute.h:46
#define MACHINE_PROGRESS
virtual void doWork()
Definition: Compute.C:108
Compute * compute
Definition: WorkDistrib.h:27
void NAMD_bug(const char *err_msg)
Definition: common.C:129
void WorkDistrib::enqueueSelfB2 ( LocalWorkMsg msg)

Definition at line 3050 of file WorkDistrib.C.

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

3050  {
3052  if ( msg->compute->localWorkMsg != msg )
3053  NAMD_bug("WorkDistrib LocalWorkMsg recycling failed!");
3054 }
LocalWorkMsg *const localWorkMsg
Definition: Compute.h:46
#define MACHINE_PROGRESS
virtual void doWork()
Definition: Compute.C:108
Compute * compute
Definition: WorkDistrib.h:27
void NAMD_bug(const char *err_msg)
Definition: common.C:129
void WorkDistrib::enqueueSelfB3 ( LocalWorkMsg msg)

Definition at line 3055 of file WorkDistrib.C.

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

3055  {
3057  if ( msg->compute->localWorkMsg != msg )
3058  NAMD_bug("WorkDistrib LocalWorkMsg recycling failed!");
3059 }
LocalWorkMsg *const localWorkMsg
Definition: Compute.h:46
#define MACHINE_PROGRESS
virtual void doWork()
Definition: Compute.C:108
Compute * compute
Definition: WorkDistrib.h:27
void NAMD_bug(const char *err_msg)
Definition: common.C:129
void WorkDistrib::enqueueThole ( LocalWorkMsg msg)

Definition at line 2991 of file WorkDistrib.C.

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

2991  {
2993  if ( msg->compute->localWorkMsg != msg )
2994  NAMD_bug("WorkDistrib LocalWorkMsg recycling failed!");
2995 }
LocalWorkMsg *const localWorkMsg
Definition: Compute.h:46
#define MACHINE_PROGRESS
virtual void doWork()
Definition: Compute.C:108
Compute * compute
Definition: WorkDistrib.h:27
void NAMD_bug(const char *err_msg)
Definition: common.C:129
void WorkDistrib::enqueueWork ( LocalWorkMsg msg)

Definition at line 2955 of file WorkDistrib.C.

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

2955  {
2957  if ( msg->compute->localWorkMsg != msg )
2958  NAMD_bug("WorkDistrib LocalWorkMsg recycling failed!");
2959 }
LocalWorkMsg *const localWorkMsg
Definition: Compute.h:46
#define MACHINE_PROGRESS
virtual void doWork()
Definition: Compute.C:108
Compute * compute
Definition: WorkDistrib.h:27
void NAMD_bug(const char *err_msg)
Definition: common.C:129
void WorkDistrib::enqueueWorkA1 ( LocalWorkMsg msg)

Definition at line 3061 of file WorkDistrib.C.

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

3061  {
3063  if ( msg->compute->localWorkMsg != msg )
3064  NAMD_bug("WorkDistrib LocalWorkMsg recycling failed!");
3065 }
LocalWorkMsg *const localWorkMsg
Definition: Compute.h:46
#define MACHINE_PROGRESS
virtual void doWork()
Definition: Compute.C:108
Compute * compute
Definition: WorkDistrib.h:27
void NAMD_bug(const char *err_msg)
Definition: common.C:129
void WorkDistrib::enqueueWorkA2 ( LocalWorkMsg msg)

Definition at line 3066 of file WorkDistrib.C.

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

3066  {
3068  if ( msg->compute->localWorkMsg != msg )
3069  NAMD_bug("WorkDistrib LocalWorkMsg recycling failed!");
3070 }
LocalWorkMsg *const localWorkMsg
Definition: Compute.h:46
#define MACHINE_PROGRESS
virtual void doWork()
Definition: Compute.C:108
Compute * compute
Definition: WorkDistrib.h:27
void NAMD_bug(const char *err_msg)
Definition: common.C:129
void WorkDistrib::enqueueWorkA3 ( LocalWorkMsg msg)

Definition at line 3071 of file WorkDistrib.C.

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

3071  {
3073  if ( msg->compute->localWorkMsg != msg )
3074  NAMD_bug("WorkDistrib LocalWorkMsg recycling failed!");
3075 }
LocalWorkMsg *const localWorkMsg
Definition: Compute.h:46
#define MACHINE_PROGRESS
virtual void doWork()
Definition: Compute.C:108
Compute * compute
Definition: WorkDistrib.h:27
void NAMD_bug(const char *err_msg)
Definition: common.C:129
void WorkDistrib::enqueueWorkB1 ( LocalWorkMsg msg)

Definition at line 3077 of file WorkDistrib.C.

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

3077  {
3079  if ( msg->compute->localWorkMsg != msg )
3080  NAMD_bug("WorkDistrib LocalWorkMsg recycling failed!");
3081 }
LocalWorkMsg *const localWorkMsg
Definition: Compute.h:46
#define MACHINE_PROGRESS
virtual void doWork()
Definition: Compute.C:108
Compute * compute
Definition: WorkDistrib.h:27
void NAMD_bug(const char *err_msg)
Definition: common.C:129
void WorkDistrib::enqueueWorkB2 ( LocalWorkMsg msg)

Definition at line 3082 of file WorkDistrib.C.

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

3082  {
3084  if ( msg->compute->localWorkMsg != msg )
3085  NAMD_bug("WorkDistrib LocalWorkMsg recycling failed!");
3086 }
LocalWorkMsg *const localWorkMsg
Definition: Compute.h:46
#define MACHINE_PROGRESS
virtual void doWork()
Definition: Compute.C:108
Compute * compute
Definition: WorkDistrib.h:27
void NAMD_bug(const char *err_msg)
Definition: common.C:129
void WorkDistrib::enqueueWorkB3 ( LocalWorkMsg msg)

Definition at line 3087 of file WorkDistrib.C.

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

3087  {
3089  if ( msg->compute->localWorkMsg != msg )
3090  NAMD_bug("WorkDistrib LocalWorkMsg recycling failed!");
3091 }
LocalWorkMsg *const localWorkMsg
Definition: Compute.h:46
#define MACHINE_PROGRESS
virtual void doWork()
Definition: Compute.C:108
Compute * compute
Definition: WorkDistrib.h:27
void NAMD_bug(const char *err_msg)
Definition: common.C:129
void WorkDistrib::enqueueWorkC ( LocalWorkMsg msg)

Definition at line 3095 of file WorkDistrib.C.

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

3095  {
3097  if ( msg->compute->localWorkMsg != msg )
3098  NAMD_bug("WorkDistrib LocalWorkMsg recycling failed!");
3099 }
LocalWorkMsg *const localWorkMsg
Definition: Compute.h:46
#define MACHINE_PROGRESS
virtual void doWork()
Definition: Compute.C:108
Compute * compute
Definition: WorkDistrib.h:27
void NAMD_bug(const char *err_msg)
Definition: common.C:129
void WorkDistrib::finishCUDA ( LocalWorkMsg msg)

Definition at line 3118 of file WorkDistrib.C.

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

3118  {
3120  // ComputeNonbondedCUDA *c = msg->compute;
3121  // if ( c->localWorkMsg != msg && c->localWorkMsg2 != msg )
3122  // NAMD_bug("WorkDistrib LocalWorkMsg recycling failed!");
3123 }
#define MACHINE_PROGRESS
virtual void doWork()
Definition: Compute.C:108
Compute * compute
Definition: WorkDistrib.h:27
void WorkDistrib::finishCUDAP2 ( LocalWorkMsg msg)

Definition at line 3124 of file WorkDistrib.C.

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

3124  {
3126 }
#define MACHINE_PROGRESS
virtual void doWork()
Definition: Compute.C:108
Compute * compute
Definition: WorkDistrib.h:27
void WorkDistrib::finishCUDAP3 ( LocalWorkMsg msg)

Definition at line 3127 of file WorkDistrib.C.

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

3127  {
3129 }
#define MACHINE_PROGRESS
virtual void doWork()
Definition: Compute.C:108
Compute * compute
Definition: WorkDistrib.h:27
void WorkDistrib::finishCUDAPatch ( FinishWorkMsg msg)

Definition at line 3114 of file WorkDistrib.C.

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

3114  {
3115  msg->compute->finishPatch(msg->data);
3116 }
Compute * compute
Definition: WorkDistrib.h:33
virtual void finishPatch(int)
Definition: Compute.C:112
void WorkDistrib::finishMIC ( LocalWorkMsg msg)

Definition at line 3134 of file WorkDistrib.C.

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

3134  {
3136 }
#define MACHINE_PROGRESS
virtual void doWork()
Definition: Compute.C:108
Compute * compute
Definition: WorkDistrib.h:27
void WorkDistrib::initHostDeviceLDB ( )

Definition at line 3389 of file WorkDistrib.C.

3389  {
3390  #if defined(NAMD_MIC)
3391  mic_hostDeviceLDB();
3392  #endif
3393 }
void WorkDistrib::mapComputes ( void  )

Definition at line 2274 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, SimParameters::computeMapFilename, computeMsmMsaType, computeMsmSerialType, computeMsmType, computeNonbondedCUDA2Type, computeNonbondedCUDAType, 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, ComputeMap::loadComputeMap(), SimParameters::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, SimParameters::sphericalBCOn, SimParameters::stirOn, SimParameters::storeComputeMap, SimParameters::tclBCOn, SimParameters::useCUDA2, SimParameters::useDPME, and SimParameters::usePMECUDA.

Referenced by Node::startup().

2275 {
2276  PatchMap *patchMap = PatchMap::Object();
2277  ComputeMap *computeMap = ComputeMap::Object();
2278  CProxy_Node nd(CkpvAccess(BOCclass_group).node);
2279  Node *node = nd.ckLocalBranch();
2280 
2281  DebugM(3,"Mapping computes\n");
2282 
2283  computeMap->allocateCids();
2284 
2285  // Handle full electrostatics
2286  if ( node->simParameters->fullDirectOn )
2287  mapComputeHomePatches(computeFullDirectType);
2288  if ( node->simParameters->FMAOn )
2289 #ifdef DPMTA
2290  mapComputeHomePatches(computeDPMTAType);
2291 #else
2292  NAMD_die("This binary does not include DPMTA (FMA).");
2293 #endif
2294  if ( node->simParameters->PMEOn ) {
2295 #ifdef DPME
2296  if ( node->simParameters->useDPME )
2297  mapComputeHomePatches(computeDPMEType);
2298  else {
2299  mapComputeHomePatches(computePmeType);
2301  mapComputeHomePatches(computeEwaldType);
2302  }
2303 #else
2304 #if defined(NAMD_CUDA) || defined(NAMD_HIP)
2305  if (node->simParameters->usePMECUDA) {
2306  mapComputePatch(computePmeCUDAType);
2307  } else
2308 #endif
2309  {
2310  mapComputePatch(computePmeType);
2311  }
2313  mapComputeHomePatches(computeEwaldType);
2314 #endif
2315  }
2316 
2317  if ( node->simParameters->globalForcesOn ) {
2318  DebugM(2,"adding ComputeGlobal\n");
2319  mapComputeHomePatches(computeGlobalType);
2320  }
2321 
2322  if ( node->simParameters->extForcesOn )
2323  mapComputeHomePatches(computeExtType);
2324 
2325  if ( node->simParameters->qmForcesOn )
2326  mapComputeHomePatches(computeQMType);
2327 
2328  if ( node->simParameters->GBISserOn )
2329  mapComputeHomePatches(computeGBISserType);
2330 
2331  if ( node->simParameters->MsmSerialOn )
2332  mapComputeHomePatches(computeMsmSerialType);
2333 #ifdef CHARM_HAS_MSA
2334  else if ( node->simParameters->MSMOn )
2335  mapComputeHomePatches(computeMsmMsaType);
2336 #else
2337  else if ( node->simParameters->MSMOn )
2338  mapComputeHomePatches(computeMsmType);
2339 #endif
2340 
2341  if ( node->simParameters->FMMOn )
2342  mapComputeHomePatches(computeFmmType);
2343 
2344 #if defined(NAMD_CUDA) || defined(NAMD_HIP)
2345 #ifdef BONDED_CUDA
2346  if (node->simParameters->bondedCUDA) {
2347  mapComputeNode(computeBondedCUDAType);
2348  }
2349 #endif
2350 #endif
2351 
2352 #if defined(NAMD_CUDA) || defined(NAMD_HIP)
2353  if (node->simParameters->useCUDA2) {
2354  mapComputeNode(computeNonbondedCUDA2Type);
2355  } else {
2356  mapComputeNode(computeNonbondedCUDAType);
2357  }
2358  mapComputeHomeTuples(computeExclsType);
2359  mapComputePatch(computeSelfExclsType);
2360 #endif
2361 
2362 #ifdef NAMD_MIC
2363  mapComputeNode(computeNonbondedMICType);
2364 #endif
2365 
2366  mapComputeNonbonded();
2367 
2368  if ( node->simParameters->LCPOOn ) {
2369  mapComputeLCPO();
2370  }
2371 
2372  // If we're doing true pair interactions, no need for bonded terms.
2373  // But if we're doing within-group interactions, we do need them.
2374  if ( !node->simParameters->pairInteractionOn ||
2376  mapComputeHomeTuples(computeBondsType);
2377  mapComputeHomeTuples(computeAnglesType);
2378  mapComputeHomeTuples(computeDihedralsType);
2379  mapComputeHomeTuples(computeImpropersType);
2380  mapComputeHomeTuples(computeCrosstermsType);
2381  mapComputePatch(computeSelfBondsType);
2382  mapComputePatch(computeSelfAnglesType);
2383  mapComputePatch(computeSelfDihedralsType);
2384  mapComputePatch(computeSelfImpropersType);
2385  mapComputePatch(computeSelfCrosstermsType);
2386  }
2387 
2388  if ( node->simParameters->goGroPair ) {
2389  // JLai
2390  mapComputeHomeTuples(computeGromacsPairType);
2391  mapComputePatch(computeSelfGromacsPairType);
2392  // End of JLai
2393  }
2394 
2395  if ( node->simParameters->drudeOn ) {
2396  mapComputeHomeTuples(computeTholeType);
2397  mapComputePatch(computeSelfTholeType);
2398  mapComputeHomeTuples(computeAnisoType);
2399  mapComputePatch(computeSelfAnisoType);
2400  }
2401 
2402  if ( node->simParameters->eFieldOn )
2403  mapComputePatch(computeEFieldType);
2404  /* BEGIN gf */
2405  if ( node->simParameters->mgridforceOn )
2406  mapComputePatch(computeGridForceType);
2407  /* END gf */
2408  if ( node->simParameters->stirOn )
2409  mapComputePatch(computeStirType);
2410  if ( node->simParameters->sphericalBCOn )
2411  mapComputePatch(computeSphericalBCType);
2412  if ( node->simParameters->cylindricalBCOn )
2413  mapComputePatch(computeCylindricalBCType);
2414  if ( node->simParameters->tclBCOn ) {
2415  mapComputeHomePatches(computeTclBCType);
2416  }
2417  if ( node->simParameters->constraintsOn )
2418  mapComputePatch(computeRestraintsType);
2419  if ( node->simParameters->consForceOn )
2420  mapComputePatch(computeConsForceType);
2421  if ( node->simParameters->consTorqueOn )
2422  mapComputePatch(computeConsTorqueType);
2423 
2424  // store the latest compute map
2426  if (simParams->storeComputeMap) {
2427  computeMap->saveComputeMap(simParams->computeMapFilename);
2428  }
2429  // override mapping decision
2430  if (simParams->loadComputeMap) {
2431  computeMap->loadComputeMap(simParams->computeMapFilename);
2432  CkPrintf("ComputeMap has been loaded from %s.\n", simParams->computeMapFilename);
2433  }
2434 }
static Node * Object()
Definition: Node.h:86
void saveComputeMap(const char *fname)
Definition: ComputeMap.C:262
Definition: Node.h:78
static PatchMap * Object()
Definition: PatchMap.h:27
SimParameters * simParameters
Definition: Node.h:178
void loadComputeMap(const char *fname)
Definition: ComputeMap.C:278
#define DebugM(x, y)
Definition: Debug.h:59
char computeMapFilename[NAMD_FILENAME_BUFFER_SIZE]
Bool pairInteractionOn
int allocateCids()
Definition: ComputeMap.C:143
void NAMD_die(const char *err_msg)
Definition: common.C:85
Bool pressureProfileEwaldOn
#define simParams
Definition: Output.C:127
static ComputeMap * Object()
Definition: ComputeMap.h:89
Bool pairInteractionSelf
void WorkDistrib::messageEnqueueWork ( Compute compute)
static

Definition at line 2732 of file WorkDistrib.C.

References Compute::cid, LocalWorkMsg::compute, computeAnglesType, computeAnisoType, computeBondsType, computeCrosstermsType, computeDihedralsType, computeExclsType, computeGromacsPairType, computeImpropersType, computeNonbondedCUDA2Type, computeNonbondedCUDAType, 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().

2732  {
2733  LocalWorkMsg *msg = compute->localWorkMsg;
2734  int seq = compute->sequence();
2735  int gbisPhase = compute->getGBISPhase();
2736 
2737  if ( seq < 0 ) {
2738  NAMD_bug("compute->sequence() < 0 in WorkDistrib::messageEnqueueWork");
2739  } else {
2740  SET_PRIORITY(msg,seq,compute->priority());
2741  }
2742 
2743  msg->compute = compute; // pointer is valid since send is to local Pe
2744  int type = compute->type();
2745  int cid = compute->cid;
2746 
2747  CProxy_WorkDistrib wdProxy(CkpvAccess(BOCclass_group).workDistrib);
2748  switch ( type ) {
2749  case computeExclsType:
2750  case computeSelfExclsType:
2751  wdProxy[CkMyPe()].enqueueExcls(msg);
2752  break;
2753  case computeBondsType:
2754  case computeSelfBondsType:
2755  wdProxy[CkMyPe()].enqueueBonds(msg);
2756  break;
2757  case computeAnglesType:
2758  case computeSelfAnglesType:
2759  wdProxy[CkMyPe()].enqueueAngles(msg);
2760  break;
2761  case computeDihedralsType:
2763  wdProxy[CkMyPe()].enqueueDihedrals(msg);
2764  break;
2765  case computeImpropersType:
2767  wdProxy[CkMyPe()].enqueueImpropers(msg);
2768  break;
2769  case computeTholeType:
2770  case computeSelfTholeType:
2771  wdProxy[CkMyPe()].enqueueThole(msg);
2772  break;
2773  case computeAnisoType:
2774  case computeSelfAnisoType:
2775  wdProxy[CkMyPe()].enqueueAniso(msg);
2776  break;
2777  case computeCrosstermsType:
2779  wdProxy[CkMyPe()].enqueueCrossterms(msg);
2780  break;
2781  // JLai
2784  wdProxy[CkMyPe()].enqueueGromacsPair(msg);
2785  break;
2786  // End of JLai
2787  case computeLCPOType:
2788  wdProxy[CkMyPe()].enqueueLCPO(msg);
2789  break;
2791  switch ( seq % 2 ) {
2792  case 0:
2793  //wdProxy[CkMyPe()].enqueueSelfA(msg);
2794  switch ( gbisPhase ) {
2795  case 1:
2796  wdProxy[CkMyPe()].enqueueSelfA1(msg);
2797  break;
2798  case 2:
2799  wdProxy[CkMyPe()].enqueueSelfA2(msg);
2800  break;
2801  case 3:
2802  wdProxy[CkMyPe()].enqueueSelfA3(msg);
2803  break;
2804  }
2805  break;
2806  case 1:
2807  //wdProxy[CkMyPe()].enqueueSelfB(msg);
2808  switch ( gbisPhase ) {
2809  case 1:
2810  wdProxy[CkMyPe()].enqueueSelfB1(msg);
2811  break;
2812  case 2:
2813  wdProxy[CkMyPe()].enqueueSelfB2(msg);
2814  break;
2815  case 3:
2816  wdProxy[CkMyPe()].enqueueSelfB3(msg);
2817  break;
2818  }
2819  break;
2820  default:
2821  NAMD_bug("WorkDistrib::messageEnqueueSelf case statement error!");
2822  }
2823  break;
2825  switch ( seq % 2 ) {
2826  case 0:
2827  //wdProxy[CkMyPe()].enqueueWorkA(msg);
2828  switch ( gbisPhase ) {
2829  case 1:
2830  wdProxy[CkMyPe()].enqueueWorkA1(msg);
2831  break;
2832  case 2:
2833  wdProxy[CkMyPe()].enqueueWorkA2(msg);
2834  break;
2835  case 3:
2836  wdProxy[CkMyPe()].enqueueWorkA3(msg);
2837  break;
2838  }
2839  break;
2840  case 1:
2841  //wdProxy[CkMyPe()].enqueueWorkB(msg);
2842  switch ( gbisPhase ) {
2843  case 1:
2844  wdProxy[CkMyPe()].enqueueWorkB1(msg);
2845  break;
2846  case 2:
2847  wdProxy[CkMyPe()].enqueueWorkB2(msg);
2848  break;
2849  case 3:
2850  wdProxy[CkMyPe()].enqueueWorkB3(msg);
2851  break;
2852  }
2853  break;
2854  case 2:
2855  wdProxy[CkMyPe()].enqueueWorkC(msg);
2856  break;
2857  default:
2858  NAMD_bug("WorkDistrib::messageEnqueueWork case statement error!");
2859  }
2860  break;
2862 #if defined(NAMD_CUDA) || defined(NAMD_HIP)
2864 // CkPrintf("WorkDistrib[%d]::CUDA seq=%d phase=%d\n", CkMyPe(), seq, gbisPhase);
2865  //wdProxy[CkMyPe()].enqueueCUDA(msg);
2866  switch ( gbisPhase ) {
2867  case 1:
2868  wdProxy[CkMyPe()].enqueueCUDA(msg);
2869  break;
2870  case 2:
2871  wdProxy[CkMyPe()].enqueueCUDAP2(msg);
2872  break;
2873  case 3:
2874  wdProxy[CkMyPe()].enqueueCUDAP3(msg);
2875  break;
2876  }
2877 #else
2879 #endif
2880  break;
2882 #ifdef NAMD_MIC
2883  wdProxy[CkMyPe()].enqueueMIC(msg);
2884 #endif
2885  break;
2886  case computePmeType:
2887  // CkPrintf("PME %d %d %x\n", CkMyPe(), seq, compute->priority());
2888  wdProxy[CkMyPe()].enqueuePme(msg);
2889  break;
2890 #if defined(NAMD_CUDA) || defined(NAMD_HIP)
2891  case computePmeCUDAType:
2892  wdProxy[CkMyPe()].enqueuePme(msg);
2893  break;
2894 #endif
2895  default:
2896  wdProxy[CkMyPe()].enqueueWork(msg);
2897  }
2898 }
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:108
Compute * compute
Definition: WorkDistrib.h:27
void NAMD_bug(const char *err_msg)
Definition: common.C:129
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
void WorkDistrib::messageFinishCUDA ( Compute compute)
static

Definition at line 2901 of file WorkDistrib.C.

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

Referenced by cuda_check_local_progress(), and cuda_check_remote_progress().

2901  {
2902  LocalWorkMsg *msg = compute->localWorkMsg;
2903  int seq = compute->sequence();
2904  int gbisPhase = compute->getGBISPhase();
2905 
2906  if ( seq < 0 ) {
2907  NAMD_bug("compute->sequence() < 0 in WorkDistrib::messageEnqueueWork");
2908  } else {
2909  SET_PRIORITY(msg,seq,compute->priority());
2910  }
2911 
2912  msg->compute = compute; // pointer is valid since send is to local Pe
2913  CProxy_WorkDistrib wdProxy(CkpvAccess(BOCclass_group).workDistrib);
2914 
2915 #if defined(NAMD_CUDA) || defined(NAMD_HIP)
2916  //wdProxy[CkMyPe()].finishCUDA(msg);
2917  switch ( gbisPhase ) {
2918  case 1:
2919  wdProxy[CkMyPe()].finishCUDA(msg);
2920  break;
2921  case 2:
2922  wdProxy[CkMyPe()].finishCUDAP2(msg);
2923  break;
2924  case 3:
2925  wdProxy[CkMyPe()].finishCUDAP3(msg);
2926  break;
2927  }
2928 #else
2930 #endif
2931 }
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:108
Compute * compute
Definition: WorkDistrib.h:27
void NAMD_bug(const char *err_msg)
Definition: common.C:129
int priority(void)
Definition: Compute.h:65
#define SET_PRIORITY(MSG, SEQ, PRIO)
Definition: Priorities.h:18
void WorkDistrib::messageFinishMIC ( Compute compute)
static

Definition at line 2934 of file WorkDistrib.C.

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

2934  {
2935  LocalWorkMsg *msg = compute->localWorkMsg;
2936  int seq = compute->sequence();
2937  int gbisPhase = compute->getGBISPhase();
2938 
2939  if ( seq < 0 ) {
2940  NAMD_bug("compute->sequence() < 0 in WorkDistrib::messageFinishMIC");
2941  } else {
2942  SET_PRIORITY(msg,seq,compute->priority());
2943  }
2944 
2945  msg->compute = compute; // pointer is valid since send is to local Pe
2946  CProxy_WorkDistrib wdProxy(CkpvAccess(BOCclass_group).workDistrib);
2947 
2948 #ifdef NAMD_MIC
2949  wdProxy[CkMyPe()].finishMIC(msg);
2950 #else
2952 #endif
2953 }
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:108
Compute * compute
Definition: WorkDistrib.h:27
void NAMD_bug(const char *err_msg)
Definition: common.C:129
int priority(void)
Definition: Compute.h:65
#define SET_PRIORITY(MSG, SEQ, PRIO)
Definition: Priorities.h:18
void WorkDistrib::patchMapInit ( void  )

Definition at line 1109 of file WorkDistrib.C.

References Lattice::a_p(), Lattice::a_r(), Lattice::b_p(), Lattice::b_r(), Lattice::c_p(), Lattice::c_r(), 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, numPatches, 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().

1110 {
1111  PatchMap *patchMap = PatchMap::Object();
1112  CProxy_Node nd(CkpvAccess(BOCclass_group).node);
1113  Node *node = nd.ckLocalBranch();
1114  SimParameters *params = node->simParameters;
1115  Lattice lattice = params->lattice;
1116 
1117  BigReal patchSize = params->patchDimension;
1118 
1119 #ifndef MEM_OPT_VERSION
1120  const int totalAtoms = node->pdb->num_atoms();
1121 #else
1122  const int totalAtoms = node->molecule->numAtoms;
1123 #endif
1124 
1125  ScaledPosition xmin, xmax;
1126 
1127  double maxNumPatches = 1.e9; // need to adjust fractional values
1128  if ( params->minAtomsPerPatch > 0 )
1129  maxNumPatches = totalAtoms / params->minAtomsPerPatch;
1130 
1131  DebugM(3,"Mapping patches\n");
1132  if ( lattice.a_p() && lattice.b_p() && lattice.c_p() ) {
1133  xmin = 0.; xmax = 0.;
1134  }
1135  else if ( params->FMAOn || params->MSMOn || params->FMMOn ) {
1136  // Need to use full box for FMA to match NAMD 1.X results.
1137 #if 0
1138  node->pdb->find_extremes(&(xmin.x),&(xmax.x),lattice.a_r());
1139  node->pdb->find_extremes(&(xmin.y),&(xmax.y),lattice.b_r());
1140  node->pdb->find_extremes(&(xmin.z),&(xmax.z),lattice.c_r());
1141 #endif
1142  node->pdb->find_extremes(lattice);
1143  node->pdb->get_extremes(xmin, xmax);
1144 #if 0
1145  printf("+++ center=%.4f %.4f %.4f\n",
1146  lattice.origin().x, lattice.origin().y, lattice.origin().z);
1147  printf("+++ xmin=%.4f xmax=%.4f\n", xmin.x, xmax.x);
1148  printf("+++ ymin=%.4f ymax=%.4f\n", xmin.y, xmax.y);
1149  printf("+++ zmin=%.4f zmax=%.4f\n", xmin.z, xmax.z);
1150 #endif
1151  // Otherwise, this allows a small number of stray atoms.
1152  }
1153  else {
1154 #if 0
1155  node->pdb->find_extremes(&(xmin.x),&(xmax.x),lattice.a_r(),0.9);
1156  node->pdb->find_extremes(&(xmin.y),&(xmax.y),lattice.b_r(),0.9);
1157  node->pdb->find_extremes(&(xmin.z),&(xmax.z),lattice.c_r(),0.9);
1158 #endif
1159  node->pdb->find_extremes(lattice, 1.0);
1160  node->pdb->get_extremes(xmin, xmax);
1161  iout << iINFO << "ORIGINAL ATOMS MINMAX IS " << xmin << " " << xmax << "\n" << endi;
1162  double frac = ( (double)totalAtoms - 10000. ) / (double)totalAtoms;
1163  if ( frac < 0.9 ) { frac = 0.9; }
1164  node->pdb->find_extremes(lattice, frac);
1165  node->pdb->get_extremes(xmin, xmax);
1166  iout << iINFO << "ADJUSTED ATOMS MINMAX IS " << xmin << " " << xmax << "\n" << endi;
1167  }
1168 
1169 #if 0
1170  BigReal origin_shift;
1171  origin_shift = lattice.a_r() * lattice.origin();
1172  xmin.x -= origin_shift;
1173  xmax.x -= origin_shift;
1174  origin_shift = lattice.b_r() * lattice.origin();
1175  xmin.y -= origin_shift;
1176  xmax.y -= origin_shift;
1177  origin_shift = lattice.c_r() * lattice.origin();
1178  xmin.z -= origin_shift;
1179  xmax.z -= origin_shift;
1180 #endif
1181 
1182  // SimParameters default is -1 for unset
1183  int twoAwayX = params->twoAwayX;
1184  int twoAwayY = params->twoAwayY;
1185  int twoAwayZ = params->twoAwayZ;
1186 
1187  // SASA implementation is not compatible with twoAway patches
1188  if (params->LCPOOn && patchSize < 32.4) {
1189  if ( twoAwayX > 0 || twoAwayY > 0 || twoAwayZ > 0 ) {
1190  iout << iWARN << "Ignoring twoAway[XYZ] due to LCPO SASA implementation.\n" << endi;
1191  }
1192  twoAwayX = twoAwayY = twoAwayZ = 0;
1193  }
1194 
1195  // if you think you know what you're doing go right ahead
1196  if ( twoAwayX > 0 ) maxNumPatches = 1.e9;
1197  if ( twoAwayY > 0 ) maxNumPatches = 1.e9;
1198  if ( twoAwayZ > 0 ) maxNumPatches = 1.e9;
1199  if ( params->maxPatches > 0 ) {
1200  maxNumPatches = params->maxPatches;
1201  iout << iINFO << "LIMITING NUMBER OF PATCHES TO " <<
1202  maxNumPatches << "\n" << endi;
1203  }
1204 
1205  int numpes = CkNumPes();
1206  SimParameters *simparam = Node::Object()->simParameters;
1207  if(simparam->simulateInitialMapping) {
1208  numpes = simparam->simulatedPEs;
1209  delete [] patchMap->nPatchesOnNode;
1210  patchMap->nPatchesOnNode = new int[numpes];
1211  memset(patchMap->nPatchesOnNode, 0, numpes*sizeof(int));
1212  }
1213 
1214 #if defined(NAMD_CUDA) || defined(NAMD_HIP) || defined(NAMD_MIC)
1215  // for CUDA be sure there are more patches than pes
1216 
1217  int numPatches = patchMap->sizeGrid(
1218  xmin,xmax,lattice,patchSize,maxNumPatches,params->staticAtomAssignment,
1219  twoAwayX>0 ? 2 : 1, twoAwayY>0 ? 2 : 1, twoAwayZ>0 ? 2 : 1);
1220  if ( numPatches < numpes && twoAwayX < 0 ) {
1221  twoAwayX = 1;
1222  numPatches = patchMap->sizeGrid(
1223  xmin,xmax,lattice,patchSize,maxNumPatches,params->staticAtomAssignment,
1224  twoAwayX>0 ? 2 : 1, twoAwayY>0 ? 2 : 1, twoAwayZ>0 ? 2 : 1);
1225  }
1226  if ( numPatches < numpes && twoAwayY < 0 ) {
1227  twoAwayY = 1;
1228  numPatches = patchMap->sizeGrid(
1229  xmin,xmax,lattice,patchSize,maxNumPatches,params->staticAtomAssignment,
1230  twoAwayX>0 ? 2 : 1, twoAwayY>0 ? 2 : 1, twoAwayZ>0 ? 2 : 1);
1231  }
1232  if ( numPatches < numpes && twoAwayZ < 0 ) {
1233  twoAwayZ = 1;
1234  numPatches = patchMap->sizeGrid(
1235  xmin,xmax,lattice,patchSize,maxNumPatches,params->staticAtomAssignment,
1236  twoAwayX>0 ? 2 : 1, twoAwayY>0 ? 2 : 1, twoAwayZ>0 ? 2 : 1);
1237  }
1238  if ( numPatches < numpes ) {
1239  #if defined(NAMD_MIC)
1240  NAMD_die("MIC-enabled NAMD requires at least one patch per thread.");
1241  #endif
1242  }
1243  if ( numPatches % numpes && numPatches <= 1.4 * numpes ) {
1244  int exactFit = numPatches - numPatches % numpes;
1245  int newNumPatches = patchMap->sizeGrid(
1246  xmin,xmax,lattice,patchSize,exactFit,params->staticAtomAssignment,
1247  twoAwayX>0 ? 2 : 1, twoAwayY>0 ? 2 : 1, twoAwayZ>0 ? 2 : 1);
1248  if ( newNumPatches == exactFit ) {
1249  iout << iINFO << "REDUCING NUMBER OF PATCHES TO IMPROVE LOAD BALANCE\n" << endi;
1250  maxNumPatches = exactFit;
1251  }
1252  }
1253 
1254  patchMap->makePatches(xmin,xmax,lattice,patchSize,maxNumPatches,
1255  params->staticAtomAssignment, params->replicaUniformPatchGrids, params->LCPOOn,
1256  twoAwayX>0 ? 2 : 1, twoAwayY>0 ? 2 : 1, twoAwayZ>0 ? 2 : 1);
1257 
1258 #else
1259 
1260  int availPes = numpes;
1261  if ( params->noPatchesOnZero && numpes > 1 ) {
1262  availPes -= 1;
1263  if(params->noPatchesOnOne && numpes > 2)
1264  availPes -= 1;
1265  }
1266 #ifdef MEM_OPT_VERSION
1267  if(params->noPatchesOnOutputPEs && numpes - params->numoutputprocs >2)
1268  {
1269  availPes -= params->numoutputprocs;
1270  if ( params->noPatchesOnZero && numpes > 1 && isOutputProcessor(0)){
1271  availPes++;
1272  }
1273  if ( params->noPatchesOnOne && numpes > 2 && isOutputProcessor(1)){
1274  availPes++;
1275  }
1276  }
1277 #endif
1278 
1279  int numPatches = patchMap->sizeGrid(
1280  xmin,xmax,lattice,patchSize,1.e9,params->staticAtomAssignment,
1281  twoAwayX ? 2 : 1, twoAwayY ? 2 : 1, twoAwayZ ? 2 : 1);
1282  if ( ( numPatches > (0.3*availPes) || numPatches > maxNumPatches
1283  ) && twoAwayZ < 0 ) {
1284  twoAwayZ = 0;
1285  numPatches = patchMap->sizeGrid(
1286  xmin,xmax,lattice,patchSize,1.e9,params->staticAtomAssignment,
1287  twoAwayX ? 2 : 1, twoAwayY ? 2 : 1, twoAwayZ ? 2 : 1);
1288  }
1289  if ( ( numPatches > (0.6*availPes) || numPatches > maxNumPatches
1290  ) && twoAwayY < 0 ) {
1291  twoAwayY = 0;
1292  numPatches = patchMap->sizeGrid(
1293  xmin,xmax,lattice,patchSize,1.e9,params->staticAtomAssignment,
1294  twoAwayX ? 2 : 1, twoAwayY ? 2 : 1, twoAwayZ ? 2 : 1);
1295  }
1296  if ( ( numPatches > availPes || numPatches > maxNumPatches
1297  ) && twoAwayX < 0 ) {
1298  twoAwayX = 0;
1299  numPatches = patchMap->sizeGrid(
1300  xmin,xmax,lattice,patchSize,1.e9,params->staticAtomAssignment,
1301  twoAwayX ? 2 : 1, twoAwayY ? 2 : 1, twoAwayZ ? 2 : 1);
1302  }
1303  if ( numPatches > availPes && numPatches <= (1.4*availPes) && availPes <= maxNumPatches ) {
1304  int newNumPatches = patchMap->sizeGrid(
1305  xmin,xmax,lattice,patchSize,availPes,params->staticAtomAssignment,
1306  twoAwayX ? 2 : 1, twoAwayY ? 2 : 1, twoAwayZ ? 2 : 1);
1307  if ( newNumPatches <= availPes && numPatches <= (1.4*newNumPatches) ) {
1308  iout << iINFO << "REDUCING NUMBER OF PATCHES TO IMPROVE LOAD BALANCE\n" << endi;
1309  maxNumPatches = availPes;
1310  }
1311  }
1312 
1313  patchMap->makePatches(xmin,xmax,lattice,patchSize,maxNumPatches,
1314  params->staticAtomAssignment, params->replicaUniformPatchGrids, params->LCPOOn,
1315  twoAwayX ? 2 : 1, twoAwayY ? 2 : 1, twoAwayZ ? 2 : 1);
1316 
1317 #endif
1318 
1319 }
static Node * Object()
Definition: Node.h:86
std::ostream & iINFO(std::ostream &s)
Definition: InfoStream.C:81
Bool simulateInitialMapping
Vector a_r() const
Definition: Lattice.h:268
Definition: Node.h:78
static PatchMap * Object()
Definition: PatchMap.h:27
Definition: Vector.h:64
SimParameters * simParameters
Definition: Node.h:178
Vector c_r() const
Definition: Lattice.h:270
#define DebugM(x, y)
Definition: Debug.h:59
std::ostream & endi(std::ostream &s)
Definition: InfoStream.C:54
BigReal z
Definition: Vector.h:66
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
Vector origin() const
Definition: Lattice.h:262
Vector b_r() const
Definition: Lattice.h:269
Bool staticAtomAssignment
Bool replicaUniformPatchGrids
BigReal x
Definition: Vector.h:66
int numAtoms
Definition: Molecule.h:557
__global__ void const int const TileList *__restrict__ TileExcl *__restrict__ const int *__restrict__ const int const float2 *__restrict__ cudaTextureObject_t const int *__restrict__ const float3 const float3 const float3 const float4 *__restrict__ const float cudaTextureObject_t cudaTextureObject_t float const PatchPairRecord *__restrict__ const int *__restrict__ const int2 *__restrict__ const unsigned int *__restrict__ unsigned int *__restrict__ int *__restrict__ int *__restrict__ TileListStat *__restrict__ const BoundingBox *__restrict__ float *__restrict__ float *__restrict__ float *__restrict__ float *__restrict__ float *__restrict__ float *__restrict__ float *__restrict__ float *__restrict__ const int numPatches
void NAMD_die(const char *err_msg)
Definition: common.C:85
PDB * pdb
Definition: Node.h:180
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:438
BigReal y
Definition: Vector.h:66
BigReal patchDimension
int b_p() const
Definition: Lattice.h:274
int isOutputProcessor(int pe)
int a_p() const
Definition: Lattice.h:273
Molecule * molecule
Definition: Node.h:176
Bool noPatchesOnOutputPEs
void get_extremes(ScaledPosition &xmin, ScaledPosition &xmax) const
Definition: PDB.h:104
double BigReal
Definition: common.h:114
int c_p() const
Definition: Lattice.h:275
void WorkDistrib::peOrderingReady ( )
static

Definition at line 170 of file WorkDistrib.C.

References cuda_initialize(), and mic_initialize().

Referenced by buildNodeAwarePeOrdering().

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

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

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

Definition at line 956 of file WorkDistrib.C.

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

956  {
957 
958  PatchMap *patchMap = PatchMap::Object();
959  CProxy_PatchMgr pm(CkpvAccess(BOCclass_group).patchMgr);
960  PatchMgr *patchMgr = pm.ckLocalBranch();
961 
962  int numPatches = patchMap->numPatches();
963 
964  FullAtomList *atoms = createAtomLists(basename);
965 
966  for(int i=0; i < numPatches; i++) {
967  patchMgr->sendAtoms(i,atoms[i]);
968  }
969 
970  delete [] atoms;
971 
972 }
static PatchMap * Object()
Definition: PatchMap.h:27
static __thread atom * atoms
void sendAtoms(PatchID pid, FullAtomList &a)
Definition: PatchMgr.C:157
__global__ void const int const TileList *__restrict__ TileExcl *__restrict__ const int *__restrict__ const int const float2 *__restrict__ cudaTextureObject_t const int *__restrict__ const float3 const float3 const float3 const float4 *__restrict__ const float cudaTextureObject_t cudaTextureObject_t float const PatchPairRecord *__restrict__ const int *__restrict__ const int2 *__restrict__ const unsigned int *__restrict__ unsigned int *__restrict__ int *__restrict__ int *__restrict__ TileListStat *__restrict__ const BoundingBox *__restrict__ float *__restrict__ float *__restrict__ float *__restrict__ float *__restrict__ float *__restrict__ float *__restrict__ float *__restrict__ float *__restrict__ const int numPatches
int numPatches(void) const
Definition: PatchMap.h:59
FullAtomList * createAtomLists(const char *basename=0)
Definition: WorkDistrib.C:622
void WorkDistrib::saveComputeMapChanges ( int  ep,
CkGroupID  chareID 
)

Definition at line 356 of file WorkDistrib.C.

Referenced by ComputeMgr::updateComputes2().

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

Definition at line 1018 of file WorkDistrib.C.

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

1019 {
1020  // Use a resend to forward messages before processing. Otherwise the
1021  // map distribution is slow on many CPUs. We need to use a tree
1022  // rather than a broadcast because some implementations of broadcast
1023  // generate a copy of the message on the sender for each recipient.
1024  // This is because MPI doesn't allow re-use of an outstanding buffer.
1025 
1026  if ( CkMyRank() ) patchMapArrived = true;
1027 
1028  if ( patchMapArrived && CkMyPe() ) {
1030 
1031  //Automatically enable spanning tree
1032  CProxy_Node nd(CkpvAccess(BOCclass_group).node);
1033  Node *node = nd.ckLocalBranch();
1034  SimParameters *params = node->simParameters;
1035  if( ( PatchMap::Object()->numPatches() <= CkNumPes()/4
1036 #ifdef NODEAWARE_PROXY_SPANNINGTREE
1037  || CkNumPes() > CkNumNodes()
1038  ) && ( CkNumNodes() > 1
1039 #endif
1040  ) && params->isSendSpanningTreeUnset() )
1042 
1043 #ifdef NODEAWARE_PROXY_SPANNINGTREE
1044  if ( CkNumPes() > CkNumNodes() && CkNumNodes() > 1
1045  && params->isRecvSpanningTreeUnset() )
1047 #endif
1048  }
1049 
1050  if ( patchMapArrived ) {
1051  if ( CkMyRank() + 1 < CkNodeSize(CkMyNode()) ) {
1052  ((CProxy_WorkDistrib(thisgroup))[CkMyPe()+1]).savePatchMap(msg);
1053  } else {
1054  delete msg;
1055  }
1056  return;
1057  }
1058 
1059  patchMapArrived = true;
1060 
1061  int self = CkMyNode();
1062  int range_begin = 0;
1063  int range_end = CkNumNodes();
1064  while ( self != range_begin ) {
1065  ++range_begin;
1066  int split = range_begin + ( range_end - range_begin ) / 2;
1067  if ( self < split ) { range_end = split; }
1068  else { range_begin = split; }
1069  }
1070  int send_near = self + 1;
1071  int send_far = send_near + ( range_end - send_near ) / 2;
1072 
1073  int pids[3];
1074  int npid = 0;
1075  if ( send_far < range_end ) pids[npid++] = CkNodeFirst(send_far);
1076  if ( send_near < send_far ) pids[npid++] = CkNodeFirst(send_near);
1077  pids[npid++] = CkMyPe(); // always send the message to ourselves
1078  CProxy_WorkDistrib(thisgroup).savePatchMap(msg,npid,pids);
1079 }
int isSendSpanningTreeUnset()
void setRecvSpanning()
Definition: ProxyMgr.C:371
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:178
void setSendSpanning()
Definition: ProxyMgr.C:362
char * patchMapData
Definition: WorkDistrib.C:979
void unpack(char *buf)
Definition: PatchMap.C:365
__global__ void const int const TileList *__restrict__ TileExcl *__restrict__ const int *__restrict__ const int const float2 *__restrict__ cudaTextureObject_t const int *__restrict__ const float3 const float3 const float3 const float4 *__restrict__ const float cudaTextureObject_t cudaTextureObject_t float const PatchPairRecord *__restrict__ const int *__restrict__ const int2 *__restrict__ const unsigned int *__restrict__ unsigned int *__restrict__ int *__restrict__ int *__restrict__ TileListStat *__restrict__ const BoundingBox *__restrict__ float *__restrict__ float *__restrict__ float *__restrict__ float *__restrict__ float *__restrict__ float *__restrict__ float *__restrict__ float *__restrict__ const int numPatches
std::vector< std::string > split(const std::string &text, std::string delimiter)
Definition: MoleculeQM.C:73
void savePatchMap(PatchMapMsg *msg)
Definition: WorkDistrib.C:1018
void WorkDistrib::send_contributeHostDeviceLDB ( int  peSetLen,
int *  peSet 
)
static

Definition at line 3395 of file WorkDistrib.C.

3395  {
3396  #if defined(NAMD_MIC)
3397  CProxy_WorkDistrib wdProxy(CkpvAccess(BOCclass_group).workDistrib);
3398  wdProxy[0].contributeHostDeviceLDB(peSetLen, peSet);
3399  #endif
3400 }
void WorkDistrib::send_initHostDeviceLDB ( )
static

Definition at line 3382 of file WorkDistrib.C.

3382  {
3383  #if defined(NAMD_MIC)
3384  CProxy_WorkDistrib wdProxy(CkpvAccess(BOCclass_group).workDistrib);
3385  wdProxy.initHostDeviceLDB();
3386  #endif
3387 }
void WorkDistrib::send_setDeviceLDBParams ( int  dt,
int  hs,
int  sp1,
int  pp1,
int  pp2 
)
static

Definition at line 3408 of file WorkDistrib.C.

3408  {
3409  #if defined(NAMD_MIC)
3410  CProxy_WorkDistrib wdProxy(CkpvAccess(BOCclass_group).workDistrib);
3411  wdProxy.setDeviceLDBParams(dt, hs, sp1, pp1, pp2);
3412  #endif
3413 }
void WorkDistrib::sendComputeMap ( void  )

Definition at line 1082 of file WorkDistrib.C.

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

Referenced by Node::startup().

1083 {
1084  if ( CkMyRank() ) return;
1085 
1086  if ( CkNumNodes() == 1 ) {
1087  computeMapArrived = true;
1089  return;
1090  }
1091 
1092  if ( ! CkMyPe() ) { // send
1093  MOStream *msg = CkpvAccess(comm)->newOutputStream(ALLBUTME, COMPUTEMAPTAG, BUFSIZE);
1094  ComputeMap::Object()->pack(msg);
1095  msg->end();
1096  delete msg;
1097  } else if ( ! CkMyRank() ) { // receive
1098  MIStream *msg = CkpvAccess(comm)->newInputStream(0, COMPUTEMAPTAG);
1099  ComputeMap::Object()->unpack(msg);
1100  delete msg;
1101  }
1102 
1103  computeMapArrived = true;
1105 }
void end(void)
Definition: MStream.C:176
void initPtrs()
Definition: ComputeMap.C:82
#define ALLBUTME
Definition: Communicate.h:14
void pack(MOStream *msg)
Definition: ComputeMap.C:63
#define COMPUTEMAPTAG
Definition: common.h:159
#define BUFSIZE
Definition: Communicate.h:15
static ComputeMap * Object()
Definition: ComputeMap.h:89
void unpack(MIStream *msg)
Definition: ComputeMap.C:70
void WorkDistrib::sendPatchMap ( void  )

Definition at line 982 of file WorkDistrib.C.

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

Referenced by Node::startup().

983 {
984  if ( CkNumPes() == 1 ) {
985  patchMapArrived = true;
986  return;
987  }
988 
989  //Automatically enable spanning tree
990  CProxy_Node nd(CkpvAccess(BOCclass_group).node);
991  Node *node = nd.ckLocalBranch();
992  SimParameters *params = node->simParameters;
993  if( ( PatchMap::Object()->numPatches() <= CkNumPes()/4
994 #ifdef NODEAWARE_PROXY_SPANNINGTREE
995  || CkNumPes() > CkNumNodes()
996  ) && ( CkNumNodes() > 1
997 #endif
998  ) && params->isSendSpanningTreeUnset() )
1000 
1001 #ifdef NODEAWARE_PROXY_SPANNINGTREE
1002  if ( CkNumPes() > CkNumNodes() && CkNumNodes() > 1
1003  && params->isRecvSpanningTreeUnset() )
1005 #endif
1006 
1007  int size = PatchMap::Object()->packSize();
1008 
1009  PatchMapMsg *mapMsg = new (size, 0) PatchMapMsg;
1010 
1011  PatchMap::Object()->pack(mapMsg->patchMapData, size);
1012 
1013  CProxy_WorkDistrib workProxy(thisgroup);
1014  workProxy[0].savePatchMap(mapMsg);
1015 }
int isSendSpanningTreeUnset()
void setRecvSpanning()
Definition: ProxyMgr.C:371
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:178
void setSendSpanning()
Definition: ProxyMgr.C:362
int packSize(void)
Definition: PatchMap.C:314
char * patchMapData
Definition: WorkDistrib.C:979
__global__ void const int const TileList *__restrict__ TileExcl *__restrict__ const int *__restrict__ const int const float2 *__restrict__ cudaTextureObject_t const int *__restrict__ const float3 const float3 const float3 const float4 *__restrict__ const float cudaTextureObject_t cudaTextureObject_t float const PatchPairRecord *__restrict__ const int *__restrict__ const int2 *__restrict__ const unsigned int *__restrict__ unsigned int *__restrict__ int *__restrict__ int *__restrict__ TileListStat *__restrict__ const BoundingBox *__restrict__ float *__restrict__ float *__restrict__ float *__restrict__ float *__restrict__ float *__restrict__ float *__restrict__ float *__restrict__ float *__restrict__ const int numPatches
void pack(char *buf, int size)
Definition: PatchMap.C:328
void WorkDistrib::setDeviceLDBParams ( int  dt,
int  hs,
int  sp1,
int  pp1,
int  pp2 
)

Definition at line 3415 of file WorkDistrib.C.

3415  {
3416  #if defined(NAMD_MIC)
3417  mic_setDeviceLDBParams(dt, hs, sp1, pp1, pp2);
3418  #endif
3419 }
void WorkDistrib::setPatchMapArrived ( bool  s)
inline

Definition at line 107 of file WorkDistrib.h.

Referenced by Node::startup().

107 {patchMapArrived=s;}
void WorkDistrib::sortPmePes ( int *  pmepes,
int  xdim,
int  ydim 
)
static

Definition at line 304 of file WorkDistrib.C.

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

Referenced by ComputePmeMgr::initialize().

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

Member Data Documentation

int * WorkDistrib::peCompactOrdering
static

Definition at line 117 of file WorkDistrib.h.

Referenced by buildNodeAwarePeOrdering().

int * WorkDistrib::peCompactOrderingIndex
static
int * WorkDistrib::peDiffuseOrdering
static
int * WorkDistrib::peDiffuseOrderingIndex
static
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: