Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members

ProxyMgr Class Reference

#include <ProxyMgr.h>

Inheritance diagram for ProxyMgr:

BOCclass 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

ProxyMgrObject ()

Static Public Attributes

int nodecount = 0

Constructor & Destructor Documentation

ProxyMgr::ProxyMgr  ) 
 

Definition at line 342 of file ProxyMgr.C.

References NAMD_bug().

00342                    { 
00343   if (CkpvAccess(ProxyMgr_instance)) {
00344     NAMD_bug("Tried to create ProxyMgr twice.");
00345   }
00346   CkpvAccess(ProxyMgr_instance) = this;
00347 }

ProxyMgr::~ProxyMgr  ) 
 

Definition at line 349 of file ProxyMgr.C.

References removeProxies().

00349                     { 
00350   removeProxies();
00351   CkpvAccess(ProxyMgr_instance) = NULL;
00352 }


Member Function Documentation

void ProxyMgr::buildProxySpanningTree  ) 
 

Definition at line 546 of file ProxyMgr.C.

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

Referenced by Node::startup().

00547 {
00548   PatchIDList pids;
00549   if (!CkMyPe()) iout << iINFO << "Building spanning tree ... send: " << proxySendSpanning << " recv: " << proxyRecvSpanning 
00550       << " with branch factor " << proxySpanDim <<"\n" << endi;
00551   PatchMap::Object()->homePatchIDList(pids);
00552   for (int i=0; i<pids.size(); i++) {
00553     HomePatch *home = PatchMap::Object()->homePatch(pids[i]);
00554     if (home == NULL) CkPrintf("ERROR: homepatch NULL\n");
00555 #ifdef NODEAWARE_PROXY_SPANNINGTREE
00556     home->buildNodeAwareSpanningTree();
00557 #else
00558     home->buildSpanningTree();
00559 #endif
00560   }
00561 }

void ProxyMgr::buildProxySpanningTree2  ) 
 

Definition at line 564 of file ProxyMgr.C.

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

Referenced by ComputeMgr::updateLocalComputes5().

00565 {
00566 #if 0
00567   //The homePatchIDList is an expensive as it goes through
00568   //every patch ids.
00569   PatchIDList pids;
00570   PatchMap::Object()->homePatchIDList(pids);
00571   for (int i=0; i<pids.size(); i++) {
00572     HomePatch *home = PatchMap::Object()->homePatch(pids[i]);
00573     if (home == NULL) CkPrintf("ERROR: homepatch NULL\n");
00574     home->sendProxies();
00575   }
00576 #else
00577   HomePatchList *hpl = PatchMap::Object()->homePatchList();
00578   HomePatchListIter iter(*hpl);
00579   for(iter=iter.begin(); iter!=iter.end(); iter++) {
00580           HomePatch *home = iter->patch;
00581           home->sendProxies();
00582   }
00583 #endif
00584 }

void ProxyMgr::buildSpanningTree0  ) 
 

Definition at line 995 of file ProxyMgr.C.

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

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

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

void ProxyMgr::createProxies void   ) 
 

Definition at line 410 of file ProxyMgr.C.

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

Referenced by Node::startup().

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

void ProxyMgr::createProxy PatchID  pid  ) 
 

Definition at line 480 of file ProxyMgr.C.

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

Referenced by ComputeNonbondedCUDA::registerPatches(), and ComputeMgr::updateLocalComputes().

00480                                  {
00481   Patch *p = PatchMap::Object()->patch(pid);
00482   if (!p) {
00483      DebugM(4,"createProxy("<<pid<<")\n");
00484      ProxyPatch *proxy = new ProxyPatch(pid);
00485      proxySet.add(ProxyElem(pid,proxy));
00486      PatchMap::Object()->registerPatch(pid,proxy);
00487   }
00488   else {
00489      DebugM(4,"createProxy("<<pid<<") found " << p->getPatchID() << "\n");
00490   }
00491     
00492 }

ProxyTree & ProxyMgr::getPtree  ) 
 

Definition at line 378 of file ProxyMgr.C.

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

00378                               {
00379   return ptree;
00380 }

int ProxyMgr::getRecvSpanning  ) 
 

Definition at line 369 of file ProxyMgr.C.

Referenced by Node::startup().

00369                               {
00370   return proxyRecvSpanning;
00371 }

int ProxyMgr::getSendSpanning  ) 
 

Definition at line 360 of file ProxyMgr.C.

Referenced by Node::startup().

00360                               {
00361   return proxySendSpanning;
00362 }

int ProxyMgr::numProxies  )  [inline]
 

Definition at line 396 of file ProxyMgr.h.

References UniqueSet< Elem >::size().

Referenced by buildSpanningTree0(), Sync::openSync(), and sendSpanningTrees().

00396 { return proxySet.size(); }

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

Definition at line 394 of file ProxyMgr.h.

Referenced by ProxyPatch::boxClosed(), Rebalancer::createSpanningTree(), Rebalancer::decrSTLoad(), Rebalancer::incrSTLoad(), Sync::openSync(), HomePatch::positionsReady(), ProxyPatch::ProxyPatch(), recvImmediateProxyAll(), recvImmediateProxyData(), recvNodeAwareSpanningTree(), recvSpanningTree(), 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 1865 of file ProxyMgr.C.

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

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

void ProxyMgr::recvData ProxyGBISP2DataMsg  ) 
 

Definition at line 1850 of file ProxyMgr.C.

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

01850                                                  {  //hp -d> pp
01851   ProxyPatch *proxy = (ProxyPatch *) PatchMap::Object()->patch(msg->patch);
01852   proxy->receiveData(msg); // deleted in ProxyPatch::receiveAtoms() ?
01853 }

void ProxyMgr::recvImmediateProxyAll ProxyDataMsg  ) 
 

Definition at line 1699 of file ProxyMgr.C.

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

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

void ProxyMgr::recvImmediateProxyData ProxyDataMsg  ) 
 

Definition at line 1584 of file ProxyMgr.C.

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

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

void ProxyMgr::recvImmediateResults ProxyCombinedResultRawMsg  ) 
 

Definition at line 1494 of file ProxyMgr.C.

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

01494                                                                    {
01495   HomePatch *home = PatchMap::Object()->homePatch(omsg->patch);
01496   if (home) {
01497     CProxy_ProxyMgr cp(CkpvAccess(BOCclass_group).proxyMgr);        
01498     CmiEnableUrgentSend(1);
01499     cp[CkMyPe()].recvResults(omsg);
01500     CmiEnableUrgentSend(0);
01501   }
01502   else {
01503     ProxyPatch *patch = (ProxyPatch *)PatchMap::Object()->patch(omsg->patch);
01504         ProxyCombinedResultMsg *ocMsg = patch->depositCombinedResultRawMsg(omsg);
01505     if (ocMsg) {
01506                 CProxy_ProxyMgr cp(CkpvAccess(BOCclass_group).proxyMgr);
01507                 ProxyCombinedResultRawMsg *cMsg = ProxyCombinedResultMsg::toRaw(ocMsg);         
01508                 cp[patch->getSpanningTreeParent()].recvImmediateResults(cMsg);
01509     }
01510   }
01511 }

void ProxyMgr::recvNodeAwareSpanningTree ProxyNodeAwareSpanningTreeMsg  ) 
 

Definition at line 1218 of file ProxyMgr.C.

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

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

void ProxyMgr::recvNodeAwareSpanningTreeOnHomePatch ProxyNodeAwareSpanningTreeMsg msg  ) 
 

Definition at line 1135 of file ProxyMgr.C.

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

01136 {
01137   HomePatch *p = PatchMap::Object()->homePatch(msg->patch);
01138   p->recvNodeAwareSpanningTree(msg);
01139   delete msg;
01140 }

void ProxyMgr::recvNodeAwareSTParent int  patch,
int  parent
 

Definition at line 1404 of file ProxyMgr.C.

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

01404                                                          {
01405 #if defined(PROCTRACE_DEBUG) && defined(NAST_DEBUG)
01406     DebugFileTrace *dft = DebugFileTrace::Object();
01407     dft->openTrace();
01408     dft->writeTrace("PMgr::recvSTParent: for ProxyPatch[%d], parent is %d\n", patch, parent);
01409     dft->closeTrace();
01410 #endif
01411     ProxyPatch *proxy = (ProxyPatch *) PatchMap::Object()->patch(patch);
01412     CmiAssert(proxy!=NULL);
01413     proxy->setSpanningTree(parent, NULL, 0);
01414 }

void ProxyMgr::recvPatchProxyInfo PatchProxyListMsg msg  ) 
 

Definition at line 646 of file ProxyMgr.C.

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

00646                                                        {
00647         int nPatches = PatchMap::Object()->numPatches();
00648         if(ptree.proxylist == NULL) ptree.proxylist = new NodeIDList[nPatches];
00649         CmiAssert(msg->numPatches == nPatches);
00650         int peIdx = 0;
00651         for(int i=0; i<nPatches; i++) {
00652                 int pid = msg->patchIDs[i];
00653                 int plen = msg->proxyListLen[i];
00654                 ptree.proxylist[pid].resize(plen);
00655                 for(int j=0; j<plen; j++) {
00656                         ptree.proxylist[pid][j] = msg->proxyPEs[peIdx++];
00657                 }               
00658         }
00659         delete msg;
00660         
00661         //debug
00662         //outputProxyTree(ptree, nPatches);
00663 
00664         ptree.proxyMsgCount = 0;
00665     // building and sending of trees is done in two steps now
00666     // so that the building step can be shifted to the load balancer
00667 #ifdef NODEAWARE_PROXY_SPANNINGTREE
00668     buildNodeAwareSpanningTree0();
00669 #else
00670     buildSpanningTree0();
00671 #endif
00672     sendSpanningTrees();
00673 }

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

Definition at line 621 of file ProxyMgr.C.

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

00622 {
00623   int nPatches = PatchMap::Object()->numPatches();
00624   if (ptree.proxylist == NULL)
00625     ptree.proxylist = new NodeIDList[nPatches];
00626   ptree.proxylist[pid].resize(n);
00627   for (int i=0; i<n; i++)
00628     ptree.proxylist[pid][i] = list[i];
00629   ptree.proxyMsgCount ++;
00630   if (ptree.proxyMsgCount == nPatches) {
00631         //debug
00632         //outputProxyTree(ptree, nPatches);
00633 
00634     ptree.proxyMsgCount = 0;
00635     // building and sending of trees is done in two steps now
00636     // so that the building step can be shifted to the load balancer
00637 #ifdef NODEAWARE_PROXY_SPANNINGTREE
00638     buildNodeAwareSpanningTree0();
00639 #else
00640     buildSpanningTree0();    
00641 #endif
00642     sendSpanningTrees();
00643   }
00644 }

void ProxyMgr::recvProxyAll ProxyDataMsg  ) 
 

Definition at line 1682 of file ProxyMgr.C.

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

Referenced by recvImmediateProxyAll().

01682                                         {
01683 //Chao Mei: hack for QD in case of SMP with immediate msg
01684 #if defined(NODEAWARE_PROXY_SPANNINGTREE) && defined(USE_NODEPATCHMGR) && (CMK_SMP) && defined(NAMDSRC_IMMQD_HACK)
01685     if(proxySendSpanning && msg->isFromImmMsgCall){
01686 //    CkPrintf("qdcreate called on pe[%d]\n", CkMyPe());
01687 //    fflush(stdout);
01688         //To compensate for the counter loss for message creation
01689         //inside the process of immediate message on comm thread
01690         CkpvAccess(_qd)->create();
01691     }
01692 #endif
01693 
01694   ProxyPatch *proxy = (ProxyPatch *) PatchMap::Object()->patch(msg->patch);
01695   proxy->receiveAll(msg); // deleted in ProxyPatch::receiveAtoms()
01696 }

void ProxyMgr::recvProxyData ProxyDataMsg  ) 
 

Definition at line 1568 of file ProxyMgr.C.

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

Referenced by recvImmediateProxyData().

01568                                          {
01569 //Chao Mei: hack for QD in case of SMP with immediate msg
01570 #if defined(NODEAWARE_PROXY_SPANNINGTREE) && defined(USE_NODEPATCHMGR) && (CMK_SMP) && defined(NAMDSRC_IMMQD_HACK)
01571     if(proxySendSpanning && msg->isFromImmMsgCall){
01572 //    CkPrintf("qdcreate called on pe[%d]\n", CkMyPe());
01573 //    fflush(stdout);
01574         //To compensate for the counter loss for message creation
01575         //inside the process of immediate message on comm thread
01576         CkpvAccess(_qd)->create();
01577     }
01578 #endif
01579   ProxyPatch *proxy = (ProxyPatch *) PatchMap::Object()->patch(msg->patch);
01580   proxy->receiveData(msg); // deleted in ProxyPatch::receiveAtoms()
01581 }

void ProxyMgr::recvRegisterProxy RegisterProxyMsg  ) 
 

Definition at line 520 of file ProxyMgr.C.

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

00520                                                  {
00521   HomePatch *homePatch = PatchMap::Object()->homePatch(msg->patch);
00522   homePatch->registerProxy(msg); // message deleted in registerProxy()
00523 }

void ProxyMgr::recvResult ProxyGBISP2ResultMsg  ) 
 

Definition at line 1861 of file ProxyMgr.C.

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

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

void ProxyMgr::recvResult ProxyGBISP1ResultMsg  ) 
 

Definition at line 1846 of file ProxyMgr.C.

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

01846                                                    { //pp -r> hp
01847   HomePatch *homePatch = PatchMap::Object()->homePatch(msg->patch);
01848   homePatch->receiveResult(msg); // message deleted in registerProxy()
01849 }

void ProxyMgr::recvResults ProxyCombinedResultRawMsg  ) 
 

Definition at line 1470 of file ProxyMgr.C.

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

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

void ProxyMgr::recvResults ProxyResultMsg  ) 
 

Definition at line 1437 of file ProxyMgr.C.

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

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

void ProxyMgr::recvResults ProxyResultVarsizeMsg  ) 
 

Definition at line 1424 of file ProxyMgr.C.

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

01424                                                      {
01425     HomePatch *home = PatchMap::Object()->homePatch(msg->patch);
01426     home->receiveResults(msg); // delete done in HomePatch::receiveResults()
01427 }

void ProxyMgr::recvSpanningTree ProxySpanningTreeMsg  ) 
 

Definition at line 1163 of file ProxyMgr.C.

References ResizeArray< Elem >::add(), PatchMap::homePatch(), j, ProxySpanningTreeMsg::node, nodecount, NodeIDList, Object(), PatchMap::Object(), ProxySpanningTreeMsg::patch, PatchMap::patch(), sendSpanningTree(), ProxyPatch::setSpanningTree(), ResizeArray< Elem >::size(), and ProxySpanningTreeMsg::tree.

01163                                                     {
01164   int size = msg->tree.size();
01165   int *child = new int[proxySpanDim];
01166   int nChild = 0;
01167   int i;
01168   ProxyPatch *proxy = (ProxyPatch *) PatchMap::Object()->patch(msg->patch);
01169   for (i=0; i<proxySpanDim; i++) {
01170     if (size > i+1) { child[i] = msg->tree[i+1]; nChild++; }
01171   }
01172   if (!PatchMap::Object()->homePatch(msg->patch)) {
01173     proxy->setSpanningTree(msg->node, child, nChild);
01174   }
01175 
01176   // build subtree and pass down
01177  if (nChild > 0) {
01178 
01179   nodecount ++;
01180   //if (nodecount > MAX_INTERNODE) 
01181   //  iout << "Processor " << CkMyPe() << "has (actual) " << nodecount << " intermediate nodes." << endi;
01182 
01183 //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]);
01184   NodeIDList *tree = new NodeIDList[proxySpanDim];
01185   int level = 1, index=1;
01186   int done = 0;
01187   while (!done) {
01188     for (int n=0; n<nChild; n++) {
01189       if (done) break;
01190       for (int j=0; j<level; j++) {
01191        if (index >= size) { done = 1; break; }
01192        tree[n].add(msg->tree[index]);
01193        index++;
01194       }
01195     }
01196     level *=proxySpanDim;
01197   }
01198 
01199   ProxyMgr *proxyMgr = ProxyMgr::Object();
01200   for (i=0; i<proxySpanDim; i++) {
01201     if (tree[i].size()) {
01202       ProxySpanningTreeMsg *cmsg = new ProxySpanningTreeMsg;
01203       cmsg->patch = msg->patch;
01204       cmsg->node = CkMyPe();
01205       cmsg->tree = tree[i];
01206       proxyMgr->sendSpanningTree(cmsg);
01207     }
01208   }
01209 
01210   delete [] tree;
01211  }
01212 
01213   delete [] child;
01214   delete msg;
01215 }

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

Definition at line 1122 of file ProxyMgr.C.

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

Referenced by sendSpanningTreeToHomePatch().

01123 {
01124   HomePatch *p = PatchMap::Object()->homePatch(pid);
01125   p->recvSpanningTree(tree, n);
01126 }

void ProxyMgr::recvUnregisterProxy UnregisterProxyMsg  ) 
 

Definition at line 540 of file ProxyMgr.C.

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

00540                                                      {
00541   HomePatch *homePatch = PatchMap::Object()->homePatch(msg->patch);
00542   homePatch->unregisterProxy(msg); // message deleted in registerProxy()
00543 }

void ProxyMgr::registerProxy PatchID  pid  ) 
 

Definition at line 506 of file ProxyMgr.C.

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

Referenced by ProxyPatch::ProxyPatch().

00506                                    {
00507   // determine which node gets message
00508   NodeID node = PatchMap::Object()->node(pid);
00509 
00510   RegisterProxyMsg *msg = new RegisterProxyMsg;
00511 
00512   msg->node=CkMyPe();
00513   msg->patch = pid;
00514 
00515   CProxy_ProxyMgr cp(CkpvAccess(BOCclass_group).proxyMgr);
00516   cp[node].recvRegisterProxy(msg);
00517 }

void ProxyMgr::removeProxies void   ) 
 

Definition at line 382 of file ProxyMgr.C.

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

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

00383 {
00384   ProxySetIter pi(proxySet);
00385   for ( pi = pi.begin(); pi != pi.end(); pi++)
00386   {
00387     delete pi->proxyPatch;
00388   }
00389   proxySet.clear();
00390 }

void ProxyMgr::removeProxy PatchID  pid  ) 
 

Definition at line 495 of file ProxyMgr.C.

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

Referenced by removeUnusedProxies().

00495                                  {
00496   ProxyElem *p = proxySet.find(ProxyElem(pid));
00497   if (p) { 
00498     PatchMap::Object()->unregisterPatch(pid,p->proxyPatch);
00499     delete p->proxyPatch;
00500     proxySet.del(ProxyElem(pid));
00501     // iout << iINFO << "Removing unused proxy " << pid << " on " << iPE << ".\n" << endi;
00502   }
00503 }

void ProxyMgr::removeUnusedProxies void   ) 
 

Definition at line 392 of file ProxyMgr.C.

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

Referenced by ComputeMgr::updateLocalComputes3().

00393 {
00394   ResizeArray<PatchID> toDelete;
00395   ProxySetIter pi(proxySet);
00396   for ( pi = pi.begin(); pi != pi.end(); pi++)
00397   {
00398     if ( pi->proxyPatch->getNumComputes() == 0 ) {
00399       toDelete.add(pi->patchID);
00400       //fprintf(stderr, "Proxy Deleted Patch %d Proc %d", pi->patchID, CkMyPe());
00401     }
00402   }
00403   PatchID *pidi = toDelete.begin();
00404   for ( ; pidi != toDelete.end(); ++pidi ) {
00405     removeProxy(*pidi);
00406   }
00407 }

void ProxyMgr::sendNodeAwareSpanningTree ProxyNodeAwareSpanningTreeMsg  ) 
 

Definition at line 1148 of file ProxyMgr.C.

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

Referenced by recvNodeAwareSpanningTree().

01148                                                                           {
01149   CProxy_ProxyMgr cp(CkpvAccess(BOCclass_group).proxyMgr);
01150   int pe = msg->allPes[0]; //the root procID
01151 
01152 #if defined(PROCTRACE_DEBUG) && defined(NAST_DEBUG)
01153   DebugFileTrace *dft = DebugFileTrace::Object();
01154   dft->openTrace();
01155   dft->writeTrace("PMgr::sndST: from proc %d for patch[%d]\n", pe, msg->patch);
01156   dft->closeTrace();
01157 #endif
01158 
01159   cp[pe].recvNodeAwareSpanningTree(msg);
01160 }

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

Definition at line 1128 of file ProxyMgr.C.

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

Referenced by sendSpanningTrees().

01129 {
01130   CProxy_ProxyMgr cp(thisgroup);
01131   ProxyNodeAwareSpanningTreeMsg *msg = ProxyNodeAwareSpanningTreeMsg::getANewMsg(pid, -1, tree, n);
01132   cp[PatchMap::Object()->node(pid)].recvNodeAwareSpanningTreeOnHomePatch(msg);
01133 }

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

Definition at line 587 of file ProxyMgr.C.

Referenced by HomePatch::sendProxies().

00588 {
00589   CProxy_ProxyMgr cp(CkpvAccess(BOCclass_group).proxyMgr);
00590   cp[0].recvProxies(pid, list, n);
00591 }

void ProxyMgr::sendProxyAll ProxyDataMsg ,
int  ,
int * 
 

Definition at line 1665 of file ProxyMgr.C.

References proxySendSpanning.

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

01665                                                              {
01666 #if defined(NODEAWARE_PROXY_SPANNINGTREE) && defined(USE_NODEPATCHMGR)
01667     if(proxySendSpanning == 1) {
01668         CProxy_NodeProxyMgr cnp(CkpvAccess(BOCclass_group).nodeProxyMgr);
01669         for(int i=0; i<pcnt-1; i++) {
01670             ProxyDataMsg *copymsg = (ProxyDataMsg *)CkCopyMsg((void **)&msg);
01671             cnp[pids[i]].recvImmediateProxyAll(copymsg);
01672         }
01673         cnp[pids[pcnt-1]].recvImmediateProxyAll(msg);
01674         return;
01675     }
01676 #endif
01677   CProxy_ProxyMgr cp(CkpvAccess(BOCclass_group).proxyMgr);
01678   cp.recvImmediateProxyAll(msg,pcnt,pids);
01679 }

void ProxyMgr::sendProxyData ProxyDataMsg ,
int  ,
int * 
 

Definition at line 1551 of file ProxyMgr.C.

References proxySendSpanning.

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

01551                                                               {
01552 #if defined(NODEAWARE_PROXY_SPANNINGTREE) && defined(USE_NODEPATCHMGR)
01553     if(proxySendSpanning == 1) {
01554         CProxy_NodeProxyMgr cnp(CkpvAccess(BOCclass_group).nodeProxyMgr);
01555         for(int i=0; i<pcnt-1; i++) {
01556             ProxyDataMsg *copymsg = (ProxyDataMsg *)CkCopyMsg((void **)&msg);
01557             cnp[pids[i]].recvImmediateProxyData(copymsg);
01558         }
01559         cnp[pids[pcnt-1]].recvImmediateProxyData(msg);
01560         return;
01561     }
01562 #endif
01563   CProxy_ProxyMgr cp(CkpvAccess(BOCclass_group).proxyMgr);
01564   cp.recvImmediateProxyData(msg,pcnt,pids);
01565 }

void ProxyMgr::sendResult ProxyGBISP2ResultMsg  ) 
 

Definition at line 1854 of file ProxyMgr.C.

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

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

void ProxyMgr::sendResult ProxyGBISP1ResultMsg  ) 
 

Definition at line 1839 of file ProxyMgr.C.

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

Referenced by ProxyPatch::boxClosed().

01839                                                    { //pp -r> hp
01840   CProxy_ProxyMgr cp(CkpvAccess(BOCclass_group).proxyMgr);
01841   NodeID node = PatchMap::Object()->node(msg->patch);
01842   CmiEnableUrgentSend(1);
01843   cp[node].recvResult(msg);
01844   CmiEnableUrgentSend(0);
01845 }

void ProxyMgr::sendResults ProxyCombinedResultMsg  ) 
 

Definition at line 1443 of file ProxyMgr.C.

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

01443                                                       {
01444   ProxyPatch *patch = (ProxyPatch *)PatchMap::Object()->patch(msg->patch);
01445   ProxyCombinedResultMsg *ocMsg = patch->depositCombinedResultMsg(msg);
01446   if (ocMsg) {
01447         ProxyCombinedResultRawMsg *cMsg = ProxyCombinedResultMsg::toRaw(ocMsg);        
01448     int destPe = patch->getSpanningTreeParent();
01449     CProxy_ProxyMgr cp(CkpvAccess(BOCclass_group).proxyMgr);
01450     CmiAssert(destPe!=CkMyPe());
01451     //if(destPe != CkMyPe()) {
01452 #if defined(NODEAWARE_PROXY_SPANNINGTREE) && defined(USE_NODEPATCHMGR)
01453       /*CkPrintf("ready to call node::recvImmRes on pe[%d] to dest[%d]\n", CkMyPe(), destPe);
01454       fflush(stdout);*/
01455 
01456       cMsg->destPe = destPe;
01457       CProxy_NodeProxyMgr cnp(CkpvAccess(BOCclass_group).nodeProxyMgr);
01458       cnp[CkNodeOf(destPe)].recvImmediateResults(cMsg);
01459 #else
01460       cp[destPe].recvImmediateResults(cMsg);
01461 #endif
01462     //}
01463     //else{
01465     //  cp[destPe].recvResults(cMsg);
01466     //}
01467   }
01468 }

void ProxyMgr::sendResults ProxyResultMsg  ) 
 

Definition at line 1429 of file ProxyMgr.C.

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

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

void ProxyMgr::sendResults ProxyResultVarsizeMsg  ) 
 

Definition at line 1416 of file ProxyMgr.C.

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

01416                                                      {
01417     CProxy_ProxyMgr cp(CkpvAccess(BOCclass_group).proxyMgr);
01418     NodeID node = PatchMap::Object()->node(msg->patch);
01419     CmiEnableUrgentSend(1);
01420     cp[node].recvResults(msg);
01421     CmiEnableUrgentSend(0);
01422 }

void ProxyMgr::sendSpanningTree ProxySpanningTreeMsg  ) 
 

Definition at line 1143 of file ProxyMgr.C.

References ProxySpanningTreeMsg::tree.

Referenced by recvSpanningTree(), and HomePatch::sendSpanningTree().

01143                                                     {
01144   CProxy_ProxyMgr cp(CkpvAccess(BOCclass_group).proxyMgr);
01145   cp[msg->tree[0]].recvSpanningTree(msg);
01146 }

void ProxyMgr::sendSpanningTrees  ) 
 

Definition at line 1095 of file ProxyMgr.C.

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

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

01096 {
01097   int numPatches = PatchMap::Object()->numPatches();
01098   for (int pid=0; pid<numPatches; pid++) {
01099     int numProxies = ptree.proxylist[pid].size();
01100 #ifdef NODEAWARE_PROXY_SPANNINGTREE
01101     if (numProxies == 0)
01102       ProxyMgr::Object()->sendNodeAwareSpanningTreeToHomePatch(pid, NULL, 0);
01103     else {
01104       ProxyMgr::Object()->sendNodeAwareSpanningTreeToHomePatch(pid, ptree.naTrees[pid].begin(), ptree.naTrees[pid].size());
01105     }
01106 #else
01107     if (numProxies == 0)
01108       ProxyMgr::Object()->sendSpanningTreeToHomePatch(pid, NULL, 0);
01109     else {
01110       ProxyMgr::Object()->sendSpanningTreeToHomePatch(pid, ptree.trees[pid].begin(), ptree.trees[pid].size());
01111     }
01112 #endif
01113   }
01114 }

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

Definition at line 1116 of file ProxyMgr.C.

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

Referenced by sendSpanningTrees().

01117 {
01118   CProxy_ProxyMgr cp(thisgroup);
01119   cp[PatchMap::Object()->node(pid)].recvSpanningTreeOnHomePatch(pid, tree, n);
01120 }

void ProxyMgr::setProxyTreeBranchFactor int  dim  ) 
 

Definition at line 373 of file ProxyMgr.C.

References proxySpanDim.

Referenced by Node::startup().

00373                                               {
00374     if(CkMyRank()!=0) return;
00375     proxySpanDim = dim;
00376 }

void ProxyMgr::setRecvSpanning  ) 
 

Definition at line 364 of file ProxyMgr.C.

References proxyRecvSpanning.

Referenced by Node::startup().

00364                                {
00365   if(CkMyRank()!=0) return;
00366   proxyRecvSpanning = 1;
00367 }

void ProxyMgr::setSendSpanning  ) 
 

Definition at line 355 of file ProxyMgr.C.

References proxySendSpanning.

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

00355                                {
00356   if(CkMyRank()!=0) return; 
00357   proxySendSpanning = 1;
00358 }

void ProxyMgr::unregisterProxy PatchID  pid  ) 
 

Definition at line 526 of file ProxyMgr.C.

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

Referenced by ProxyPatch::~ProxyPatch().

00526                                      {
00527   // determine which node gets message
00528   NodeID node = PatchMap::Object()->node(pid);
00529 
00530   UnregisterProxyMsg *msg = new UnregisterProxyMsg;
00531 
00532   msg->node=CkMyPe();
00533   msg->patch = pid;
00534 
00535   CProxy_ProxyMgr cp(CkpvAccess(BOCclass_group).proxyMgr);
00536   cp[node].recvUnregisterProxy(msg);
00537 }


Member Data Documentation

int ProxyMgr::nodecount = 0 [static]
 

Definition at line 340 of file ProxyMgr.C.

Referenced by recvNodeAwareSpanningTree(), and recvSpanningTree().


The documentation for this class was generated from the following files:
Generated on Fri May 25 04:07:24 2012 for NAMD by  doxygen 1.3.9.1