WorkDistrib Class Reference

#include <WorkDistrib.h>

List of all members.

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 saveComputeMap (ComputeMapMsg *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

Classes

struct  pe_sortop_compact
struct  pe_sortop_diffuse


Detailed Description

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

01365 {
01366   PatchMap *patchMap = PatchMap::Object();
01367   int nNodes = Node::Object()->numNodes();
01368   SimParameters *simparam = Node::Object()->simParameters;
01369   if(simparam->simulateInitialMapping) {
01370           nNodes = simparam->simulatedPEs;
01371   }
01372 
01373 #if (CMK_BLUEGENEP | CMK_BLUEGENEL) && USE_TOPOMAP 
01374   TopoManager tmgr;
01375   int numPes = tmgr.getDimNX() * tmgr.getDimNY() * tmgr.getDimNZ();
01376   if (numPes > patchMap->numPatches() && (assignPatchesTopoGridRecBisection() > 0)) {
01377     CkPrintf ("Blue Gene/L topology partitioner finished successfully \n");
01378   }
01379   else
01380 #endif
01381   assignPatchesSpaceFillingCurve();       
01382   
01383   int *nAtoms = new int[nNodes];
01384   int numAtoms=0;
01385   int i;
01386   for(i=0; i < nNodes; i++)
01387     nAtoms[i] = 0;
01388 
01389   for(i=0; i < patchMap->numPatches(); i++)
01390   {
01391     //    iout << iINFO << "Patch " << i << " has " 
01392     //   << patchMap->patch(i)->getNumAtoms() << " atoms and "
01393     //   << patchMap->patch(i)->getNumAtoms() * 
01394     //            patchMap->patch(i)->getNumAtoms() 
01395     //   << " pairs.\n" << endi;         
01396 #ifdef MEM_OPT_VERSION
01397       numAtoms += patchMap->numAtoms(i);
01398       nAtoms[patchMap->node(i)] += patchMap->numAtoms(i);         
01399 #else
01400     if (patchMap->patch(i)) {
01401       numAtoms += patchMap->patch(i)->getNumAtoms();
01402       nAtoms[patchMap->node(i)] += patchMap->patch(i)->getNumAtoms();     
01403     }
01404 #endif
01405   }
01406 
01407   if ( numAtoms != Node::Object()->molecule->numAtoms ) {
01408     for(i=0; i < nNodes; i++)
01409       iout << iINFO << nAtoms[i] << " atoms assigned to node " << i << "\n" << endi;
01410     iout << iINFO << "Assigned " << numAtoms << " atoms but expected " << Node::Object()->molecule->numAtoms << "\n" << endi;
01411     NAMD_die("Incorrect atom count in WorkDistrib::assignNodeToPatch\n");
01412   }
01413 
01414   delete [] nAtoms;
01415  
01416   //  PatchMap::Object()->printPatchMap();
01417 }

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(), and randtopo.

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

03435                                                                    {
03436   #if defined(NAMD_MIC)
03437     mic_contributeHostDeviceLDB(peSetLen, peSet);
03438   #endif
03439 }

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, Molecule::atommass(), atoms, 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, if(), PatchMap::index_a(), PatchMap::index_b(), PatchMap::index_c(), SimParameters::initialTemp, iout, Molecule::is_atom_fixed(), 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, and PatchMap::Object().

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

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

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

03006                                                  {
03007   msg->compute->doWork();  MACHINE_PROGRESS
03008   if ( msg->compute->localWorkMsg != msg )
03009     NAMD_bug("WorkDistrib LocalWorkMsg recycling failed!");
03010 }

void WorkDistrib::enqueueAniso ( LocalWorkMsg msg  ) 

Definition at line 3030 of file WorkDistrib.C.

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

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

void WorkDistrib::enqueueBonds ( LocalWorkMsg msg  ) 

Definition at line 3000 of file WorkDistrib.C.

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

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

void WorkDistrib::enqueueCrossterms ( LocalWorkMsg msg  ) 

Definition at line 3036 of file WorkDistrib.C.

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

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

void WorkDistrib::enqueueCUDA ( LocalWorkMsg msg  ) 

Definition at line 3134 of file WorkDistrib.C.

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

03134                                                {
03135   msg->compute->doWork();  MACHINE_PROGRESS
03136   // ComputeNonbondedCUDA *c = msg->compute;
03137   // if ( c->localWorkMsg != msg && c->localWorkMsg2 != msg )
03138   //   NAMD_bug("WorkDistrib LocalWorkMsg recycling failed!");
03139 }

void WorkDistrib::enqueueCUDAP2 ( LocalWorkMsg msg  ) 

Definition at line 3140 of file WorkDistrib.C.

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

03140                                                  {
03141   msg->compute->doWork();  MACHINE_PROGRESS
03142 }

void WorkDistrib::enqueueCUDAP3 ( LocalWorkMsg msg  ) 

Definition at line 3143 of file WorkDistrib.C.

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

03143                                                  {
03144   msg->compute->doWork();  MACHINE_PROGRESS
03145 }

void WorkDistrib::enqueueDihedrals ( LocalWorkMsg msg  ) 

Definition at line 3012 of file WorkDistrib.C.

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

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

void WorkDistrib::enqueueExcls ( LocalWorkMsg msg  ) 

Definition at line 2994 of file WorkDistrib.C.

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

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

void WorkDistrib::enqueueGromacsPair ( LocalWorkMsg msg  ) 

Definition at line 3043 of file WorkDistrib.C.

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

03043                                                       {
03044   msg->compute->doWork();
03045   MACHINE_PROGRESS
03046   if ( msg->compute->localWorkMsg != msg )
03047     NAMD_bug("\nWorkDistrib LocalWorkMsg recycling failed! Check enqueueGromacsPair from WorkDistrib.C\n");
03048 }

void WorkDistrib::enqueueImpropers ( LocalWorkMsg msg  ) 

Definition at line 3018 of file WorkDistrib.C.

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

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

void WorkDistrib::enqueueLCPO ( LocalWorkMsg msg  ) 

Definition at line 3057 of file WorkDistrib.C.

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

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

void WorkDistrib::enqueueMIC ( LocalWorkMsg msg  ) 

Definition at line 3164 of file WorkDistrib.C.

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

03164                                               {
03165   msg->compute->doWork();  MACHINE_PROGRESS
03166 }

void WorkDistrib::enqueuePme ( LocalWorkMsg msg  ) 

Definition at line 3051 of file WorkDistrib.C.

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

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

void WorkDistrib::enqueueSelfA1 ( LocalWorkMsg msg  ) 

Definition at line 3062 of file WorkDistrib.C.

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

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

void WorkDistrib::enqueueSelfA2 ( LocalWorkMsg msg  ) 

Definition at line 3067 of file WorkDistrib.C.

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

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

void WorkDistrib::enqueueSelfA3 ( 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::enqueueSelfB1 ( LocalWorkMsg msg  ) 

Definition at line 3078 of file WorkDistrib.C.

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

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

void WorkDistrib::enqueueSelfB2 ( LocalWorkMsg msg  ) 

Definition at line 3083 of file WorkDistrib.C.

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

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

void WorkDistrib::enqueueSelfB3 ( LocalWorkMsg msg  ) 

Definition at line 3088 of file WorkDistrib.C.

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

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

void WorkDistrib::enqueueThole ( 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::enqueueWork ( LocalWorkMsg msg  ) 

Definition at line 2988 of file WorkDistrib.C.

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

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

void WorkDistrib::enqueueWorkA1 ( LocalWorkMsg msg  ) 

Definition at line 3094 of file WorkDistrib.C.

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

03094                                                  {
03095   msg->compute->doWork();  MACHINE_PROGRESS
03096   if ( msg->compute->localWorkMsg != msg )
03097     NAMD_bug("WorkDistrib LocalWorkMsg recycling failed!");
03098 }

void WorkDistrib::enqueueWorkA2 ( LocalWorkMsg msg  ) 

Definition at line 3099 of file WorkDistrib.C.

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

03099                                                  {
03100   msg->compute->doWork();  MACHINE_PROGRESS
03101   if ( msg->compute->localWorkMsg != msg )
03102     NAMD_bug("WorkDistrib LocalWorkMsg recycling failed!");
03103 }

void WorkDistrib::enqueueWorkA3 ( LocalWorkMsg msg  ) 

Definition at line 3104 of file WorkDistrib.C.

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

03104                                                  {
03105   msg->compute->doWork();  MACHINE_PROGRESS
03106   if ( msg->compute->localWorkMsg != msg )
03107     NAMD_bug("WorkDistrib LocalWorkMsg recycling failed!");
03108 }

void WorkDistrib::enqueueWorkB1 ( LocalWorkMsg msg  ) 

Definition at line 3110 of file WorkDistrib.C.

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

03110                                                  {
03111   msg->compute->doWork();  MACHINE_PROGRESS
03112   if ( msg->compute->localWorkMsg != msg )
03113     NAMD_bug("WorkDistrib LocalWorkMsg recycling failed!");
03114 }

void WorkDistrib::enqueueWorkB2 ( LocalWorkMsg msg  ) 

Definition at line 3115 of file WorkDistrib.C.

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

03115                                                  {
03116   msg->compute->doWork();  MACHINE_PROGRESS
03117   if ( msg->compute->localWorkMsg != msg )
03118     NAMD_bug("WorkDistrib LocalWorkMsg recycling failed!");
03119 }

void WorkDistrib::enqueueWorkB3 ( LocalWorkMsg msg  ) 

Definition at line 3120 of file WorkDistrib.C.

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

03120                                                  {
03121   msg->compute->doWork();  MACHINE_PROGRESS
03122   if ( msg->compute->localWorkMsg != msg )
03123     NAMD_bug("WorkDistrib LocalWorkMsg recycling failed!");
03124 }

void WorkDistrib::enqueueWorkC ( LocalWorkMsg msg  ) 

Definition at line 3128 of file WorkDistrib.C.

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

03128                                                 {
03129   msg->compute->doWork();  MACHINE_PROGRESS
03130   if ( msg->compute->localWorkMsg != msg )
03131     NAMD_bug("WorkDistrib LocalWorkMsg recycling failed!");
03132 }

void WorkDistrib::finishCUDA ( LocalWorkMsg msg  ) 

Definition at line 3151 of file WorkDistrib.C.

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

03151                                               {
03152   msg->compute->doWork();  MACHINE_PROGRESS
03153   // ComputeNonbondedCUDA *c = msg->compute;
03154   // if ( c->localWorkMsg != msg && c->localWorkMsg2 != msg )
03155   //   NAMD_bug("WorkDistrib LocalWorkMsg recycling failed!");
03156 }

void WorkDistrib::finishCUDAP2 ( LocalWorkMsg msg  ) 

Definition at line 3157 of file WorkDistrib.C.

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

03157                                                 {
03158   msg->compute->doWork();  MACHINE_PROGRESS
03159 }

void WorkDistrib::finishCUDAP3 ( LocalWorkMsg msg  ) 

Definition at line 3160 of file WorkDistrib.C.

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

03160                                                 {
03161   msg->compute->doWork();  MACHINE_PROGRESS
03162 }

void WorkDistrib::finishCUDAPatch ( FinishWorkMsg msg  ) 

Definition at line 3147 of file WorkDistrib.C.

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

03147                                                     {
03148   msg->compute->finishPatch(msg->data);
03149 }

void WorkDistrib::finishMIC ( LocalWorkMsg msg  ) 

Definition at line 3167 of file WorkDistrib.C.

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

03167                                              {
03168   msg->compute->doWork();  MACHINE_PROGRESS
03169 }

void WorkDistrib::initHostDeviceLDB (  ) 

Definition at line 3422 of file WorkDistrib.C.

03422                                     {
03423   #if defined(NAMD_MIC)
03424     mic_hostDeviceLDB();
03425   #endif
03426 }

void WorkDistrib::mapComputes ( void   ) 

Definition at line 2285 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, 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::mgridforceOn, SimParameters::MSMOn, SimParameters::MsmSerialOn, NAMD_die(), Node::Object(), ComputeMap::Object(), PatchMap::Object(), optPmeType, SimParameters::pairInteractionOn, SimParameters::pairInteractionSelf, SimParameters::PMEOn, SimParameters::pressureProfileEwaldOn, SimParameters::qmForcesOn, ComputeMap::saveComputeMap(), Node::simParameters, simParams, SimParameters::sphericalBCOn, SimParameters::stirOn, SimParameters::tclBCOn, SimParameters::useCUDA2, SimParameters::useDPME, SimParameters::useOptPME, and SimParameters::usePMECUDA.

Referenced by Node::startup().

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

void WorkDistrib::messageEnqueueWork ( Compute  )  [static]

Definition at line 2757 of file WorkDistrib.C.

References Compute::cid, LocalWorkMsg::compute, computeAnglesType, computeAnisoType, computeBondsType, computeCrosstermsType, computeDihedralsType, computeExclsType, computeGromacsPairType, computeImpropersType, computeLCPOType, 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(), optPmeType, Compute::priority(), Compute::sequence(), SET_PRIORITY, and Compute::type().

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

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

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

Referenced by cuda_check_local_progress(), and cuda_check_remote_progress().

02934                                                     {
02935   LocalWorkMsg *msg = compute->localWorkMsg;
02936   int seq = compute->sequence();
02937   int gbisPhase = compute->getGBISPhase();
02938 
02939   if ( seq < 0 ) {
02940     NAMD_bug("compute->sequence() < 0 in WorkDistrib::messageEnqueueWork");
02941   } else {
02942     SET_PRIORITY(msg,seq,compute->priority());
02943   }
02944 
02945   msg->compute = compute; // pointer is valid since send is to local Pe
02946   CProxy_WorkDistrib wdProxy(CkpvAccess(BOCclass_group).workDistrib);
02947 
02948 #ifdef NAMD_CUDA
02949     //wdProxy[CkMyPe()].finishCUDA(msg);
02950     switch ( gbisPhase ) {
02951        case 1:
02952          wdProxy[CkMyPe()].finishCUDA(msg);
02953          break;
02954        case 2:
02955          wdProxy[CkMyPe()].finishCUDAP2(msg);
02956          break;
02957        case 3:
02958          wdProxy[CkMyPe()].finishCUDAP3(msg);
02959          break;
02960     }
02961 #else
02962     msg->compute->doWork();  MACHINE_PROGRESS
02963 #endif
02964 }

void WorkDistrib::messageFinishMIC ( Compute  )  [static]

Definition at line 2967 of file WorkDistrib.C.

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

02967                                                    {
02968   LocalWorkMsg *msg = compute->localWorkMsg;
02969   int seq = compute->sequence();
02970   int gbisPhase = compute->getGBISPhase();
02971 
02972   if ( seq < 0 ) {
02973     NAMD_bug("compute->sequence() < 0 in WorkDistrib::messageFinishMIC");
02974   } else {
02975     SET_PRIORITY(msg,seq,compute->priority());
02976   }
02977 
02978   msg->compute = compute; // pointer is valid since send is to local Pe
02979   CProxy_WorkDistrib wdProxy(CkpvAccess(BOCclass_group).workDistrib);
02980 
02981 #ifdef NAMD_MIC
02982     wdProxy[CkMyPe()].finishMIC(msg);
02983 #else
02984     msg->compute->doWork();  MACHINE_PROGRESS
02985 #endif
02986 }

void WorkDistrib::patchMapInit ( void   ) 

Definition at line 1150 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, PatchMap::nPatchesOnNode, 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().

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

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  ) 

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::saveComputeMap ( ComputeMapMsg msg  ) 

Definition at line 1104 of file WorkDistrib.C.

References ComputeMapMsg::computeMapData, ComputeMap::initPtrs(), NAMD_bug(), ComputeMapMsg::nComputes, ComputeMap::Object(), eabffunc::split(), and ComputeMap::unpack().

01105 {
01106   // Use a resend to forward messages before processing.  Otherwise the
01107   // map distribution is slow on many CPUs.  We need to use a tree
01108   // rather than a broadcast because some implementations of broadcast
01109   // generate a copy of the message on the sender for each recipient.
01110   // This is because MPI doesn't allow re-use of an outstanding buffer.
01111 
01112   if ( CkMyRank() ) {
01113     NAMD_bug("WorkDistrib::saveComputeMap called on non-rank-zero pe");
01114   }
01115 
01116   if ( computeMapArrived && CkMyPe() ) {
01117     ComputeMap::Object()->unpack(msg->nComputes, msg->computeMapData);
01118   }
01119 
01120   if ( computeMapArrived ) {
01121     delete msg;
01122     ComputeMap::Object()->initPtrs();
01123     return;
01124   }
01125 
01126   computeMapArrived = true;
01127 
01128   int self = CkMyNode();
01129   int range_begin = 0;
01130   int range_end = CkNumNodes();
01131   while ( self != range_begin ) {
01132     ++range_begin;
01133     int split = range_begin + ( range_end - range_begin ) / 2;
01134     if ( self < split ) { range_end = split; }
01135     else { range_begin = split; }
01136   }
01137   int send_near = self + 1;
01138   int send_far = send_near + ( range_end - send_near ) / 2;
01139 
01140   int pids[3];
01141   int npid = 0;
01142   if ( send_far < range_end ) pids[npid++] = CkNodeFirst(send_far);
01143   if ( send_near < send_far ) pids[npid++] = CkNodeFirst(send_near);
01144   pids[npid++] = CkMyPe();  // always send the message to ourselves
01145   CProxy_WorkDistrib(thisgroup).saveComputeMap(msg,npid,pids);
01146 }

void WorkDistrib::saveComputeMapChanges ( int  ,
CkGroupID   
)

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, eabffunc::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 3428 of file WorkDistrib.C.

03428                                                                         {
03429   #if defined(NAMD_MIC)
03430     CProxy_WorkDistrib wdProxy(CkpvAccess(BOCclass_group).workDistrib);
03431     wdProxy[0].contributeHostDeviceLDB(peSetLen, peSet);
03432   #endif
03433 }

void WorkDistrib::send_initHostDeviceLDB (  )  [static]

Definition at line 3415 of file WorkDistrib.C.

03415                                          {
03416   #if defined(NAMD_MIC)
03417     CProxy_WorkDistrib wdProxy(CkpvAccess(BOCclass_group).workDistrib);
03418     wdProxy.initHostDeviceLDB();
03419   #endif
03420 }

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

Definition at line 3441 of file WorkDistrib.C.

03441                                                                                    {
03442   #if defined(NAMD_MIC)
03443     CProxy_WorkDistrib wdProxy(CkpvAccess(BOCclass_group).workDistrib);
03444     wdProxy.setDeviceLDBParams(dt, hs, sp1, pp1, pp2);
03445   #endif
03446 }

void WorkDistrib::sendComputeMap ( void   ) 

Definition at line 1084 of file WorkDistrib.C.

References ComputeMapMsg::computeMapData, ComputeMap::initPtrs(), ComputeMapMsg::nComputes, ComputeMap::numComputes(), ComputeMap::Object(), and ComputeMap::pack().

Referenced by Node::startup().

01085 {
01086   if ( CkNumNodes() == 1 ) {
01087     computeMapArrived = true;
01088     ComputeMap::Object()->initPtrs();
01089     return;
01090   }
01091 
01092   int size = ComputeMap::Object()->numComputes();
01093 
01094   ComputeMapMsg *mapMsg = new (size, 0) ComputeMapMsg;
01095 
01096   mapMsg->nComputes = size;
01097   ComputeMap::Object()->pack(mapMsg->computeMapData);
01098 
01099   CProxy_WorkDistrib workProxy(thisgroup);
01100   workProxy[0].saveComputeMap(mapMsg);
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 3448 of file WorkDistrib.C.

03448                                                                               {
03449   #if defined(NAMD_MIC)
03450     mic_setDeviceLDBParams(dt, hs, sp1, pp1, pp2);
03451   #endif
03452 }

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

Definition at line 109 of file WorkDistrib.h.

Referenced by Node::startup().

00109 {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(), npatches, 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

int * WorkDistrib::peCompactOrdering [static]

Definition at line 119 of file WorkDistrib.h.

Referenced by buildNodeAwarePeOrdering().

int * WorkDistrib::peCompactOrderingIndex [static]

Definition at line 120 of file WorkDistrib.h.

Referenced by buildNodeAwarePeOrdering(), WorkDistrib::pe_sortop_compact::operator()(), and TopoManagerWrapper::pe_sortop_topo::operator()().

int * WorkDistrib::peDiffuseOrdering [static]

Definition at line 117 of file WorkDistrib.h.

Referenced by buildNodeAwarePeOrdering(), generatePmePeList2(), ParallelIOMgr::initialize(), and ComputePmeMgr::initialize().

int * WorkDistrib::peDiffuseOrderingIndex [static]

Definition at line 118 of file WorkDistrib.h.

Referenced by buildNodeAwarePeOrdering(), and WorkDistrib::pe_sortop_diffuse::operator()().

int WorkDistrib::peOrderingInit [static]

Definition at line 116 of file WorkDistrib.h.

Referenced by buildNodeAwarePeOrdering().


The documentation for this class was generated from the following files:
Generated on Tue Nov 21 01:17:21 2017 for NAMD by  doxygen 1.4.7