ProxyMgr Class Reference

#include <ProxyMgr.h>

List of all members.

Public Member Functions

 ProxyMgr ()
 ~ProxyMgr ()
void removeProxies (void)
void removeUnusedProxies (void)
void createProxies (void)
void createProxy (PatchID pid)
void removeProxy (PatchID pid)
void registerProxy (PatchID pid)
void recvRegisterProxy (RegisterProxyMsg *)
void unregisterProxy (PatchID pid)
void recvUnregisterProxy (UnregisterProxyMsg *)
void setSendSpanning ()
int getSendSpanning ()
void setRecvSpanning ()
int getRecvSpanning ()
void setProxyTreeBranchFactor (int dim)
void buildProxySpanningTree ()
void sendSpanningTrees ()
void sendSpanningTreeToHomePatch (int pid, int *tree, int n)
void recvSpanningTreeOnHomePatch (int pid, int *tree, int n)
void sendSpanningTree (ProxySpanningTreeMsg *)
void recvSpanningTree (ProxySpanningTreeMsg *)
void sendNodeAwareSpanningTreeToHomePatch (int pid, proxyTreeNode *tree, int n)
void recvNodeAwareSpanningTreeOnHomePatch (ProxyNodeAwareSpanningTreeMsg *msg)
void sendNodeAwareSpanningTree (ProxyNodeAwareSpanningTreeMsg *)
void recvNodeAwareSpanningTree (ProxyNodeAwareSpanningTreeMsg *)
void recvNodeAwareSTParent (int patch, int parent)
void buildProxySpanningTree2 ()
void sendProxies (int pid, int *list, int n)
void recvProxies (int pid, int *list, int n)
void recvPatchProxyInfo (PatchProxyListMsg *msg)
void buildSpanningTree0 ()
void sendResults (ProxyResultVarsizeMsg *)
void recvResults (ProxyResultVarsizeMsg *)
void sendResults (ProxyResultMsg *)
void recvResults (ProxyResultMsg *)
void sendResults (ProxyCombinedResultMsg *)
void sendResult (ProxyGBISP1ResultMsg *)
void recvResult (ProxyGBISP1ResultMsg *)
void recvData (ProxyGBISP2DataMsg *)
void sendResult (ProxyGBISP2ResultMsg *)
void recvResult (ProxyGBISP2ResultMsg *)
void recvData (ProxyGBISP3DataMsg *)
void recvResults (ProxyCombinedResultRawMsg *)
void recvImmediateResults (ProxyCombinedResultRawMsg *)
void sendProxyData (ProxyDataMsg *, int, int *)
void recvImmediateProxyData (ProxyDataMsg *)
void recvProxyData (ProxyDataMsg *)
void sendProxyAll (ProxyDataMsg *, int, int *)
void recvImmediateProxyAll (ProxyDataMsg *)
void recvProxyAll (ProxyDataMsg *)
int numProxies ()
ProxyTreegetPtree ()

Static Public Member Functions

static ProxyMgrObject ()

Static Public Attributes

static int nodecount = 0


Detailed Description

Definition at line 316 of file ProxyMgr.h.


Constructor & Destructor Documentation

ProxyMgr::ProxyMgr (  ) 

Definition at line 349 of file ProxyMgr.C.

References NAMD_bug().

00349                    { 
00350   if (CkpvAccess(ProxyMgr_instance)) {
00351     NAMD_bug("Tried to create ProxyMgr twice.");
00352   }
00353   CkpvAccess(ProxyMgr_instance) = this;
00354 }

ProxyMgr::~ProxyMgr (  ) 

Definition at line 356 of file ProxyMgr.C.

References removeProxies().

00356                     { 
00357   removeProxies();
00358   CkpvAccess(ProxyMgr_instance) = NULL;
00359 }


Member Function Documentation

void ProxyMgr::buildProxySpanningTree (  ) 

Definition at line 559 of file ProxyMgr.C.

References endi(), PatchMap::homePatch(), PatchMap::homePatchIDList(), iINFO(), iout, PatchMap::Object(), proxyRecvSpanning, proxySendSpanning, proxySpanDim, and ResizeArray< Elem >::size().

Referenced by Node::startup().

00560 {
00561   PatchIDList pids;
00562   if (!CkMyPe()) iout << iINFO << "Building spanning tree ... send: " << proxySendSpanning << " recv: " << proxyRecvSpanning 
00563       << " with branch factor " << proxySpanDim <<"\n" << endi;
00564   PatchMap::Object()->homePatchIDList(pids);
00565   for (int i=0; i<pids.size(); i++) {
00566     HomePatch *home = PatchMap::Object()->homePatch(pids[i]);
00567     if (home == NULL) CkPrintf("ERROR: homepatch NULL\n");
00568 #ifdef NODEAWARE_PROXY_SPANNINGTREE
00569     home->buildNodeAwareSpanningTree();
00570 #else
00571     home->buildSpanningTree();
00572 #endif
00573   }
00574 }

void ProxyMgr::buildProxySpanningTree2 (  ) 

Definition at line 577 of file ProxyMgr.C.

References ResizeArrayIter< T >::begin(), ResizeArrayIter< T >::end(), PatchMap::homePatch(), PatchMap::homePatchIDList(), PatchMap::homePatchList(), PatchMap::Object(), and ResizeArray< Elem >::size().

Referenced by ComputeMgr::updateLocalComputes5().

00578 {
00579 #if 0
00580   //The homePatchIDList is an expensive as it goes through
00581   //every patch ids.
00582   PatchIDList pids;
00583   PatchMap::Object()->homePatchIDList(pids);
00584   for (int i=0; i<pids.size(); i++) {
00585     HomePatch *home = PatchMap::Object()->homePatch(pids[i]);
00586     if (home == NULL) CkPrintf("ERROR: homepatch NULL\n");
00587     home->sendProxies();
00588   }
00589 #else
00590   HomePatchList *hpl = PatchMap::Object()->homePatchList();
00591   HomePatchListIter iter(*hpl);
00592   for(iter=iter.begin(); iter!=iter.end(); iter++) {
00593           HomePatch *home = iter->patch;
00594           home->sendProxies();
00595   }
00596 #endif
00597 }

void ProxyMgr::buildSpanningTree0 (  ) 

Definition at line 1007 of file ProxyMgr.C.

References ResizeArray< Elem >::find(), if(), MAX_INTERNODE, PatchMap::node(), noInterNode(), PatchMap::numPatches(), PatchMap::Object(), processCpuLoad(), ProxyTree::proxylist, proxyRecvSpanning, proxySendSpanning, proxySpanDim, ResizeArray< Elem >::resize(), ResizeArray< Elem >::setall(), ResizeArray< Elem >::size(), ProxyTree::sizes, ResizeArray< Elem >::swap(), and ProxyTree::trees.

Referenced by Rebalancer::createSpanningTree(), recvPatchProxyInfo(), and recvProxies().

01008 {
01009         CkPrintf("Info: build spanning tree with send: %d, recv: %d with branch factor %d\n", 
01010                          proxySendSpanning, proxyRecvSpanning, proxySpanDim);
01011 
01012   int i;
01013 
01014   processCpuLoad();
01015 
01016   int *numPatchesOnNode = new int[CkNumPes()];
01017   int numNodesWithPatches = 0;
01018   for (i=0; i<CkNumPes(); i++) numPatchesOnNode[i] = 0;
01019   int numPatches = PatchMap::Object()->numPatches();
01020   for (i=0; i<numPatches; i++) {
01021     int node = PatchMap::Object()->node(i);
01022     numPatchesOnNode[node]++;
01023     if (numPatchesOnNode[node] == 1)
01024       numNodesWithPatches ++;
01025   }
01026   int patchNodesLast =
01027     ( numNodesWithPatches < ( 0.7 * CkNumPes() ) );
01028   int *ntrees = new int[CkNumPes()];
01029   for (i=0; i<CkNumPes(); i++) ntrees[i] = 0;
01030   if (ptree.trees == NULL) ptree.trees = new NodeIDList[numPatches];
01031   for (int pid=0; pid<numPatches; pid++) 
01032   {
01033     int numProxies = ptree.proxylist[pid].size();
01034     if (numProxies == 0) {
01035       //CkPrintf ("This is sheer evil!\n\n");
01036       //ProxyMgr::Object()->sendSpanningTreeToHomePatch(pid, NULL, 0);
01037       delete [] ntrees;
01038       delete [] numPatchesOnNode;
01039       return;
01040     }
01041     NodeIDList &tree = ptree.trees[pid];   // spanning tree
01042     NodeIDList oldtree;  oldtree.swap(tree);
01043     tree.resize(numProxies+1);
01044     tree.setall(-1);
01045     tree[0] = PatchMap::Object()->node(pid);
01046     int s=1, e=numProxies;
01047     int nNonPatch = 0;
01048     int treesize = 1;
01049     int pp;
01050 
01051     // keep tree persistent for non-intermediate nodes
01052     for (pp=0; pp<numProxies; pp++) {
01053       int p = ptree.proxylist[pid][pp];
01054       int oldindex = oldtree.find(p);
01055       if (oldindex != -1 && oldindex <= numProxies) {
01056         int isIntermediate = (oldindex*proxySpanDim+1 <= numProxies);
01057         if (!isIntermediate) {
01058           tree[oldindex] = p;
01059         }
01060         else if (ntrees[p] < MAX_INTERNODE) {
01061           tree[oldindex] = p;
01062           ntrees[p] ++;
01063         }
01064       }
01065     }
01066 
01067     for (pp=0; pp<numProxies; pp++) {
01068       int p = ptree.proxylist[pid][pp];              // processor number
01069       if (tree.find(p) != -1) continue;        // already used
01070       treesize++;
01071       if (patchNodesLast && numPatchesOnNode[p] ) {
01072         while (tree[e] != -1) { e--; if (e==-1) e = numProxies; }
01073         tree[e] = p;
01074         int isIntermediate = (e*proxySpanDim+1 <= numProxies);
01075         if (isIntermediate) ntrees[p]++;
01076       }
01077       else {
01078         while (tree[s] != -1) { s++; if (s==numProxies+1) s = 1; }
01079         int isIntermediate = (s*proxySpanDim+1 <= numProxies);
01080         if (isIntermediate && (ntrees[p] >= MAX_INTERNODE || noInterNode(p))) {   // TOO MANY INTERMEDIATE TREES
01081         //if (isIntermediate && ntrees[p] >= MAX_INTERNODE)    // TOO MANY INTERMEDIATE TREES
01082           while (tree[e] != -1) { e--; if (e==-1) e = numProxies; }
01083           tree[e] = p;
01084           isIntermediate = (e*proxySpanDim+1 <= numProxies);
01085           if (isIntermediate) ntrees[p]++;
01086         }
01087         else {
01088           tree[s] = p;
01089           nNonPatch++;
01090           if (isIntermediate) ntrees[p]++;
01091         }
01092       }
01093     }
01094     // send homepatch's proxy tree
01095     if(ptree.sizes)
01096       ptree.sizes[pid] = treesize;
01097     //ProxyMgr::Object()->sendSpanningTreeToHomePatch(pid, &tree[0], treesize);
01098   }
01099   /*for (i=0; i<CkNumPes(); i++) {
01100     if (ntrees[i] > MAX_INTERNODE) iout << "Processor " << i << "has (guess) " << ntrees[i] << " intermediate nodes." << endi;
01101   }*/
01102   delete [] ntrees;
01103   delete [] numPatchesOnNode;
01104 }

void ProxyMgr::createProxies ( void   ) 

Definition at line 417 of file ProxyMgr.C.

References UniqueSet< Elem >::add(), PatchMap::basePatchIDList(), computeNonbondedPairType, computeNonbondedSelfType, PatchMap::MaxOneAway, ComputeMap::node(), PatchMap::node(), ComputeMap::numComputes(), PatchMap::numPatches(), numPatches, ComputeMap::numPids(), ComputeMap::Object(), PatchMap::Object(), ComputeMap::pid(), PatchMap::registerPatch(), removeProxies(), ResizeArray< Elem >::size(), ComputeMap::type(), and PatchMap::upstreamNeighbors().

Referenced by Node::startup().

00418 {
00419   // Delete the old proxies.
00420   removeProxies();
00421 
00422   PatchMap *patchMap = PatchMap::Object();
00423   int numPatches = patchMap->numPatches();
00424   int myNode = CkMyPe();
00425   enum PatchFlag { Unknown, Home, NeedProxy };
00426   int *patchFlag = new int[numPatches]; 
00427   int i, j;
00428 
00429   // Note all home patches.
00430   for ( i = 0; i < numPatches; ++i )
00431   {
00432     patchFlag[i] = ( patchMap->node(i) == myNode ) ? Home : Unknown;
00433   }
00434 
00435 #ifndef NAMD_CUDA
00436   // Add all upstream neighbors.
00437   PatchID neighbors[PatchMap::MaxOneAway];
00438   PatchIDList basepids;
00439   patchMap->basePatchIDList(myNode,basepids);
00440   for ( i = 0; i < basepids.size(); ++i )
00441   {
00442     if ( patchMap->node(basepids[i]) != myNode ) {
00443         patchFlag[basepids[i]] = NeedProxy;
00444     }
00445     int numNeighbors = patchMap->upstreamNeighbors(basepids[i],neighbors);
00446     for ( j = 0; j < numNeighbors; ++j )
00447     {
00448       if ( ! patchFlag[neighbors[j]] ) {
00449         patchFlag[neighbors[j]] = NeedProxy;
00450       }
00451     }
00452   }
00453 #endif
00454 
00455   ComputeMap *computeMap = ComputeMap::Object();
00456 
00457   // Check all patch-based compute objects.
00458   int nc = computeMap->numComputes();
00459   for ( i = 0; i < nc; ++i )
00460   {
00461 #if defined(NAMD_CUDA)
00462     ComputeType t = computeMap->type(i);
00463     if ( t == computeNonbondedSelfType || t == computeNonbondedPairType )
00464       continue;
00465 #elif defined(NAMD_MIC)
00466     ComputeType t = computeMap->type(i);
00467     if ( computeMap->directToDevice(i) != 0 ) { continue; } // NOTE: Compute for device will take care of requiring the patch
00468 #endif
00469     if ( computeMap->node(i) != myNode ) 
00470       continue;
00471     int numPid = computeMap->numPids(i);
00472     for ( j = 0; j < numPid; ++j )
00473     {
00474       int pid = computeMap->pid(i,j);
00475       if ( ! patchFlag[pid] ) {
00476         patchFlag[pid] = NeedProxy;
00477       }
00478     }
00479   }
00480   // Create proxy list
00481   for ( i = 0; i < numPatches; ++i ) {
00482     if ( patchFlag[i] == NeedProxy )
00483     { // create proxy patch
00484       ProxyPatch *proxy = new ProxyPatch(i);
00485       proxySet.add(ProxyElem(i, proxy));
00486       patchMap->registerPatch(i, proxy);
00487     }
00488   }
00489   delete[] patchFlag;
00490 }

void ProxyMgr::createProxy ( PatchID  pid  ) 

Definition at line 493 of file ProxyMgr.C.

References UniqueSet< Elem >::add(), DebugM, Patch::getPatchID(), PatchMap::Object(), PatchMap::patch(), and PatchMap::registerPatch().

Referenced by ComputeHomeTuples< AnisoElem, aniso, aniso >::initialize(), ComputeNonbondedCUDA::registerPatches(), and ComputeMgr::updateLocalComputes().

00493                                  {
00494   Patch *p = PatchMap::Object()->patch(pid);
00495   if (!p) {
00496      DebugM(4,"createProxy("<<pid<<")\n");
00497      ProxyPatch *proxy = new ProxyPatch(pid);
00498      proxySet.add(ProxyElem(pid,proxy));
00499      PatchMap::Object()->registerPatch(pid,proxy);
00500   }
00501   else {
00502      DebugM(4,"createProxy("<<pid<<") found " << p->getPatchID() << "\n");
00503   }
00504     
00505 }

ProxyTree & ProxyMgr::getPtree (  ) 

Definition at line 385 of file ProxyMgr.C.

Referenced by Rebalancer::createSpanningTree(), Rebalancer::decrSTLoad(), and Rebalancer::incrSTLoad().

00385                               {
00386   return ptree;
00387 }

int ProxyMgr::getRecvSpanning (  ) 

Definition at line 376 of file ProxyMgr.C.

References proxyRecvSpanning.

Referenced by Node::startup().

00376                               {
00377   return proxyRecvSpanning;
00378 }

int ProxyMgr::getSendSpanning (  ) 

Definition at line 367 of file ProxyMgr.C.

References proxySendSpanning.

Referenced by Node::startup().

00367                               {
00368   return proxySendSpanning;
00369 }

int ProxyMgr::numProxies (  )  [inline]

Definition at line 396 of file ProxyMgr.h.

00396 { return proxySet.size(); }

static ProxyMgr* ProxyMgr::Object (  )  [inline, static]

Definition at line 394 of file ProxyMgr.h.

Referenced by ProxyPatch::boxClosed(), Rebalancer::createSpanningTree(), Rebalancer::decrSTLoad(), Rebalancer::incrSTLoad(), ComputeHomeTuples< AnisoElem, aniso, aniso >::initialize(), Sync::openSync(), HomePatch::positionsReady(), ProxyPatch::ProxyPatch(), recvImmediateProxyAll(), recvImmediateProxyData(), recvNodeAwareSpanningTree(), ComputeNonbondedCUDA::registerPatches(), WorkDistrib::savePatchMap(), WorkDistrib::sendPatchMap(), HomePatch::sendProxies(), HomePatch::sendSpanningTree(), sendSpanningTrees(), Node::startup(), ComputeMgr::updateLocalComputes5(), and ProxyPatch::~ProxyPatch().

00394 { return CkpvAccess(ProxyMgr_instance); }

void ProxyMgr::recvData ( ProxyGBISP3DataMsg  ) 

Definition at line 1877 of file ProxyMgr.C.

References PatchMap::Object(), ProxyGBISP3DataMsg::patch, PatchMap::patch(), and ProxyPatch::receiveData().

01877                                                  {   //hp -d> pp
01878   ProxyPatch *proxy = (ProxyPatch *) PatchMap::Object()->patch(msg->patch);
01879   proxy->receiveData(msg); // deleted in ProxyPatch::receiveAtoms() ?
01880 }

void ProxyMgr::recvData ( ProxyGBISP2DataMsg  ) 

Definition at line 1862 of file ProxyMgr.C.

References PatchMap::Object(), ProxyGBISP2DataMsg::patch, PatchMap::patch(), and ProxyPatch::receiveData().

01862                                                  {  //hp -d> pp
01863   ProxyPatch *proxy = (ProxyPatch *) PatchMap::Object()->patch(msg->patch);
01864   proxy->receiveData(msg); // deleted in ProxyPatch::receiveAtoms() ?
01865 }

void ProxyMgr::recvImmediateProxyAll ( ProxyDataMsg  ) 

Definition at line 1711 of file ProxyMgr.C.

References ProxyPatch::getSpanningTreeChildPtr(), ProxyPatch::getSpanningTreeNChild(), Object(), PatchMap::Object(), ProxyDataMsg::patch, PatchMap::patch(), proxySendSpanning, and sendProxyAll().

01711                                                  {
01712   ProxyPatch *proxy = (ProxyPatch *) PatchMap::Object()->patch(msg->patch);
01713   #if defined(PROCTRACE_DEBUG) && defined(NAST_DEBUG)
01714   DebugFileTrace *dft = DebugFileTrace::Object();
01715   dft->openTrace();
01716   dft->writeTrace("PMgr::recvImmPAll for patch[%d]\n", msg->patch);
01717   CmiAssert(proxy!=NULL);
01718   dft->writeTrace("PMgr::recvImmPAll assertion OK for patch[%d]\n", msg->patch);
01719   dft->closeTrace();
01720   #endif
01721   if (proxySendSpanning == 1) {
01722     // copy the message and send to spanning children
01723     //int *pids = (int*)alloca(proxy->getSpanningTreeNChild()*sizeof(int));
01724     //int npid = proxy->getSpanningTreeChild(pids);
01725     int npid = proxy->getSpanningTreeNChild();
01726     int *pids = (int *)proxy->getSpanningTreeChildPtr();
01727     if (npid) {
01728         ProxyDataMsg *newmsg = (ProxyDataMsg *)CkCopyMsg((void **)&msg);      
01729 #if CMK_PERSISTENT_COMM && USE_PERSISTENT_TREE
01730         int ntreephs;
01731         PersistentHandle *treephs = proxy->getSpanningTreePhs(ntreephs);
01732         CmiAssert(treephs && ntreephs == npid);
01733         CmiUsePersistentHandle(treephs, ntreephs);
01734 #endif
01735         ProxyMgr::Object()->sendProxyAll(newmsg,npid,pids);
01736 #if CMK_PERSISTENT_COMM && USE_PERSISTENT_TREE
01737         CmiUsePersistentHandle(NULL, 0);
01738 #endif
01739     }
01740   }
01741   /* send to self via EP method to preserve priority */
01742   CProxy_ProxyMgr cp(CkpvAccess(BOCclass_group).proxyMgr);
01743   cp[CkMyPe()].recvProxyAll(msg);
01744 }

void ProxyMgr::recvImmediateProxyData ( ProxyDataMsg  ) 

Definition at line 1596 of file ProxyMgr.C.

References ProxyPatch::getSpanningTreeChildPtr(), ProxyPatch::getSpanningTreeNChild(), Object(), PatchMap::Object(), ProxyDataMsg::patch, PatchMap::patch(), proxySendSpanning, and sendProxyData().

01596                                                   {
01597   ProxyPatch *proxy = (ProxyPatch *) PatchMap::Object()->patch(msg->patch);  
01598   if (proxySendSpanning == 1) {
01599     // copy the message and send to spanning children
01600     //int *pids = (int*)alloca(proxy->getSpanningTreeNChild()*sizeof(int));
01601     //int npid = proxy->getSpanningTreeChild(pids);
01602     int npid = proxy->getSpanningTreeNChild();
01603     int *pids = (int *)proxy->getSpanningTreeChildPtr();
01604     if (npid) {        
01605         ProxyDataMsg *newmsg = (ProxyDataMsg *)CkCopyMsg((void **)&msg);     
01606 #if CMK_PERSISTENT_COMM && USE_PERSISTENT_TREE
01607         int ntreephs;
01608         PersistentHandle *treephs = proxy->getSpanningTreePhs(ntreephs);
01609         CmiAssert(treephs && ntreephs == npid);
01610         CmiUsePersistentHandle(treephs, ntreephs);
01611 #endif
01612         ProxyMgr::Object()->sendProxyData(newmsg,npid,pids);
01613 #if CMK_PERSISTENT_COMM && USE_PERSISTENT_TREE
01614         CmiUsePersistentHandle(NULL, 0);
01615 #endif
01616       #if 0
01617       //ChaoMei: buggy code??? the spanning tree doesn't always have 2 levels
01618       //At the second level of the tree immediate messages are not needed
01619       CProxy_ProxyMgr cp(CkpvAccess(BOCclass_group).proxyMgr);
01620       cp.recvProxyData(newmsg,npid,pids);
01621       #endif
01622     }
01623   }
01624   /* send to self via EP method to preserve priority */
01625   CProxy_ProxyMgr cp(CkpvAccess(BOCclass_group).proxyMgr);
01626   cp[CkMyPe()].recvProxyData(msg);
01627 }

void ProxyMgr::recvImmediateResults ( ProxyCombinedResultRawMsg  ) 

Definition at line 1506 of file ProxyMgr.C.

References ProxyPatch::depositCombinedResultRawMsg(), ProxyPatch::getSpanningTreeParent(), PatchMap::homePatch(), PatchMap::Object(), PatchMap::patch(), ProxyCombinedResultRawMsg::patch, and ProxyCombinedResultMsg::toRaw().

01506                                                                    {
01507   HomePatch *home = PatchMap::Object()->homePatch(omsg->patch);
01508   if (home) {
01509     CProxy_ProxyMgr cp(CkpvAccess(BOCclass_group).proxyMgr);        
01510     CmiEnableUrgentSend(1);
01511     cp[CkMyPe()].recvResults(omsg);
01512     CmiEnableUrgentSend(0);
01513   }
01514   else {
01515     ProxyPatch *patch = (ProxyPatch *)PatchMap::Object()->patch(omsg->patch);
01516         ProxyCombinedResultMsg *ocMsg = patch->depositCombinedResultRawMsg(omsg);
01517     if (ocMsg) {
01518                 CProxy_ProxyMgr cp(CkpvAccess(BOCclass_group).proxyMgr);
01519                 ProxyCombinedResultRawMsg *cMsg = ProxyCombinedResultMsg::toRaw(ocMsg);         
01520                 cp[patch->getSpanningTreeParent()].recvImmediateResults(cMsg);
01521     }
01522   }
01523 }

void ProxyMgr::recvNodeAwareSpanningTree ( ProxyNodeAwareSpanningTreeMsg  ) 

Definition at line 1230 of file ProxyMgr.C.

References ResizeArray< Elem >::add(), ALLOCA, ProxyNodeAwareSpanningTreeMsg::allPes, ResizeArray< Elem >::item(), nodecount, ProxyNodeAwareSpanningTreeMsg::numNodesWithProxies, ProxyNodeAwareSpanningTreeMsg::numPesOfNode, Object(), PatchMap::Object(), PatchMap::patch(), ProxyNodeAwareSpanningTreeMsg::patch, ProxyNodeAwareSpanningTreeMsg::printOut(), ProxyNodeAwareSpanningTreeMsg::procID, NodeProxyMgr::registerPatch(), sendNodeAwareSpanningTree(), ProxyPatch::setSpanningTree(), and ResizeArray< Elem >::size().

01230                                                                           {
01231 #if defined(PROCTRACE_DEBUG) && defined(NAST_DEBUG)
01232     DebugFileTrace *dft = DebugFileTrace::Object();
01233     dft->openTrace();
01234     dft->writeTrace("PMgr::recvST0 for patch[%d] with #nodes=%d\n", msg->patch, msg->numNodesWithProxies);
01235     dft->closeTrace();
01236     msg->printOut("PMgr::recvST");
01237 #endif
01238 
01239     //This function is divided into three parts. The tree root is msg->allPes[0]
01240     //1. set up its own immediate childrens
01241     int treesize = msg->numNodesWithProxies; //at least include one as its internal procs    
01242     int iNChild = msg->numPesOfNode[0]-1; //number of internal children
01243     int eNChild = treesize-1; //number of external children
01244 
01245     CmiAssert(treesize>0);
01246     //use the same way of computing children in HomePatch::setupChildrenFromProxySpanningTree    
01247     eNChild = (proxySpanDim>eNChild)?eNChild:proxySpanDim;
01248     int iSlots = proxySpanDim-eNChild;
01249     if(iNChild>0) {
01250         if(iSlots==0){
01251             //at least having one internal child
01252             iNChild = 1;    
01253         }else{
01254             iNChild = (iSlots>iNChild)?iNChild:iSlots;
01255         }
01256     }    
01257     int numChild = iNChild + eNChild;
01258     if(numChild==0){
01259         //Indicating this proxy is a leaf in the spanning tree
01260         ProxyPatch *proxy = (ProxyPatch *) PatchMap::Object()->patch(msg->patch);
01261         proxy->setSpanningTree(msg->procID, NULL, 0);
01262 #if defined(NODEAWARE_PROXY_SPANNINGTREE) && defined(USE_NODEPATCHMGR)
01263                 //When using NODEPATCHMGR, the proc-level is a flat list attached to the node
01264                 //while the node-level spanning tree obeys the branch factor.
01265                 //As a result, when passing down spanning trees, if this proc is on the same node
01266                 //of its parent, then the NodeProxyMgr has already been set by its parent. There's
01267                 //no need resetting here. However, the nodeChildren attached to this proxy has
01268                 //to be set to NULL. -Chao Mei
01269                 int onSameNode = (CkMyNode() == CkNodeOf(msg->procID));
01270         //set up proxyInfo inside NodeProxyMgr
01271         if(!onSameNode && !PatchMap::Object()->homePatch(msg->patch)){
01272             //only when this processor contains a proxy patch of "msg->patch"
01273             //is the patch registeration in NodeProxyMgr needed,
01274             //and itself needs to be registered
01275             CProxy_NodeProxyMgr pm(CkpvAccess(BOCclass_group).nodeProxyMgr);
01276             NodeProxyMgr *npm = pm[CkMyNode()].ckLocalBranch();        
01277             npm->registerPatch(msg->patch, msg->numPesOfNode[0], msg->allPes);            
01278         }
01279         //set children in terms of node ids
01280         proxy->setSTNodeChildren(0, NULL);       
01281 #endif
01282         delete msg;
01283         return;
01284     }
01285 
01286     nodecount++;
01287     //if (nodecount > MAX_INTERNODE) 
01288     //  iout << "Processor " << CkMyPe() << "has (actual) " << nodecount << " intermediate nodes." << endi;
01289 
01290     if(!PatchMap::Object()->homePatch(msg->patch)){
01291         //the home patch of this spanning tree has been already set
01292         //in HomePatch::setupChildrenFromProxySpanningTree, so we
01293         //only care about the children setup for proxy patches here
01294         ProxyPatch *proxy = (ProxyPatch *) PatchMap::Object()->patch(msg->patch);
01295         ALLOCA(int,children,numChild);
01296         //add external children
01297         int *p = msg->allPes + msg->numPesOfNode[0];
01298         for(int i=0; i<eNChild; i++) {
01299             children[i] = *p;
01300             p += msg->numPesOfNode[i+1];
01301         }
01302         //add internal children
01303         for(int i=eNChild, j=1; i<numChild; i++, j++) {
01304             children[i] = msg->allPes[j]; 
01305         }
01306         proxy->setSpanningTree(msg->procID, children, numChild);
01307 
01308 #if defined(NODEAWARE_PROXY_SPANNINGTREE) && defined(USE_NODEPATCHMGR)
01309                 int onSameNode = (CkMyNode() == CkNodeOf(msg->procID));
01310                 if(!onSameNode) {
01311                         //set up proxyInfo inside NodeProxyMgr
01312                         CProxy_NodeProxyMgr pm(CkpvAccess(BOCclass_group).nodeProxyMgr);
01313                         NodeProxyMgr *npm = pm[CkMyNode()].ckLocalBranch();        
01314                         npm->registerPatch(msg->patch, msg->numPesOfNode[0], msg->allPes);        
01315         
01316                         //set children in terms of node ids
01317                         ALLOCA(int,nodeChildren,eNChild+1);
01318                         p = msg->allPes + msg->numPesOfNode[0];
01319                         for(int i=0; i<eNChild; i++) {
01320                                 nodeChildren[i] = CkNodeOf(*p);
01321                                 p += msg->numPesOfNode[i+1];
01322                         }
01323                         //the last entry always stores the node id that contains this proxy
01324                         nodeChildren[eNChild] = CkNodeOf(msg->allPes[0]);
01325                         proxy->setSTNodeChildren(eNChild+1, nodeChildren);
01326                 } else {
01327                         proxy->setSTNodeChildren(0, NULL);
01328                 }
01329 #endif
01330     }
01331 
01332     //2. send msgs for the tree to children proxies
01333     ResizeArray<int> *exTreeChildSize = new ResizeArray<int>[numChild];
01334     ResizeArray<int *> *exTreeChildPtr = new ResizeArray<int *>[numChild];    
01335 
01336     //2a. first processing children of external nodes
01337     if(eNChild > 0) {    
01338         int nodesToCnt = 1; //the number of children each root (current root's 
01339                             //immedidate external nodes) has in each level
01340         int pos = 1; //track the iteration over msg->numPesOfNode and skip the current root
01341         int *pePtr = msg->allPes + msg->numPesOfNode[0];
01342         int done = 0;
01343         while(!done) {
01344             for(int childID=0; childID<eNChild; childID++) {
01345                 //iterate nodes on each level
01346                 for(int i=0; i<nodesToCnt; i++) {
01347                     int cursize = msg->numPesOfNode[pos];
01348                     exTreeChildSize[childID].add(cursize);
01349                     exTreeChildPtr[childID].add(pePtr);
01350                     pos++;
01351                     pePtr += cursize; 
01352                     if(pos==msg->numNodesWithProxies) {
01353                         done = 1;
01354                         break;
01355                     }
01356                 }
01357                 if(done) break;                         
01358             }
01359             nodesToCnt *= proxySpanDim;
01360         }
01361     }
01362 
01363     //2b. secondly processing children on the same node
01364     if(iNChild>0) {
01365         int nodesToCnt = 1; //the number of children each root (current root's 
01366                             //immedidate internal child proxies) has in each level
01367         int pos = 1; //track the iteration over proxies on the same node and skip the current root
01368         int *pePtr = msg->allPes+1; //skip the root
01369         int done = 0;
01370         while(!done) {
01371             for(int childID=eNChild; childID<numChild; childID++) {
01372                 //iterate nodes on each level
01373                 for(int i=0; i<nodesToCnt; i++) {                    
01374                     exTreeChildSize[childID].add(1);
01375                     exTreeChildPtr[childID].add(pePtr);
01376                     pos++;
01377                     pePtr++; 
01378                     if(pos==msg->numPesOfNode[0]) {
01379                         done = 1;
01380                         break;
01381                     }
01382                 }
01383                 if(done) break;                         
01384             }
01385             nodesToCnt *= proxySpanDim;
01386         }
01387     }
01388           
01389     for(int i=0; i<numChild; i++) {                
01390         ResizeArray<int> *allSizes = &exTreeChildSize[i];
01391         ResizeArray<int *> *allPtrs = &exTreeChildPtr[i];
01392         int totalNodes = allSizes->size();
01393         int totalPes = 0;
01394         for(int j=0; j<totalNodes; j++) totalPes += allSizes->item(j);
01395         ProxyNodeAwareSpanningTreeMsg *cmsg = new(totalNodes, totalPes, 0) ProxyNodeAwareSpanningTreeMsg;
01396         cmsg->patch = msg->patch;
01397         cmsg->procID = CkMyPe();
01398         cmsg->numNodesWithProxies = totalNodes;
01399         int *pAllPes = cmsg->allPes;
01400         for(int j=0; j<totalNodes; j++) {
01401             int numPes = allSizes->item(j);
01402             cmsg->numPesOfNode[j] = numPes;
01403             memcpy(pAllPes, allPtrs->item(j), sizeof(int)*numPes);
01404             pAllPes += numPes;
01405         }
01406         #if defined(PROCTRACE_DEBUG) && defined(NAST_DEBUG)
01407         cmsg->printOut("sndChi:");
01408         #endif
01409         ProxyMgr::Object()->sendNodeAwareSpanningTree(cmsg);
01410     }
01411     delete [] exTreeChildSize;
01412     delete [] exTreeChildPtr;  
01413     delete msg;
01414 }

void ProxyMgr::recvNodeAwareSpanningTreeOnHomePatch ( ProxyNodeAwareSpanningTreeMsg msg  ) 

Definition at line 1147 of file ProxyMgr.C.

References PatchMap::homePatch(), PatchMap::Object(), ProxyNodeAwareSpanningTreeMsg::patch, and HomePatch::recvNodeAwareSpanningTree().

01148 {
01149   HomePatch *p = PatchMap::Object()->homePatch(msg->patch);
01150   p->recvNodeAwareSpanningTree(msg);
01151   delete msg;
01152 }

void ProxyMgr::recvNodeAwareSTParent ( int  patch,
int  parent 
)

Definition at line 1416 of file ProxyMgr.C.

References PatchMap::Object(), PatchMap::patch(), and ProxyPatch::setSpanningTree().

01416                                                          {
01417 #if defined(PROCTRACE_DEBUG) && defined(NAST_DEBUG)
01418     DebugFileTrace *dft = DebugFileTrace::Object();
01419     dft->openTrace();
01420     dft->writeTrace("PMgr::recvSTParent: for ProxyPatch[%d], parent is %d\n", patch, parent);
01421     dft->closeTrace();
01422 #endif
01423     ProxyPatch *proxy = (ProxyPatch *) PatchMap::Object()->patch(patch);
01424     CmiAssert(proxy!=NULL);
01425     proxy->setSpanningTree(parent, NULL, 0);
01426 }

void ProxyMgr::recvPatchProxyInfo ( PatchProxyListMsg msg  ) 

Definition at line 659 of file ProxyMgr.C.

References buildSpanningTree0(), PatchProxyListMsg::numPatches, PatchMap::numPatches(), PatchMap::Object(), PatchProxyListMsg::patchIDs, ProxyTree::proxylist, PatchProxyListMsg::proxyListLen, ProxyTree::proxyMsgCount, PatchProxyListMsg::proxyPEs, ResizeArray< Elem >::resize(), and sendSpanningTrees().

00659                                                        {
00660         int nPatches = PatchMap::Object()->numPatches();
00661         if(ptree.proxylist == NULL) ptree.proxylist = new NodeIDList[nPatches];
00662         CmiAssert(msg->numPatches == nPatches);
00663         int peIdx = 0;
00664         for(int i=0; i<nPatches; i++) {
00665                 int pid = msg->patchIDs[i];
00666                 int plen = msg->proxyListLen[i];
00667                 ptree.proxylist[pid].resize(plen);
00668                 for(int j=0; j<plen; j++) {
00669                         ptree.proxylist[pid][j] = msg->proxyPEs[peIdx++];
00670                 }               
00671         }
00672         delete msg;
00673         
00674         //debug
00675         //outputProxyTree(ptree, nPatches);
00676 
00677         ptree.proxyMsgCount = 0;
00678     // building and sending of trees is done in two steps now
00679     // so that the building step can be shifted to the load balancer
00680 #ifdef NODEAWARE_PROXY_SPANNINGTREE
00681     buildNodeAwareSpanningTree0();
00682 #else
00683     buildSpanningTree0();
00684 #endif
00685     sendSpanningTrees();
00686 }

void ProxyMgr::recvProxies ( int  pid,
int *  list,
int  n 
)

Definition at line 634 of file ProxyMgr.C.

References buildSpanningTree0(), if(), PatchMap::numPatches(), PatchMap::Object(), ProxyTree::proxylist, ProxyTree::proxyMsgCount, ResizeArray< Elem >::resize(), and sendSpanningTrees().

00635 {
00636   int nPatches = PatchMap::Object()->numPatches();
00637   if (ptree.proxylist == NULL)
00638     ptree.proxylist = new NodeIDList[nPatches];
00639   ptree.proxylist[pid].resize(n);
00640   for (int i=0; i<n; i++)
00641     ptree.proxylist[pid][i] = list[i];
00642   ptree.proxyMsgCount ++;
00643   if (ptree.proxyMsgCount == nPatches) {
00644         //debug
00645         //outputProxyTree(ptree, nPatches);
00646 
00647     ptree.proxyMsgCount = 0;
00648     // building and sending of trees is done in two steps now
00649     // so that the building step can be shifted to the load balancer
00650 #ifdef NODEAWARE_PROXY_SPANNINGTREE
00651     buildNodeAwareSpanningTree0();
00652 #else
00653     buildSpanningTree0();    
00654 #endif
00655     sendSpanningTrees();
00656   }
00657 }

void ProxyMgr::recvProxyAll ( ProxyDataMsg  ) 

Definition at line 1694 of file ProxyMgr.C.

References PatchMap::Object(), ProxyDataMsg::patch, PatchMap::patch(), proxySendSpanning, and ProxyPatch::receiveAll().

01694                                         {
01695 //Chao Mei: hack for QD in case of SMP with immediate msg
01696 #if defined(NODEAWARE_PROXY_SPANNINGTREE) && defined(USE_NODEPATCHMGR) && (CMK_SMP) && defined(NAMDSRC_IMMQD_HACK)
01697     if(proxySendSpanning && msg->isFromImmMsgCall){
01698 //    CkPrintf("qdcreate called on pe[%d]\n", CkMyPe());
01699 //    fflush(stdout);
01700         //To compensate for the counter loss for message creation
01701         //inside the process of immediate message on comm thread
01702         CkpvAccess(_qd)->create();
01703     }
01704 #endif
01705 
01706   ProxyPatch *proxy = (ProxyPatch *) PatchMap::Object()->patch(msg->patch);
01707   proxy->receiveAll(msg); // deleted in ProxyPatch::receiveAtoms()
01708 }

void ProxyMgr::recvProxyData ( ProxyDataMsg  ) 

Definition at line 1580 of file ProxyMgr.C.

References PatchMap::Object(), ProxyDataMsg::patch, PatchMap::patch(), proxySendSpanning, and ProxyPatch::receiveData().

01580                                          {
01581 //Chao Mei: hack for QD in case of SMP with immediate msg
01582 #if defined(NODEAWARE_PROXY_SPANNINGTREE) && defined(USE_NODEPATCHMGR) && (CMK_SMP) && defined(NAMDSRC_IMMQD_HACK)
01583     if(proxySendSpanning && msg->isFromImmMsgCall){
01584 //    CkPrintf("qdcreate called on pe[%d]\n", CkMyPe());
01585 //    fflush(stdout);
01586         //To compensate for the counter loss for message creation
01587         //inside the process of immediate message on comm thread
01588         CkpvAccess(_qd)->create();
01589     }
01590 #endif
01591   ProxyPatch *proxy = (ProxyPatch *) PatchMap::Object()->patch(msg->patch);
01592   proxy->receiveData(msg); // deleted in ProxyPatch::receiveAtoms()
01593 }

void ProxyMgr::recvRegisterProxy ( RegisterProxyMsg  ) 

Definition at line 533 of file ProxyMgr.C.

References PatchMap::homePatch(), PatchMap::Object(), RegisterProxyMsg::patch, and HomePatch::registerProxy().

00533                                                  {
00534   HomePatch *homePatch = PatchMap::Object()->homePatch(msg->patch);
00535   homePatch->registerProxy(msg); // message deleted in registerProxy()
00536 }

void ProxyMgr::recvResult ( ProxyGBISP2ResultMsg  ) 

Definition at line 1873 of file ProxyMgr.C.

References PatchMap::homePatch(), PatchMap::Object(), ProxyGBISP2ResultMsg::patch, and HomePatch::receiveResult().

01873                                                    { //pp -r> hp
01874   HomePatch *homePatch = PatchMap::Object()->homePatch(msg->patch);
01875   homePatch->receiveResult(msg); // message deleted in registerProxy()
01876 }

void ProxyMgr::recvResult ( ProxyGBISP1ResultMsg  ) 

Definition at line 1858 of file ProxyMgr.C.

References PatchMap::homePatch(), PatchMap::Object(), ProxyGBISP1ResultMsg::patch, and HomePatch::receiveResult().

01858                                                    { //pp -r> hp
01859   HomePatch *homePatch = PatchMap::Object()->homePatch(msg->patch);
01860   homePatch->receiveResult(msg); // message deleted in registerProxy()
01861 }

void ProxyMgr::recvResults ( ProxyCombinedResultRawMsg  ) 

Definition at line 1482 of file ProxyMgr.C.

References PatchMap::homePatch(), NAMD_bug(), PatchMap::Object(), ProxyCombinedResultRawMsg::patch, proxyRecvSpanning, and HomePatch::receiveResults().

01482                                                           {
01483         ProxyCombinedResultRawMsg *msg = omsg;
01484 
01485 //Chao Mei: hack for QD in case of SMP with immediate msg
01486 #if defined(NODEAWARE_PROXY_SPANNINGTREE) && defined(USE_NODEPATCHMGR) && (CMK_SMP) && defined(NAMDSRC_IMMQD_HACK)
01487     if(proxyRecvSpanning && msg->isFromImmMsgCall){
01488 //    CkPrintf("qdcreate called on pe[%d]\n", CkMyPe());
01489 //    fflush(stdout);
01490         //To compensate for the counter loss for message creation
01491         //inside the process of immediate message on comm thread
01492         CkpvAccess(_qd)->create();
01493     }
01494 #endif
01495 
01496   HomePatch *home = PatchMap::Object()->homePatch(msg->patch);
01497   if (home) {
01498     //printf("Home got a message\n");
01499     home->receiveResults(msg); // delete done in HomePatch::receiveResults()
01500   }
01501   else {
01502     NAMD_bug("ProxyMgr should receive result message on home processor");
01503   }
01504 }

void ProxyMgr::recvResults ( ProxyResultMsg  ) 

Definition at line 1449 of file ProxyMgr.C.

References PatchMap::homePatch(), PatchMap::Object(), ProxyResultMsg::patch, and HomePatch::receiveResults().

01449                                               {
01450   HomePatch *home = PatchMap::Object()->homePatch(msg->patch);
01451   home->receiveResults(msg); // delete done in HomePatch::receiveResults()
01452 }

void ProxyMgr::recvResults ( ProxyResultVarsizeMsg  ) 

Definition at line 1436 of file ProxyMgr.C.

References PatchMap::homePatch(), PatchMap::Object(), ProxyResultVarsizeMsg::patch, and HomePatch::receiveResults().

01436                                                      {
01437     HomePatch *home = PatchMap::Object()->homePatch(msg->patch);
01438     home->receiveResults(msg); // delete done in HomePatch::receiveResults()
01439 }

void ProxyMgr::recvSpanningTree ( ProxySpanningTreeMsg  ) 

Definition at line 1175 of file ProxyMgr.C.

References ProxySpanningTreeMsg::node, PatchMap::Object(), ProxySpanningTreeMsg::patch, PatchMap::patch(), proxySpanDim, ProxyPatch::setSpanningTree(), ResizeArray< Elem >::size(), and ProxySpanningTreeMsg::tree.

01175                                                     {
01176   int size = msg->tree.size();
01177   int *child = new int[proxySpanDim];
01178   int nChild = 0;
01179   int i;
01180   ProxyPatch *proxy = (ProxyPatch *) PatchMap::Object()->patch(msg->patch);
01181   for (i=0; i<proxySpanDim; i++) {
01182     if (size > i+1) { child[i] = msg->tree[i+1]; nChild++; }
01183   }
01184   if (!PatchMap::Object()->homePatch(msg->patch)) {
01185     proxy->setSpanningTree(msg->node, child, nChild);
01186   }
01187 
01188   // build subtree and pass down
01189  if (nChild > 0) {
01190 
01191   nodecount ++;
01192   //if (nodecount > MAX_INTERNODE) 
01193   //  iout << "Processor " << CkMyPe() << "has (actual) " << nodecount << " intermediate nodes." << endi;
01194 
01195 //CkPrintf("[%d] %d:(%d) %d %d %d %d %d\n", CkMyPe(), msg->patch, size, msg->tree[0], msg->tree[1], msg->tree[2], msg->tree[3], msg->tree[4]);
01196   NodeIDList *tree = new NodeIDList[proxySpanDim];
01197   int level = 1, index=1;
01198   int done = 0;
01199   while (!done) {
01200     for (int n=0; n<nChild; n++) {
01201       if (done) break;
01202       for (int j=0; j<level; j++) {
01203        if (index >= size) { done = 1; break; }
01204        tree[n].add(msg->tree[index]);
01205        index++;
01206       }
01207     }
01208     level *=proxySpanDim;
01209   }
01210 
01211   ProxyMgr *proxyMgr = ProxyMgr::Object();
01212   for (i=0; i<proxySpanDim; i++) {
01213     if (tree[i].size()) {
01214       ProxySpanningTreeMsg *cmsg = new ProxySpanningTreeMsg;
01215       cmsg->patch = msg->patch;
01216       cmsg->node = CkMyPe();
01217       cmsg->tree.copy(tree[i]);  // copy data for thread safety
01218       proxyMgr->sendSpanningTree(cmsg);
01219     }
01220   }
01221 
01222   delete [] tree;
01223  }
01224 
01225   delete [] child;
01226   delete msg;
01227 }

void ProxyMgr::recvSpanningTreeOnHomePatch ( int  pid,
int *  tree,
int  n 
)

Definition at line 1134 of file ProxyMgr.C.

References PatchMap::homePatch(), PatchMap::Object(), and HomePatch::recvSpanningTree().

01135 {
01136   HomePatch *p = PatchMap::Object()->homePatch(pid);
01137   p->recvSpanningTree(tree, n);
01138 }

void ProxyMgr::recvUnregisterProxy ( UnregisterProxyMsg  ) 

Definition at line 553 of file ProxyMgr.C.

References PatchMap::homePatch(), PatchMap::Object(), UnregisterProxyMsg::patch, and HomePatch::unregisterProxy().

00553                                                      {
00554   HomePatch *homePatch = PatchMap::Object()->homePatch(msg->patch);
00555   homePatch->unregisterProxy(msg); // message deleted in registerProxy()
00556 }

void ProxyMgr::registerProxy ( PatchID  pid  ) 

Definition at line 519 of file ProxyMgr.C.

References RegisterProxyMsg::node, PatchMap::node(), PatchMap::Object(), and RegisterProxyMsg::patch.

Referenced by ProxyPatch::ProxyPatch().

00519                                    {
00520   // determine which node gets message
00521   NodeID node = PatchMap::Object()->node(pid);
00522 
00523   RegisterProxyMsg *msg = new RegisterProxyMsg;
00524 
00525   msg->node=CkMyPe();
00526   msg->patch = pid;
00527 
00528   CProxy_ProxyMgr cp(CkpvAccess(BOCclass_group).proxyMgr);
00529   cp[node].recvRegisterProxy(msg);
00530 }

void ProxyMgr::removeProxies ( void   ) 

Definition at line 389 of file ProxyMgr.C.

References UniqueSetIter< T >::begin(), UniqueSet< Elem >::clear(), and UniqueSetIter< T >::end().

Referenced by createProxies(), and ~ProxyMgr().

00390 {
00391   ProxySetIter pi(proxySet);
00392   for ( pi = pi.begin(); pi != pi.end(); pi++)
00393   {
00394     delete pi->proxyPatch;
00395   }
00396   proxySet.clear();
00397 }

void ProxyMgr::removeProxy ( PatchID  pid  ) 

Definition at line 508 of file ProxyMgr.C.

References UniqueSet< Elem >::del(), UniqueSet< Elem >::find(), PatchMap::Object(), ProxyElem::proxyPatch, and PatchMap::unregisterPatch().

Referenced by removeUnusedProxies().

00508                                  {
00509   ProxyElem *p = proxySet.find(ProxyElem(pid));
00510   if (p) { 
00511     PatchMap::Object()->unregisterPatch(pid,p->proxyPatch);
00512     delete p->proxyPatch;
00513     proxySet.del(ProxyElem(pid));
00514     // iout << iINFO << "Removing unused proxy " << pid << " on " << iPE << ".\n" << endi;
00515   }
00516 }

void ProxyMgr::removeUnusedProxies ( void   ) 

Definition at line 399 of file ProxyMgr.C.

References ResizeArray< Elem >::add(), ResizeArray< Elem >::begin(), UniqueSetIter< T >::begin(), ResizeArray< Elem >::end(), UniqueSetIter< T >::end(), and removeProxy().

Referenced by ComputeMgr::updateLocalComputes3().

00400 {
00401   ResizeArray<PatchID> toDelete;
00402   ProxySetIter pi(proxySet);
00403   for ( pi = pi.begin(); pi != pi.end(); pi++)
00404   {
00405     if ( pi->proxyPatch->getNumComputes() == 0 ) {
00406       toDelete.add(pi->patchID);
00407       //fprintf(stderr, "Proxy Deleted Patch %d Proc %d", pi->patchID, CkMyPe());
00408     }
00409   }
00410   PatchID *pidi = toDelete.begin();
00411   for ( ; pidi != toDelete.end(); ++pidi ) {
00412     removeProxy(*pidi);
00413   }
00414 }

void ProxyMgr::sendNodeAwareSpanningTree ( ProxyNodeAwareSpanningTreeMsg  ) 

Definition at line 1160 of file ProxyMgr.C.

References ProxyNodeAwareSpanningTreeMsg::allPes, and ProxyNodeAwareSpanningTreeMsg::patch.

Referenced by recvNodeAwareSpanningTree().

01160                                                                           {
01161   CProxy_ProxyMgr cp(CkpvAccess(BOCclass_group).proxyMgr);
01162   int pe = msg->allPes[0]; //the root procID
01163 
01164 #if defined(PROCTRACE_DEBUG) && defined(NAST_DEBUG)
01165   DebugFileTrace *dft = DebugFileTrace::Object();
01166   dft->openTrace();
01167   dft->writeTrace("PMgr::sndST: from proc %d for patch[%d]\n", pe, msg->patch);
01168   dft->closeTrace();
01169 #endif
01170 
01171   cp[pe].recvNodeAwareSpanningTree(msg);
01172 }

void ProxyMgr::sendNodeAwareSpanningTreeToHomePatch ( int  pid,
proxyTreeNode tree,
int  n 
)

Definition at line 1140 of file ProxyMgr.C.

References ProxyNodeAwareSpanningTreeMsg::getANewMsg(), PatchMap::node(), and PatchMap::Object().

Referenced by sendSpanningTrees().

01141 {
01142   CProxy_ProxyMgr cp(thisgroup);
01143   ProxyNodeAwareSpanningTreeMsg *msg = ProxyNodeAwareSpanningTreeMsg::getANewMsg(pid, -1, tree, n);
01144   cp[PatchMap::Object()->node(pid)].recvNodeAwareSpanningTreeOnHomePatch(msg);
01145 }

void ProxyMgr::sendProxies ( int  pid,
int *  list,
int  n 
)

Definition at line 600 of file ProxyMgr.C.

Referenced by HomePatch::sendProxies().

00601 {
00602   CProxy_ProxyMgr cp(CkpvAccess(BOCclass_group).proxyMgr);
00603   cp[0].recvProxies(pid, list, n);
00604 }

void ProxyMgr::sendProxyAll ( ProxyDataMsg ,
int  ,
int *   
)

Definition at line 1677 of file ProxyMgr.C.

References proxySendSpanning.

Referenced by HomePatch::positionsReady(), and recvImmediateProxyAll().

01677                                                              {
01678 #if defined(NODEAWARE_PROXY_SPANNINGTREE) && defined(USE_NODEPATCHMGR)
01679     if(proxySendSpanning == 1) {
01680         CProxy_NodeProxyMgr cnp(CkpvAccess(BOCclass_group).nodeProxyMgr);
01681         for(int i=0; i<pcnt-1; i++) {
01682             ProxyDataMsg *copymsg = (ProxyDataMsg *)CkCopyMsg((void **)&msg);
01683             cnp[pids[i]].recvImmediateProxyAll(copymsg);
01684         }
01685         cnp[pids[pcnt-1]].recvImmediateProxyAll(msg);
01686         return;
01687     }
01688 #endif
01689   CProxy_ProxyMgr cp(CkpvAccess(BOCclass_group).proxyMgr);
01690   cp.recvImmediateProxyAll(msg,pcnt,pids);
01691 }

void ProxyMgr::sendProxyData ( ProxyDataMsg ,
int  ,
int *   
)

Definition at line 1563 of file ProxyMgr.C.

References proxySendSpanning.

Referenced by HomePatch::positionsReady(), and recvImmediateProxyData().

01563                                                               {
01564 #if defined(NODEAWARE_PROXY_SPANNINGTREE) && defined(USE_NODEPATCHMGR)
01565     if(proxySendSpanning == 1) {
01566         CProxy_NodeProxyMgr cnp(CkpvAccess(BOCclass_group).nodeProxyMgr);
01567         for(int i=0; i<pcnt-1; i++) {
01568             ProxyDataMsg *copymsg = (ProxyDataMsg *)CkCopyMsg((void **)&msg);
01569             cnp[pids[i]].recvImmediateProxyData(copymsg);
01570         }
01571         cnp[pids[pcnt-1]].recvImmediateProxyData(msg);
01572         return;
01573     }
01574 #endif
01575   CProxy_ProxyMgr cp(CkpvAccess(BOCclass_group).proxyMgr);
01576   cp.recvImmediateProxyData(msg,pcnt,pids);
01577 }

void ProxyMgr::sendResult ( ProxyGBISP2ResultMsg  ) 

Definition at line 1866 of file ProxyMgr.C.

References PatchMap::node(), PatchMap::Object(), and ProxyGBISP2ResultMsg::patch.

01866                                                    { //pp -r> hp
01867   CProxy_ProxyMgr cp(CkpvAccess(BOCclass_group).proxyMgr);
01868   NodeID node = PatchMap::Object()->node(msg->patch);
01869   CmiEnableUrgentSend(1);
01870   cp[node].recvResult(msg);
01871   CmiEnableUrgentSend(0);
01872 }

void ProxyMgr::sendResult ( ProxyGBISP1ResultMsg  ) 

Definition at line 1851 of file ProxyMgr.C.

References PatchMap::node(), PatchMap::Object(), and ProxyGBISP1ResultMsg::patch.

Referenced by ProxyPatch::boxClosed().

01851                                                    { //pp -r> hp
01852   CProxy_ProxyMgr cp(CkpvAccess(BOCclass_group).proxyMgr);
01853   NodeID node = PatchMap::Object()->node(msg->patch);
01854   CmiEnableUrgentSend(1);
01855   cp[node].recvResult(msg);
01856   CmiEnableUrgentSend(0);
01857 }

void ProxyMgr::sendResults ( ProxyCombinedResultMsg  ) 

Definition at line 1455 of file ProxyMgr.C.

References ProxyPatch::depositCombinedResultMsg(), ProxyPatch::getSpanningTreeParent(), PatchMap::Object(), ProxyCombinedResultMsg::patch, PatchMap::patch(), and ProxyCombinedResultMsg::toRaw().

01455                                                       {
01456   ProxyPatch *patch = (ProxyPatch *)PatchMap::Object()->patch(msg->patch);
01457   ProxyCombinedResultMsg *ocMsg = patch->depositCombinedResultMsg(msg);
01458   if (ocMsg) {
01459         ProxyCombinedResultRawMsg *cMsg = ProxyCombinedResultMsg::toRaw(ocMsg);        
01460     int destPe = patch->getSpanningTreeParent();
01461     CProxy_ProxyMgr cp(CkpvAccess(BOCclass_group).proxyMgr);
01462     CmiAssert(destPe!=CkMyPe());
01463     //if(destPe != CkMyPe()) {
01464 #if defined(NODEAWARE_PROXY_SPANNINGTREE) && defined(USE_NODEPATCHMGR)
01465       /*CkPrintf("ready to call node::recvImmRes on pe[%d] to dest[%d]\n", CkMyPe(), destPe);
01466       fflush(stdout);*/
01467 
01468       cMsg->destPe = destPe;
01469       CProxy_NodeProxyMgr cnp(CkpvAccess(BOCclass_group).nodeProxyMgr);
01470       cnp[CkNodeOf(destPe)].recvImmediateResults(cMsg);
01471 #else
01472       cp[destPe].recvImmediateResults(cMsg);
01473 #endif
01474     //}
01475     //else{
01477     //  cp[destPe].recvResults(cMsg);
01478     //}
01479   }
01480 }

void ProxyMgr::sendResults ( ProxyResultMsg  ) 

Definition at line 1441 of file ProxyMgr.C.

References PatchMap::node(), PatchMap::Object(), and ProxyResultMsg::patch.

01441                                               {
01442   CProxy_ProxyMgr cp(CkpvAccess(BOCclass_group).proxyMgr);
01443   NodeID node = PatchMap::Object()->node(msg->patch);
01444   CmiEnableUrgentSend(1);
01445   cp[node].recvResults(msg);
01446   CmiEnableUrgentSend(0);
01447 }

void ProxyMgr::sendResults ( ProxyResultVarsizeMsg  ) 

Definition at line 1428 of file ProxyMgr.C.

References PatchMap::node(), PatchMap::Object(), and ProxyResultVarsizeMsg::patch.

01428                                                      {
01429     CProxy_ProxyMgr cp(CkpvAccess(BOCclass_group).proxyMgr);
01430     NodeID node = PatchMap::Object()->node(msg->patch);
01431     CmiEnableUrgentSend(1);
01432     cp[node].recvResults(msg);
01433     CmiEnableUrgentSend(0);
01434 }

void ProxyMgr::sendSpanningTree ( ProxySpanningTreeMsg  ) 

Definition at line 1155 of file ProxyMgr.C.

References ProxySpanningTreeMsg::tree.

Referenced by HomePatch::sendSpanningTree().

01155                                                     {
01156   CProxy_ProxyMgr cp(CkpvAccess(BOCclass_group).proxyMgr);
01157   cp[msg->tree[0]].recvSpanningTree(msg);
01158 }

void ProxyMgr::sendSpanningTrees (  ) 

Definition at line 1107 of file ProxyMgr.C.

References ResizeArray< Elem >::begin(), PatchMap::numPatches(), Object(), PatchMap::Object(), ProxyTree::proxylist, sendNodeAwareSpanningTreeToHomePatch(), sendSpanningTreeToHomePatch(), ResizeArray< Elem >::size(), and ProxyTree::trees.

Referenced by recvPatchProxyInfo(), recvProxies(), and ComputeMgr::updateLocalComputes5().

01108 {
01109   int numPatches = PatchMap::Object()->numPatches();
01110   for (int pid=0; pid<numPatches; pid++) {
01111     int numProxies = ptree.proxylist[pid].size();
01112 #ifdef NODEAWARE_PROXY_SPANNINGTREE
01113     if (numProxies == 0)
01114       ProxyMgr::Object()->sendNodeAwareSpanningTreeToHomePatch(pid, NULL, 0);
01115     else {
01116       ProxyMgr::Object()->sendNodeAwareSpanningTreeToHomePatch(pid, ptree.naTrees[pid].begin(), ptree.naTrees[pid].size());
01117     }
01118 #else
01119     if (numProxies == 0)
01120       ProxyMgr::Object()->sendSpanningTreeToHomePatch(pid, NULL, 0);
01121     else {
01122       ProxyMgr::Object()->sendSpanningTreeToHomePatch(pid, ptree.trees[pid].begin(), ptree.trees[pid].size());
01123     }
01124 #endif
01125   }
01126 }

void ProxyMgr::sendSpanningTreeToHomePatch ( int  pid,
int *  tree,
int  n 
)

Definition at line 1128 of file ProxyMgr.C.

References PatchMap::node(), and PatchMap::Object().

Referenced by sendSpanningTrees().

01129 {
01130   CProxy_ProxyMgr cp(thisgroup);
01131   cp[PatchMap::Object()->node(pid)].recvSpanningTreeOnHomePatch(pid, tree, n);
01132 }

void ProxyMgr::setProxyTreeBranchFactor ( int  dim  ) 

Definition at line 380 of file ProxyMgr.C.

References proxySpanDim.

Referenced by Node::startup().

00380                                               {
00381     if(CkMyRank()!=0) return;
00382     proxySpanDim = dim;
00383 }

void ProxyMgr::setRecvSpanning (  ) 

Definition at line 371 of file ProxyMgr.C.

References proxyRecvSpanning.

Referenced by WorkDistrib::savePatchMap(), WorkDistrib::sendPatchMap(), and Node::startup().

00371                                {
00372   if(CkMyRank()!=0) return;
00373   proxyRecvSpanning = 1;
00374 }

void ProxyMgr::setSendSpanning (  ) 

Definition at line 362 of file ProxyMgr.C.

References proxySendSpanning.

Referenced by WorkDistrib::savePatchMap(), WorkDistrib::sendPatchMap(), and Node::startup().

00362                                {
00363   if(CkMyRank()!=0) return; 
00364   proxySendSpanning = 1;
00365 }

void ProxyMgr::unregisterProxy ( PatchID  pid  ) 

Definition at line 539 of file ProxyMgr.C.

References UnregisterProxyMsg::node, PatchMap::node(), PatchMap::Object(), and UnregisterProxyMsg::patch.

Referenced by ProxyPatch::~ProxyPatch().

00539                                      {
00540   // determine which node gets message
00541   NodeID node = PatchMap::Object()->node(pid);
00542 
00543   UnregisterProxyMsg *msg = new UnregisterProxyMsg;
00544 
00545   msg->node=CkMyPe();
00546   msg->patch = pid;
00547 
00548   CProxy_ProxyMgr cp(CkpvAccess(BOCclass_group).proxyMgr);
00549   cp[node].recvUnregisterProxy(msg);
00550 }


Member Data Documentation

int ProxyMgr::nodecount = 0 [static]

Definition at line 398 of file ProxyMgr.h.

Referenced by recvNodeAwareSpanningTree(), and ComputeMgr::updateLocalComputes3().


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