#include <ProxyPatch.h>
Inheritance diagram for ProxyPatch:

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) |
| ProxyCombinedResultMsg * | depositCombinedResultMsg (ProxyCombinedResultMsg *) |
| ProxyCombinedResultMsg * | depositCombinedResultRawMsg (ProxyCombinedResultRawMsg *) |
Protected Member Functions | |
| virtual void | boxClosed (int) |
|
|
Definition at line 23 of file ProxyPatch.C. References DebugM, ProxyMgr::Object(), PROXYMSGNOTBUFFERED, and ProxyMgr::registerProxy(). 00023 : 00024 Patch(pd), proxyMsgBufferStatus(PROXYMSGNOTBUFFERED), 00025 curProxyMsg(NULL), prevProxyMsg(NULL) 00026 { 00027 DebugM(4, "ProxyPatch(" << pd << ") at " << this << "\n"); 00028 ProxyMgr::Object()->registerProxy(patchID); 00029 numAtoms = -1; 00030 parent = -1; 00031 00032 #ifndef NODEAWARE_PROXY_SPANNINGTREE 00033 nChild = 0; 00034 child = new int[proxySpanDim]; 00035 #endif 00036 00037 #if CMK_PERSISTENT_COMM && USE_PERSISTENT_TREE 00038 localphs = 0; 00039 #ifdef REMOVE_PROXYRESULTMSG_EXTRACOPY 00040 int msgstart = sizeof(envelope)+sizeof(ProxyResultVarsizeMsg); 00041 #else 00042 int msgstart = sizeof(envelope)+sizeof(ProxyResultMsg); 00043 #endif 00044 localphs = CmiCreatePersistent(PatchMap::Object()->node(patchID), 30000, msgstart); 00045 ntreephs = 0; 00046 #ifdef NODEAWARE_PROXY_SPANNINGTREE 00047 treephs = NULL; 00048 #else 00049 treephs = new PersistentHandle[proxySpanDim]; 00050 #endif 00051 #endif 00052 00053 // DMK - Atom Separation (water vs. non-water) 00054 #if NAMD_SeparateWaters != 0 00055 numWaterAtoms = -1; 00056 #endif 00057 00058 #if defined(NODEAWARE_PROXY_SPANNINGTREE) && defined(USE_NODEPATCHMGR) 00059 depositLock = CmiCreateLock(); 00060 #endif 00061 }
|
|
|
Definition at line 63 of file ProxyPatch.C. References ResizeArray< Elem >::begin(), DebugM, ResizeArray< Elem >::end(), ProxyMgr::Object(), ResizeArray< Elem >::resize(), AtomMapper::unregisterIDsCompAtomExt(), and ProxyMgr::unregisterProxy(). 00064 {
00065 DebugM(4, "ProxyPatch(" << patchID << ") deleted at " << this << "\n");
00066 ProxyMgr::Object()->unregisterProxy(patchID);
00067
00068 // ProxyPatch may be freed because of load balancing if the compute object
00069 // it corresponds to no longer exist on this specific processor.
00070 CmiAssert(prevProxyMsg!=NULL);
00071 if(prevProxyMsg!=NULL) {
00072 // #ifdef REMOVE_PROXYDATAMSG_EXTRACOPY
00073 // AtomMap::Object()->unregisterIDs(patchID,positionPtrBegin, positionPtrEnd);
00074 // #else
00075 atomMapper->unregisterIDsCompAtomExt(pExt.begin(),pExt.end());
00076 // #endif
00077 #if ! CMK_PERSISTENT_COMM || ! USE_PERSISTENT_TREE
00078 delete prevProxyMsg;
00079 #endif
00080 prevProxyMsg = NULL;
00081 }
00082
00083
00084 #ifdef NODEAWARE_PROXY_SPANNINGTREE
00085 #ifdef USE_NODEPATCHMGR
00086 delete [] nodeChildren;
00087 #endif
00088 #endif
00089 delete [] child;
00090
00091 p.resize(0);
00092 pExt.resize(0);
00093
00094 lcpoType.resize(0);
00095
00096 #if CMK_PERSISTENT_COMM && USE_PERSISTENT_TREE
00097 CmiDestoryPersistent(localphs);
00098 localphs = 0;
00099 for (int i=0; i<ntreephs; i++) CmiDestoryPersistent(treephs[i]);
00100 delete [] treephs;
00101 #endif
00102 }
|
|
|
Implements Patch. Definition at line 104 of file ProxyPatch.C. References DebugM, ProxyGBISP2ResultMsg::dEdaSum, ProxyGBISP2ResultMsg::dEdaSumLen, Flags::doFullElectrostatics, Flags::doNonbonded, GB1_PROXY_RESULTS_PRIORITY, GB2_PROXY_RESULTS_PRIORITY, ProxyMgr::Object(), ProxyGBISP2ResultMsg::origPe, ProxyGBISP1ResultMsg::origPe, ProxyGBISP2ResultMsg::patch, ProxyGBISP1ResultMsg::patch, PATCH_PRIORITY, ProxyGBISP1ResultMsg::psiSum, ProxyGBISP1ResultMsg::psiSumLen, receiveAll(), receiveData(), ProxyMgr::sendResult(), Flags::sequence, and SET_PRIORITY. 00104 {
00105 ProxyGBISP1ResultMsg *msg1;
00106 ProxyGBISP2ResultMsg *msg2;
00107
00108 if (box == 1) { // force Box
00109 // Note: delay the deletion of proxyDataMsg (of the
00110 // current step) until the next step. This is done
00111 // for the sake of atom migration (ProxyDataMsg)
00112 // as the ProxyPatch has to unregister the atoms
00113 // of the previous step in the AtomMap data structure
00114 // also denotes end of gbis phase 3
00115 sendResults();
00116 } else if ( box == 5) {//end phase 1
00117 //this msg should only have nonzero atoms if flags.doNonbonded
00118 int msgAtoms = (flags.doNonbonded) ? numAtoms : 0;
00119 msg1 = new (msgAtoms,PRIORITY_SIZE) ProxyGBISP1ResultMsg;
00120 for (int i = 0; i < msgAtoms; i++) {
00121 msg1->psiSum[i] = psiSum[i];
00122 }
00123 msg1->patch = patchID;
00124 msg1->psiSumLen = msgAtoms;
00125 msg1->origPe = CkMyPe();
00126 SET_PRIORITY(msg1,flags.sequence,GB1_PROXY_RESULTS_PRIORITY + PATCH_PRIORITY(patchID));
00127 ProxyMgr::Object()->sendResult(msg1);
00128 } else if ( box == 8) {//end phase 2
00129 //this msg should only have nonzero atoms if flags.doFullElectrostatics
00130 int msgAtoms = (flags.doFullElectrostatics) ? numAtoms : 0;
00131 msg2 = new (msgAtoms,PRIORITY_SIZE) ProxyGBISP2ResultMsg;
00132 for (int i = 0; i < msgAtoms; i++) {
00133 msg2->dEdaSum[i] = dEdaSum[i];
00134 }
00135 msg2->patch = patchID;
00136 msg2->dEdaSumLen = msgAtoms;
00137 msg2->origPe = CkMyPe();
00138 SET_PRIORITY(msg2,flags.sequence,GB2_PROXY_RESULTS_PRIORITY + PATCH_PRIORITY(patchID));
00139 ProxyMgr::Object()->sendResult(msg2);
00140 } else if (box == 9) {
00141 //nothing
00142 } else if (box == 10) {
00143 // LCPO do nothing
00144 }
00145
00146
00147 if ( ! --boxesOpen ) {
00148 DebugM(2,patchID << ": " << "Checking message buffer.\n");
00149
00150 if(proxyMsgBufferStatus == PROXYALLMSGBUFFERED) {
00151 CmiAssert(curProxyMsg != NULL);
00152 DebugM(3,"Patch " << patchID << " processing buffered proxy ALL data.\n");
00153 receiveAll(curProxyMsg);
00154 }else if(proxyMsgBufferStatus == PROXYDATAMSGBUFFERED) {
00155 CmiAssert(curProxyMsg != NULL);
00156 DebugM(3,"Patch " << patchID << " processing buffered proxy data.\n");
00157 receiveData(curProxyMsg);
00158 }
00159 } else {
00160 DebugM(3,"ProxyPatch " << patchID << ": " << boxesOpen << " boxes left to close.\n");
00161 }
00162 }
|
|
|
Definition at line 455 of file ProxyPatch.C. References ResizeArray< Elem >::add(), ResizeArray< Elem >::begin(), ResizeArray< Elem >::end(), ProxyCombinedResultMsg::forceList, and ProxyCombinedResultMsg::nodes. Referenced by ProxyMgr::sendResults(). 00455 {
00456 #if defined(NODEAWARE_PROXY_SPANNINGTREE) && defined(USE_NODEPATCHMGR)
00457 CmiLock(depositLock);
00458 #endif
00459 nWait++;
00460 if (nWait == 1) msgCBuffer = msg;
00461 else {
00462 NodeIDList::iterator n_i, n_e;
00463 n_i = msg->nodes.begin();
00464 n_e = msg->nodes.end();
00465 for (; n_i!=n_e; ++n_i) msgCBuffer->nodes.add(*n_i);
00466 for ( int k = 0; k < Results::maxNumForces; ++k )
00467 {
00468 register ForceList::iterator r_i;
00469 r_i = msgCBuffer->forceList[k]->begin();
00470 register ForceList::iterator f_i, f_e;
00471 f_i = msg->forceList[k]->begin();
00472 f_e = msg->forceList[k]->end();
00473 // for ( ; f_i != f_e; ++f_i, ++r_i ) *r_i += *f_i;
00474
00475 int nf = f_e - f_i;
00476 #ifdef ARCH_POWERPC
00477 #pragma disjoint (*f_i, *r_i)
00478 #pragma unroll(4)
00479 #endif
00480 for (int count = 0; count < nf; count++) {
00481 r_i[count].x += f_i[count].x;
00482 r_i[count].y += f_i[count].y;
00483 r_i[count].z += f_i[count].z;
00484 }
00485
00486 }
00487 delete msg;
00488 }
00489 //CkPrintf("[%d:%d] wait: %d of %d (%d %d %d)\n", CkMyPe(), patchID, nWait, nChild+1, parent, child[0],child[1]);
00490 if (nWait == nChild + 1) {
00491 nWait = 0;
00492 #if defined(NODEAWARE_PROXY_SPANNINGTREE) && defined(USE_NODEPATCHMGR)
00493 CmiUnlock(depositLock);
00494 #endif
00495
00496 return msgCBuffer;
00497 }
00498
00499 #if defined(NODEAWARE_PROXY_SPANNINGTREE) && defined(USE_NODEPATCHMGR)
00500 CmiUnlock(depositLock);
00501 #endif
00502
00503 return NULL;
00504 }
|
|
|
Definition at line 519 of file ProxyPatch.C. References ResizeArray< Elem >::add(), ResizeArray< Elem >::begin(), ProxyCombinedResultRawMsg::flLen, Force, ProxyCombinedResultRawMsg::forceArr, ProxyCombinedResultMsg::forceList, ProxyCombinedResultMsg::fromRaw(), ProxyCombinedResultRawMsg::isForceNonZero, ProxyCombinedResultRawMsg::nodes, ProxyCombinedResultMsg::nodes, ProxyCombinedResultRawMsg::nodeSize, Vector::x, Vector::y, and Vector::z. Referenced by NodeProxyMgr::recvImmediateResults(), and ProxyMgr::recvImmediateResults(). 00519 {
00520 #if defined(NODEAWARE_PROXY_SPANNINGTREE) && defined(USE_NODEPATCHMGR)
00521 CmiLock(depositLock);
00522 #endif
00523 nWait++;
00524 if (nWait == 1) msgCBuffer = ProxyCombinedResultMsg::fromRaw(msg);
00525 else {
00526 for (int i=0; i<msg->nodeSize; i++) msgCBuffer->nodes.add(msg->nodes[i]);
00527
00528 register char* isNonZero = msg->isForceNonZero;
00529 register Force* f_i = msg->forceArr;
00530 for ( int k = 0; k < Results::maxNumForces; ++k )
00531 {
00532 register ForceList::iterator r_i;
00533 r_i = msgCBuffer->forceList[k]->begin();
00534 int nf = msg->flLen[k];
00535
00536 #ifdef ARCH_POWERPC
00537 #pragma disjoint (*f_i, *r_i)
00538 #endif
00539 for (int count = 0; count < nf; count++) {
00540 if(*isNonZero){
00541 r_i[count].x += f_i->x;
00542 r_i[count].y += f_i->y;
00543 r_i[count].z += f_i->z;
00544 f_i++;
00545 }
00546 isNonZero++;
00547 }
00548 }
00549 delete msg;
00550 }
00551 //CkPrintf("[%d:%d] wait: %d of %d (%d %d %d)\n", CkMyPe(), patchID, nWait, nChild+1, parent, child[0],child[1]);
00552 if (nWait == nChild + 1) {
00553 nWait = 0;
00554 #if defined(NODEAWARE_PROXY_SPANNINGTREE) && defined(USE_NODEPATCHMGR)
00555 CmiUnlock(depositLock);
00556 #endif
00557
00558 return msgCBuffer;
00559 }
00560
00561 #if defined(NODEAWARE_PROXY_SPANNINGTREE) && defined(USE_NODEPATCHMGR)
00562 CmiUnlock(depositLock);
00563 #endif
00564
00565 return NULL;
00566 }
|
|
|
Definition at line 450 of file ProxyPatch.C. 00450 {
00451 for (int i=0; i<nChild; i++) c[i] = child[i];
00452 return nChild;
00453 }
|
|
|
Definition at line 35 of file ProxyPatch.h. Referenced by ProxyMgr::recvImmediateProxyAll(), and ProxyMgr::recvImmediateProxyData(). 00035 { return child; }
|
|
|
Definition at line 36 of file ProxyPatch.h. Referenced by ProxyMgr::recvImmediateProxyAll(), and ProxyMgr::recvImmediateProxyData(). 00036 { return nChild; }
|
|
|
Definition at line 33 of file ProxyPatch.h. Referenced by NodeProxyMgr::recvImmediateResults(), ProxyMgr::recvImmediateResults(), and ProxyMgr::sendResults(). 00033 { return parent; }
|
|
|
Definition at line 233 of file ProxyPatch.C. References ProxyDataMsg::avgPlLen, ProxyDataMsg::avgPositionList, ResizeArray< Elem >::begin(), ProxyDataMsg::cudaAtomList, DebugM, Flags::doGBIS, Flags::doLCPO, ResizeArray< Elem >::end(), ProxyDataMsg::flags, ProxyDataMsg::intRadList, ProxyDataMsg::lcpoTypeList, ProxyDataMsg::plExtLen, ProxyDataMsg::plLen, ProxyDataMsg::positionExtList, ProxyDataMsg::positionList, Patch::positionsReady(), ResizeArray< Elem >::resize(), AtomMapper::unregisterIDsCompAtomExt(), ProxyDataMsg::velocityList, and ProxyDataMsg::vlLen. Referenced by boxClosed(), and ProxyMgr::recvProxyAll(). 00234 {
00235 DebugM(3, "receiveAll(" << patchID << ")\n");
00236
00237 if ( boxesOpen )
00238 {
00239 proxyMsgBufferStatus = PROXYALLMSGBUFFERED;
00240 curProxyMsg = msg;
00241 return;
00242 }
00243
00244 //The prevProxyMsg has to be deleted after this if-statement because
00245 // positionPtrBegin points to the space inside the prevProxyMsg
00246 if(prevProxyMsg!=NULL) {
00247 // #ifdef REMOVE_PROXYDATAMSG_EXTRACOPY
00248 // AtomMap::Object()->unregisterIDs(patchID,positionPtrBegin,positionPtrEnd);
00249 // #else
00250 atomMapper->unregisterIDsCompAtomExt(pExt.begin(), pExt.end());
00251 // #endif
00252 }
00253 //Now delete the ProxyDataMsg of the previous step
00254 #if ! CMK_PERSISTENT_COMM || ! USE_PERSISTENT_TREE
00255 delete prevProxyMsg;
00256 #endif
00257 curProxyMsg = msg;
00258 prevProxyMsg = curProxyMsg;
00259
00260 flags = msg->flags;
00261
00262 #ifdef REMOVE_PROXYDATAMSG_EXTRACOPY
00263 //We could set them to 0 for the sake of easy debugging
00264 //if there are something wrong in the "reuse position arrays" code
00265 //--Chao Mei
00266 //p.resize(0);
00267 //p_avg.resize(0);
00268 positionPtrBegin = msg->positionList;
00269 positionPtrEnd = msg->positionList + msg->plLen;
00270 #else
00271 p.resize(msg->plLen);
00272 memcpy(p.begin(), msg->positionList, sizeof(CompAtom)*(msg->plLen));
00273 #endif
00274
00275 #ifdef NAMD_CUDA
00276 cudaAtomPtr = msg->cudaAtomList;
00277 #endif
00278
00279 numAtoms = msg->plLen;
00280 //numAtoms = p.size();
00281
00282 avgPositionPtrBegin = msg->avgPositionList;
00283 avgPositionPtrEnd = msg->avgPositionList + msg->avgPlLen;
00284
00285 // BEGIN LA
00286 velocityPtrBegin = msg->velocityList;
00287 velocityPtrEnd = msg->velocityList + msg->vlLen;
00288 // END LA
00289
00290 if (flags.doGBIS) {
00291 intRad.resize(numAtoms*2);
00292 for (int i = 0; i < numAtoms*2;i++) {
00293 intRad[i] = msg->intRadList[i];
00294 }
00295 }
00296
00297 if (flags.doLCPO) {
00298 lcpoType.resize(numAtoms);
00299 for (int i = 0; i < numAtoms; i++) {
00300 lcpoType[i] = msg->lcpoTypeList[i];
00301 }
00302 }
00303
00304 //We cannot reuse the CompAtomExt list inside the msg because
00305 //the information is needed at every step. In the current implementation
00306 //scheme, the ProxyDataMsg msg will be deleted for every step.
00307 //In order to keep this information, we have to do the extra copy. But
00308 //this overhead is amortized among the steps that atoms don't migrate
00309 // --Chao Mei
00310 pExt.resize(msg->plExtLen);
00311 memcpy(pExt.begin(), msg->positionExtList, sizeof(CompAtomExt)*(msg->plExtLen));
00312
00313 // DMK - Atom Separation (water vs. non-water)
00314 #if NAMD_SeparateWaters != 0
00315 numWaterAtoms = msg->numWaterAtoms;
00316 #endif
00317
00318 positionsReady(1);
00319 }
|
|
|
Definition at line 513 of file ProxyPatch.C. References ResizeArray< Elem >::begin(), ProxyGBISP3DataMsg::dHdrPrefix, ProxyGBISP3DataMsg::dHdrPrefixLen, and Patch::gbisP3Ready(). 00513 {
00514 memcpy(dHdrPrefix.begin(), msg->dHdrPrefix, sizeof(Real)*msg->dHdrPrefixLen);
00515 delete msg;
00516 Patch::gbisP3Ready();
00517 }
|
|
|
Definition at line 507 of file ProxyPatch.C. References ResizeArray< Elem >::begin(), ProxyGBISP2DataMsg::bornRad, and Patch::gbisP2Ready(). 00507 {
00508 memcpy(bornRad.begin(), msg->bornRad, sizeof(Real)*numAtoms);
00509 delete msg;
00510 Patch::gbisP2Ready();
00511 }
|
|
|
Definition at line 165 of file ProxyPatch.C. References ProxyDataMsg::avgPlLen, ProxyDataMsg::avgPositionList, ResizeArray< Elem >::begin(), ProxyDataMsg::cudaAtomList, DebugM, ProxyDataMsg::flags, ProxyDataMsg::plExtLen, ProxyDataMsg::plLen, ProxyDataMsg::positionExtList, ProxyDataMsg::positionList, Patch::positionsReady(), ResizeArray< Elem >::resize(), ProxyDataMsg::velocityList, and ProxyDataMsg::vlLen. Referenced by boxClosed(), ProxyMgr::recvData(), and ProxyMgr::recvProxyData(). 00166 {
00167 DebugM(3, "receiveData(" << patchID << ")\n");
00168
00169 //delete the ProxyDataMsg of the previous step
00170 delete prevProxyMsg;
00171 prevProxyMsg = NULL;
00172
00173 if ( boxesOpen )
00174 {
00175 proxyMsgBufferStatus = PROXYDATAMSGBUFFERED;
00176 // store message in queue (only need one element, though)
00177 curProxyMsg = msg;
00178 return;
00179 }
00180
00181 //Reuse position arrays inside proxyDataMsg --Chao Mei
00182 curProxyMsg = msg;
00183 prevProxyMsg = curProxyMsg;
00184 flags = msg->flags;
00185
00186 #ifdef REMOVE_PROXYDATAMSG_EXTRACOPY
00187 //We could set them to 0 for the sake of easy debugging
00188 //if there are something wrong in the "reuse position arrays" code
00189 //--Chao Mei
00190 //p.resize(0);
00191 //p_avg.resize(0);
00192 positionPtrBegin = msg->positionList;
00193 positionPtrEnd = msg->positionList + msg->plLen;
00194 #else
00195 p.resize(msg->plLen);
00196 memcpy(p.begin(), msg->positionList, sizeof(CompAtom)*(msg->plLen));
00197 #endif
00198
00199 #ifdef NAMD_CUDA
00200 cudaAtomPtr = msg->cudaAtomList;
00201 #endif
00202
00203 avgPositionPtrBegin = msg->avgPositionList;
00204 avgPositionPtrEnd = msg->avgPositionList + msg->avgPlLen;
00205
00206 // BEGIN LA
00207 velocityPtrBegin = msg->velocityList;
00208 velocityPtrEnd = msg->velocityList + msg->vlLen;
00209 // END LA
00210
00211 if ( numAtoms == -1 ) { // for new proxies since receiveAtoms is not called
00212 //numAtoms = p.size();
00213 numAtoms = msg->plLen;
00214
00215 //Retrieve the CompAtomExt list
00216 CmiAssert(msg->plExtLen!=0);
00217 pExt.resize(msg->plExtLen);
00218 memcpy(pExt.begin(), msg->positionExtList, sizeof(CompAtomExt)*(msg->plExtLen));
00219
00220
00221 // DMK - Atom Separation (water vs. non-water)
00222 #if NAMD_SeparateWaters != 0
00223 numWaterAtoms = msg->numWaterAtoms;
00224 #endif
00225
00226 positionsReady(1);
00227 } else {
00228 positionsReady(0);
00229 }
00230 }
|
|
||||||||||||||||
|
Definition at line 434 of file ProxyPatch.C. Referenced by ProxyMgr::recvNodeAwareSpanningTree(), ProxyMgr::recvNodeAwareSTParent(), and ProxyMgr::recvSpanningTree(). 00434 {
00435 #if CMK_PERSISTENT_COMM && USE_PERSISTENT_TREE
00436 if (ntreephs!=0) {
00437 for (int i=0; i<ntreephs; i++) CmiDestoryPersistent(treephs[i]);
00438 }
00439 for (int i=0; i<n; i++) {
00440 treephs[i] = CmiCreatePersistent(c[i], 27000, sizeof(envelope)+sizeof(ProxyDataMsg));
00441 }
00442 ntreephs = n;
00443 #endif
00444 parent=p; nChild = n; nWait = 0;
00445 for (int i=0; i<n; i++) child[i] = c[i];
00446 //CkPrintf("setSpanningTree: [%d:%d] %d %d:%d %d\n", CkMyPe(), patchID, parent, nChild, child[0], child[1]);
00447 }
|
1.3.9.1