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

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

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

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

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(), 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       a[j].charge = molecule->atomcharge(aid);
00835 
00836 //Modifications for alchemical fep
00837       if ( alchOn || lesOn || pairInteractionOn || pressureProfileTypes) {
00838         a[j].partition = molecule->get_fep_type(aid);
00839       } 
00840       else {
00841         a[j].partition = 0;
00842       }
00843 //fepe
00844 
00845     }
00846 
00847     int size, allfixed, k;
00848     for(j=0; j < n; j+=size) {
00849       size = a[j].hydrogenGroupSize;
00850       if ( ! size ) {
00851         NAMD_bug("Mother atom with hydrogenGroupSize of 0!");
00852       }
00853       allfixed = 1;
00854       for ( k = 0; k < size; ++k ) {
00855         allfixed = ( allfixed && (a[j+k].atomFixed) );
00856       }
00857       for ( k = 0; k < size; ++k ) {
00858         a[j+k].groupFixed = allfixed ? 1 : 0;
00859       }
00860     }
00861 
00862     if ( params->outputPatchDetails ) {
00863       int patchId = i;
00864       int numAtomsInPatch = n;
00865       int numFixedAtomsInPatch = 0;
00866       int numAtomsInFixedGroupsInPatch = 0;
00867       for(j=0; j < n; j++) {
00868         numFixedAtomsInPatch += ( a[j].atomFixed ? 1 : 0 );
00869         numAtomsInFixedGroupsInPatch += ( a[j].groupFixed ? 1 : 0 );
00870       }
00871       iout << "PATCH_DETAILS:"
00872            << " patch " << patchId
00873            << " atoms " << numAtomsInPatch
00874            << " fixed_atoms " << numFixedAtomsInPatch
00875            << " fixed_groups " << numAtomsInFixedGroupsInPatch
00876            << "\n" << endi;
00877     }
00878   }
00879 
00880   return atoms;
00881 
00882 }

void WorkDistrib::createHomePatches ( void   ) 

Definition at line 887 of file WorkDistrib.C.

References atoms, createAtomLists(), PatchMgr::createHomePatch(), DebugM, endi(), iINFO(), iout, PatchMap::numPatches(), numPatches, and PatchMap::Object().

Referenced by Node::startup().

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

void WorkDistrib::distributeHomePatches ( void   ) 

Definition at line 928 of file WorkDistrib.C.

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

Referenced by Node::startup().

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

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

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

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

void WorkDistrib::enqueueAniso ( LocalWorkMsg msg  ) 

Definition at line 3028 of file WorkDistrib.C.

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

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

void WorkDistrib::enqueueBonds ( 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::enqueueCrossterms ( 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::enqueueCUDA ( LocalWorkMsg msg  ) 

Definition at line 3132 of file WorkDistrib.C.

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

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

void WorkDistrib::enqueueCUDAP2 ( LocalWorkMsg msg  ) 

Definition at line 3138 of file WorkDistrib.C.

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

03138                                                  {
03139   msg->compute->doWork();  MACHINE_PROGRESS
03140 }

void WorkDistrib::enqueueCUDAP3 ( LocalWorkMsg msg  ) 

Definition at line 3141 of file WorkDistrib.C.

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

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

void WorkDistrib::enqueueDihedrals ( LocalWorkMsg msg  ) 

Definition at line 3010 of file WorkDistrib.C.

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

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

void WorkDistrib::enqueueExcls ( 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::enqueueGromacsPair ( LocalWorkMsg msg  ) 

Definition at line 3041 of file WorkDistrib.C.

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

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

void WorkDistrib::enqueueImpropers ( LocalWorkMsg msg  ) 

Definition at line 3016 of file WorkDistrib.C.

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

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

void WorkDistrib::enqueueLCPO ( LocalWorkMsg msg  ) 

Definition at line 3055 of file WorkDistrib.C.

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

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

void WorkDistrib::enqueueMIC ( LocalWorkMsg msg  ) 

Definition at line 3162 of file WorkDistrib.C.

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

03162                                               {
03163   msg->compute->doWork();  MACHINE_PROGRESS
03164 }

void WorkDistrib::enqueuePme ( LocalWorkMsg msg  ) 

Definition at line 3049 of file WorkDistrib.C.

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

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

void WorkDistrib::enqueueSelfA1 ( LocalWorkMsg msg  ) 

Definition at line 3060 of file WorkDistrib.C.

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

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

void WorkDistrib::enqueueSelfA2 ( LocalWorkMsg msg  ) 

Definition at line 3065 of file WorkDistrib.C.

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

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

void WorkDistrib::enqueueSelfA3 ( LocalWorkMsg msg  ) 

Definition at line 3070 of file WorkDistrib.C.

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

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

void WorkDistrib::enqueueSelfB1 ( LocalWorkMsg msg  ) 

Definition at line 3076 of file WorkDistrib.C.

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

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

void WorkDistrib::enqueueSelfB2 ( LocalWorkMsg msg  ) 

Definition at line 3081 of file WorkDistrib.C.

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

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

void WorkDistrib::enqueueSelfB3 ( LocalWorkMsg msg  ) 

Definition at line 3086 of file WorkDistrib.C.

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

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

void WorkDistrib::enqueueThole ( LocalWorkMsg msg  ) 

Definition at line 3022 of file WorkDistrib.C.

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

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

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

Definition at line 3092 of file WorkDistrib.C.

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

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

void WorkDistrib::enqueueWorkA2 ( LocalWorkMsg msg  ) 

Definition at line 3097 of file WorkDistrib.C.

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

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

void WorkDistrib::enqueueWorkA3 ( LocalWorkMsg msg  ) 

Definition at line 3102 of file WorkDistrib.C.

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

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

void WorkDistrib::enqueueWorkB1 ( LocalWorkMsg msg  ) 

Definition at line 3108 of file WorkDistrib.C.

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

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

void WorkDistrib::enqueueWorkB2 ( LocalWorkMsg msg  ) 

Definition at line 3113 of file WorkDistrib.C.

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

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

void WorkDistrib::enqueueWorkB3 ( LocalWorkMsg msg  ) 

Definition at line 3118 of file WorkDistrib.C.

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

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

void WorkDistrib::enqueueWorkC ( LocalWorkMsg msg  ) 

Definition at line 3126 of file WorkDistrib.C.

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

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

void WorkDistrib::finishCUDA ( LocalWorkMsg msg  ) 

Definition at line 3149 of file WorkDistrib.C.

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

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

void WorkDistrib::finishCUDAP2 ( LocalWorkMsg msg  ) 

Definition at line 3155 of file WorkDistrib.C.

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

03155                                                 {
03156   msg->compute->doWork();  MACHINE_PROGRESS
03157 }

void WorkDistrib::finishCUDAP3 ( LocalWorkMsg msg  ) 

Definition at line 3158 of file WorkDistrib.C.

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

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

void WorkDistrib::finishCUDAPatch ( FinishWorkMsg msg  ) 

Definition at line 3145 of file WorkDistrib.C.

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

03145                                                     {
03146   msg->compute->finishPatch(msg->data);
03147 }

void WorkDistrib::finishMIC ( LocalWorkMsg msg  ) 

Definition at line 3165 of file WorkDistrib.C.

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

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

void WorkDistrib::initHostDeviceLDB (  ) 

Definition at line 3420 of file WorkDistrib.C.

03420                                     {
03421   #if defined(NAMD_MIC)
03422     mic_hostDeviceLDB();
03423   #endif
03424 }

void WorkDistrib::mapComputes ( void   ) 

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

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

void WorkDistrib::messageEnqueueWork ( Compute  )  [static]

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

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

void WorkDistrib::messageFinishCUDA ( Compute  )  [static]

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

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

void WorkDistrib::messageFinishMIC ( Compute  )  [static]

Definition at line 2965 of file WorkDistrib.C.

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

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

void WorkDistrib::patchMapInit ( void   ) 

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

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

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

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

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

void WorkDistrib::saveComputeMap ( ComputeMapMsg msg  ) 

Definition at line 1102 of file WorkDistrib.C.

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

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

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

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

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

Definition at line 3426 of file WorkDistrib.C.

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

void WorkDistrib::send_initHostDeviceLDB (  )  [static]

Definition at line 3413 of file WorkDistrib.C.

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

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

Definition at line 3439 of file WorkDistrib.C.

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

void WorkDistrib::sendComputeMap ( void   ) 

Definition at line 1082 of file WorkDistrib.C.

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

Referenced by Node::startup().

01083 {
01084   if ( CkNumNodes() == 1 ) {
01085     computeMapArrived = true;
01086     ComputeMap::Object()->initPtrs();
01087     return;
01088   }
01089 
01090   int size = ComputeMap::Object()->numComputes();
01091 
01092   ComputeMapMsg *mapMsg = new (size, 0) ComputeMapMsg;
01093 
01094   mapMsg->nComputes = size;
01095   ComputeMap::Object()->pack(mapMsg->computeMapData);
01096 
01097   CProxy_WorkDistrib workProxy(thisgroup);
01098   workProxy[0].saveComputeMap(mapMsg);
01099 }

void WorkDistrib::sendPatchMap ( void   ) 

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

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

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

Definition at line 3446 of file WorkDistrib.C.

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

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 Mon Sep 25 01:17:20 2017 for NAMD by  doxygen 1.4.7