NAMD
Public Member Functions | Protected Member Functions | List of all members
ProxyPatch Class Reference

#include <ProxyPatch.h>

Inheritance diagram for ProxyPatch:
Patch

Public Member Functions

 ProxyPatch (PatchID pd)
 
virtual ~ProxyPatch (void)
 
void receiveData (ProxyDataMsg *)
 
void receiveAll (ProxyDataMsg *)
 
void receiveData (ProxyGBISP2DataMsg *)
 
void receiveData (ProxyGBISP3DataMsg *)
 
void setSpanningTree (int, int *, int)
 
int getSpanningTreeParent ()
 
int getSpanningTreeChild (int *)
 
const int * getSpanningTreeChildPtr ()
 
int getSpanningTreeNChild (void)
 
ProxyCombinedResultMsgdepositCombinedResultMsg (ProxyCombinedResultMsg *)
 
ProxyCombinedResultMsgdepositCombinedResultRawMsg (ProxyCombinedResultRawMsg *)
 
- Public Member Functions inherited from Patch
 Patch (PatchID pd)
 
int hasNewAtoms ()
 
virtual ~Patch ()
 
Box< Patch, CompAtom > * registerPositionPickup (Compute *cid)
 
void unregisterPositionPickup (Compute *cid, Box< Patch, CompAtom > **const box)
 
Box< Patch, CompAtom > * registerAvgPositionPickup (Compute *cid)
 
void unregisterAvgPositionPickup (Compute *cid, Box< Patch, CompAtom > **const box)
 
Box< Patch, CompAtom > * registerVelocityPickup (Compute *cid)
 
void unregisterVelocityPickup (Compute *cid, Box< Patch, CompAtom > **const box)
 
Box< Patch, Real > * registerIntRadPickup (Compute *cid)
 
void unregisterIntRadPickup (Compute *cid, Box< Patch, Real > **const box)
 
Box< Patch, GBReal > * registerPsiSumDeposit (Compute *cid)
 
void unregisterPsiSumDeposit (Compute *cid, Box< Patch, GBReal > **const box)
 
Box< Patch, Real > * registerBornRadPickup (Compute *cid)
 
void unregisterBornRadPickup (Compute *cid, Box< Patch, Real > **const box)
 
Box< Patch, GBReal > * registerDEdaSumDeposit (Compute *cid)
 
void unregisterDEdaSumDeposit (Compute *cid, Box< Patch, GBReal > **const box)
 
Box< Patch, Real > * registerDHdrPrefixPickup (Compute *cid)
 
void unregisterDHdrPrefixPickup (Compute *cid, Box< Patch, Real > **const box)
 
Box< Patch, int > * registerLcpoTypePickup (Compute *cid)
 
void unregisterLcpoTypePickup (Compute *cid, Box< Patch, int > **const box)
 
Box< Patch, Results > * registerForceDeposit (Compute *cid)
 
void unregisterForceDeposit (Compute *cid, Box< Patch, Results > **const box)
 
void positionsReady (int n=0, int startup=1)
 
void positionBoxClosed (void)
 
void forceBoxClosed (void)
 
void avgPositionBoxClosed (void)
 
void velocityBoxClosed (void)
 
void intRadBoxClosed (void)
 
void psiSumBoxClosed (void)
 
void bornRadBoxClosed (void)
 
void dEdaSumBoxClosed (void)
 
void dHdrPrefixBoxClosed (void)
 
void gbisP2Ready ()
 
void gbisP3Ready ()
 
void lcpoTypeBoxClosed (void)
 
int getNumAtoms () const
 
int getNumFixedAtoms () const
 
void setNumFixedAtoms (int numFixed)
 
PatchID getPatchID () const
 
int getNumComputes () const
 
CompAtomExtgetCompAtomExtInfo ()
 
CompAtomgetCompAtomInfo ()
 
CudaAtomgetCudaAtomList ()
 

Protected Member Functions

virtual void boxClosed (int)
 

Additional Inherited Members

- Public Attributes inherited from Patch
Latticelattice
 
Flags flags
 
- Protected Attributes inherited from Patch
const PatchID patchID
 
int numAtoms
 
int numFixedAtoms
 
CompAtomList p
 
CompAtomList p_avg
 
CompAtomList v
 
AtomMapperatomMapper
 
RealList intRad
 
GBRealList psiSum
 
GBRealList psiFin
 
RealList bornRad
 
RealList dHdrPrefix
 
GBRealList dEdaSum
 
IntList lcpoType
 
CompAtomExtList pExt
 
CompAtomavgPositionPtrBegin
 
CompAtomavgPositionPtrEnd
 
CompAtomvelocityPtrBegin
 
CompAtomvelocityPtrEnd
 
CudaAtomcudaAtomPtr
 
ForceList f [Results::maxNumForces]
 
Results results
 
int computesSortedByPriority
 
int firstHoldableCompute
 
OwnerBox< Patch, CompAtompositionBox
 
ComputePtrList positionComputeList
 
OwnerBox< Patch, CompAtomavgPositionBox
 
ComputePtrList avgPositionComputeList
 
OwnerBox< Patch, CompAtomvelocityBox
 
ComputePtrList velocityComputeList
 
OwnerBox< Patch, RealintRadBox
 
ComputePtrList intRadComputeList
 
OwnerBox< Patch, GBRealpsiSumBox
 
ComputePtrList psiSumComputeList
 
OwnerBox< Patch, RealbornRadBox
 
ComputePtrList bornRadComputeList
 
OwnerBox< Patch, GBRealdEdaSumBox
 
ComputePtrList dEdaSumComputeList
 
OwnerBox< Patch, RealdHdrPrefixBox
 
ComputePtrList dHdrPrefixComputeList
 
OwnerBox< Patch, int > lcpoTypeBox
 
ComputePtrList lcpoTypeComputeList
 
OwnerBox< Patch, ResultsforceBox
 
ComputePtrList forceComputeList
 
int boxesOpen
 
int _hasNewAtoms
 
int * child
 
int nChild
 

Detailed Description

Definition at line 19 of file ProxyPatch.h.

Constructor & Destructor Documentation

◆ ProxyPatch()

ProxyPatch::ProxyPatch ( PatchID  pd)

Definition at line 26 of file ProxyPatch.C.

References Patch::child, DebugM, Patch::nChild, Patch::numAtoms, PatchMap::Object(), ProxyMgr::Object(), Patch::patchID, proxySpanDim, and ProxyMgr::registerProxy().

26  :
27  Patch(pd), proxyMsgBufferStatus(PROXYMSGNOTBUFFERED),
28  curProxyMsg(NULL), prevProxyMsg(NULL)
29 {
30  DebugM(4, "ProxyPatch(" << pd << ") at " << this << "\n");
32  numAtoms = -1;
33  parent = -1;
34 
35 #ifndef NODEAWARE_PROXY_SPANNINGTREE
36  nChild = 0;
37  child = new int[proxySpanDim];
38 #endif
39 
40 #if CMK_PERSISTENT_COMM && USE_PERSISTENT_TREE
41  localphs = 0;
42 #ifdef REMOVE_PROXYRESULTMSG_EXTRACOPY
43  int msgstart = sizeof(envelope)+sizeof(ProxyResultVarsizeMsg);
44 #else
45  int msgstart = sizeof(envelope)+sizeof(ProxyResultMsg);
46 #endif
47  localphs = CmiCreatePersistent(PatchMap::Object()->node(patchID), 30000, msgstart);
48  ntreephs = 0;
49 #ifdef NODEAWARE_PROXY_SPANNINGTREE
50  treephs = NULL;
51 #else
52  treephs = new PersistentHandle[proxySpanDim];
53 #endif
54 #endif
55 
56  // DMK - Atom Separation (water vs. non-water)
57  #if NAMD_SeparateWaters != 0
58  numWaterAtoms = -1;
59  #endif
60 
61  #if defined(NODEAWARE_PROXY_SPANNINGTREE) && defined(USE_NODEPATCHMGR)
62  depositLock = CmiCreateLock();
63  #endif
64 }
#define PROXYMSGNOTBUFFERED
Definition: ProxyPatch.h:15
static ProxyMgr * Object()
Definition: ProxyMgr.h:394
static PatchMap * Object()
Definition: PatchMap.h:27
#define DebugM(x, y)
Definition: Debug.h:75
Patch(PatchID pd)
Definition: Patch.C:44
int numAtoms
Definition: Patch.h:151
const PatchID patchID
Definition: Patch.h:150
void registerProxy(PatchID pid)
Definition: ProxyMgr.C:518
int * child
Definition: Patch.h:269
int proxySpanDim
Definition: ProxyMgr.C:47
int nChild
Definition: Patch.h:270

◆ ~ProxyPatch()

ProxyPatch::~ProxyPatch ( void  )
virtual

Definition at line 66 of file ProxyPatch.C.

References Patch::atomMapper, ResizeArray< Elem >::begin(), Patch::child, DebugM, ResizeArray< Elem >::end(), Patch::lcpoType, ProxyMgr::Object(), Patch::p, Patch::patchID, Patch::pExt, ResizeArray< Elem >::resize(), AtomMapper::unregisterIDsCompAtomExt(), and ProxyMgr::unregisterProxy().

67 {
68  DebugM(4, "ProxyPatch(" << patchID << ") deleted at " << this << "\n");
70 
71  // ProxyPatch may be freed because of load balancing if the compute object
72  // it corresponds to no longer exist on this specific processor.
73  CmiAssert(prevProxyMsg!=NULL);
74  if(prevProxyMsg!=NULL) {
75 // #ifdef REMOVE_PROXYDATAMSG_EXTRACOPY
76 // AtomMap::Object()->unregisterIDs(patchID,positionPtrBegin, positionPtrEnd);
77 // #else
79 // #endif
80 #if ! CMK_PERSISTENT_COMM || ! USE_PERSISTENT_TREE
81  delete prevProxyMsg;
82 #endif
83  prevProxyMsg = NULL;
84  }
85 
86 
87 #ifdef NODEAWARE_PROXY_SPANNINGTREE
88  #ifdef USE_NODEPATCHMGR
89  delete [] nodeChildren;
90  #endif
91 #endif
92  delete [] child;
93 
94  p.resize(0);
95  pExt.resize(0);
96 
97  lcpoType.resize(0);
98 
99 #if CMK_PERSISTENT_COMM && USE_PERSISTENT_TREE
100  CmiDestoryPersistent(localphs);
101  localphs = 0;
102  for (int i=0; i<ntreephs; i++) CmiDestoryPersistent(treephs[i]);
103  delete [] treephs;
104 #endif
105 }
static ProxyMgr * Object()
Definition: ProxyMgr.h:394
#define DebugM(x, y)
Definition: Debug.h:75
AtomMapper * atomMapper
Definition: Patch.h:159
void resize(int i)
Definition: ResizeArray.h:84
void unregisterProxy(PatchID pid)
Definition: ProxyMgr.C:538
IntList lcpoType
Definition: Patch.h:171
CompAtomList p
Definition: Patch.h:153
iterator begin(void)
Definition: ResizeArray.h:36
const PatchID patchID
Definition: Patch.h:150
iterator end(void)
Definition: ResizeArray.h:37
int * child
Definition: Patch.h:269
CompAtomExtList pExt
Definition: Patch.h:181
void unregisterIDsCompAtomExt(const CompAtomExt *begin, const CompAtomExt *end)
Definition: AtomMap.C:76

Member Function Documentation

◆ boxClosed()

void ProxyPatch::boxClosed ( int  box)
protectedvirtual

Implements Patch.

Definition at line 107 of file ProxyPatch.C.

References Patch::boxesOpen, DebugM, ProxyGBISP2ResultMsg::dEdaSum, Patch::dEdaSum, ProxyGBISP2ResultMsg::dEdaSumLen, Flags::doFullElectrostatics, Flags::doNonbonded, Patch::flags, GB1_PROXY_RESULTS_PRIORITY, GB2_PROXY_RESULTS_PRIORITY, Patch::numAtoms, ProxyMgr::Object(), ProxyGBISP1ResultMsg::origPe, ProxyGBISP2ResultMsg::origPe, ProxyGBISP1ResultMsg::patch, ProxyGBISP2ResultMsg::patch, PATCH_PRIORITY, Patch::patchID, PRIORITY_SIZE, PROXYALLMSGBUFFERED, PROXYDATAMSGBUFFERED, ProxyGBISP1ResultMsg::psiSum, Patch::psiSum, ProxyGBISP1ResultMsg::psiSumLen, receiveAll(), receiveData(), ProxyMgr::sendResult(), Flags::sequence, and SET_PRIORITY.

107  {
108  ProxyGBISP1ResultMsg *msg1;
109  ProxyGBISP2ResultMsg *msg2;
110 
111  if (box == 1) { // force Box
112  // Note: delay the deletion of proxyDataMsg (of the
113  // current step) until the next step. This is done
114  // for the sake of atom migration (ProxyDataMsg)
115  // as the ProxyPatch has to unregister the atoms
116  // of the previous step in the AtomMap data structure
117  // also denotes end of gbis phase 3
118  sendResults();
119  } else if ( box == 5) {//end phase 1
120  //this msg should only have nonzero atoms if flags.doNonbonded
121  int msgAtoms = (flags.doNonbonded) ? numAtoms : 0;
122  msg1 = new (msgAtoms,PRIORITY_SIZE) ProxyGBISP1ResultMsg;
123  for (int i = 0; i < msgAtoms; i++) {
124  msg1->psiSum[i] = psiSum[i];
125  }
126  msg1->patch = patchID;
127  msg1->psiSumLen = msgAtoms;
128  msg1->origPe = CkMyPe();
130  ProxyMgr::Object()->sendResult(msg1);
131  } else if ( box == 8) {//end phase 2
132  //this msg should only have nonzero atoms if flags.doFullElectrostatics
133  int msgAtoms = (flags.doFullElectrostatics) ? numAtoms : 0;
134  msg2 = new (msgAtoms,PRIORITY_SIZE) ProxyGBISP2ResultMsg;
135  for (int i = 0; i < msgAtoms; i++) {
136  msg2->dEdaSum[i] = dEdaSum[i];
137  }
138  msg2->patch = patchID;
139  msg2->dEdaSumLen = msgAtoms;
140  msg2->origPe = CkMyPe();
142  ProxyMgr::Object()->sendResult(msg2);
143  } else if (box == 9) {
144  //nothing
145  } else if (box == 10) {
146  // LCPO do nothing
147  }
148 
149 
150  if ( ! --boxesOpen ) {
151  DebugM(2,patchID << ": " << "Checking message buffer.\n");
152 
153  if(proxyMsgBufferStatus == PROXYALLMSGBUFFERED) {
154  CmiAssert(curProxyMsg != NULL);
155  DebugM(3,"Patch " << patchID << " processing buffered proxy ALL data.\n");
156  receiveAll(curProxyMsg);
157  }else if(proxyMsgBufferStatus == PROXYDATAMSGBUFFERED) {
158  CmiAssert(curProxyMsg != NULL);
159  DebugM(3,"Patch " << patchID << " processing buffered proxy data.\n");
160  receiveData(curProxyMsg);
161  }
162  } else {
163  DebugM(3,"ProxyPatch " << patchID << ": " << boxesOpen << " boxes left to close.\n");
164  }
165 }
static ProxyMgr * Object()
Definition: ProxyMgr.h:394
#define GB1_PROXY_RESULTS_PRIORITY
Definition: Priorities.h:54
#define DebugM(x, y)
Definition: Debug.h:75
void receiveAll(ProxyDataMsg *)
Definition: ProxyPatch.C:245
GBRealList dEdaSum
Definition: Patch.h:167
Flags flags
Definition: Patch.h:128
#define PRIORITY_SIZE
Definition: Priorities.h:13
int boxesOpen
Definition: Patch.h:250
GBRealList psiSum
Definition: Patch.h:163
GBReal * dEdaSum
Definition: ProxyMgr.h:51
int doFullElectrostatics
Definition: PatchTypes.h:23
void receiveData(ProxyDataMsg *)
Definition: ProxyPatch.C:168
#define GB2_PROXY_RESULTS_PRIORITY
Definition: Priorities.h:62
int numAtoms
Definition: Patch.h:151
int sequence
Definition: PatchTypes.h:18
int doNonbonded
Definition: PatchTypes.h:22
#define PROXYALLMSGBUFFERED
Definition: ProxyPatch.h:17
#define PROXYDATAMSGBUFFERED
Definition: ProxyPatch.h:16
const PatchID patchID
Definition: Patch.h:150
#define SET_PRIORITY(MSG, SEQ, PRIO)
Definition: Priorities.h:18
void sendResult(ProxyGBISP1ResultMsg *)
Definition: ProxyMgr.C:1850
#define PATCH_PRIORITY(PID)
Definition: Priorities.h:25

◆ depositCombinedResultMsg()

ProxyCombinedResultMsg * ProxyPatch::depositCombinedResultMsg ( ProxyCombinedResultMsg msg)

Definition at line 476 of file ProxyPatch.C.

References ResizeArray< Elem >::add(), ResizeArray< Elem >::begin(), ResizeArray< Elem >::end(), ProxyCombinedResultMsg::forceList, Results::maxNumForces, Patch::nChild, ProxyCombinedResultMsg::nodes, Vector::x, Vector::y, and Vector::z.

Referenced by ProxyMgr::sendResults().

476  {
477 #if defined(NODEAWARE_PROXY_SPANNINGTREE) && defined(USE_NODEPATCHMGR)
478  CmiLock(depositLock);
479 #endif
480  nWait++;
481  if (nWait == 1) msgCBuffer = msg;
482  else {
483  NodeIDList::iterator n_i, n_e;
484  n_i = msg->nodes.begin();
485  n_e = msg->nodes.end();
486  for (; n_i!=n_e; ++n_i) msgCBuffer->nodes.add(*n_i);
487  for ( int k = 0; k < Results::maxNumForces; ++k )
488  {
489  register ForceList::iterator r_i;
490  r_i = msgCBuffer->forceList[k]->begin();
491  register ForceList::iterator f_i, f_e;
492  f_i = msg->forceList[k]->begin();
493  f_e = msg->forceList[k]->end();
494  // for ( ; f_i != f_e; ++f_i, ++r_i ) *r_i += *f_i;
495 
496  int nf = f_e - f_i;
497 #ifdef ARCH_POWERPC
498 #pragma disjoint (*f_i, *r_i)
499 #pragma unroll(4)
500 #endif
501  for (int count = 0; count < nf; count++) {
502  r_i[count].x += f_i[count].x;
503  r_i[count].y += f_i[count].y;
504  r_i[count].z += f_i[count].z;
505  }
506 
507  }
508  delete msg;
509  }
510 //CkPrintf("[%d:%d] wait: %d of %d (%d %d %d)\n", CkMyPe(), patchID, nWait, nChild+1, parent, child[0],child[1]);
511  if (nWait == nChild + 1) {
512  nWait = 0;
513 #if defined(NODEAWARE_PROXY_SPANNINGTREE) && defined(USE_NODEPATCHMGR)
514  CmiUnlock(depositLock);
515 #endif
516 
517  return msgCBuffer;
518  }
519 
520 #if defined(NODEAWARE_PROXY_SPANNINGTREE) && defined(USE_NODEPATCHMGR)
521  CmiUnlock(depositLock);
522 #endif
523 
524  return NULL;
525 }
Definition: Vector.h:72
BigReal z
Definition: Vector.h:74
int add(const Elem &elem)
Definition: ResizeArray.h:101
BigReal x
Definition: Vector.h:74
ForceList * forceList[Results::maxNumForces]
Definition: ProxyMgr.h:254
iterator begin(void)
Definition: ResizeArray.h:36
iterator end(void)
Definition: ResizeArray.h:37
BigReal y
Definition: Vector.h:74
int nChild
Definition: Patch.h:270

◆ depositCombinedResultRawMsg()

ProxyCombinedResultMsg * ProxyPatch::depositCombinedResultRawMsg ( ProxyCombinedResultRawMsg msg)

Definition at line 540 of file ProxyPatch.C.

References ResizeArray< Elem >::add(), ResizeArray< Elem >::begin(), ProxyCombinedResultRawMsg::flLen, ProxyCombinedResultRawMsg::forceArr, ProxyCombinedResultMsg::forceList, ProxyCombinedResultMsg::fromRaw(), ProxyCombinedResultRawMsg::isForceNonZero, Results::maxNumForces, Patch::nChild, ProxyCombinedResultRawMsg::nodes, ProxyCombinedResultMsg::nodes, ProxyCombinedResultRawMsg::nodeSize, Vector::x, Vector::y, and Vector::z.

Referenced by ProxyMgr::recvImmediateResults(), and NodeProxyMgr::recvImmediateResults().

540  {
541 #if defined(NODEAWARE_PROXY_SPANNINGTREE) && defined(USE_NODEPATCHMGR)
542  CmiLock(depositLock);
543 #endif
544  nWait++;
545  if (nWait == 1) msgCBuffer = ProxyCombinedResultMsg::fromRaw(msg);
546  else {
547  for (int i=0; i<msg->nodeSize; i++) msgCBuffer->nodes.add(msg->nodes[i]);
548 
549  register char* isNonZero = msg->isForceNonZero;
550  register Force* f_i = msg->forceArr;
551  for ( int k = 0; k < Results::maxNumForces; ++k )
552  {
553  register ForceList::iterator r_i;
554  r_i = msgCBuffer->forceList[k]->begin();
555  int nf = msg->flLen[k];
556 
557 #ifdef ARCH_POWERPC
558 #pragma disjoint (*f_i, *r_i)
559 #endif
560  for (int count = 0; count < nf; count++) {
561  if(*isNonZero){
562  r_i[count].x += f_i->x;
563  r_i[count].y += f_i->y;
564  r_i[count].z += f_i->z;
565  f_i++;
566  }
567  isNonZero++;
568  }
569  }
570  delete msg;
571  }
572 //CkPrintf("[%d:%d] wait: %d of %d (%d %d %d)\n", CkMyPe(), patchID, nWait, nChild+1, parent, child[0],child[1]);
573  if (nWait == nChild + 1) {
574  nWait = 0;
575 #if defined(NODEAWARE_PROXY_SPANNINGTREE) && defined(USE_NODEPATCHMGR)
576  CmiUnlock(depositLock);
577 #endif
578 
579  return msgCBuffer;
580  }
581 
582 #if defined(NODEAWARE_PROXY_SPANNINGTREE) && defined(USE_NODEPATCHMGR)
583  CmiUnlock(depositLock);
584 #endif
585 
586  return NULL;
587 }
Definition: Vector.h:72
static ProxyCombinedResultMsg * fromRaw(ProxyCombinedResultRawMsg *msg)
Definition: ProxyMgr.C:302
BigReal z
Definition: Vector.h:74
int add(const Elem &elem)
Definition: ResizeArray.h:101
BigReal x
Definition: Vector.h:74
ForceList * forceList[Results::maxNumForces]
Definition: ProxyMgr.h:254
iterator begin(void)
Definition: ResizeArray.h:36
BigReal y
Definition: Vector.h:74
int flLen[Results::maxNumForces]
Definition: ProxyMgr.h:233
int nChild
Definition: Patch.h:270

◆ getSpanningTreeChild()

int ProxyPatch::getSpanningTreeChild ( int *  c)

Definition at line 471 of file ProxyPatch.C.

References Patch::child, and Patch::nChild.

471  {
472  for (int i=0; i<nChild; i++) c[i] = child[i];
473  return nChild;
474 }
int * child
Definition: Patch.h:269
int nChild
Definition: Patch.h:270

◆ getSpanningTreeChildPtr()

const int* ProxyPatch::getSpanningTreeChildPtr ( )
inline

Definition at line 35 of file ProxyPatch.h.

References Patch::child.

Referenced by ProxyMgr::recvImmediateProxyAll(), and ProxyMgr::recvImmediateProxyData().

35 { return child; }
int * child
Definition: Patch.h:269

◆ getSpanningTreeNChild()

int ProxyPatch::getSpanningTreeNChild ( void  )
inline

Definition at line 36 of file ProxyPatch.h.

References Patch::nChild.

Referenced by ProxyMgr::recvImmediateProxyAll(), and ProxyMgr::recvImmediateProxyData().

36 { return nChild; }
int nChild
Definition: Patch.h:270

◆ getSpanningTreeParent()

int ProxyPatch::getSpanningTreeParent ( )
inline

Definition at line 33 of file ProxyPatch.h.

Referenced by ProxyMgr::recvImmediateResults(), NodeProxyMgr::recvImmediateResults(), and ProxyMgr::sendResults().

33 { return parent; }

◆ receiveAll()

void ProxyPatch::receiveAll ( ProxyDataMsg msg)

Definition at line 245 of file ProxyPatch.C.

References Patch::atomMapper, ProxyDataMsg::avgPlLen, ProxyDataMsg::avgPositionList, Patch::avgPositionPtrBegin, Patch::avgPositionPtrEnd, ResizeArray< Elem >::begin(), Patch::boxesOpen, ProxyDataMsg::cudaAtomList, Patch::cudaAtomPtr, DebugM, Flags::doGBIS, Flags::doLCPO, ResizeArray< Elem >::end(), ProxyDataMsg::flags, Patch::flags, Patch::intRad, ProxyDataMsg::intRadList, Patch::lcpoType, ProxyDataMsg::lcpoTypeList, NAMD_bug(), Patch::numAtoms, Node::Object(), Patch::p, Patch::patchID, Patch::pExt, ProxyDataMsg::plExtLen, ProxyDataMsg::plLen, ProxyDataMsg::positionExtList, ProxyDataMsg::positionList, Patch::positionsReady(), PROXYALLMSGBUFFERED, ResizeArray< Elem >::resize(), Node::simParameters, AtomMapper::unregisterIDsCompAtomExt(), SimParameters::useAVXTiles, ProxyDataMsg::velocityList, Patch::velocityPtrBegin, Patch::velocityPtrEnd, and ProxyDataMsg::vlLen.

Referenced by boxClosed(), and ProxyMgr::recvProxyAll().

246 {
247  DebugM(3, "receiveAll(" << patchID << ")\n");
248 
249  if ( boxesOpen )
250  {
251  proxyMsgBufferStatus = PROXYALLMSGBUFFERED;
252  curProxyMsg = msg;
253  return;
254  }
255 
256  //The prevProxyMsg has to be deleted after this if-statement because
257  // positionPtrBegin points to the space inside the prevProxyMsg
258  if(prevProxyMsg!=NULL) {
259 // #ifdef REMOVE_PROXYDATAMSG_EXTRACOPY
260 // AtomMap::Object()->unregisterIDs(patchID,positionPtrBegin,positionPtrEnd);
261 // #else
263 // #endif
264  }
265  //Now delete the ProxyDataMsg of the previous step
266 #if ! CMK_PERSISTENT_COMM || ! USE_PERSISTENT_TREE
267  delete prevProxyMsg;
268 #endif
269  curProxyMsg = msg;
270  prevProxyMsg = curProxyMsg;
271 
272  flags = msg->flags;
273 
274 #ifdef REMOVE_PROXYDATAMSG_EXTRACOPY
275  if ( ((int64)msg->positionList) % 32 ) { // not aligned
276  p.resize(msg->plLen);
277  positionPtrBegin = p.begin();
278  memcpy(positionPtrBegin, msg->positionList, sizeof(CompAtom)*(msg->plLen));
279  } else { // aligned
280  positionPtrBegin = msg->positionList;
281  }
282  positionPtrEnd = positionPtrBegin + msg->plLen;
283  if ( ((int64)positionPtrBegin) % 32 ) NAMD_bug("ProxyPatch::receiveAll positionPtrBegin not 32-byte aligned");
284 #else
285  p.resize(msg->plLen);
286  memcpy(p.begin(), msg->positionList, sizeof(CompAtom)*(msg->plLen));
287 #endif
288 
289 // DMK
290 #if defined(NAMD_CUDA) || defined(NAMD_HIP) || defined(NAMD_MIC)
291  cudaAtomPtr = msg->cudaAtomList;
292 #endif
293 
294 #if defined(NAMD_AVXTILES)
296  cudaAtomPtr = msg->cudaAtomList;
297  tiles.realloc(msg->plLen, cudaAtomPtr);
298  }
299 #endif
300  numAtoms = msg->plLen;
301  //numAtoms = p.size();
302 
305 
306  // BEGIN LA
308  velocityPtrEnd = msg->velocityList + msg->vlLen;
309  // END LA
310 
311  if (flags.doGBIS) {
313  for (int i = 0; i < numAtoms*2;i++) {
314  intRad[i] = msg->intRadList[i];
315  }
316  }
317 
318  if (flags.doLCPO) {
320  for (int i = 0; i < numAtoms; i++) {
321  lcpoType[i] = msg->lcpoTypeList[i];
322  }
323  }
324 
325  //We cannot reuse the CompAtomExt list inside the msg because
326  //the information is needed at every step. In the current implementation
327  //scheme, the ProxyDataMsg msg will be deleted for every step.
328  //In order to keep this information, we have to do the extra copy. But
329  //this overhead is amortized among the steps that atoms don't migrate
330  // --Chao Mei
331  pExt.resize(msg->plExtLen);
332  memcpy(pExt.begin(), msg->positionExtList, sizeof(CompAtomExt)*(msg->plExtLen));
333 
334  // DMK - Atom Separation (water vs. non-water)
335  #if NAMD_SeparateWaters != 0
336  numWaterAtoms = msg->numWaterAtoms;
337  #endif
338 
339  positionsReady(1);
340 }
static Node * Object()
Definition: Node.h:86
int * lcpoTypeList
Definition: ProxyMgr.h:112
RealList intRad
Definition: Patch.h:162
CompAtom * velocityPtrEnd
Definition: Patch.h:209
SimParameters * simParameters
Definition: Node.h:181
#define DebugM(x, y)
Definition: Debug.h:75
CompAtom * avgPositionPtrEnd
Definition: Patch.h:205
CompAtom * avgPositionList
Definition: ProxyMgr.h:104
CompAtom * velocityList
Definition: ProxyMgr.h:107
CudaAtom * cudaAtomPtr
Definition: Patch.h:212
AtomMapper * atomMapper
Definition: Patch.h:159
Flags flags
Definition: Patch.h:128
void resize(int i)
Definition: ResizeArray.h:84
int boxesOpen
Definition: Patch.h:250
IntList lcpoType
Definition: Patch.h:171
CudaAtom * cudaAtomList
Definition: ProxyMgr.h:123
void NAMD_bug(const char *err_msg)
Definition: common.C:195
int plExtLen
Definition: ProxyMgr.h:121
CompAtomList p
Definition: Patch.h:153
int numAtoms
Definition: Patch.h:151
CompAtom * avgPositionPtrBegin
Definition: Patch.h:204
#define PROXYALLMSGBUFFERED
Definition: ProxyPatch.h:17
Flags flags
Definition: ProxyMgr.h:98
Real * intRadList
Definition: ProxyMgr.h:110
CompAtom * positionList
Definition: ProxyMgr.h:102
iterator begin(void)
Definition: ResizeArray.h:36
const PatchID patchID
Definition: Patch.h:150
iterator end(void)
Definition: ResizeArray.h:37
int doLCPO
Definition: PatchTypes.h:30
CompAtomExt * positionExtList
Definition: ProxyMgr.h:122
int doGBIS
Definition: PatchTypes.h:29
int avgPlLen
Definition: ProxyMgr.h:103
int64_t int64
Definition: common.h:39
CompAtomExtList pExt
Definition: Patch.h:181
void positionsReady(int n=0, int startup=1)
Definition: Patch.C:403
CompAtom * velocityPtrBegin
Definition: Patch.h:208
void unregisterIDsCompAtomExt(const CompAtomExt *begin, const CompAtomExt *end)
Definition: AtomMap.C:76

◆ receiveData() [1/3]

void ProxyPatch::receiveData ( ProxyDataMsg msg)

Definition at line 168 of file ProxyPatch.C.

References ProxyDataMsg::avgPlLen, ProxyDataMsg::avgPositionList, Patch::avgPositionPtrBegin, Patch::avgPositionPtrEnd, ResizeArray< Elem >::begin(), Patch::boxesOpen, ProxyDataMsg::cudaAtomList, Patch::cudaAtomPtr, DebugM, ProxyDataMsg::flags, Patch::flags, NAMD_bug(), Patch::numAtoms, Node::Object(), Patch::p, Patch::patchID, Patch::pExt, ProxyDataMsg::plExtLen, ProxyDataMsg::plLen, ProxyDataMsg::positionExtList, ProxyDataMsg::positionList, Patch::positionsReady(), PROXYDATAMSGBUFFERED, ResizeArray< Elem >::resize(), Node::simParameters, SimParameters::useAVXTiles, ProxyDataMsg::velocityList, Patch::velocityPtrBegin, Patch::velocityPtrEnd, and ProxyDataMsg::vlLen.

Referenced by boxClosed(), ProxyMgr::recvData(), and ProxyMgr::recvProxyData().

169 {
170  DebugM(3, "receiveData(" << patchID << ")\n");
171 
172  //delete the ProxyDataMsg of the previous step
173  delete prevProxyMsg;
174  prevProxyMsg = NULL;
175 
176  if ( boxesOpen )
177  {
178  proxyMsgBufferStatus = PROXYDATAMSGBUFFERED;
179  // store message in queue (only need one element, though)
180  curProxyMsg = msg;
181  return;
182  }
183 
184  //Reuse position arrays inside proxyDataMsg --Chao Mei
185  curProxyMsg = msg;
186  prevProxyMsg = curProxyMsg;
187  flags = msg->flags;
188 
189 #ifdef REMOVE_PROXYDATAMSG_EXTRACOPY
190  if ( ((int64)msg->positionList) % 32 ) { // not aligned
191  p.resize(msg->plLen);
192  positionPtrBegin = p.begin();
193  memcpy(positionPtrBegin, msg->positionList, sizeof(CompAtom)*(msg->plLen));
194  } else { // aligned
195  positionPtrBegin = msg->positionList;
196  }
197  positionPtrEnd = positionPtrBegin + msg->plLen;
198  if ( ((int64)positionPtrBegin) % 32 ) NAMD_bug("ProxyPatch::receiveData positionPtrBegin not 32-byte aligned");
199 #else
200  p.resize(msg->plLen);
201  memcpy(p.begin(), msg->positionList, sizeof(CompAtom)*(msg->plLen));
202 #endif
203 
204 // DMK
205 #if defined(NAMD_CUDA) || defined(NAMD_HIP) || defined(NAMD_MIC)
206  cudaAtomPtr = msg->cudaAtomList;
207 #endif
208 
209 #if defined(NAMD_AVXTILES)
211  cudaAtomPtr = msg->cudaAtomList;
212  tiles.realloc(msg->plLen, cudaAtomPtr);
213  }
214 #endif
217 
218  // BEGIN LA
220  velocityPtrEnd = msg->velocityList + msg->vlLen;
221  // END LA
222 
223  if ( numAtoms == -1 ) { // for new proxies since receiveAtoms is not called
224  //numAtoms = p.size();
225  numAtoms = msg->plLen;
226 
227  //Retrieve the CompAtomExt list
228  CmiAssert(msg->plExtLen!=0);
229  pExt.resize(msg->plExtLen);
230  memcpy(pExt.begin(), msg->positionExtList, sizeof(CompAtomExt)*(msg->plExtLen));
231 
232 
233  // DMK - Atom Separation (water vs. non-water)
234  #if NAMD_SeparateWaters != 0
235  numWaterAtoms = msg->numWaterAtoms;
236  #endif
237 
238  positionsReady(1);
239  } else {
240  positionsReady(0);
241  }
242 }
static Node * Object()
Definition: Node.h:86
CompAtom * velocityPtrEnd
Definition: Patch.h:209
SimParameters * simParameters
Definition: Node.h:181
#define DebugM(x, y)
Definition: Debug.h:75
CompAtom * avgPositionPtrEnd
Definition: Patch.h:205
CompAtom * avgPositionList
Definition: ProxyMgr.h:104
CompAtom * velocityList
Definition: ProxyMgr.h:107
CudaAtom * cudaAtomPtr
Definition: Patch.h:212
Flags flags
Definition: Patch.h:128
void resize(int i)
Definition: ResizeArray.h:84
int boxesOpen
Definition: Patch.h:250
CudaAtom * cudaAtomList
Definition: ProxyMgr.h:123
void NAMD_bug(const char *err_msg)
Definition: common.C:195
int plExtLen
Definition: ProxyMgr.h:121
CompAtomList p
Definition: Patch.h:153
int numAtoms
Definition: Patch.h:151
CompAtom * avgPositionPtrBegin
Definition: Patch.h:204
Flags flags
Definition: ProxyMgr.h:98
CompAtom * positionList
Definition: ProxyMgr.h:102
#define PROXYDATAMSGBUFFERED
Definition: ProxyPatch.h:16
iterator begin(void)
Definition: ResizeArray.h:36
const PatchID patchID
Definition: Patch.h:150
CompAtomExt * positionExtList
Definition: ProxyMgr.h:122
int avgPlLen
Definition: ProxyMgr.h:103
int64_t int64
Definition: common.h:39
CompAtomExtList pExt
Definition: Patch.h:181
void positionsReady(int n=0, int startup=1)
Definition: Patch.C:403
CompAtom * velocityPtrBegin
Definition: Patch.h:208

◆ receiveData() [2/3]

void ProxyPatch::receiveData ( ProxyGBISP2DataMsg msg)

Definition at line 528 of file ProxyPatch.C.

References ResizeArray< Elem >::begin(), ProxyGBISP2DataMsg::bornRad, Patch::bornRad, Patch::gbisP2Ready(), and Patch::numAtoms.

528  {
529  memcpy(bornRad.begin(), msg->bornRad, sizeof(Real)*numAtoms);
530  delete msg;
532 }
float Real
Definition: common.h:118
void gbisP2Ready()
Definition: Patch.C:598
int numAtoms
Definition: Patch.h:151
RealList bornRad
Definition: Patch.h:165
iterator begin(void)
Definition: ResizeArray.h:36

◆ receiveData() [3/3]

void ProxyPatch::receiveData ( ProxyGBISP3DataMsg msg)

Definition at line 534 of file ProxyPatch.C.

References ResizeArray< Elem >::begin(), ProxyGBISP3DataMsg::dHdrPrefix, Patch::dHdrPrefix, ProxyGBISP3DataMsg::dHdrPrefixLen, and Patch::gbisP3Ready().

534  {
535  memcpy(dHdrPrefix.begin(), msg->dHdrPrefix, sizeof(Real)*msg->dHdrPrefixLen);
536  delete msg;
538 }
float Real
Definition: common.h:118
RealList dHdrPrefix
Definition: Patch.h:166
void gbisP3Ready()
Definition: Patch.C:614
iterator begin(void)
Definition: ResizeArray.h:36
Real * dHdrPrefix
Definition: ProxyMgr.h:59

◆ setSpanningTree()

void ProxyPatch::setSpanningTree ( int  p,
int *  c,
int  n 
)

Definition at line 455 of file ProxyPatch.C.

References Patch::child, Patch::nChild, and Patch::p.

Referenced by ProxyMgr::recvNodeAwareSpanningTree(), ProxyMgr::recvNodeAwareSTParent(), and ProxyMgr::recvSpanningTree().

455  {
456 #if CMK_PERSISTENT_COMM && USE_PERSISTENT_TREE
457  if (ntreephs!=0) {
458  for (int i=0; i<ntreephs; i++) CmiDestoryPersistent(treephs[i]);
459  }
460  for (int i=0; i<n; i++) {
461  treephs[i] = CmiCreatePersistent(c[i], 27000, sizeof(envelope)+sizeof(ProxyDataMsg));
462  }
463  ntreephs = n;
464 #endif
465  parent=p; nChild = n; nWait = 0;
466  for (int i=0; i<n; i++) child[i] = c[i];
467 //CkPrintf("setSpanningTree: [%d:%d] %d %d:%d %d\n", CkMyPe(), patchID, parent, nChild, child[0], child[1]);
468 }
CompAtomList p
Definition: Patch.h:153
int * child
Definition: Patch.h:269
int nChild
Definition: Patch.h:270

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