NodeProxyMgr Class Reference

#include <ProxyMgr.h>

List of all members.

Public Member Functions

 NodeProxyMgr ()
 ~NodeProxyMgr ()
void createProxyInfo (int numPs)
void registerPatch (int patchID, int numPes, int *pes)
proxyTreeNodegetPatchProxyInfo (int patchID)
void registerLocalProxyMgr (CkGroupID one)
const CkGroupID & getLocalProxyMgr ()
void registerLocalPatchMap (int rank, PatchMap *one)
PatchMapgetLocalPatchMap (int rank)
void recvImmediateProxyData (ProxyDataMsg *msg)
void recvImmediateProxyAll (ProxyDataMsg *msg)
void recvImmediateResults (ProxyCombinedResultRawMsg *)
void createSTForHomePatches (PatchMap *pmap)
void sendProxyList (int pid, int *plist, int size)
void sendProxyListInfo (PatchProxyListMsg *msg)
void contributeToParent ()


Detailed Description

Definition at line 426 of file ProxyMgr.h.


Constructor & Destructor Documentation

NodeProxyMgr::NodeProxyMgr (  )  [inline]

Definition at line 450 of file ProxyMgr.h.

References numPatches.

00450                   {
00451         proxyInfo = NULL;
00452         numPatches = 0;
00453         localPatchMaps = new PatchMap *[CkMyNodeSize()];
00454 
00455                 parentNode = -1;
00456                 numKidNodes = 0;
00457                 kidRecved = 0;
00458                 numHomePatches = 0;
00459                 homepatchRecved = 0;
00460                 localProxyLists = NULL;
00461                 remoteProxyLists = NULL;
00462                 localDepositLock = CmiCreateLock();
00463                 remoteDepositLock = CmiCreateLock();
00464     }

NodeProxyMgr::~NodeProxyMgr (  )  [inline]

Definition at line 465 of file ProxyMgr.h.

References numPatches.

00465                    {
00466         for(int i=0; i<numPatches; i++) {
00467             delete proxyInfo[i];
00468         }
00469         delete [] proxyInfo;
00470         delete [] localPatchMaps;
00471 
00472                 CmiDestroyLock(localDepositLock);
00473                 CmiDestroyLock(remoteDepositLock);
00474     }


Member Function Documentation

void NodeProxyMgr::contributeToParent (  ) 

Definition at line 2008 of file ProxyMgr.C.

References PatchProxyListMsg::createPatchProxyListMsg().

Referenced by sendProxyList(), and sendProxyListInfo().

02008                                      {
02009         if(homepatchRecved!=numHomePatches || kidRecved != numKidNodes) return;
02010 
02011         homepatchRecved = 0;
02012         kidRecved = 0;
02013         //construct the msg
02014         PatchProxyListMsg *msg = PatchProxyListMsg::createPatchProxyListMsg(remoteProxyLists, numKidNodes, localProxyLists, numHomePatches);
02015         if(parentNode == -1) {
02016                 //send to proxy mgr on PE[0] as this is the root node
02017                 CProxy_ProxyMgr cp(CkpvAccess(BOCclass_group).proxyMgr);
02018                 cp[0].recvPatchProxyInfo(msg);
02019         }else{
02020                 CProxy_NodeProxyMgr cnp(thisgroup);
02021                 cnp[parentNode].sendProxyListInfo(msg);
02022         }
02023         for(int i=0; i<numKidNodes; i++) {
02024                 delete remoteProxyLists[i];
02025         }
02026 }

void NodeProxyMgr::createProxyInfo ( int  numPs  )  [inline]

Definition at line 476 of file ProxyMgr.h.

References numPatches.

00476                                    {
00477         numPatches = numPs;
00478         proxyInfo = new proxyTreeNode *[numPs];
00479         memset(proxyInfo, 0, sizeof(proxyTreeNode *)*numPs);
00480     }

void NodeProxyMgr::createSTForHomePatches ( PatchMap pmap  ) 

Definition at line 1922 of file ProxyMgr.C.

References HOMEPATCH_TREE_BRFACTOR, and PatchMap::numPatchesOnNode().

01922                                                        {
01923         //We use implicit tree construction for all home patches
01924         std::vector<int> nodesWithPatches; //record the id of node that has home patches
01925         int myNodeIdx = -1; //the index into the above vector of this node
01926         for(int nodeId=0; nodeId<CkNumNodes(); ++nodeId) {
01927                 int hpCnt = 0;
01928                 int firstPe = CkNodeFirst(nodeId);
01929                 int endPe = firstPe + CkNodeSize(nodeId);
01930                 for(int pe=firstPe; pe < endPe; ++pe) {
01931                         hpCnt += pmap->numPatchesOnNode(pe);
01932                 }
01933                 if(hpCnt==0) continue;
01934 
01935                 nodesWithPatches.push_back(nodeId);
01936                 if(CkMyNode() == nodeId) {
01937                         //on my node
01938                         myNodeIdx = nodesWithPatches.size()-1;
01939                         numHomePatches = hpCnt;
01940                         homepatchRecved = 0;
01941                         localProxyLists = new ProxyListInfo[hpCnt];
01942                         memset(localProxyLists, 0, sizeof(ProxyListInfo)*hpCnt);                        
01943                 }
01944         }
01945 
01946         if(myNodeIdx==-1){
01947                 //there's no home patches on this node
01948                 //just set to a value that doesn't make sense in spanning tree.
01949                 parentNode = -2; 
01950                 numKidNodes = 0;
01951                 kidRecved = 0;
01952                 return;
01953         }
01954         
01955         //calculate parent
01956         if(myNodeIdx == 0) {
01957                 parentNode = -1;
01958         }else{
01959                 int parentIdx = (myNodeIdx-1)/HOMEPATCH_TREE_BRFACTOR;
01960                 parentNode = nodesWithPatches[parentIdx];
01961         }
01962 
01963         //calculate kids
01964         numKidNodes = 0;
01965         int totalNodes = nodesWithPatches.size();
01966         for(int i=1; i<=HOMEPATCH_TREE_BRFACTOR; i++) {
01967                 int kidId = myNodeIdx*HOMEPATCH_TREE_BRFACTOR+i;
01968                 if(kidId >= totalNodes) break;
01969                 numKidNodes++;
01970         }
01971         if(numKidNodes!=0) {
01972                 remoteProxyLists = new PatchProxyListMsg *[numKidNodes];
01973         }
01974         kidRecved = 0;
01975 
01976         //CkPrintf("Node[%d] has %d homepatches with parent=%d and %d kids \n", CkMyNode(), numHomePatches, parentNode, numKidNodes);
01977 }

PatchMap* NodeProxyMgr::getLocalPatchMap ( int  rank  )  [inline]

Definition at line 495 of file ProxyMgr.h.

00495                                         {
00496         return localPatchMaps[rank];
00497     }   

const CkGroupID& NodeProxyMgr::getLocalProxyMgr (  )  [inline]

Definition at line 489 of file ProxyMgr.h.

00489                                        {
00490         return localProxyMgr;
00491     }

proxyTreeNode* NodeProxyMgr::getPatchProxyInfo ( int  patchID  )  [inline]

Definition at line 482 of file ProxyMgr.h.

00482                                                  {
00483         return proxyInfo[patchID];
00484     }

void NodeProxyMgr::recvImmediateProxyAll ( ProxyDataMsg msg  ) 

Definition at line 1746 of file ProxyMgr.C.

References proxyTreeNode::numPes, PatchMap::patch(), ProxyDataMsg::patch, and proxyTreeNode::peIDs.

01746                                                           {    
01747 #if defined(NODEAWARE_PROXY_SPANNINGTREE) && defined(USE_NODEPATCHMGR)
01748     CProxy_ProxyMgr cp(localProxyMgr);
01749     proxyTreeNode *ptn = proxyInfo[msg->patch];
01750     CmiAssert(ptn->numPes!=0);
01751     #if defined(PROCTRACE_DEBUG) && defined(NAST_DEBUG)
01752     //This could be executed on comm thd.
01753     printf("NodePMgr::recvImmPAll for patch[%d] on node %d rank %d, prepare to send proc ", msg->patch, CkMyNode(), CkMyRank());
01754     for(int i=0; i<ptn->numPes; i++) {
01755         printf("%d, ", ptn->peIDs[i]);
01756     }
01757     printf("\n");
01758     fflush(stdout);
01759     #endif
01760 
01761     //re-send msg to this nodes's children nodes.
01762     //only the first pe of a node of node-aware ST should contain children nodes
01763     int rank = CkRankOf(ptn->peIDs[0]);
01764     PatchMap *pmap = localPatchMaps[rank];
01765     ProxyPatch *ppatch = (ProxyPatch *)pmap->patch(msg->patch);
01766 
01767     int npid = ppatch->getSTNNodeChild();
01768     int *pids = ppatch->getSTNodeChildPtr();
01769     if(npid>0) {        
01770         //only needs to send to other nodes, so check the last entry of pids.
01771         //This is because the data for proxies on the same node have been sent
01772         //later in this function by NodeProxyMgr.
01773         if(pids[npid-1]==CkMyNode()) npid--;
01774     }
01775     
01776 #if CMK_PERSISTENT_COMM && USE_PERSISTENT_TREE
01777     if (npid) {
01778         int ntreephs;
01779         PersistentHandle *treephs = ppatch->getSpanningTreePhs(ntreephs);
01780         CmiAssert(treephs && ntreephs >= npid);
01781         CmiUsePersistentHandle(treephs, ntreephs);
01782     }
01783 #endif
01784     CProxy_NodeProxyMgr cnp(thisgroup);
01785     for(int i=0; i<npid; i++) {
01786         ProxyDataMsg *copymsg = (ProxyDataMsg *)CkCopyMsg((void **)&msg);
01787         cnp[pids[i]].recvImmediateProxyAll(copymsg);
01788     }    
01789 #if CMK_PERSISTENT_COMM && USE_PERSISTENT_TREE
01790     CmiUsePersistentHandle(NULL, 0);
01791 #endif
01792 
01793     //re-send msg to it's internal cores
01794 #if CMK_SMP && defined(NAMDSRC_IMMQD_HACK)
01795     msg->isFromImmMsgCall = (CkMyRank()==CkMyNodeSize());
01796 #endif
01797     cp.recvProxyAll(msg, ptn->numPes, ptn->peIDs);
01798 #else
01799     CkAbort("Bad execution path to NodeProxyMgr::recvImmediateProxyData\n");
01800 #endif
01801 }

void NodeProxyMgr::recvImmediateProxyData ( ProxyDataMsg msg  ) 

Definition at line 1629 of file ProxyMgr.C.

References proxyTreeNode::numPes, PatchMap::patch(), ProxyDataMsg::patch, and proxyTreeNode::peIDs.

01629                                                            {    
01630 #if defined(NODEAWARE_PROXY_SPANNINGTREE) && defined(USE_NODEPATCHMGR)
01631     CProxy_ProxyMgr cp(localProxyMgr);
01632     proxyTreeNode *ptn = proxyInfo[msg->patch];
01633     CmiAssert(ptn->numPes!=0);
01634 
01635     //re-send msg to this nodes's children nodes.
01636     //only the first pe of a node of node-aware ST should contain children nodes
01637     int rank = CkRankOf(ptn->peIDs[0]);
01638     PatchMap *pmap = localPatchMaps[rank];
01639     ProxyPatch *ppatch = (ProxyPatch *)pmap->patch(msg->patch);
01640 
01641     int npid = ppatch->getSTNNodeChild();
01642     int *pids = ppatch->getSTNodeChildPtr();
01643     if(npid>0) {        
01644         //only needs to send to other nodes, so check the last entry of pids.
01645         //This is because the data for proxies on the same node have been sent
01646         //later in this function by NodeProxyMgr.
01647         if(pids[npid-1]==CkMyNode()) npid--;
01648     }    
01649     CProxy_NodeProxyMgr cnp(thisgroup);
01650 #if CMK_PERSISTENT_COMM && USE_PERSISTENT_TREE
01651     if (npid) {
01652         int ntreephs;
01653         PersistentHandle *treephs = ppatch->getSpanningTreePhs(ntreephs);
01654         CmiAssert(treephs && ntreephs >= npid);
01655         CmiUsePersistentHandle(treephs, ntreephs);
01656     }
01657 #endif
01658     for(int i=0; i<npid; i++) {
01659         ProxyDataMsg *copymsg = (ProxyDataMsg *)CkCopyMsg((void **)&msg);
01660         cnp[pids[i]].recvImmediateProxyData(copymsg);
01661     }    
01662 #if CMK_PERSISTENT_COMM && USE_PERSISTENT_TREE
01663     CmiUsePersistentHandle(NULL, 0);
01664 #endif
01665 
01666     //re-send msg to it's internal cores
01667 #if CMK_SMP && defined(NAMDSRC_IMMQD_HACK)
01668     msg->isFromImmMsgCall = (CkMyRank()==CkMyNodeSize());
01669 #endif
01670     cp.recvProxyData(msg, ptn->numPes, ptn->peIDs);
01671 #else
01672     CkAbort("Bad execution path to NodeProxyMgr::recvImmediateProxyData\n");
01673 #endif
01674 }

void NodeProxyMgr::recvImmediateResults ( ProxyCombinedResultRawMsg  ) 

Definition at line 1525 of file ProxyMgr.C.

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

01525                                                                       {
01526     ProxyCombinedResultRawMsg *msg = omsg;
01527 #if defined(NODEAWARE_PROXY_SPANNINGTREE) && defined(USE_NODEPATCHMGR)
01528     //CkPrintf("recvImmRes called on comm thread%d pe[%d]\n", CkMyRank()==CmiMyNodeSize(), CkMyPe());
01529     //fflush(stdout);
01530 
01531     int destRank = CkRankOf(msg->destPe);
01532     PatchMap *pmap = localPatchMaps[destRank];
01533     HomePatch *home = pmap->homePatch(msg->patch);
01534     if (home) {
01535 #if CMK_SMP && defined(NAMDSRC_IMMQD_HACK)
01536         msg->isFromImmMsgCall = (CkMyRank()==CkMyNodeSize());
01537 #endif
01538         CProxy_ProxyMgr cp(localProxyMgr);
01539         CmiEnableUrgentSend(1);
01540         cp[msg->destPe].recvResults(msg);
01541         CmiEnableUrgentSend(0);
01542 /*
01543         char *srcfrom = "Isfrom";
01544         if(CkMyRank()!=CmiMyNodeSize()) srcfrom="Notfrom";
01545       CkPrintf("%s comm thread from pe[%d]\n", srcfrom, CkMyPe());
01546       fflush(stdout);
01547 */
01548     }
01549     else {
01550         ProxyPatch *patch = (ProxyPatch *)pmap->patch(msg->patch);
01551         ProxyCombinedResultMsg *ocMsg = patch->depositCombinedResultRawMsg(msg); 
01552         if (ocMsg) {
01553             CProxy_NodeProxyMgr cnp(thisgroup);
01554             ocMsg->destPe = patch->getSpanningTreeParent();
01555                         ProxyCombinedResultRawMsg *cMsg = ProxyCombinedResultMsg::toRaw(ocMsg);
01556             cnp[CkNodeOf(cMsg->destPe)].recvImmediateResults(cMsg);
01557         }
01558     }
01559 #endif
01560 }

void NodeProxyMgr::registerLocalPatchMap ( int  rank,
PatchMap one 
) [inline]

Definition at line 492 of file ProxyMgr.h.

00492                                                        {
00493         localPatchMaps[rank] = one;
00494     }

void NodeProxyMgr::registerLocalProxyMgr ( CkGroupID  one  )  [inline]

Definition at line 486 of file ProxyMgr.h.

00486                                              {
00487         localProxyMgr = one;
00488     }

void NodeProxyMgr::registerPatch ( int  patchID,
int  numPes,
int *  pes 
)

Definition at line 1840 of file ProxyMgr.C.

Referenced by ProxyMgr::recvNodeAwareSpanningTree().

01840                                                                  {
01841     if(proxyInfo[patchID]) {
01842         delete proxyInfo[patchID];
01843     }
01844     if(numPes == 0) {
01845         proxyInfo[patchID] = NULL;
01846     }else{
01847         proxyInfo[patchID] = new proxyTreeNode(CkNodeOf(pes[0]),numPes,pes);
01848     }
01849 }

void NodeProxyMgr::sendProxyList ( int  pid,
int *  plist,
int  size 
)

Definition at line 1979 of file ProxyMgr.C.

References contributeToParent(), ProxyListInfo::numProxies, ProxyListInfo::patchID, and ProxyListInfo::proxyList.

Referenced by HomePatch::sendProxies().

01979                                                              {
01980         int insertIdx; //indexed from 0
01981         CmiLock(localDepositLock);
01982         insertIdx = homepatchRecved++; //ensure the atomic increment
01983 
01984         localProxyLists[insertIdx].patchID = pid;
01985         localProxyLists[insertIdx].numProxies = size;
01986         localProxyLists[insertIdx].proxyList = plist;
01987 
01988         if(insertIdx == (numHomePatches-1)) {
01989                 //all local home patches have contributed
01990                 contributeToParent();
01991         }
01992         CmiUnlock(localDepositLock);
01993 }

void NodeProxyMgr::sendProxyListInfo ( PatchProxyListMsg msg  ) 

Definition at line 1995 of file ProxyMgr.C.

References contributeToParent().

01995                                                           {
01996         int insertIdx; //indexed from 0
01997         CmiLock(localDepositLock);
01998         insertIdx = kidRecved++;
01999         
02000         remoteProxyLists[insertIdx] = msg;
02001         if(insertIdx == (numKidNodes-1)) {
02002                 //all kids have contributed;
02003                 contributeToParent();
02004         }
02005         CmiUnlock(localDepositLock);
02006 }


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