NAMD
Public Member Functions | List of all members
NodeProxyMgr Class Reference

#include <ProxyMgr.h>

Inheritance diagram for NodeProxyMgr:

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::NodeProxyMgr ( )
inline

Definition at line 450 of file ProxyMgr.h.

450  {
451  proxyInfo = NULL;
452  numPatches = 0;
453  localPatchMaps = new PatchMap *[CkMyNodeSize()];
454 
455  parentNode = -1;
456  numKidNodes = 0;
457  kidRecved = 0;
458  numHomePatches = 0;
459  homepatchRecved = 0;
460  localProxyLists = NULL;
461  remoteProxyLists = NULL;
462  localDepositLock = CmiCreateLock();
463  remoteDepositLock = CmiCreateLock();
464  }

◆ ~NodeProxyMgr()

NodeProxyMgr::~NodeProxyMgr ( )
inline

Definition at line 465 of file ProxyMgr.h.

465  {
466  for(int i=0; i<numPatches; i++) {
467  delete proxyInfo[i];
468  }
469  delete [] proxyInfo;
470  delete [] localPatchMaps;
471 
472  CmiDestroyLock(localDepositLock);
473  CmiDestroyLock(remoteDepositLock);
474  }

Member Function Documentation

◆ contributeToParent()

void NodeProxyMgr::contributeToParent ( )

Definition at line 2007 of file ProxyMgr.C.

References PatchProxyListMsg::createPatchProxyListMsg().

Referenced by sendProxyList(), and sendProxyListInfo().

2007  {
2008  if(homepatchRecved!=numHomePatches || kidRecved != numKidNodes) return;
2009 
2010  homepatchRecved = 0;
2011  kidRecved = 0;
2012  //construct the msg
2013  PatchProxyListMsg *msg = PatchProxyListMsg::createPatchProxyListMsg(remoteProxyLists, numKidNodes, localProxyLists, numHomePatches);
2014  if(parentNode == -1) {
2015  //send to proxy mgr on PE[0] as this is the root node
2016  CProxy_ProxyMgr cp(CkpvAccess(BOCclass_group).proxyMgr);
2017  cp[0].recvPatchProxyInfo(msg);
2018  }else{
2019  CProxy_NodeProxyMgr cnp(thisgroup);
2020  cnp[parentNode].sendProxyListInfo(msg);
2021  }
2022  for(int i=0; i<numKidNodes; i++) {
2023  delete remoteProxyLists[i];
2024  }
2025 }
static PatchProxyListMsg * createPatchProxyListMsg(PatchProxyListMsg **bufs, int bufSize, ProxyListInfo *info, int size)
Definition: ProxyMgr.C:1881

◆ createProxyInfo()

void NodeProxyMgr::createProxyInfo ( int  numPs)
inline

Definition at line 476 of file ProxyMgr.h.

476  {
477  numPatches = numPs;
478  proxyInfo = new proxyTreeNode *[numPs];
479  memset(proxyInfo, 0, sizeof(proxyTreeNode *)*numPs);
480  }

◆ createSTForHomePatches()

void NodeProxyMgr::createSTForHomePatches ( PatchMap pmap)

Definition at line 1921 of file ProxyMgr.C.

References HOMEPATCH_TREE_BRFACTOR, and PatchMap::numPatchesOnNode().

1921  {
1922  //We use implicit tree construction for all home patches
1923  std::vector<int> nodesWithPatches; //record the id of node that has home patches
1924  int myNodeIdx = -1; //the index into the above vector of this node
1925  for(int nodeId=0; nodeId<CkNumNodes(); ++nodeId) {
1926  int hpCnt = 0;
1927  int firstPe = CkNodeFirst(nodeId);
1928  int endPe = firstPe + CkNodeSize(nodeId);
1929  for(int pe=firstPe; pe < endPe; ++pe) {
1930  hpCnt += pmap->numPatchesOnNode(pe);
1931  }
1932  if(hpCnt==0) continue;
1933 
1934  nodesWithPatches.push_back(nodeId);
1935  if(CkMyNode() == nodeId) {
1936  //on my node
1937  myNodeIdx = nodesWithPatches.size()-1;
1938  numHomePatches = hpCnt;
1939  homepatchRecved = 0;
1940  localProxyLists = new ProxyListInfo[hpCnt];
1941  memset(localProxyLists, 0, sizeof(ProxyListInfo)*hpCnt);
1942  }
1943  }
1944 
1945  if(myNodeIdx==-1){
1946  //there's no home patches on this node
1947  //just set to a value that doesn't make sense in spanning tree.
1948  parentNode = -2;
1949  numKidNodes = 0;
1950  kidRecved = 0;
1951  return;
1952  }
1953 
1954  //calculate parent
1955  if(myNodeIdx == 0) {
1956  parentNode = -1;
1957  }else{
1958  int parentIdx = (myNodeIdx-1)/HOMEPATCH_TREE_BRFACTOR;
1959  parentNode = nodesWithPatches[parentIdx];
1960  }
1961 
1962  //calculate kids
1963  numKidNodes = 0;
1964  int totalNodes = nodesWithPatches.size();
1965  for(int i=1; i<=HOMEPATCH_TREE_BRFACTOR; i++) {
1966  int kidId = myNodeIdx*HOMEPATCH_TREE_BRFACTOR+i;
1967  if(kidId >= totalNodes) break;
1968  numKidNodes++;
1969  }
1970  if(numKidNodes!=0) {
1971  remoteProxyLists = new PatchProxyListMsg *[numKidNodes];
1972  }
1973  kidRecved = 0;
1974 
1975  //CkPrintf("Node[%d] has %d homepatches with parent=%d and %d kids \n", CkMyNode(), numHomePatches, parentNode, numKidNodes);
1976 }
#define HOMEPATCH_TREE_BRFACTOR
Definition: ProxyMgr.C:1920
int numPatchesOnNode(int node)
Definition: PatchMap.h:60

◆ getLocalPatchMap()

PatchMap* NodeProxyMgr::getLocalPatchMap ( int  rank)
inline

Definition at line 495 of file ProxyMgr.h.

495  {
496  return localPatchMaps[rank];
497  }

◆ getLocalProxyMgr()

const CkGroupID& NodeProxyMgr::getLocalProxyMgr ( )
inline

Definition at line 489 of file ProxyMgr.h.

489  {
490  return localProxyMgr;
491  }

◆ getPatchProxyInfo()

proxyTreeNode* NodeProxyMgr::getPatchProxyInfo ( int  patchID)
inline

Definition at line 482 of file ProxyMgr.h.

482  {
483  return proxyInfo[patchID];
484  }

◆ recvImmediateProxyAll()

void NodeProxyMgr::recvImmediateProxyAll ( ProxyDataMsg msg)

Definition at line 1745 of file ProxyMgr.C.

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

1745  {
1746 #if defined(NODEAWARE_PROXY_SPANNINGTREE) && defined(USE_NODEPATCHMGR)
1747  CProxy_ProxyMgr cp(localProxyMgr);
1748  proxyTreeNode *ptn = proxyInfo[msg->patch];
1749  CmiAssert(ptn->numPes!=0);
1750  #if defined(PROCTRACE_DEBUG) && defined(NAST_DEBUG)
1751  //This could be executed on comm thd.
1752  printf("NodePMgr::recvImmPAll for patch[%d] on node %d rank %d, prepare to send proc ", msg->patch, CkMyNode(), CkMyRank());
1753  for(int i=0; i<ptn->numPes; i++) {
1754  printf("%d, ", ptn->peIDs[i]);
1755  }
1756  printf("\n");
1757  fflush(stdout);
1758  #endif
1759 
1760  //re-send msg to this nodes's children nodes.
1761  //only the first pe of a node of node-aware ST should contain children nodes
1762  int rank = CkRankOf(ptn->peIDs[0]);
1763  PatchMap *pmap = localPatchMaps[rank];
1764  ProxyPatch *ppatch = (ProxyPatch *)pmap->patch(msg->patch);
1765 
1766  int npid = ppatch->getSTNNodeChild();
1767  int *pids = ppatch->getSTNodeChildPtr();
1768  if(npid>0) {
1769  //only needs to send to other nodes, so check the last entry of pids.
1770  //This is because the data for proxies on the same node have been sent
1771  //later in this function by NodeProxyMgr.
1772  if(pids[npid-1]==CkMyNode()) npid--;
1773  }
1774 
1775 #if CMK_PERSISTENT_COMM && USE_PERSISTENT_TREE
1776  if (npid) {
1777  int ntreephs;
1778  PersistentHandle *treephs = ppatch->getSpanningTreePhs(ntreephs);
1779  CmiAssert(treephs && ntreephs >= npid);
1780  CmiUsePersistentHandle(treephs, ntreephs);
1781  }
1782 #endif
1783  CProxy_NodeProxyMgr cnp(thisgroup);
1784  for(int i=0; i<npid; i++) {
1785  ProxyDataMsg *copymsg = (ProxyDataMsg *)CkCopyMsg((void **)&msg);
1786  cnp[pids[i]].recvImmediateProxyAll(copymsg);
1787  }
1788 #if CMK_PERSISTENT_COMM && USE_PERSISTENT_TREE
1789  CmiUsePersistentHandle(NULL, 0);
1790 #endif
1791 
1792  //re-send msg to it's internal cores
1793 #if CMK_SMP && defined(NAMDSRC_IMMQD_HACK)
1794  msg->isFromImmMsgCall = (CkMyRank()==CkMyNodeSize());
1795 #endif
1796  cp.recvProxyAll(msg, ptn->numPes, ptn->peIDs);
1797 #else
1798  CkAbort("Bad execution path to NodeProxyMgr::recvImmediateProxyData\n");
1799 #endif
1800 }
Patch * patch(PatchID pid)
Definition: PatchMap.h:244
PatchID patch
Definition: ProxyMgr.h:97
int32 * peIDs
Definition: NamdTypes.h:318
int32 numPes
Definition: NamdTypes.h:319

◆ recvImmediateProxyData()

void NodeProxyMgr::recvImmediateProxyData ( ProxyDataMsg msg)

Definition at line 1628 of file ProxyMgr.C.

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

1628  {
1629 #if defined(NODEAWARE_PROXY_SPANNINGTREE) && defined(USE_NODEPATCHMGR)
1630  CProxy_ProxyMgr cp(localProxyMgr);
1631  proxyTreeNode *ptn = proxyInfo[msg->patch];
1632  CmiAssert(ptn->numPes!=0);
1633 
1634  //re-send msg to this nodes's children nodes.
1635  //only the first pe of a node of node-aware ST should contain children nodes
1636  int rank = CkRankOf(ptn->peIDs[0]);
1637  PatchMap *pmap = localPatchMaps[rank];
1638  ProxyPatch *ppatch = (ProxyPatch *)pmap->patch(msg->patch);
1639 
1640  int npid = ppatch->getSTNNodeChild();
1641  int *pids = ppatch->getSTNodeChildPtr();
1642  if(npid>0) {
1643  //only needs to send to other nodes, so check the last entry of pids.
1644  //This is because the data for proxies on the same node have been sent
1645  //later in this function by NodeProxyMgr.
1646  if(pids[npid-1]==CkMyNode()) npid--;
1647  }
1648  CProxy_NodeProxyMgr cnp(thisgroup);
1649 #if CMK_PERSISTENT_COMM && USE_PERSISTENT_TREE
1650  if (npid) {
1651  int ntreephs;
1652  PersistentHandle *treephs = ppatch->getSpanningTreePhs(ntreephs);
1653  CmiAssert(treephs && ntreephs >= npid);
1654  CmiUsePersistentHandle(treephs, ntreephs);
1655  }
1656 #endif
1657  for(int i=0; i<npid; i++) {
1658  ProxyDataMsg *copymsg = (ProxyDataMsg *)CkCopyMsg((void **)&msg);
1659  cnp[pids[i]].recvImmediateProxyData(copymsg);
1660  }
1661 #if CMK_PERSISTENT_COMM && USE_PERSISTENT_TREE
1662  CmiUsePersistentHandle(NULL, 0);
1663 #endif
1664 
1665  //re-send msg to it's internal cores
1666 #if CMK_SMP && defined(NAMDSRC_IMMQD_HACK)
1667  msg->isFromImmMsgCall = (CkMyRank()==CkMyNodeSize());
1668 #endif
1669  cp.recvProxyData(msg, ptn->numPes, ptn->peIDs);
1670 #else
1671  CkAbort("Bad execution path to NodeProxyMgr::recvImmediateProxyData\n");
1672 #endif
1673 }
Patch * patch(PatchID pid)
Definition: PatchMap.h:244
PatchID patch
Definition: ProxyMgr.h:97
int32 * peIDs
Definition: NamdTypes.h:318
int32 numPes
Definition: NamdTypes.h:319

◆ recvImmediateResults()

void NodeProxyMgr::recvImmediateResults ( ProxyCombinedResultRawMsg omsg)

Definition at line 1524 of file ProxyMgr.C.

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

1524  {
1525  ProxyCombinedResultRawMsg *msg = omsg;
1526 #if defined(NODEAWARE_PROXY_SPANNINGTREE) && defined(USE_NODEPATCHMGR)
1527  //CkPrintf("recvImmRes called on comm thread%d pe[%d]\n", CkMyRank()==CmiMyNodeSize(), CkMyPe());
1528  //fflush(stdout);
1529 
1530  int destRank = CkRankOf(msg->destPe);
1531  PatchMap *pmap = localPatchMaps[destRank];
1532  HomePatch *home = pmap->homePatch(msg->patch);
1533  if (home) {
1534 #if CMK_SMP && defined(NAMDSRC_IMMQD_HACK)
1535  msg->isFromImmMsgCall = (CkMyRank()==CkMyNodeSize());
1536 #endif
1537  CProxy_ProxyMgr cp(localProxyMgr);
1538  CmiEnableUrgentSend(1);
1539  cp[msg->destPe].recvResults(msg);
1540  CmiEnableUrgentSend(0);
1541 /*
1542  char *srcfrom = "Isfrom";
1543  if(CkMyRank()!=CmiMyNodeSize()) srcfrom="Notfrom";
1544  CkPrintf("%s comm thread from pe[%d]\n", srcfrom, CkMyPe());
1545  fflush(stdout);
1546 */
1547  }
1548  else {
1549  ProxyPatch *patch = (ProxyPatch *)pmap->patch(msg->patch);
1551  if (ocMsg) {
1552  CProxy_NodeProxyMgr cnp(thisgroup);
1553  ocMsg->destPe = patch->getSpanningTreeParent();
1555  cnp[CkNodeOf(cMsg->destPe)].recvImmediateResults(cMsg);
1556  }
1557  }
1558 #endif
1559 }
Patch * patch(PatchID pid)
Definition: PatchMap.h:244
HomePatch * homePatch(PatchID pid)
Definition: PatchMap.h:249
static ProxyCombinedResultRawMsg * toRaw(ProxyCombinedResultMsg *msg)
Definition: ProxyMgr.C:247
ProxyCombinedResultMsg * depositCombinedResultRawMsg(ProxyCombinedResultRawMsg *)
Definition: ProxyPatch.C:540
int getSpanningTreeParent()
Definition: ProxyPatch.h:33

◆ registerLocalPatchMap()

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

Definition at line 492 of file ProxyMgr.h.

492  {
493  localPatchMaps[rank] = one;
494  }

◆ registerLocalProxyMgr()

void NodeProxyMgr::registerLocalProxyMgr ( CkGroupID  one)
inline

Definition at line 486 of file ProxyMgr.h.

486  {
487  localProxyMgr = one;
488  }

◆ registerPatch()

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

Definition at line 1839 of file ProxyMgr.C.

Referenced by ProxyMgr::recvNodeAwareSpanningTree().

1839  {
1840  if(proxyInfo[patchID]) {
1841  delete proxyInfo[patchID];
1842  }
1843  if(numPes == 0) {
1844  proxyInfo[patchID] = NULL;
1845  }else{
1846  proxyInfo[patchID] = new proxyTreeNode(CkNodeOf(pes[0]),numPes,pes);
1847  }
1848 }

◆ sendProxyList()

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

Definition at line 1978 of file ProxyMgr.C.

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

Referenced by HomePatch::sendProxies().

1978  {
1979  int insertIdx; //indexed from 0
1980  CmiLock(localDepositLock);
1981  insertIdx = homepatchRecved++; //ensure the atomic increment
1982 
1983  localProxyLists[insertIdx].patchID = pid;
1984  localProxyLists[insertIdx].numProxies = size;
1985  localProxyLists[insertIdx].proxyList = plist;
1986 
1987  if(insertIdx == (numHomePatches-1)) {
1988  //all local home patches have contributed
1990  }
1991  CmiUnlock(localDepositLock);
1992 }
int numProxies
Definition: ProxyMgr.h:410
int * proxyList
Definition: ProxyMgr.h:411
void contributeToParent()
Definition: ProxyMgr.C:2007

◆ sendProxyListInfo()

void NodeProxyMgr::sendProxyListInfo ( PatchProxyListMsg msg)

Definition at line 1994 of file ProxyMgr.C.

References contributeToParent().

1994  {
1995  int insertIdx; //indexed from 0
1996  CmiLock(localDepositLock);
1997  insertIdx = kidRecved++;
1998 
1999  remoteProxyLists[insertIdx] = msg;
2000  if(insertIdx == (numKidNodes-1)) {
2001  //all kids have contributed;
2003  }
2004  CmiUnlock(localDepositLock);
2005 }
void contributeToParent()
Definition: ProxyMgr.C:2007

The documentation for this class was generated from the following files: