WorkDistrib Class Reference

#include <WorkDistrib.h>

List of all members.

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

References eventMachineProgress, and NAMD_bug().

00102 {
00103   CkpvAccess(BOCclass_group).workDistrib = thisgroup;
00104   patchMapArrived = false;
00105   computeMapArrived = false;
00106 
00107 #if CMK_SMP
00108 #define MACHINE_PROGRESS
00109 #else
00110 #define MACHINE_PROGRESS { traceUserEvent(eventMachineProgress);  CmiMachineProgressImpl(); }
00111   if ( CkMyNodeSize() > 1 ) NAMD_bug("CkMyNodeSize() > 1 for non-smp build");
00112   eventMachineProgress = traceRegisterUserEvent("CmiMachineProgressImpl",233);
00113 #endif
00114 }

WorkDistrib::~WorkDistrib ( void   ) 

Definition at line 117 of file WorkDistrib.C.

00118 { }


Member Function Documentation

void WorkDistrib::assignNodeToPatch ( void   ) 

Definition at line 1319 of file WorkDistrib.C.

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

Referenced by Node::startup().

01320 {
01321   PatchMap *patchMap = PatchMap::Object();
01322   int nNodes = Node::Object()->numNodes();
01323   SimParameters *simparam = Node::Object()->simParameters;
01324   if(simparam->simulateInitialMapping) {
01325           nNodes = simparam->simulatedPEs;
01326   }
01327 
01328 #if (CMK_BLUEGENEP | CMK_BLUEGENEL) && USE_TOPOMAP 
01329   TopoManager tmgr;
01330   int numPes = tmgr.getDimNX() * tmgr.getDimNY() * tmgr.getDimNZ();
01331   if (numPes > patchMap->numPatches() && (assignPatchesTopoGridRecBisection() > 0)) {
01332     CkPrintf ("Blue Gene/L topology partitioner finished successfully \n");
01333   }
01334   else
01335 #endif
01336   assignPatchesSpaceFillingCurve();       
01337   
01338   int *nAtoms = new int[nNodes];
01339   int numAtoms=0;
01340   int i;
01341   for(i=0; i < nNodes; i++)
01342     nAtoms[i] = 0;
01343 
01344   for(i=0; i < patchMap->numPatches(); i++)
01345   {
01346     //    iout << iINFO << "Patch " << i << " has " 
01347     //   << patchMap->patch(i)->getNumAtoms() << " atoms and "
01348     //   << patchMap->patch(i)->getNumAtoms() * 
01349     //            patchMap->patch(i)->getNumAtoms() 
01350     //   << " pairs.\n" << endi;         
01351 #ifdef MEM_OPT_VERSION
01352       numAtoms += patchMap->numAtoms(i);
01353       nAtoms[patchMap->node(i)] += patchMap->numAtoms(i);         
01354 #else
01355     if (patchMap->patch(i)) {
01356       numAtoms += patchMap->patch(i)->getNumAtoms();
01357       nAtoms[patchMap->node(i)] += patchMap->patch(i)->getNumAtoms();     
01358     }
01359 #endif
01360   }
01361 
01362   if ( numAtoms != Node::Object()->molecule->numAtoms ) {
01363     for(i=0; i < nNodes; i++)
01364       iout << iINFO << nAtoms[i] << " atoms assigned to node " << i << "\n" << endi;
01365     iout << iINFO << "Assigned " << numAtoms << " atoms but expected " << Node::Object()->molecule->numAtoms << "\n" << endi;
01366     NAMD_die("Incorrect atom count in WorkDistrib::assignNodeToPatch\n");
01367   }
01368 
01369   delete [] nAtoms;
01370  
01371   //  PatchMap::Object()->printPatchMap();
01372 }

void WorkDistrib::buildNodeAwarePeOrdering ( void   )  [static]

Definition at line 176 of file WorkDistrib.C.

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

Referenced by build_ordering().

00176                                            {
00177 
00178  CmiMemLock();
00179  if ( ! peOrderingInit ) {
00180   //CkPrintf("WorkDistrib::buildNodeAwarePeOrdering on pe %d\n", CkMyPe());
00181 
00182   const int numPhys = CmiNumPhysicalNodes();
00183   const int numNode = CmiNumNodes();
00184   const int numPe = CmiNumPes();
00185   ResizeArray<int> numNodeInPhys(numPhys);
00186   ResizeArray<int> rankInPhysOfNode(numNode);
00187 
00188   peDiffuseOrdering = new int[numPe];
00189   peDiffuseOrderingIndex = new int[numPe];
00190   peCompactOrdering = new int[numPe];
00191   peCompactOrderingIndex = new int[numPe];
00192 
00193   int k = 0;
00194   for ( int ph=0; ph<numPhys; ++ph ) {
00195     int *pes, npes;
00196     CmiGetPesOnPhysicalNode(ph, &pes, &npes);
00197     for ( int i=0; i<npes; ++i, ++k ) {
00198       peCompactOrdering[k] = pes[i];
00199     }
00200     numNodeInPhys[ph] = 0;
00201     for ( int i=0, j=0; i<npes; i += CmiNodeSize(CmiNodeOf(pes[i])), ++j ) {
00202       rankInPhysOfNode[CmiNodeOf(pes[i])] = j;
00203       numNodeInPhys[ph] += 1;
00204     }
00205   }
00206 
00207   if ( randtopo && numPhys > 2 ) {
00208     if ( ! CkMyNode() ) {
00209       iout << iWARN << "RANDOMIZING PHYSICAL NODE ORDERING\n" << endi;
00210     }
00211     ResizeArray<int> randPhysOrder(numPhys);
00212     for ( int j=0; j<numPhys; ++j ) {
00213       randPhysOrder[j] = j;
00214     }
00215     Random(314159265).reorder(randPhysOrder.begin()+2, numPhys-2);
00216     for ( int j=0, k=0; j<numPhys; ++j ) {
00217       const int ph = randPhysOrder[j];
00218       int *pes, npes;
00219       CmiGetPesOnPhysicalNode(ph, &pes, &npes);
00220       for ( int i=0; i<npes; ++i, ++k ) {
00221         peCompactOrdering[k] = pes[i];
00222       }
00223     }
00224   }
00225 
00226   for ( int i=0; i<numPe; ++i ) {
00227     peDiffuseOrdering[i] = i;
00228   }
00229   std::sort(peDiffuseOrdering, peDiffuseOrdering+numPe,
00230     pe_sortop_bit_reversed(rankInPhysOfNode.begin()));
00231 
00232   for ( int i=0; i<numPe; ++i ) {
00233     peDiffuseOrderingIndex[peDiffuseOrdering[i]] = i;
00234     peCompactOrderingIndex[peCompactOrdering[i]] = i;
00235   }
00236 
00237   if ( 0 && CmiMyNode() == 0 ) for ( int i=0; i<numPe; ++i ) {
00238     CkPrintf("order %5d %5d %5d %5d %5d\n", i,
00239       peDiffuseOrdering[i],
00240       peDiffuseOrderingIndex[i],
00241       peCompactOrdering[i],
00242       peCompactOrderingIndex[i]);
00243   }
00244 
00245   peOrderingInit = 1;
00246  }
00247  CmiMemUnlock();
00248  peOrderingReady();
00249 
00250 }

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

Definition at line 3397 of file WorkDistrib.C.

03397                                                                    {
03398   #if defined(NAMD_MIC)
03399     mic_contributeHostDeviceLDB(peSetLen, peSet);
03400   #endif
03401 }

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

Definition at line 618 of file WorkDistrib.C.

References ResizeArray< Elem >::add(), SimParameters::alchOn, Lattice::apply_transform(), PatchMap::assignToPatch(), Molecule::atomcharge(), CompAtomExt::atomFixed, HydrogenGroupID::atomID, Molecule::atommass(), atoms, HydrogenGroupID::atomsInGroup, HydrogenGroupID::atomsInMigrationGroup, Molecule::atomvdwtype(), ResizeArray< Elem >::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< Elem >::size(), sortAtomsForPatches(), SimParameters::staticAtomAssignment, atom_constants::status, FullAtom::status, FullAtom::transform, TRUE, CompAtom::vdwType, and FullAtom::velocity.

Referenced by createHomePatches(), and reinitAtoms().

00619 {
00620   int i;
00621   StringList *current;  //  Pointer used to retrieve configuration items
00622   CProxy_Node nd(CkpvAccess(BOCclass_group).node);
00623   Node *node = nd.ckLocalBranch();
00624   PatchMap *patchMap = PatchMap::Object();
00625   CProxy_PatchMgr pm(CkpvAccess(BOCclass_group).patchMgr);
00626   PatchMgr *patchMgr = pm.ckLocalBranch();
00627   SimParameters *params = node->simParameters;
00628   Molecule *molecule = node->molecule;
00629   PDB *pdb = node->pdb;
00630 
00631   int numPatches = patchMap->numPatches();
00632   int numAtoms = pdb->num_atoms();
00633 
00634   Vector *positions = new Position[numAtoms];
00635   Vector *velocities = new Velocity[numAtoms];
00636 
00637  if ( basename ) {
00638   if ( params->binaryOutput ) {
00639     read_binary_file((std::string(basename)+".coor").c_str(), positions, numAtoms);
00640     read_binary_file((std::string(basename)+".vel").c_str(), velocities, numAtoms);
00641   } else {
00642     PDB coorpdb((std::string(basename)+".coor").c_str());
00643     if ( coorpdb.num_atoms() != numAtoms ) {
00644       NAMD_die("Incorrect atom count in coordinate pdb file");
00645     }
00646     coorpdb.get_all_positions(positions);
00647     velocities_from_PDB((std::string(basename)+".vel").c_str(), velocities, numAtoms);
00648   }
00649  } else {
00650   pdb->get_all_positions(positions);
00651 
00652   if ( params->initialTemp < 0.0 ) {
00653     Bool binvels=FALSE;
00654 
00655     //  Reading the veolcities from a PDB
00656     current = node->configList->find("velocities");
00657 
00658     if (current == NULL) {
00659       current = node->configList->find("binvelocities");
00660       binvels = TRUE;
00661     }
00662 
00663     if (!binvels) {
00664       velocities_from_PDB(current->data, velocities, numAtoms);
00665     }
00666     else {
00667       velocities_from_binfile(current->data, velocities, numAtoms);
00668     }
00669   }
00670   else {
00671     // Random velocities for a given temperature
00672     random_velocities(params->initialTemp, molecule, velocities, numAtoms);
00673   }
00674  }
00675 
00676   //  If COMMotion == no, remove center of mass motion
00677   if (!(params->comMove)) {
00678     remove_com_motion(velocities, molecule, numAtoms);
00679   }
00680 
00681   FullAtomList *atoms = new FullAtomList[numPatches];
00682 
00683   const Lattice lattice = params->lattice;
00684 
00685     if ( params->staticAtomAssignment ) {
00686       FullAtomList sortAtoms;
00687       for ( i=0; i < numAtoms; i++ ) {
00688         HydrogenGroupID &h = molecule->hydrogenGroup[i];
00689         if ( ! h.isMP ) continue;
00690         FullAtom a;
00691         a.id = i;
00692         a.migrationGroupSize = h.isMP ? h.atomsInMigrationGroup : 0;
00693         a.position = positions[h.atomID];
00694         sortAtoms.add(a);
00695       } 
00696       int *order = new int[sortAtoms.size()];
00697       for ( i=0; i < sortAtoms.size(); i++ ) {
00698         order[i] = i;
00699       } 
00700       int *breaks = new int[numPatches];
00701       sortAtomsForPatches(order,breaks,sortAtoms.begin(),
00702                         sortAtoms.size(),numAtoms,
00703                         patchMap->gridsize_c(),
00704                         patchMap->gridsize_b(),
00705                         patchMap->gridsize_a());
00706 
00707       i = 0;
00708       for ( int pid = 0; pid < numPatches; ++pid ) {
00709         int iend = breaks[pid];
00710         for ( ; i<iend; ++i ) {
00711           FullAtom &sa = sortAtoms[order[i]];
00712           int mgs = sa.migrationGroupSize;
00713 /*
00714 CkPrintf("patch %d (%d %d %d) has group %d atom %d size %d at %.2f %.2f %.2f\n",
00715           pid, patchMap->index_a(pid), patchMap->index_b(pid), 
00716           patchMap->index_c(pid), order[i], sa.id, mgs,
00717           sa.position.x, sa.position.y, sa.position.z);
00718 */
00719           for ( int k=0; k<mgs; ++k ) {
00720             HydrogenGroupID &h = molecule->hydrogenGroup[sa.id + k];
00721             int aid = h.atomID;
00722             FullAtom a;
00723             a.id = aid;
00724             a.position = positions[aid];
00725             a.velocity = velocities[aid];
00726             a.vdwType = molecule->atomvdwtype(aid);
00727             a.status = molecule->getAtoms()[aid].status;
00728             a.langevinParam = molecule->langevin_param(aid);
00729             a.hydrogenGroupSize = h.isGP ? h.atomsInGroup : 0;
00730             a.migrationGroupSize = h.isMP ? h.atomsInMigrationGroup : 0;
00731             if(params->rigidBonds != RIGID_NONE) {
00732               a.rigidBondLength = molecule->rigid_bond_length(aid);
00733             }else{
00734               a.rigidBondLength = 0.0;
00735             }
00736             atoms[pid].add(a);
00737           }
00738         }
00739 CkPrintf("patch %d (%d %d %d) has %d atoms\n",
00740           pid, patchMap->index_a(pid), patchMap->index_b(pid), 
00741           patchMap->index_c(pid), atoms[pid].size());
00742       }
00743       delete [] order;
00744       delete [] breaks;
00745     } else
00746     {
00747     // split atoms into patches based on migration group and position
00748     int aid, pid=0;
00749     for(i=0; i < numAtoms; i++)
00750       {
00751       // Assign atoms to patches without splitting hydrogen groups.
00752       // We know that the hydrogenGroup array is sorted with group parents
00753       // listed first.  Thus, only change the pid if an atom is a group parent.
00754       HydrogenGroupID &h = molecule->hydrogenGroup[i];
00755       aid = h.atomID;
00756       FullAtom a;
00757       a.id = aid;
00758       a.position = positions[aid];
00759       a.velocity = velocities[aid];
00760       a.vdwType = molecule->atomvdwtype(aid);
00761       a.status = molecule->getAtoms()[aid].status;
00762       a.langevinParam = molecule->langevin_param(aid);
00763       a.hydrogenGroupSize = h.isGP ? h.atomsInGroup : 0;
00764       a.migrationGroupSize = h.isMP ? h.atomsInMigrationGroup : 0;
00765       if(params->rigidBonds != RIGID_NONE) {
00766         a.rigidBondLength = molecule->rigid_bond_length(aid);
00767       }else{
00768         a.rigidBondLength = 0.0;
00769       }
00770       if (h.isMP) {
00771         pid = patchMap->assignToPatch(positions[aid],lattice);
00772       } // else: don't change pid
00773       atoms[pid].add(a);
00774       }
00775     }
00776 
00777   delete [] positions;
00778   delete [] velocities;
00779 
00780   for(i=0; i < numPatches; i++)
00781   {
00782     ScaledPosition center(0.5*(patchMap->min_a(i)+patchMap->max_a(i)),
00783                           0.5*(patchMap->min_b(i)+patchMap->max_b(i)),
00784                           0.5*(patchMap->min_c(i)+patchMap->max_c(i)));
00785 
00786     int n = atoms[i].size();
00787     FullAtom *a = atoms[i].begin();
00788     int j;
00789 //Modifications for alchemical fep
00790     Bool alchOn = params->alchOn;
00791 //fepe
00792     Bool lesOn = params->lesOn;
00793   
00794     Bool pairInteractionOn = params->pairInteractionOn;
00795 
00796     Bool pressureProfileTypes = (params->pressureProfileAtomTypes > 1);
00797 
00798     Transform mother_transform;
00799     for(j=0; j < n; j++)
00800     {
00801       int aid = a[j].id;
00802 
00803       a[j].nonbondedGroupSize = 0;  // must be set based on coordinates
00804 
00805       a[j].atomFixed = molecule->is_atom_fixed(aid) ? 1 : 0;
00806       a[j].fixedPosition = a[j].position;
00807 
00808       if ( a[j].migrationGroupSize ) {
00809        if ( a[j].migrationGroupSize != a[j].hydrogenGroupSize ) {
00810             Position pos = a[j].position;
00811             int mgs = a[j].migrationGroupSize;
00812             int c = 1;
00813             for ( int k=a[j].hydrogenGroupSize; k<mgs;
00814                                 k+=a[j+k].hydrogenGroupSize ) {
00815               pos += a[j+k].position;
00816               ++c;
00817             }
00818             pos *= 1./c;
00819             mother_transform = a[j].transform;  // should be 0,0,0
00820             pos = lattice.nearest(pos,center,&mother_transform);
00821             a[j].position = lattice.apply_transform(a[j].position,mother_transform);
00822             a[j].transform = mother_transform;
00823        } else {
00824         a[j].position = lattice.nearest(
00825                 a[j].position, center, &(a[j].transform));
00826         mother_transform = a[j].transform;
00827        }
00828       } else {
00829         a[j].position = lattice.apply_transform(a[j].position,mother_transform);
00830         a[j].transform = mother_transform;
00831       }
00832 
00833       a[j].mass = molecule->atommass(aid);
00834       // Using double precision division for reciprocal mass.
00835       a[j].recipMass = ( a[j].mass > 0 ? (1. / a[j].mass) : 0 );
00836       a[j].charge = molecule->atomcharge(aid);
00837 
00838 //Modifications for alchemical fep
00839       if ( alchOn || lesOn || pairInteractionOn || pressureProfileTypes) {
00840         a[j].partition = molecule->get_fep_type(aid);
00841       } 
00842       else {
00843         a[j].partition = 0;
00844       }
00845 //fepe
00846 
00847     }
00848 
00849     int size, allfixed, k;
00850     for(j=0; j < n; j+=size) {
00851       size = a[j].hydrogenGroupSize;
00852       if ( ! size ) {
00853         NAMD_bug("Mother atom with hydrogenGroupSize of 0!");
00854       }
00855       allfixed = 1;
00856       for ( k = 0; k < size; ++k ) {
00857         allfixed = ( allfixed && (a[j+k].atomFixed) );
00858       }
00859       for ( k = 0; k < size; ++k ) {
00860         a[j+k].groupFixed = allfixed ? 1 : 0;
00861       }
00862     }
00863 
00864     if ( params->outputPatchDetails ) {
00865       int patchId = i;
00866       int numAtomsInPatch = n;
00867       int numFixedAtomsInPatch = 0;
00868       int numAtomsInFixedGroupsInPatch = 0;
00869       for(j=0; j < n; j++) {
00870         numFixedAtomsInPatch += ( a[j].atomFixed ? 1 : 0 );
00871         numAtomsInFixedGroupsInPatch += ( a[j].groupFixed ? 1 : 0 );
00872       }
00873       iout << "PATCH_DETAILS:"
00874            << " patch " << patchId
00875            << " atoms " << numAtomsInPatch
00876            << " fixed_atoms " << numFixedAtomsInPatch
00877            << " fixed_groups " << numAtomsInFixedGroupsInPatch
00878            << "\n" << endi;
00879     }
00880   }
00881 
00882   return atoms;
00883 
00884 }

void WorkDistrib::createHomePatches ( void   ) 

Definition at line 889 of file WorkDistrib.C.

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

Referenced by Node::startup().

00890 {
00891   int i;
00892   PatchMap *patchMap = PatchMap::Object();
00893   CProxy_PatchMgr pm(CkpvAccess(BOCclass_group).patchMgr);
00894   PatchMgr *patchMgr = pm.ckLocalBranch();
00895 
00896   int numPatches = patchMap->numPatches();
00897 
00898   FullAtomList *atoms = createAtomLists();
00899     
00900 #ifdef MEM_OPT_VERSION
00901 /*  CProxy_Node nd(CkpvAccess(BOCclass_group).node);
00902   Node *node = nd.ckLocalBranch();
00903   node->molecule->delEachAtomSigs();
00904   node->molecule->delMassChargeSpace();
00905 */
00906 #endif
00907 
00908   int maxAtoms = -1;
00909   int maxPatch = -1;
00910   for(i=0; i < numPatches; i++) {
00911     int numAtoms = atoms[i].size();
00912     if ( numAtoms > maxAtoms ) { maxAtoms = numAtoms; maxPatch = i; }
00913   }
00914   iout << iINFO << "LARGEST PATCH (" << maxPatch <<
00915         ") HAS " << maxAtoms << " ATOMS\n" << endi;
00916 
00917   for(i=0; i < numPatches; i++)
00918   {
00919     if ( ! ( i % 100 ) )
00920     {
00921       DebugM(3,"Created " << i << " patches so far.\n");
00922     }
00923 
00924     patchMgr->createHomePatch(i,atoms[i]);
00925   }
00926 
00927   delete [] atoms;
00928 }

void WorkDistrib::distributeHomePatches ( void   ) 

Definition at line 930 of file WorkDistrib.C.

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

Referenced by Node::startup().

00930                                         {
00931   // ref BOC
00932   CProxy_Node nd(CkpvAccess(BOCclass_group).node);
00933   Node *node = nd.ckLocalBranch();
00934   CProxy_PatchMgr pm(CkpvAccess(BOCclass_group).patchMgr);
00935   PatchMgr *patchMgr = pm.ckLocalBranch();
00936   // ref singleton
00937   PatchMap *patchMap = PatchMap::Object();
00938 
00939   // Move patches to the proper node
00940   for(int i=0;i < patchMap->numPatches(); i++)
00941   {
00942     if (patchMap->node(i) != node->myid() )
00943     {
00944       DebugM(3,"patchMgr->movePatch("
00945         << i << "," << patchMap->node(i) << ")\n");
00946       patchMgr->movePatch(i,patchMap->node(i));
00947     }
00948   }
00949   patchMgr->sendMovePatches();
00950 }

void WorkDistrib::doneSaveComputeMap ( CkReductionMsg *  msg  ) 

Definition at line 423 of file WorkDistrib.C.

00423                                                         {
00424   delete msg;
00425 
00426   CkSendMsgBranch(saveComputeMapReturnEP, CkAllocMsg(0,0,0), 0, saveComputeMapReturnChareID);
00427 }

void WorkDistrib::enqueueAngles ( LocalWorkMsg msg  ) 

Definition at line 2968 of file WorkDistrib.C.

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

02968                                                  {
02969   msg->compute->doWork();  MACHINE_PROGRESS
02970   if ( msg->compute->localWorkMsg != msg )
02971     NAMD_bug("WorkDistrib LocalWorkMsg recycling failed!");
02972 }

void WorkDistrib::enqueueAniso ( LocalWorkMsg msg  ) 

Definition at line 2992 of file WorkDistrib.C.

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

02992                                                 {
02993   msg->compute->doWork();  MACHINE_PROGRESS
02994   if ( msg->compute->localWorkMsg != msg )
02995     NAMD_bug("WorkDistrib LocalWorkMsg recycling failed!");
02996 }

void WorkDistrib::enqueueBonds ( LocalWorkMsg msg  ) 

Definition at line 2962 of file WorkDistrib.C.

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

02962                                                 {
02963   msg->compute->doWork();  MACHINE_PROGRESS
02964   if ( msg->compute->localWorkMsg != msg )
02965     NAMD_bug("WorkDistrib LocalWorkMsg recycling failed!");
02966 }

void WorkDistrib::enqueueCrossterms ( LocalWorkMsg msg  ) 

Definition at line 2998 of file WorkDistrib.C.

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

02998                                                      {
02999   msg->compute->doWork();  MACHINE_PROGRESS
03000   if ( msg->compute->localWorkMsg != msg )
03001     NAMD_bug("WorkDistrib LocalWorkMsg recycling failed!");
03002 }

void WorkDistrib::enqueueCUDA ( LocalWorkMsg msg  ) 

Definition at line 3096 of file WorkDistrib.C.

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

03096                                                {
03097   msg->compute->doWork();  MACHINE_PROGRESS
03098   // ComputeNonbondedCUDA *c = msg->compute;
03099   // if ( c->localWorkMsg != msg && c->localWorkMsg2 != msg )
03100   //   NAMD_bug("WorkDistrib LocalWorkMsg recycling failed!");
03101 }

void WorkDistrib::enqueueCUDAP2 ( LocalWorkMsg msg  ) 

Definition at line 3102 of file WorkDistrib.C.

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

03102                                                  {
03103   msg->compute->doWork();  MACHINE_PROGRESS
03104 }

void WorkDistrib::enqueueCUDAP3 ( LocalWorkMsg msg  ) 

Definition at line 3105 of file WorkDistrib.C.

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

03105                                                  {
03106   msg->compute->doWork();  MACHINE_PROGRESS
03107 }

void WorkDistrib::enqueueDihedrals ( LocalWorkMsg msg  ) 

Definition at line 2974 of file WorkDistrib.C.

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

02974                                                     {
02975   msg->compute->doWork();  MACHINE_PROGRESS
02976   if ( msg->compute->localWorkMsg != msg )
02977     NAMD_bug("WorkDistrib LocalWorkMsg recycling failed!");
02978 }

void WorkDistrib::enqueueExcls ( LocalWorkMsg msg  ) 

Definition at line 2956 of file WorkDistrib.C.

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

02956                                                 {
02957   msg->compute->doWork();  MACHINE_PROGRESS
02958   if ( msg->compute->localWorkMsg != msg )
02959     NAMD_bug("WorkDistrib LocalWorkMsg recycling failed!");
02960 }

void WorkDistrib::enqueueGromacsPair ( LocalWorkMsg msg  ) 

Definition at line 3005 of file WorkDistrib.C.

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

03005                                                       {
03006   msg->compute->doWork();
03007   MACHINE_PROGRESS
03008   if ( msg->compute->localWorkMsg != msg )
03009     NAMD_bug("\nWorkDistrib LocalWorkMsg recycling failed! Check enqueueGromacsPair from WorkDistrib.C\n");
03010 }

void WorkDistrib::enqueueImpropers ( LocalWorkMsg msg  ) 

Definition at line 2980 of file WorkDistrib.C.

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

02980                                                     {
02981   msg->compute->doWork();  MACHINE_PROGRESS
02982   if ( msg->compute->localWorkMsg != msg )
02983     NAMD_bug("WorkDistrib LocalWorkMsg recycling failed!");
02984 }

void WorkDistrib::enqueueLCPO ( LocalWorkMsg msg  ) 

Definition at line 3019 of file WorkDistrib.C.

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

03019                                                {
03020   msg->compute->doWork();
03021   if ( msg->compute->localWorkMsg != msg )
03022     NAMD_bug("WorkDistrib LocalWorkMsg recycling failed!");
03023 }

void WorkDistrib::enqueueMIC ( LocalWorkMsg msg  ) 

Definition at line 3126 of file WorkDistrib.C.

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

03126                                               {
03127   msg->compute->doWork();  MACHINE_PROGRESS
03128 }

void WorkDistrib::enqueuePme ( LocalWorkMsg msg  ) 

Definition at line 3013 of file WorkDistrib.C.

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

03013                                               {
03014   msg->compute->doWork();  MACHINE_PROGRESS
03015   if ( msg->compute->localWorkMsg != msg )
03016     NAMD_bug("WorkDistrib LocalWorkMsg recycling failed!");
03017 }

void WorkDistrib::enqueueSelfA1 ( LocalWorkMsg msg  ) 

Definition at line 3024 of file WorkDistrib.C.

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

03024                                                  {
03025   msg->compute->doWork();  MACHINE_PROGRESS
03026   if ( msg->compute->localWorkMsg != msg )
03027     NAMD_bug("WorkDistrib LocalWorkMsg recycling failed!");
03028 }

void WorkDistrib::enqueueSelfA2 ( LocalWorkMsg msg  ) 

Definition at line 3029 of file WorkDistrib.C.

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

03029                                                  {
03030   msg->compute->doWork();  MACHINE_PROGRESS
03031   if ( msg->compute->localWorkMsg != msg )
03032     NAMD_bug("WorkDistrib LocalWorkMsg recycling failed!");
03033 }

void WorkDistrib::enqueueSelfA3 ( LocalWorkMsg msg  ) 

Definition at line 3034 of file WorkDistrib.C.

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

03034                                                  {
03035   msg->compute->doWork();  MACHINE_PROGRESS
03036   if ( msg->compute->localWorkMsg != msg )
03037     NAMD_bug("WorkDistrib LocalWorkMsg recycling failed!");
03038 }

void WorkDistrib::enqueueSelfB1 ( LocalWorkMsg msg  ) 

Definition at line 3040 of file WorkDistrib.C.

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

03040                                                  {
03041   msg->compute->doWork();  MACHINE_PROGRESS
03042   if ( msg->compute->localWorkMsg != msg )
03043     NAMD_bug("WorkDistrib LocalWorkMsg recycling failed!");
03044 }

void WorkDistrib::enqueueSelfB2 ( LocalWorkMsg msg  ) 

Definition at line 3045 of file WorkDistrib.C.

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

03045                                                  {
03046   msg->compute->doWork();  MACHINE_PROGRESS
03047   if ( msg->compute->localWorkMsg != msg )
03048     NAMD_bug("WorkDistrib LocalWorkMsg recycling failed!");
03049 }

void WorkDistrib::enqueueSelfB3 ( LocalWorkMsg msg  ) 

Definition at line 3050 of file WorkDistrib.C.

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

03050                                                  {
03051   msg->compute->doWork();  MACHINE_PROGRESS
03052   if ( msg->compute->localWorkMsg != msg )
03053     NAMD_bug("WorkDistrib LocalWorkMsg recycling failed!");
03054 }

void WorkDistrib::enqueueThole ( LocalWorkMsg msg  ) 

Definition at line 2986 of file WorkDistrib.C.

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

02986                                                 {
02987   msg->compute->doWork();  MACHINE_PROGRESS
02988   if ( msg->compute->localWorkMsg != msg )
02989     NAMD_bug("WorkDistrib LocalWorkMsg recycling failed!");
02990 }

void WorkDistrib::enqueueWork ( LocalWorkMsg msg  ) 

Definition at line 2950 of file WorkDistrib.C.

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

02950                                                {
02951   msg->compute->doWork();  MACHINE_PROGRESS
02952   if ( msg->compute->localWorkMsg != msg )
02953     NAMD_bug("WorkDistrib LocalWorkMsg recycling failed!");
02954 }

void WorkDistrib::enqueueWorkA1 ( LocalWorkMsg msg  ) 

Definition at line 3056 of file WorkDistrib.C.

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

03056                                                  {
03057   msg->compute->doWork();  MACHINE_PROGRESS
03058   if ( msg->compute->localWorkMsg != msg )
03059     NAMD_bug("WorkDistrib LocalWorkMsg recycling failed!");
03060 }

void WorkDistrib::enqueueWorkA2 ( LocalWorkMsg msg  ) 

Definition at line 3061 of file WorkDistrib.C.

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

03061                                                  {
03062   msg->compute->doWork();  MACHINE_PROGRESS
03063   if ( msg->compute->localWorkMsg != msg )
03064     NAMD_bug("WorkDistrib LocalWorkMsg recycling failed!");
03065 }

void WorkDistrib::enqueueWorkA3 ( LocalWorkMsg msg  ) 

Definition at line 3066 of file WorkDistrib.C.

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

03066                                                  {
03067   msg->compute->doWork();  MACHINE_PROGRESS
03068   if ( msg->compute->localWorkMsg != msg )
03069     NAMD_bug("WorkDistrib LocalWorkMsg recycling failed!");
03070 }

void WorkDistrib::enqueueWorkB1 ( LocalWorkMsg msg  ) 

Definition at line 3072 of file WorkDistrib.C.

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

03072                                                  {
03073   msg->compute->doWork();  MACHINE_PROGRESS
03074   if ( msg->compute->localWorkMsg != msg )
03075     NAMD_bug("WorkDistrib LocalWorkMsg recycling failed!");
03076 }

void WorkDistrib::enqueueWorkB2 ( LocalWorkMsg msg  ) 

Definition at line 3077 of file WorkDistrib.C.

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

03077                                                  {
03078   msg->compute->doWork();  MACHINE_PROGRESS
03079   if ( msg->compute->localWorkMsg != msg )
03080     NAMD_bug("WorkDistrib LocalWorkMsg recycling failed!");
03081 }

void WorkDistrib::enqueueWorkB3 ( LocalWorkMsg msg  ) 

Definition at line 3082 of file WorkDistrib.C.

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

03082                                                  {
03083   msg->compute->doWork();  MACHINE_PROGRESS
03084   if ( msg->compute->localWorkMsg != msg )
03085     NAMD_bug("WorkDistrib LocalWorkMsg recycling failed!");
03086 }

void WorkDistrib::enqueueWorkC ( LocalWorkMsg msg  ) 

Definition at line 3090 of file WorkDistrib.C.

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

03090                                                 {
03091   msg->compute->doWork();  MACHINE_PROGRESS
03092   if ( msg->compute->localWorkMsg != msg )
03093     NAMD_bug("WorkDistrib LocalWorkMsg recycling failed!");
03094 }

void WorkDistrib::finishCUDA ( LocalWorkMsg msg  ) 

Definition at line 3113 of file WorkDistrib.C.

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

03113                                               {
03114   msg->compute->doWork();  MACHINE_PROGRESS
03115   // ComputeNonbondedCUDA *c = msg->compute;
03116   // if ( c->localWorkMsg != msg && c->localWorkMsg2 != msg )
03117   //   NAMD_bug("WorkDistrib LocalWorkMsg recycling failed!");
03118 }

void WorkDistrib::finishCUDAP2 ( LocalWorkMsg msg  ) 

Definition at line 3119 of file WorkDistrib.C.

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

03119                                                 {
03120   msg->compute->doWork();  MACHINE_PROGRESS
03121 }

void WorkDistrib::finishCUDAP3 ( LocalWorkMsg msg  ) 

Definition at line 3122 of file WorkDistrib.C.

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

03122                                                 {
03123   msg->compute->doWork();  MACHINE_PROGRESS
03124 }

void WorkDistrib::finishCUDAPatch ( FinishWorkMsg msg  ) 

Definition at line 3109 of file WorkDistrib.C.

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

03109                                                     {
03110   msg->compute->finishPatch(msg->data);
03111 }

void WorkDistrib::finishMIC ( LocalWorkMsg msg  ) 

Definition at line 3129 of file WorkDistrib.C.

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

03129                                              {
03130   msg->compute->doWork();  MACHINE_PROGRESS
03131 }

void WorkDistrib::initHostDeviceLDB (  ) 

Definition at line 3384 of file WorkDistrib.C.

03384                                     {
03385   #if defined(NAMD_MIC)
03386     mic_hostDeviceLDB();
03387   #endif
03388 }

void WorkDistrib::mapComputes ( void   ) 

Definition at line 2269 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(), Node::Object(), ComputeMap::Object(), PatchMap::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().

02270 {
02271   PatchMap *patchMap = PatchMap::Object();
02272   ComputeMap *computeMap = ComputeMap::Object();
02273   CProxy_Node nd(CkpvAccess(BOCclass_group).node);
02274   Node *node = nd.ckLocalBranch();
02275 
02276   DebugM(3,"Mapping computes\n");
02277 
02278   computeMap->allocateCids();
02279 
02280   // Handle full electrostatics
02281   if ( node->simParameters->fullDirectOn )
02282     mapComputeHomePatches(computeFullDirectType);
02283   if ( node->simParameters->FMAOn )
02284 #ifdef DPMTA
02285     mapComputeHomePatches(computeDPMTAType);
02286 #else
02287     NAMD_die("This binary does not include DPMTA (FMA).");
02288 #endif
02289   if ( node->simParameters->PMEOn ) {
02290 #ifdef DPME
02291     if ( node->simParameters->useDPME )
02292       mapComputeHomePatches(computeDPMEType);
02293     else {
02294       mapComputeHomePatches(computePmeType);
02295       if ( node->simParameters->pressureProfileEwaldOn )
02296         mapComputeHomePatches(computeEwaldType);
02297     }
02298 #else
02299 #ifdef NAMD_CUDA
02300     if (node->simParameters->usePMECUDA) {
02301       mapComputePatch(computePmeCUDAType);
02302     } else
02303 #endif
02304     {
02305       mapComputePatch(computePmeType);
02306     }
02307     if ( node->simParameters->pressureProfileEwaldOn )
02308       mapComputeHomePatches(computeEwaldType);
02309 #endif
02310   }
02311 
02312   if ( node->simParameters->globalForcesOn ) {
02313     DebugM(2,"adding ComputeGlobal\n");
02314     mapComputeHomePatches(computeGlobalType);
02315   }
02316 
02317   if ( node->simParameters->extForcesOn )
02318     mapComputeHomePatches(computeExtType);
02319 
02320   if ( node->simParameters->qmForcesOn )
02321     mapComputeHomePatches(computeQMType);
02322 
02323   if ( node->simParameters->GBISserOn )
02324     mapComputeHomePatches(computeGBISserType);
02325 
02326   if ( node->simParameters->MsmSerialOn )
02327     mapComputeHomePatches(computeMsmSerialType);
02328 #ifdef CHARM_HAS_MSA
02329   else if ( node->simParameters->MSMOn )
02330     mapComputeHomePatches(computeMsmMsaType);
02331 #else
02332   else if ( node->simParameters->MSMOn )
02333     mapComputeHomePatches(computeMsmType);
02334 #endif
02335 
02336   if ( node->simParameters->FMMOn )
02337     mapComputeHomePatches(computeFmmType);
02338 
02339 #ifdef NAMD_CUDA
02340 #ifdef BONDED_CUDA
02341   if (node->simParameters->bondedCUDA) {
02342     mapComputeNode(computeBondedCUDAType);
02343   }
02344 #endif
02345 #endif
02346 
02347 #ifdef NAMD_CUDA
02348   if (node->simParameters->useCUDA2) {
02349     mapComputeNode(computeNonbondedCUDA2Type);
02350   } else {
02351     mapComputeNode(computeNonbondedCUDAType);
02352   }
02353   mapComputeHomeTuples(computeExclsType);
02354   mapComputePatch(computeSelfExclsType);
02355 #endif
02356 
02357 #ifdef NAMD_MIC
02358   mapComputeNode(computeNonbondedMICType);
02359 #endif
02360 
02361   mapComputeNonbonded();
02362 
02363   if ( node->simParameters->LCPOOn ) {
02364     mapComputeLCPO();
02365   }
02366 
02367   // If we're doing true pair interactions, no need for bonded terms.
02368   // But if we're doing within-group interactions, we do need them.
02369   if ( !node->simParameters->pairInteractionOn || 
02370       node->simParameters->pairInteractionSelf) { 
02371     mapComputeHomeTuples(computeBondsType);
02372     mapComputeHomeTuples(computeAnglesType);
02373     mapComputeHomeTuples(computeDihedralsType);
02374     mapComputeHomeTuples(computeImpropersType);
02375     mapComputeHomeTuples(computeCrosstermsType);
02376     mapComputePatch(computeSelfBondsType);
02377     mapComputePatch(computeSelfAnglesType);
02378     mapComputePatch(computeSelfDihedralsType);
02379     mapComputePatch(computeSelfImpropersType);
02380     mapComputePatch(computeSelfCrosstermsType);
02381   }
02382 
02383   if ( node->simParameters->goGroPair ) {
02384       // JLai
02385       mapComputeHomeTuples(computeGromacsPairType);
02386       mapComputePatch(computeSelfGromacsPairType);
02387     // End of JLai
02388   }
02389 
02390   if ( node->simParameters->drudeOn ) {
02391     mapComputeHomeTuples(computeTholeType);
02392     mapComputePatch(computeSelfTholeType);
02393     mapComputeHomeTuples(computeAnisoType);
02394     mapComputePatch(computeSelfAnisoType);
02395   }
02396 
02397   if ( node->simParameters->eFieldOn )
02398     mapComputePatch(computeEFieldType);
02399   /* BEGIN gf */
02400   if ( node->simParameters->mgridforceOn )
02401     mapComputePatch(computeGridForceType);
02402   /* END gf */
02403   if ( node->simParameters->stirOn )
02404     mapComputePatch(computeStirType);
02405   if ( node->simParameters->sphericalBCOn )
02406     mapComputePatch(computeSphericalBCType);
02407   if ( node->simParameters->cylindricalBCOn )
02408     mapComputePatch(computeCylindricalBCType);
02409   if ( node->simParameters->tclBCOn ) {
02410     mapComputeHomePatches(computeTclBCType);
02411   }
02412   if ( node->simParameters->constraintsOn )
02413     mapComputePatch(computeRestraintsType);
02414   if ( node->simParameters->consForceOn )
02415     mapComputePatch(computeConsForceType);
02416   if ( node->simParameters->consTorqueOn )
02417     mapComputePatch(computeConsTorqueType);
02418 
02419     // store the latest compute map
02420   SimParameters *simParams = Node::Object()->simParameters;
02421   if (simParams->storeComputeMap) {
02422     computeMap->saveComputeMap(simParams->computeMapFilename);
02423   }
02424     // override mapping decision
02425   if (simParams->loadComputeMap) {
02426     computeMap->loadComputeMap(simParams->computeMapFilename);
02427     CkPrintf("ComputeMap has been loaded from %s.\n", simParams->computeMapFilename);
02428   }
02429 }

void WorkDistrib::messageEnqueueWork ( Compute compute  )  [static]

Definition at line 2727 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(), ComputePmeMgr::submitReductions(), and ComputePmeMgr::ungridCalc().

02727                                                      {
02728   LocalWorkMsg *msg = compute->localWorkMsg;
02729   int seq = compute->sequence();
02730   int gbisPhase = compute->getGBISPhase();
02731 
02732   if ( seq < 0 ) {
02733     NAMD_bug("compute->sequence() < 0 in WorkDistrib::messageEnqueueWork");
02734   } else {
02735     SET_PRIORITY(msg,seq,compute->priority());
02736   }
02737 
02738   msg->compute = compute; // pointer is valid since send is to local Pe
02739   int type = compute->type();
02740   int cid = compute->cid;
02741 
02742   CProxy_WorkDistrib wdProxy(CkpvAccess(BOCclass_group).workDistrib);
02743   switch ( type ) {
02744   case computeExclsType:
02745   case computeSelfExclsType:
02746     wdProxy[CkMyPe()].enqueueExcls(msg);
02747     break;
02748   case computeBondsType:
02749   case computeSelfBondsType:
02750     wdProxy[CkMyPe()].enqueueBonds(msg);
02751     break;
02752   case computeAnglesType:
02753   case computeSelfAnglesType:
02754     wdProxy[CkMyPe()].enqueueAngles(msg);
02755     break;
02756   case computeDihedralsType:
02757   case computeSelfDihedralsType:
02758     wdProxy[CkMyPe()].enqueueDihedrals(msg);
02759     break;
02760   case computeImpropersType:
02761   case computeSelfImpropersType:
02762     wdProxy[CkMyPe()].enqueueImpropers(msg);
02763     break;
02764   case computeTholeType:
02765   case computeSelfTholeType:
02766     wdProxy[CkMyPe()].enqueueThole(msg);
02767     break;
02768   case computeAnisoType:
02769   case computeSelfAnisoType:
02770     wdProxy[CkMyPe()].enqueueAniso(msg);
02771     break;
02772   case computeCrosstermsType:
02773   case computeSelfCrosstermsType:
02774     wdProxy[CkMyPe()].enqueueCrossterms(msg);
02775     break;
02776   // JLai
02777   case computeGromacsPairType:
02778   case computeSelfGromacsPairType:
02779     wdProxy[CkMyPe()].enqueueGromacsPair(msg);
02780     break;    
02781   // End of JLai
02782   case computeLCPOType:
02783     wdProxy[CkMyPe()].enqueueLCPO(msg);
02784     break;
02785   case computeNonbondedSelfType:
02786     switch ( seq % 2 ) {
02787     case 0:
02788       //wdProxy[CkMyPe()].enqueueSelfA(msg);
02789       switch ( gbisPhase ) {
02790          case 1:
02791            wdProxy[CkMyPe()].enqueueSelfA1(msg);
02792            break;
02793          case 2:
02794            wdProxy[CkMyPe()].enqueueSelfA2(msg);
02795            break;
02796          case 3:
02797            wdProxy[CkMyPe()].enqueueSelfA3(msg);
02798            break;
02799       }
02800       break;
02801     case 1:
02802       //wdProxy[CkMyPe()].enqueueSelfB(msg);
02803       switch ( gbisPhase ) {
02804          case 1:
02805            wdProxy[CkMyPe()].enqueueSelfB1(msg);
02806            break;
02807          case 2:
02808            wdProxy[CkMyPe()].enqueueSelfB2(msg);
02809            break;
02810          case 3:
02811            wdProxy[CkMyPe()].enqueueSelfB3(msg);
02812            break;
02813       }
02814       break;
02815     default:
02816       NAMD_bug("WorkDistrib::messageEnqueueSelf case statement error!");
02817     }
02818     break;
02819   case computeNonbondedPairType:
02820     switch ( seq % 2 ) {
02821     case 0:
02822       //wdProxy[CkMyPe()].enqueueWorkA(msg);
02823       switch ( gbisPhase ) {
02824          case 1:
02825            wdProxy[CkMyPe()].enqueueWorkA1(msg);
02826            break;
02827          case 2:
02828            wdProxy[CkMyPe()].enqueueWorkA2(msg);
02829            break;
02830          case 3:
02831            wdProxy[CkMyPe()].enqueueWorkA3(msg);
02832            break;
02833       }
02834       break;
02835     case 1:
02836       //wdProxy[CkMyPe()].enqueueWorkB(msg);
02837       switch ( gbisPhase ) {
02838          case 1:
02839            wdProxy[CkMyPe()].enqueueWorkB1(msg);
02840            break;
02841          case 2:
02842            wdProxy[CkMyPe()].enqueueWorkB2(msg);
02843            break;
02844          case 3:
02845            wdProxy[CkMyPe()].enqueueWorkB3(msg);
02846            break;
02847       }
02848       break;
02849     case 2:
02850       wdProxy[CkMyPe()].enqueueWorkC(msg);
02851       break;
02852     default:
02853       NAMD_bug("WorkDistrib::messageEnqueueWork case statement error!");
02854     }
02855     break;
02856   case computeNonbondedCUDAType:
02857 #ifdef NAMD_CUDA
02858   case computeNonbondedCUDA2Type:
02859 //     CkPrintf("WorkDistrib[%d]::CUDA seq=%d phase=%d\n", CkMyPe(), seq, gbisPhase);
02860     //wdProxy[CkMyPe()].enqueueCUDA(msg);
02861     switch ( gbisPhase ) {
02862        case 1:
02863          wdProxy[CkMyPe()].enqueueCUDA(msg);
02864          break;
02865        case 2:
02866          wdProxy[CkMyPe()].enqueueCUDAP2(msg);
02867          break;
02868        case 3:
02869          wdProxy[CkMyPe()].enqueueCUDAP3(msg);
02870          break;
02871     }
02872 #else
02873     msg->compute->doWork();  MACHINE_PROGRESS
02874 #endif
02875     break;
02876   case computeNonbondedMICType:
02877 #ifdef NAMD_MIC
02878     wdProxy[CkMyPe()].enqueueMIC(msg);
02879 #endif
02880     break;
02881   case computePmeType:
02882     // CkPrintf("PME %d %d %x\n", CkMyPe(), seq, compute->priority());
02883     wdProxy[CkMyPe()].enqueuePme(msg);
02884     break;
02885 #ifdef NAMD_CUDA
02886   case computePmeCUDAType:
02887     wdProxy[CkMyPe()].enqueuePme(msg);
02888     break;
02889 #endif
02890   default:
02891     wdProxy[CkMyPe()].enqueueWork(msg);
02892   }
02893 }

void WorkDistrib::messageFinishCUDA ( Compute compute  )  [static]

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

02896                                                     {
02897   LocalWorkMsg *msg = compute->localWorkMsg;
02898   int seq = compute->sequence();
02899   int gbisPhase = compute->getGBISPhase();
02900 
02901   if ( seq < 0 ) {
02902     NAMD_bug("compute->sequence() < 0 in WorkDistrib::messageEnqueueWork");
02903   } else {
02904     SET_PRIORITY(msg,seq,compute->priority());
02905   }
02906 
02907   msg->compute = compute; // pointer is valid since send is to local Pe
02908   CProxy_WorkDistrib wdProxy(CkpvAccess(BOCclass_group).workDistrib);
02909 
02910 #ifdef NAMD_CUDA
02911     //wdProxy[CkMyPe()].finishCUDA(msg);
02912     switch ( gbisPhase ) {
02913        case 1:
02914          wdProxy[CkMyPe()].finishCUDA(msg);
02915          break;
02916        case 2:
02917          wdProxy[CkMyPe()].finishCUDAP2(msg);
02918          break;
02919        case 3:
02920          wdProxy[CkMyPe()].finishCUDAP3(msg);
02921          break;
02922     }
02923 #else
02924     msg->compute->doWork();  MACHINE_PROGRESS
02925 #endif
02926 }

void WorkDistrib::messageFinishMIC ( Compute compute  )  [static]

Definition at line 2929 of file WorkDistrib.C.

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

02929                                                    {
02930   LocalWorkMsg *msg = compute->localWorkMsg;
02931   int seq = compute->sequence();
02932   int gbisPhase = compute->getGBISPhase();
02933 
02934   if ( seq < 0 ) {
02935     NAMD_bug("compute->sequence() < 0 in WorkDistrib::messageFinishMIC");
02936   } else {
02937     SET_PRIORITY(msg,seq,compute->priority());
02938   }
02939 
02940   msg->compute = compute; // pointer is valid since send is to local Pe
02941   CProxy_WorkDistrib wdProxy(CkpvAccess(BOCclass_group).workDistrib);
02942 
02943 #ifdef NAMD_MIC
02944     wdProxy[CkMyPe()].finishMIC(msg);
02945 #else
02946     msg->compute->doWork();  MACHINE_PROGRESS
02947 #endif
02948 }

void WorkDistrib::patchMapInit ( void   ) 

Definition at line 1105 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, Node::Object(), PatchMap::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().

01106 {
01107   PatchMap *patchMap = PatchMap::Object();
01108   CProxy_Node nd(CkpvAccess(BOCclass_group).node);
01109   Node *node = nd.ckLocalBranch();
01110   SimParameters *params = node->simParameters;
01111   Lattice lattice = params->lattice;
01112 
01113   BigReal patchSize = params->patchDimension;
01114 
01115 #ifndef MEM_OPT_VERSION
01116   const int totalAtoms = node->pdb->num_atoms();
01117 #else
01118   const int totalAtoms = node->molecule->numAtoms;
01119 #endif
01120 
01121   ScaledPosition xmin, xmax;
01122 
01123   double maxNumPatches = 1.e9;  // need to adjust fractional values
01124   if ( params->minAtomsPerPatch > 0 )
01125     maxNumPatches = totalAtoms / params->minAtomsPerPatch;
01126 
01127   DebugM(3,"Mapping patches\n");
01128   if ( lattice.a_p() && lattice.b_p() && lattice.c_p() ) {
01129     xmin = 0.;  xmax = 0.;
01130   }
01131   else if ( params->FMAOn || params->MSMOn || params->FMMOn ) {
01132   // Need to use full box for FMA to match NAMD 1.X results.
01133 #if 0
01134     node->pdb->find_extremes(&(xmin.x),&(xmax.x),lattice.a_r());
01135     node->pdb->find_extremes(&(xmin.y),&(xmax.y),lattice.b_r());
01136     node->pdb->find_extremes(&(xmin.z),&(xmax.z),lattice.c_r());
01137 #endif
01138     node->pdb->find_extremes(lattice);
01139     node->pdb->get_extremes(xmin, xmax);
01140 #if 0
01141     printf("+++ center=%.4f %.4f %.4f\n",
01142         lattice.origin().x, lattice.origin().y, lattice.origin().z);
01143     printf("+++ xmin=%.4f  xmax=%.4f\n", xmin.x, xmax.x);
01144     printf("+++ ymin=%.4f  ymax=%.4f\n", xmin.y, xmax.y);
01145     printf("+++ zmin=%.4f  zmax=%.4f\n", xmin.z, xmax.z);
01146 #endif
01147   // Otherwise, this allows a small number of stray atoms.
01148   }
01149   else {
01150 #if 0
01151     node->pdb->find_extremes(&(xmin.x),&(xmax.x),lattice.a_r(),0.9);
01152     node->pdb->find_extremes(&(xmin.y),&(xmax.y),lattice.b_r(),0.9);
01153     node->pdb->find_extremes(&(xmin.z),&(xmax.z),lattice.c_r(),0.9);
01154 #endif
01155     node->pdb->find_extremes(lattice, 1.0);
01156     node->pdb->get_extremes(xmin, xmax);
01157     iout << iINFO << "ORIGINAL ATOMS MINMAX IS " << xmin << "  " << xmax << "\n" << endi;
01158     double frac = ( (double)totalAtoms - 10000. ) / (double)totalAtoms;
01159     if ( frac < 0.9 ) { frac = 0.9; }
01160     node->pdb->find_extremes(lattice, frac);
01161     node->pdb->get_extremes(xmin, xmax);
01162     iout << iINFO << "ADJUSTED ATOMS MINMAX IS " << xmin << "  " << xmax << "\n" << endi;
01163   }
01164 
01165 #if 0
01166   BigReal origin_shift;
01167   origin_shift = lattice.a_r() * lattice.origin();
01168   xmin.x -= origin_shift;
01169   xmax.x -= origin_shift;
01170   origin_shift = lattice.b_r() * lattice.origin();
01171   xmin.y -= origin_shift;
01172   xmax.y -= origin_shift;
01173   origin_shift = lattice.c_r() * lattice.origin();
01174   xmin.z -= origin_shift;
01175   xmax.z -= origin_shift;
01176 #endif
01177 
01178   // SimParameters default is -1 for unset
01179   int twoAwayX = params->twoAwayX;
01180   int twoAwayY = params->twoAwayY;
01181   int twoAwayZ = params->twoAwayZ;
01182 
01183   // SASA implementation is not compatible with twoAway patches
01184   if (params->LCPOOn && patchSize < 32.4) {
01185     if ( twoAwayX > 0 || twoAwayY > 0 || twoAwayZ > 0 ) {
01186       iout << iWARN << "Ignoring twoAway[XYZ] due to LCPO SASA implementation.\n" << endi;
01187     }
01188     twoAwayX = twoAwayY = twoAwayZ = 0;
01189   }
01190 
01191   // if you think you know what you're doing go right ahead
01192   if ( twoAwayX > 0 ) maxNumPatches = 1.e9;
01193   if ( twoAwayY > 0 ) maxNumPatches = 1.e9;
01194   if ( twoAwayZ > 0 ) maxNumPatches = 1.e9;
01195   if ( params->maxPatches > 0 ) {
01196       maxNumPatches = params->maxPatches;
01197       iout << iINFO << "LIMITING NUMBER OF PATCHES TO " <<
01198                                 maxNumPatches << "\n" << endi;
01199   }
01200 
01201   int numpes = CkNumPes();
01202   SimParameters *simparam = Node::Object()->simParameters;
01203   if(simparam->simulateInitialMapping) {
01204     numpes = simparam->simulatedPEs;
01205     delete [] patchMap->nPatchesOnNode;
01206     patchMap->nPatchesOnNode = new int[numpes];
01207     memset(patchMap->nPatchesOnNode, 0, numpes*sizeof(int));    
01208   }
01209 
01210 #if defined(NAMD_CUDA) || defined(NAMD_MIC)
01211   // for CUDA be sure there are more patches than pes
01212 
01213   int numPatches = patchMap->sizeGrid(
01214         xmin,xmax,lattice,patchSize,maxNumPatches,params->staticAtomAssignment,
01215         twoAwayX>0 ? 2 : 1, twoAwayY>0 ? 2 : 1, twoAwayZ>0 ? 2 : 1);
01216   if ( numPatches < numpes && twoAwayX < 0 ) {
01217     twoAwayX = 1;
01218     numPatches = patchMap->sizeGrid(
01219         xmin,xmax,lattice,patchSize,maxNumPatches,params->staticAtomAssignment,
01220         twoAwayX>0 ? 2 : 1, twoAwayY>0 ? 2 : 1, twoAwayZ>0 ? 2 : 1);
01221   }
01222   if ( numPatches < numpes && twoAwayY < 0 ) {
01223     twoAwayY = 1;
01224     numPatches = patchMap->sizeGrid(
01225         xmin,xmax,lattice,patchSize,maxNumPatches,params->staticAtomAssignment,
01226         twoAwayX>0 ? 2 : 1, twoAwayY>0 ? 2 : 1, twoAwayZ>0 ? 2 : 1);
01227   }
01228   if ( numPatches < numpes && twoAwayZ < 0 ) {
01229     twoAwayZ = 1;
01230     numPatches = patchMap->sizeGrid(
01231         xmin,xmax,lattice,patchSize,maxNumPatches,params->staticAtomAssignment,
01232         twoAwayX>0 ? 2 : 1, twoAwayY>0 ? 2 : 1, twoAwayZ>0 ? 2 : 1);
01233   }
01234   if ( numPatches < numpes ) {
01235     #if defined(NAMD_MIC)
01236     NAMD_die("MIC-enabled NAMD requires at least one patch per thread.");
01237     #endif
01238   }
01239   if ( numPatches % numpes && numPatches <= 1.4 * numpes ) {
01240     int exactFit = numPatches - numPatches % numpes;
01241     int newNumPatches = patchMap->sizeGrid(
01242         xmin,xmax,lattice,patchSize,exactFit,params->staticAtomAssignment,
01243         twoAwayX>0 ? 2 : 1, twoAwayY>0 ? 2 : 1, twoAwayZ>0 ? 2 : 1);
01244     if ( newNumPatches == exactFit ) {
01245       iout << iINFO << "REDUCING NUMBER OF PATCHES TO IMPROVE LOAD BALANCE\n" << endi;
01246       maxNumPatches = exactFit;
01247     }
01248   }
01249 
01250   patchMap->makePatches(xmin,xmax,lattice,patchSize,maxNumPatches,
01251         params->staticAtomAssignment, params->replicaUniformPatchGrids, params->LCPOOn,
01252         twoAwayX>0 ? 2 : 1, twoAwayY>0 ? 2 : 1, twoAwayZ>0 ? 2 : 1);
01253 
01254 #else
01255 
01256   int availPes = numpes;
01257   if ( params->noPatchesOnZero && numpes > 1 ) {
01258       availPes -= 1;
01259       if(params->noPatchesOnOne && numpes > 2)
01260         availPes -= 1;
01261   }
01262 #ifdef MEM_OPT_VERSION
01263   if(params->noPatchesOnOutputPEs && numpes - params->numoutputprocs >2)
01264     {
01265       availPes -= params->numoutputprocs;
01266       if ( params->noPatchesOnZero && numpes > 1 && isOutputProcessor(0)){
01267         availPes++;
01268       }
01269       if ( params->noPatchesOnOne && numpes > 2 && isOutputProcessor(1)){
01270         availPes++;
01271       }
01272     }
01273 #endif
01274 
01275   int numPatches = patchMap->sizeGrid(
01276         xmin,xmax,lattice,patchSize,1.e9,params->staticAtomAssignment,
01277         twoAwayX ? 2 : 1, twoAwayY ? 2 : 1, twoAwayZ ? 2 : 1);
01278   if ( ( numPatches > (0.3*availPes) || numPatches > maxNumPatches
01279        ) && twoAwayZ < 0 ) {
01280     twoAwayZ = 0;
01281     numPatches = patchMap->sizeGrid(
01282         xmin,xmax,lattice,patchSize,1.e9,params->staticAtomAssignment,
01283         twoAwayX ? 2 : 1, twoAwayY ? 2 : 1, twoAwayZ ? 2 : 1);
01284   }
01285   if ( ( numPatches > (0.6*availPes) || numPatches > maxNumPatches
01286        ) && twoAwayY < 0 ) {
01287     twoAwayY = 0;
01288     numPatches = patchMap->sizeGrid(
01289         xmin,xmax,lattice,patchSize,1.e9,params->staticAtomAssignment,
01290         twoAwayX ? 2 : 1, twoAwayY ? 2 : 1, twoAwayZ ? 2 : 1);
01291   }
01292   if ( ( numPatches > availPes || numPatches > maxNumPatches
01293        ) && twoAwayX < 0 ) {
01294     twoAwayX = 0;
01295     numPatches = patchMap->sizeGrid(
01296         xmin,xmax,lattice,patchSize,1.e9,params->staticAtomAssignment,
01297         twoAwayX ? 2 : 1, twoAwayY ? 2 : 1, twoAwayZ ? 2 : 1);
01298   }
01299   if ( numPatches > availPes && numPatches <= (1.4*availPes) && availPes <= maxNumPatches ) {
01300     int newNumPatches = patchMap->sizeGrid(
01301         xmin,xmax,lattice,patchSize,availPes,params->staticAtomAssignment,
01302         twoAwayX ? 2 : 1, twoAwayY ? 2 : 1, twoAwayZ ? 2 : 1);
01303     if ( newNumPatches <= availPes && numPatches <= (1.4*newNumPatches) ) {
01304       iout << iINFO << "REDUCING NUMBER OF PATCHES TO IMPROVE LOAD BALANCE\n" << endi;
01305       maxNumPatches = availPes;
01306     }
01307   }
01308 
01309   patchMap->makePatches(xmin,xmax,lattice,patchSize,maxNumPatches,
01310         params->staticAtomAssignment, params->replicaUniformPatchGrids, params->LCPOOn,
01311         twoAwayX ? 2 : 1, twoAwayY ? 2 : 1, twoAwayZ ? 2 : 1);
01312 
01313 #endif
01314 
01315 }

void WorkDistrib::peOrderingReady (  )  [static]

Definition at line 166 of file WorkDistrib.C.

References cuda_initialize(), and mic_initialize().

Referenced by buildNodeAwarePeOrdering().

00166                                   {
00167   //CkPrintf("WorkDistrib::peOrderingReady on %d\n", CkMyPe());
00168 #ifdef NAMD_CUDA
00169   cuda_initialize();
00170 #endif
00171 #ifdef NAMD_MIC
00172   mic_initialize();
00173 #endif
00174 }

void WorkDistrib::recvComputeMapChanges ( ComputeMapChangeMsg msg  ) 

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

00370                                                                 {
00371 
00372   delete msg;
00373 
00374   ComputeMap *computeMap = ComputeMap::Object();
00375 
00376   int i;
00377   int nc = computeMap->numComputes();
00378   
00379   if ( ! CkMyPe() ) { // send
00380     // CkPrintf("At %f on %d WorkDistrib::recvComputeMapChanges %d\n", CmiWallTimer(), CkMyPe(), nc);
00381     MOStream *msg = CkpvAccess(comm)->newOutputStream(ALLBUTME, COMPUTEMAPTAG, BUFSIZE);
00382     msg->put(nc);
00383     for (i=0; i<nc; i++) {
00384       int data = computeMap->newNode(i);
00385       msg->put(data);
00386     }
00387     msg->put(nc);
00388     for (i=0; i<nc; i++) {
00389       char data = computeMap->newNumPartitions(i);
00390       msg->put(data);
00391     }
00392     msg->put(nc);
00393     msg->end();
00394     delete msg;
00395     // CkPrintf("At %f on %d done WorkDistrib::recvComputeMapChanges %d\n", CmiWallTimer(), CkMyPe(), nc);
00396   } else if ( ! CkMyRank() ) { // receive
00397     // if ( CkMyNode() == 1 ) CkPrintf("At %f on %d WorkDistrib::recvComputeMapChanges %d\n", CmiWallTimer(), CkMyPe(), nc);
00398     MIStream *msg = CkpvAccess(comm)->newInputStream(0, COMPUTEMAPTAG);
00399     msg->get(i);
00400     if ( i != nc ) NAMD_bug("WorkDistrib::recvComputeMapChanges check 1 failed\n");
00401     for (i=0; i<nc; i++) {
00402       int data;
00403       msg->get(data);
00404       computeMap->setNewNode(i,data);
00405     }
00406     msg->get(i);
00407     if ( i != nc ) NAMD_bug("WorkDistrib::recvComputeMapChanges check 2 failed\n");
00408     for (i=0; i<nc; i++) {
00409       char data;
00410       msg->get(data);
00411       computeMap->setNewNumPartitions(i,data);
00412     }
00413     msg->get(i);
00414     if ( i != nc ) NAMD_bug("WorkDistrib::recvComputeMapChanges check 3 failed\n");
00415     delete msg;
00416     // if ( CkMyNode() == 1 ) CkPrintf("At %f on %d done WorkDistrib::recvComputeMapChanges %d\n", CmiWallTimer(), CkMyPe(), nc);
00417   }
00418 
00419   CkCallback cb(CkIndex_WorkDistrib::doneSaveComputeMap(NULL), 0, thisgroup);
00420   contribute(0, NULL, CkReduction::random, cb);
00421 }

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

Definition at line 952 of file WorkDistrib.C.

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

00952                                                   {
00953 
00954   PatchMap *patchMap = PatchMap::Object();
00955   CProxy_PatchMgr pm(CkpvAccess(BOCclass_group).patchMgr);
00956   PatchMgr *patchMgr = pm.ckLocalBranch();
00957 
00958   int numPatches = patchMap->numPatches();
00959 
00960   FullAtomList *atoms = createAtomLists(basename);
00961 
00962   for(int i=0; i < numPatches; i++) {
00963     patchMgr->sendAtoms(i,atoms[i]);
00964   }
00965 
00966   delete [] atoms;
00967 
00968 }

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

Definition at line 352 of file WorkDistrib.C.

Referenced by ComputeMgr::updateComputes2().

00353 {
00354   saveComputeMapReturnEP = ep;
00355   saveComputeMapReturnChareID = chareID;
00356 
00357   ComputeMapChangeMsg *mapMsg = new (0, 0, 0) ComputeMapChangeMsg;
00358   CProxy_WorkDistrib(thisgroup).recvComputeMapChanges(mapMsg);
00359 
00360 /*
00361     // store the latest compute map
00362   SimParameters *simParams = Node::Object()->simParameters;
00363   if (simParams->storeComputeMap) {
00364     computeMap->saveComputeMap(simParams->computeMapFilename);
00365     CkPrintf("ComputeMap has been stored in %s.\n", simParams->computeMapFilename);
00366   }
00367 */
00368 }

void WorkDistrib::savePatchMap ( PatchMapMsg msg  ) 

Definition at line 1014 of file WorkDistrib.C.

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

01015 {
01016   // Use a resend to forward messages before processing.  Otherwise the
01017   // map distribution is slow on many CPUs.  We need to use a tree
01018   // rather than a broadcast because some implementations of broadcast
01019   // generate a copy of the message on the sender for each recipient.
01020   // This is because MPI doesn't allow re-use of an outstanding buffer.
01021 
01022   if ( CkMyRank() ) patchMapArrived = true;
01023 
01024   if ( patchMapArrived && CkMyPe() ) {
01025     PatchMap::Object()->unpack(msg->patchMapData);
01026 
01027     //Automatically enable spanning tree
01028     CProxy_Node nd(CkpvAccess(BOCclass_group).node);
01029     Node *node = nd.ckLocalBranch();
01030     SimParameters *params = node->simParameters;
01031     if( ( PatchMap::Object()->numPatches() <= CkNumPes()/4
01032 #ifdef NODEAWARE_PROXY_SPANNINGTREE 
01033         || CkNumPes() > CkNumNodes()
01034         ) && ( CkNumNodes() > 1
01035 #endif
01036       ) && params->isSendSpanningTreeUnset() )
01037       ProxyMgr::Object()->setSendSpanning();
01038 
01039 #ifdef NODEAWARE_PROXY_SPANNINGTREE 
01040     if ( CkNumPes() > CkNumNodes() && CkNumNodes() > 1
01041           && params->isRecvSpanningTreeUnset() )
01042       ProxyMgr::Object()->setRecvSpanning();
01043 #endif
01044   }
01045 
01046   if ( patchMapArrived ) {
01047     if ( CkMyRank() + 1 < CkNodeSize(CkMyNode()) ) {
01048       ((CProxy_WorkDistrib(thisgroup))[CkMyPe()+1]).savePatchMap(msg);
01049     } else {
01050       delete msg;
01051     }
01052     return;
01053   }
01054 
01055   patchMapArrived = true;
01056 
01057   int self = CkMyNode();
01058   int range_begin = 0;
01059   int range_end = CkNumNodes();
01060   while ( self != range_begin ) {
01061     ++range_begin;
01062     int split = range_begin + ( range_end - range_begin ) / 2;
01063     if ( self < split ) { range_end = split; }
01064     else { range_begin = split; }
01065   }
01066   int send_near = self + 1;
01067   int send_far = send_near + ( range_end - send_near ) / 2;
01068 
01069   int pids[3];
01070   int npid = 0;
01071   if ( send_far < range_end ) pids[npid++] = CkNodeFirst(send_far);
01072   if ( send_near < send_far ) pids[npid++] = CkNodeFirst(send_near);
01073   pids[npid++] = CkMyPe();  // always send the message to ourselves
01074   CProxy_WorkDistrib(thisgroup).savePatchMap(msg,npid,pids);
01075 }

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

Definition at line 3390 of file WorkDistrib.C.

03390                                                                         {
03391   #if defined(NAMD_MIC)
03392     CProxy_WorkDistrib wdProxy(CkpvAccess(BOCclass_group).workDistrib);
03393     wdProxy[0].contributeHostDeviceLDB(peSetLen, peSet);
03394   #endif
03395 }

void WorkDistrib::send_initHostDeviceLDB (  )  [static]

Definition at line 3377 of file WorkDistrib.C.

03377                                          {
03378   #if defined(NAMD_MIC)
03379     CProxy_WorkDistrib wdProxy(CkpvAccess(BOCclass_group).workDistrib);
03380     wdProxy.initHostDeviceLDB();
03381   #endif
03382 }

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

Definition at line 3403 of file WorkDistrib.C.

03403                                                                                    {
03404   #if defined(NAMD_MIC)
03405     CProxy_WorkDistrib wdProxy(CkpvAccess(BOCclass_group).workDistrib);
03406     wdProxy.setDeviceLDBParams(dt, hs, sp1, pp1, pp2);
03407   #endif
03408 }

void WorkDistrib::sendComputeMap ( void   ) 

Definition at line 1078 of file WorkDistrib.C.

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

Referenced by Node::startup().

01079 {
01080   if ( CkMyRank() ) return;
01081 
01082   if ( CkNumNodes() == 1 ) {
01083     computeMapArrived = true;
01084     ComputeMap::Object()->initPtrs();
01085     return;
01086   }
01087 
01088   if ( ! CkMyPe() ) { // send
01089     MOStream *msg = CkpvAccess(comm)->newOutputStream(ALLBUTME, COMPUTEMAPTAG, BUFSIZE);
01090     ComputeMap::Object()->pack(msg);
01091     msg->end();
01092     delete msg;
01093   } else if ( ! CkMyRank() ) { // receive
01094     MIStream *msg = CkpvAccess(comm)->newInputStream(0, COMPUTEMAPTAG);
01095     ComputeMap::Object()->unpack(msg);
01096     delete msg;
01097   }
01098 
01099   computeMapArrived = true;
01100   ComputeMap::Object()->initPtrs();
01101 }

void WorkDistrib::sendPatchMap ( void   ) 

Definition at line 978 of file WorkDistrib.C.

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

Referenced by Node::startup().

00979 {
00980   if ( CkNumPes() == 1 ) {
00981     patchMapArrived = true;
00982     return;
00983   }
00984 
00985   //Automatically enable spanning tree
00986   CProxy_Node nd(CkpvAccess(BOCclass_group).node);
00987   Node *node = nd.ckLocalBranch();
00988   SimParameters *params = node->simParameters;
00989   if( ( PatchMap::Object()->numPatches() <= CkNumPes()/4
00990 #ifdef NODEAWARE_PROXY_SPANNINGTREE 
00991       || CkNumPes() > CkNumNodes()
00992       ) && ( CkNumNodes() > 1
00993 #endif
00994     ) && params->isSendSpanningTreeUnset() )
00995     ProxyMgr::Object()->setSendSpanning();
00996 
00997 #ifdef NODEAWARE_PROXY_SPANNINGTREE 
00998   if ( CkNumPes() > CkNumNodes() && CkNumNodes() > 1
00999         && params->isRecvSpanningTreeUnset() )
01000     ProxyMgr::Object()->setRecvSpanning();
01001 #endif
01002 
01003   int size = PatchMap::Object()->packSize();
01004 
01005   PatchMapMsg *mapMsg = new (size, 0) PatchMapMsg;
01006 
01007   PatchMap::Object()->pack(mapMsg->patchMapData, size);
01008 
01009   CProxy_WorkDistrib workProxy(thisgroup);
01010   workProxy[0].savePatchMap(mapMsg);
01011 }

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

Definition at line 3410 of file WorkDistrib.C.

03410                                                                               {
03411   #if defined(NAMD_MIC)
03412     mic_setDeviceLDBParams(dt, hs, sp1, pp1, pp2);
03413   #endif
03414 }

void WorkDistrib::setPatchMapArrived ( bool  s  )  [inline]

Definition at line 107 of file WorkDistrib.h.

Referenced by Node::startup().

00107 {patchMapArrived=s;}

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

Definition at line 300 of file WorkDistrib.C.

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

Referenced by ComputePmeMgr::initialize().

00300                                                             {
00301   int numpes = CkNumPes();
00302   ResizeArray<int> count(numpes);
00303   ResizeArray<ScaledPosition> sumPos(numpes);
00304   ResizeArray<ScaledPosition> avgPos(numpes);
00305   for ( int i=0; i<numpes; ++i ) {
00306     count[i] = 0;
00307     sumPos[i] = 0;
00308     avgPos[i] = 0;
00309   }
00310   PatchMap *patchMap = PatchMap::Object();
00311   for ( int i=0, npatches=patchMap->numPatches(); i<npatches; ++i ) {
00312     int pe = patchMap->node(i);
00313     count[pe] += 1;
00314     sumPos[pe] += patchMap->center(i);
00315   }
00316   const int npmepes = xdim*ydim;
00317   ResizeArray<int> sortpes(npmepes);
00318   for ( int i=0; i<npmepes; ++i ) {
00319     int pe = sortpes[i] = pmepes[i];
00320     int cnt = count[pe];
00321     ScaledPosition sum = sumPos[pe];
00322     if ( cnt == 0 ) {
00323       // average over node
00324       int node = CkNodeOf(pe);
00325       int nsize = CkNodeSize(node);
00326       int pe2 = CkNodeFirst(node);
00327       for ( int j=0; j<nsize; ++j, ++pe2 )  {
00328         cnt += count[pe2];
00329         sum += sumPos[pe2];
00330       }
00331     }
00332     if ( cnt == 0 ) {
00333       // average over physical node
00334       int node = CmiPhysicalNodeID(pe);
00335       int nsize, *nlist;
00336       CmiGetPesOnPhysicalNode(node, &nlist, &nsize);
00337       for ( int j=0; j<nsize; ++j )  {
00338         int pe2 = nlist[j];
00339         cnt += count[pe2];
00340         sum += sumPos[pe2];
00341       }
00342     }
00343     if ( cnt ) {
00344       avgPos[pe] = sum / cnt;
00345     }
00346   }
00347   recursive_bisect_coord(0, xdim, 0, ydim, sortpes.begin(), avgPos.begin(), pmepes, ydim);
00348 }


Member Data Documentation

Definition at line 117 of file WorkDistrib.h.

Referenced by buildNodeAwarePeOrdering().

Definition at line 114 of file WorkDistrib.h.

Referenced by buildNodeAwarePeOrdering().


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

Generated on 6 Dec 2019 for NAMD by  doxygen 1.6.1