10 #include "main.decl.h"    13 #include "ProxyMgr.decl.h"    22 #define MIN_DEBUG_LEVEL 2    28   curProxyMsg(NULL), prevProxyMsg(NULL)
    30   DebugM(4, 
"ProxyPatch(" << pd << 
") at " << 
this << 
"\n");
    35 #ifndef NODEAWARE_PROXY_SPANNINGTREE    40 #if CMK_PERSISTENT_COMM && USE_PERSISTENT_TREE    42 #ifdef REMOVE_PROXYRESULTMSG_EXTRACOPY    49 #ifdef NODEAWARE_PROXY_SPANNINGTREE    57   #if NAMD_SeparateWaters != 0    61   #if defined(NODEAWARE_PROXY_SPANNINGTREE) && defined(USE_NODEPATCHMGR)    62     depositLock = CmiCreateLock();
    68   DebugM(4, 
"ProxyPatch(" << 
patchID << 
") deleted at " << 
this << 
"\n");
    73   CmiAssert(prevProxyMsg!=NULL);
    74   if(prevProxyMsg!=NULL) {
    80 #if ! CMK_PERSISTENT_COMM || ! USE_PERSISTENT_TREE    87 #ifdef NODEAWARE_PROXY_SPANNINGTREE    88   #ifdef USE_NODEPATCHMGR    89   delete [] nodeChildren;  
    99 #if CMK_PERSISTENT_COMM && USE_PERSISTENT_TREE   100   CmiDestoryPersistent(localphs);
   102   for (
int i=0; i<ntreephs; i++)  CmiDestoryPersistent(treephs[i]);
   119   } 
else if ( box == 5) {
   123     for (
int i = 0; i < msgAtoms; i++) {
   131   } 
else if ( box == 8) {
   135     for (
int i = 0; i < msgAtoms; i++) {
   143   } 
else if (box == 9) {
   145   } 
else if (box == 10) {
   154           CmiAssert(curProxyMsg != NULL);
   155           DebugM(3,
"Patch " << 
patchID << 
" processing buffered proxy ALL data.\n");
   158           CmiAssert(curProxyMsg != NULL);
   159           DebugM(3,
"Patch " << 
patchID << 
" processing buffered proxy data.\n");
   186   prevProxyMsg = curProxyMsg;
   189 #ifdef REMOVE_PROXYDATAMSG_EXTRACOPY   192     positionPtrBegin = 
p.
begin();
   197   positionPtrEnd = positionPtrBegin + msg->
plLen;
   198   if ( ((
int64)positionPtrBegin) % 32 ) 
NAMD_bug(
"ProxyPatch::receiveData positionPtrBegin not 32-byte aligned");
   205 #if defined(NAMD_CUDA) || defined(NAMD_HIP) || defined(NAMD_MIC)   209 #if defined(NAMD_AVXTILES)   234     #if NAMD_SeparateWaters != 0   235       numWaterAtoms = msg->numWaterAtoms;
   258   if(prevProxyMsg!=NULL) {
   266 #if ! CMK_PERSISTENT_COMM || ! USE_PERSISTENT_TREE   270   prevProxyMsg = curProxyMsg;
   274 #ifdef REMOVE_PROXYDATAMSG_EXTRACOPY   277     positionPtrBegin = 
p.
begin();
   282   positionPtrEnd = positionPtrBegin + msg->
plLen;
   283   if ( ((
int64)positionPtrBegin) % 32 ) 
NAMD_bug(
"ProxyPatch::receiveAll positionPtrBegin not 32-byte aligned");
   290 #if defined(NAMD_CUDA) || defined(NAMD_HIP) || defined(NAMD_MIC)   294 #if defined(NAMD_AVXTILES)   313     for (
int i = 0; i < 
numAtoms*2;i++) {
   320     for (
int i = 0; i < 
numAtoms; i++) {
   335   #if NAMD_SeparateWaters != 0   336     numWaterAtoms = msg->numWaterAtoms;
   342 void ProxyPatch::sendResults(
void)
   350     for ( ; f_i != f_e; ++f_i, ++f2_i ) *f_i += *f2_i;
   356 #if CMK_PERSISTENT_COMM && USE_PERSISTENT_TREE   357   CmiUsePersistentHandle(&localphs, 1);
   361 #ifdef REMOVE_PROXYRESULTMSG_EXTRACOPY   365     msg->
node = CkMyPe();
   385 #if CMK_PERSISTENT_COMM && USE_PERSISTENT_TREE   386   CmiUsePersistentHandle(NULL, 0);
   390 #ifdef NODEAWARE_PROXY_SPANNINGTREE   392 #if CMK_PERSISTENT_COMM && USE_PERSISTENT_TREE && ! defined(USE_NODEPATCHMGR)   394       for (
int i=0; i<ntreephs; i++)  CmiDestoryPersistent(treephs[i]);
   399       treephs = 
new PersistentHandle[n];
   400       for (
int i=0; i<n; i++) {
   401            treephs[i] = CmiCreatePersistent(c[i], 27000, 
sizeof(envelope)+
sizeof(
ProxyDataMsg));
   406   parent=
p; 
nChild = n; nWait = 0;
   413   for (
int i=0; i<n; i++) 
child[i] = c[i];
   415   #if defined(PROCTRACE_DEBUG) && defined(NAST_DEBUG)   416     DebugFileTrace *dft = DebugFileTrace::Object();
   418     dft->writeTrace(
"ProxyPatch[%d] has %d children: ", 
patchID, 
nChild);
   419     for(
int i=0; i<
nChild; i++)
   420         dft->writeTrace(
"%d ", 
child[i]);
   421     dft->writeTrace(
"\n");
   427 #ifdef USE_NODEPATCHMGR   428 void ProxyPatch::setSTNodeChildren(
int numNids, 
int *nids){
   429 #if CMK_PERSISTENT_COMM && USE_PERSISTENT_TREE   430   if (numNodeChild!=0) {
   431       for (
int i=0; i<numNodeChild; i++)  CmiDestoryPersistent(treephs[i]);
   436       treephs = 
new PersistentHandle[numNids];
   437       for (
int i=0; i<numNids; i++) {
   438            treephs[i] = CmiCreateNodePersistent(nids[i], 27000, 
sizeof(envelope)+
sizeof(
ProxyDataMsg));
   443     numNodeChild = numNids;
   444     delete [] nodeChildren;
   449     nodeChildren = 
new int[numNids];
   450     for(
int i=0; i<numNids; i++) nodeChildren[i] = nids[i]; 
   454 #else //branch for NODEAWARE_PROXY_SPANNINGTREE not defined   456 #if CMK_PERSISTENT_COMM && USE_PERSISTENT_TREE   458       for (
int i=0; i<ntreephs; i++)  CmiDestoryPersistent(treephs[i]);
   460   for (
int i=0; i<n; i++) {
   461        treephs[i] = CmiCreatePersistent(c[i], 27000, 
sizeof(envelope)+
sizeof(
ProxyDataMsg));
   465   parent=
p; 
nChild = n; nWait = 0;
   466   for (
int i=0; i<n; i++) 
child[i] = c[i];
   477 #if defined(NODEAWARE_PROXY_SPANNINGTREE) && defined(USE_NODEPATCHMGR)   478   CmiLock(depositLock);
   481   if (nWait == 1) msgCBuffer = msg;
   486     for (; n_i!=n_e; ++n_i) msgCBuffer->
nodes.
add(*n_i);
   498 #pragma disjoint (*f_i, *r_i)   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;
   511   if (nWait == 
nChild + 1) {
   513 #if defined(NODEAWARE_PROXY_SPANNINGTREE) && defined(USE_NODEPATCHMGR)   514     CmiUnlock(depositLock);
   520 #if defined(NODEAWARE_PROXY_SPANNINGTREE) && defined(USE_NODEPATCHMGR)   521   CmiUnlock(depositLock);
   541 #if defined(NODEAWARE_PROXY_SPANNINGTREE) && defined(USE_NODEPATCHMGR)   542   CmiLock(depositLock);
   555         int nf = msg->
flLen[k];
   558 #pragma disjoint (*f_i, *r_i)   560                 for (
int count = 0; count < nf; count++) {
   562                                 r_i[count].
x += f_i->
x;
   563                                 r_i[count].
y += f_i->
y;
   564                                 r_i[count].
z += f_i->
z;
   573   if (nWait == 
nChild + 1) {
   575 #if defined(NODEAWARE_PROXY_SPANNINGTREE) && defined(USE_NODEPATCHMGR)   576     CmiUnlock(depositLock);
   582 #if defined(NODEAWARE_PROXY_SPANNINGTREE) && defined(USE_NODEPATCHMGR)   583   CmiUnlock(depositLock);
 
#define PROXYMSGNOTBUFFERED
 
#define PROXY_RESULTS_PRIORITY
 
static ProxyResultVarsizeMsg * getANewMsg(NodeID nid, PatchID pid, int prioSize, ForceList *fls)
 
static ProxyMgr * Object()
 
static PatchMap * Object()
 
#define GB1_PROXY_RESULTS_PRIORITY
 
CompAtom * velocityPtrEnd
 
SimParameters * simParameters
 
static ProxyCombinedResultMsg * fromRaw(ProxyCombinedResultRawMsg *msg)
 
void receiveAll(ProxyDataMsg *)
 
CompAtom * avgPositionPtrEnd
 
CompAtom * avgPositionList
 
int add(const Elem &elem)
 
void unregisterProxy(PatchID pid)
 
ProxyCombinedResultMsg * depositCombinedResultRawMsg(ProxyCombinedResultRawMsg *)
 
void NAMD_bug(const char *err_msg)
 
void receiveData(ProxyDataMsg *)
 
int getSpanningTreeChild(int *)
 
#define GB2_PROXY_RESULTS_PRIORITY
 
CompAtom * avgPositionPtrBegin
 
#define PROXYALLMSGBUFFERED
 
ForceList * forceList[Results::maxNumForces]
 
void setSpanningTree(int, int *, int)
 
ProxyCombinedResultMsg * depositCombinedResultMsg(ProxyCombinedResultMsg *)
 
#define PROXYDATAMSGBUFFERED
 
ForceList * forceList[Results::maxNumForces]
 
void registerProxy(PatchID pid)
 
void sendResults(ProxyResultVarsizeMsg *)
 
int flLen[Results::maxNumForces]
 
CompAtomExt * positionExtList
 
#define SET_PRIORITY(MSG, SEQ, PRIO)
 
void sendResult(ProxyGBISP1ResultMsg *)
 
ForceList f[Results::maxNumForces]
 
virtual ~ProxyPatch(void)
 
virtual void boxClosed(int)
 
void positionsReady(int n=0, int startup=1)
 
#define PATCH_PRIORITY(PID)
 
CompAtom * velocityPtrBegin
 
void unregisterIDsCompAtomExt(const CompAtomExt *begin, const CompAtomExt *end)