Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members

ComputeMgr.C

Go to the documentation of this file.
00001 
00007 #include "InfoStream.h"
00008 #include "ProcessorPrivate.h"
00009 
00010 //#define DEBUGM
00011 #define MIN_DEBUG_LEVEL 1
00012 #include "Debug.h"
00013 
00014 #include "BOCgroup.h"
00015 #include "ComputeMgr.decl.h"
00016 #include "ComputeMgr.h"
00017 #include "ProxyMgr.decl.h"
00018 #include "ProxyMgr.h"
00019 
00020 #include "Node.h"
00021 #include "ComputeMap.h"
00022 #include "PatchMap.h"
00023 #include "PatchMap.inl"
00024 
00025 #include "Compute.h"
00026 #include "ComputeNonbondedUtil.h"
00027 #include "ComputeNonbondedSelf.h"
00028 #include "ComputeNonbondedPair.h"
00029 #include "ComputeAngles.h"
00030 #include "ComputeDihedrals.h"
00031 #include "ComputeImpropers.h"
00032 #include "ComputeCrossterms.h"
00033 #include "ComputeBonds.h"
00034 #include "ComputeFullDirect.h"
00035 #include "ComputeGlobal.h"
00036 #include "ComputeGlobalMsgs.h"
00037 #include "ComputeExt.h"
00038 #include "ComputeDPMTA.h"
00039 #include "ComputeDPME.h"
00040 #include "ComputeDPMEMsgs.h"
00041 #include "ComputePme.h"
00042 #include "ComputeEwald.h"
00043 #include "ComputeEField.h"
00044 /* BEGIN gf */
00045 #include "ComputeGridForce.h"
00046 /* END gf */
00047 #include "ComputeStir.h"
00048 #include "ComputeSphericalBC.h"
00049 #include "ComputeCylindricalBC.h"
00050 #include "ComputeTclBC.h"
00051 #include "ComputeRestraints.h"
00052 #include "ComputeConsForce.h"
00053 #include "ComputeConsForceMsgs.h"
00054 #include "WorkDistrib.h"
00055 
00056 /* include all of the specific masters we need here */
00057 #include "FreeEnergyEnums.h"
00058 #include "FreeEnergyAssert.h"
00059 #include "FreeEnergyGroup.h"
00060 #include "FreeEnergyVector.h"
00061 #include "FreeEnergyRestrain.h"
00062 #include "FreeEnergyRMgr.h"
00063 #include "FreeEnergyLambda.h"
00064 #include "FreeEnergyLambdMgr.h"
00065 
00066 #include "GlobalMasterTest.h"
00067 #include "GlobalMasterIMD.h"
00068 #include "GlobalMasterTcl.h"
00069 #include "GlobalMasterSMD.h"
00070 #include "GlobalMasterTMD.h"
00071 #include "GlobalMasterEasy.h"
00072 #include "GlobalMasterMisc.h"
00073 #include "GlobalMasterFreeEnergy.h"
00074 #include "GlobalMasterColvars.h"
00075 
00076 ComputeMgr::ComputeMgr()
00077 {
00078     CkpvAccess(BOCclass_group).computeMgr = thisgroup;
00079     computeGlobalObject = 0;
00080     computeDPMEObject = 0;
00081     computeEwaldObject = 0;
00082     computeNonbondedWorkArrays = new ComputeNonbondedWorkArrays;
00083 }
00084 
00085 ComputeMgr::~ComputeMgr(void)
00086 {
00087     delete computeNonbondedWorkArrays;
00088 }
00089 
00090 void ComputeMgr::updateComputes(int ep, CkGroupID chareID)
00091 {
00092     updateComputesReturnEP = ep;
00093     updateComputesReturnChareID = chareID;
00094     updateComputesCount = CkNumPes();
00095 
00096     if (CkMyPe())
00097     {
00098         iout << iPE << iERRORF << "updateComputes signaled on wrong Pe!\n" << endi;
00099         CkExit();
00100         return;
00101     }
00102 
00103 #if CHARM_VERSION > 050402
00104     CkStartQD(CkIndex_ComputeMgr::updateComputes2((CkQdMsg*)0),&thishandle);
00105 #else
00106     CkStartQD(CProxy_ComputeMgr::ckIdx_updateComputes2((CkQdMsg*)0),&thishandle);
00107 #endif
00108 }
00109 
00110 void ComputeMgr::updateComputes2(CkQdMsg *msg)
00111 {
00112     delete msg;
00113 
00114     CProxy_WorkDistrib wd(CkpvAccess(BOCclass_group).workDistrib);
00115     WorkDistrib  *workDistrib = wd.ckLocalBranch();
00116 #if CHARM_VERSION > 050402
00117     workDistrib->saveComputeMapChanges(CkIndex_ComputeMgr::updateComputes3(),thisgroup);
00118 #else
00119     workDistrib->saveComputeMapChanges(CProxy_ComputeMgr::ckIdx_updateComputes3(),thisgroup);
00120 #endif
00121 }
00122 
00123 void ComputeMgr::updateComputes3()
00124 {
00125     CProxy_ComputeMgr(thisgroup).updateLocalComputes();
00126 }
00127 
00128 void ComputeMgr::updateLocalComputes()
00129 {
00130     ComputeMap *computeMap = ComputeMap::Object();
00131     CProxy_ProxyMgr pm(CkpvAccess(BOCclass_group).proxyMgr);
00132     ProxyMgr *proxyMgr = pm.ckLocalBranch();
00133 
00134     computeFlag = new int[computeMap->numComputes()];
00135 
00136     for (int i=0; i<computeMap->numComputes(); i++)
00137     {
00138         DebugM(3, "updateLocalComputes("<<i<<") curnode="<<computeMap->node(i)
00139                <<" newnode="<<computeMap->newNode(i)<<"\n");
00140         computeFlag[i] = 0;
00141 
00142         if (computeMap->newNode(i) == CkMyPe() && computeMap->node(i) != CkMyPe())
00143         {
00144             DebugM(4, "updateLocal - creating new computeID("<<i<<")\n");
00145             computeFlag[i] = 1;
00146             computeMap->setNode(i,computeMap->newNode(i));
00147             for (int n=0; n < computeMap->numPids(i); n++)
00148             {
00149                 proxyMgr->createProxy(computeMap->pid(i,n));
00150             }
00151         }
00152         else if (computeMap->node(i) == CkMyPe() &&
00153                  (computeMap->newNode(i) != -1 && computeMap->newNode(i) != CkMyPe() ))
00154         {
00155             DebugM(4, "updateLocal - deleting computeID("<<i<<")\n");
00156             computeFlag[i] = -1;
00157             computeMap->setNode(i,computeMap->newNode(i));
00158         }
00159         else if (computeMap->newNode(i) != -1)
00160         {
00161             computeMap->setNode(i,computeMap->newNode(i));
00162         }
00163         computeMap->setNewNode(i,-1);
00164     }
00165 
00166     if (!CkMyPe())
00167     {
00168 #if CHARM_VERSION > 050402
00169         CkStartQD(CkIndex_ComputeMgr::updateLocalComputes2((CkQdMsg*)0), &thishandle);
00170 #else
00171         CkStartQD(CProxy_ComputeMgr::ckIdx_updateLocalComputes2((CkQdMsg*)0), &thishandle);
00172 #endif
00173     }
00174 }
00175 
00176 void
00177 ComputeMgr::updateLocalComputes2(CkQdMsg *msg)
00178 {
00179     delete msg;
00180     CProxy_ComputeMgr(thisgroup).updateLocalComputes3();
00181 }
00182 
00183 void
00184 ComputeMgr::updateLocalComputes3()
00185 {
00186     ComputeMap *computeMap = ComputeMap::Object();
00187     CProxy_ProxyMgr pm(CkpvAccess(BOCclass_group).proxyMgr);
00188     ProxyMgr *proxyMgr = pm.ckLocalBranch();
00189 
00190     ProxyMgr::nodecount = 0;
00191 
00192     for (int i=0; i<computeMap->numComputes(); i++)
00193     {
00194         if (1 == computeFlag[i])
00195         {
00196             DebugM(4, "updateLocalCompute3() - create computeID(" << i << ")\n");
00197             createCompute(i, computeMap);
00198         }
00199         else if (-1 == computeFlag[i])
00200         {
00201             // remove this compute
00202             DebugM(4, "updateLocalCompute3() - delete computeID(" << i << ")\n");
00203             delete computeMap->compute(i);
00204             computeMap->registerCompute(i,NULL);
00205         }
00206     }
00207     delete[] computeFlag;
00208 
00209     proxyMgr->removeUnusedProxies();
00210 
00211     DebugM(4, "msg to doneUpdateLocalComputes on Pe("<<CkMyPe()<<")\n");
00212     ComputeMap::Object()->checkMap();
00213     PatchMap::Object()->checkMap();
00214 
00215     if (!CkMyPe())
00216     {
00217 #if CHARM_VERSION > 050402
00218         CkStartQD(CkIndex_ComputeMgr::updateLocalComputes4((CkQdMsg*)0), &thishandle);
00219 #else
00220         CkStartQD(CProxy_ComputeMgr::ckIdx_updateLocalComputes4((CkQdMsg*)0), &thishandle);
00221 #endif
00222 // added a new phase to build spanning tree after load balance
00223 // was
00224 //    CkStartQD(CProxy_ComputeMgr::ckIdx_doneUpdateLocalComputes(), &thishandle);
00225     }
00226     //CSendMsgBranch(ComputeMgr, doneUpdateLocalComputes, thisgroup, 0);
00227 }
00228 
00229 void
00230 ComputeMgr::updateLocalComputes4(CkQdMsg *msg)
00231 {
00232     delete msg;
00233     CProxy_ComputeMgr(thisgroup).updateLocalComputes5();
00234 }
00235 
00236 int firstphase = 1;
00237 
00238 void
00239 ComputeMgr::updateLocalComputes5()
00240 {
00241     // we always use the centralized building of spanning tree
00242     // distributed building of ST called in Node.C only
00243     if (proxySendSpanning || proxyRecvSpanning)
00244         ProxyMgr::Object()->buildProxySpanningTree2();
00245 
00246     // this code needs to be turned on if we want to
00247     // shift the creation of ST to the load balancer
00248 
00249 #if 0
00250     if (proxySendSpanning || proxyRecvSpanning)
00251     {
00252         if (firstphase)
00253             ProxyMgr::Object()->buildProxySpanningTree2();
00254         else
00255             if (CkMyPe() == 0)
00256                 ProxyMgr::Object()->sendSpanningTrees();
00257 
00258         firstphase = 0;
00259     }
00260 #endif
00261 
00262     if (!CkMyPe())
00263 #if CHARM_VERSION > 050402
00264         CkStartQD(CkIndex_ComputeMgr::doneUpdateLocalComputes(), &thishandle);
00265 #else
00266         CkStartQD(CProxy_ComputeMgr::ckIdx_doneUpdateLocalComputes(), &thishandle);
00267 #endif
00268 }
00269 
00270 void ComputeMgr::doneUpdateLocalComputes()
00271 {
00272 
00273 //  if (!--updateComputesCount) {
00274     DebugM(4, "doneUpdateLocalComputes on Pe("<<CkMyPe()<<")\n");
00275     void *msg = CkAllocMsg(0,0,0);
00276     CkSendMsgBranch(updateComputesReturnEP,msg,0,updateComputesReturnChareID);
00277 //  }
00278 }
00279 
00280 //
00281 void
00282 ComputeMgr::createCompute(ComputeID i, ComputeMap *map)
00283 {
00284     Compute *c;
00285     PatchID pid2[2];
00286     PatchIDList pids;
00287     int trans2[2];
00288     SimParameters *simParams = Node::Object()->simParameters;
00289 
00290     switch ( map->type(i) )
00291     {
00292     case computeNonbondedSelfType:
00293         c = new ComputeNonbondedSelf(i,map->computeData[i].pids[0].pid,
00294                                      computeNonbondedWorkArrays,
00295                                      map->partition(i),map->partition(i)+1,
00296                                      map->numPartitions(i)); // unknown delete
00297         ++numNonbondedSelf;
00298         map->registerCompute(i,c);
00299         c->initialize();
00300         break;
00301     case computeNonbondedPairType:
00302         pid2[0] = map->computeData[i].pids[0].pid;
00303         trans2[0] = map->computeData[i].pids[0].trans;
00304         pid2[1] = map->computeData[i].pids[1].pid;
00305         trans2[1] = map->computeData[i].pids[1].trans;
00306         c = new ComputeNonbondedPair(i,pid2,trans2,
00307                                      computeNonbondedWorkArrays,
00308                                      map->partition(i),map->partition(i)+1,
00309                                      map->numPartitions(i)); // unknown delete
00310         ++numNonbondedPair;
00311         map->registerCompute(i,c);
00312         c->initialize();
00313         break;
00314     case computeBondsType:
00315         PatchMap::Object()->basePatchIDList(CkMyPe(),pids);
00316         c = new ComputeBonds(i,pids); // unknown delete
00317         map->registerCompute(i,c);
00318         c->initialize();
00319         break;
00320     case computeAnglesType:
00321         PatchMap::Object()->basePatchIDList(CkMyPe(),pids);
00322         c = new ComputeAngles(i,pids); // unknown delete
00323         map->registerCompute(i,c);
00324         c->initialize();
00325         break;
00326     case computeDihedralsType:
00327         PatchMap::Object()->basePatchIDList(CkMyPe(),pids);
00328         c = new ComputeDihedrals(i,pids); // unknown delete
00329         map->registerCompute(i,c);
00330         c->initialize();
00331         break;
00332     case computeImpropersType:
00333         PatchMap::Object()->basePatchIDList(CkMyPe(),pids);
00334         c = new ComputeImpropers(i,pids); // unknown delete
00335         map->registerCompute(i,c);
00336         c->initialize();
00337         break;
00338     case computeCrosstermsType:
00339         PatchMap::Object()->basePatchIDList(CkMyPe(),pids);
00340         c = new ComputeCrossterms(i,pids); // unknown delete
00341         map->registerCompute(i,c);
00342         c->initialize();
00343         break;
00344     case computeSelfBondsType:
00345         c = new ComputeSelfBonds(i,map->computeData[i].pids[0].pid);
00346         map->registerCompute(i,c);
00347         c->initialize();
00348         break;
00349     case computeSelfAnglesType:
00350         c = new ComputeSelfAngles(i,map->computeData[i].pids[0].pid);
00351         map->registerCompute(i,c);
00352         c->initialize();
00353         break;
00354     case computeSelfDihedralsType:
00355         c = new ComputeSelfDihedrals(i,map->computeData[i].pids[0].pid);
00356         map->registerCompute(i,c);
00357         c->initialize();
00358         break;
00359     case computeSelfImpropersType:
00360         c = new ComputeSelfImpropers(i,map->computeData[i].pids[0].pid);
00361         map->registerCompute(i,c);
00362         c->initialize();
00363         break;
00364     case computeSelfCrosstermsType:
00365         c = new ComputeSelfCrossterms(i,map->computeData[i].pids[0].pid);
00366         map->registerCompute(i,c);
00367         c->initialize();
00368         break;
00369 #ifdef DPMTA
00370     case computeDPMTAType:
00371         c = new ComputeDPMTA(i); // unknown delete
00372         map->registerCompute(i,c);
00373         c->initialize();
00374         break;
00375 #endif
00376 #ifdef DPME
00377     case computeDPMEType:
00378         c = computeDPMEObject = new ComputeDPME(i,this); // unknown delete
00379         map->registerCompute(i,c);
00380         c->initialize();
00381         break;
00382 #endif
00383     case computePmeType:
00384         c = new ComputePme(i); // unknown delete
00385         map->registerCompute(i,c);
00386         c->initialize();
00387         break;
00388     case computeEwaldType:
00389         c = computeEwaldObject = new ComputeEwald(i,this); // unknown delete
00390         map->registerCompute(i,c);
00391         c->initialize();
00392         break;
00393     case computeFullDirectType:
00394         c = new ComputeFullDirect(i); // unknown delete
00395         map->registerCompute(i,c);
00396         c->initialize();
00397         break;
00398     case computeGlobalType:
00399         c = computeGlobalObject = new ComputeGlobal(i,this); // unknown delete
00400         map->registerCompute(i,c);
00401         c->initialize();
00402         break;
00403     case computeStirType:
00404         c = new ComputeStir(i,map->computeData[i].pids[0].pid); // unknown delete
00405         map->registerCompute(i,c);
00406         c->initialize();
00407         break;
00408     case computeExtType:
00409         c = new ComputeExt(i); // unknown delete
00410         map->registerCompute(i,c);
00411         c->initialize();
00412         break;
00413     case computeEFieldType:
00414         c = new ComputeEField(i,map->computeData[i].pids[0].pid); // unknown delete
00415         map->registerCompute(i,c);
00416         c->initialize();
00417         break;
00418         /* BEGIN gf */
00419     case computeGridForceType:
00420         c = new ComputeGridForce(i,map->computeData[i].pids[0].pid);
00421         map->registerCompute(i,c);
00422         c->initialize();
00423         break;
00424         /* END gf */
00425     case computeSphericalBCType:
00426         c = new ComputeSphericalBC(i,map->computeData[i].pids[0].pid); // unknown delete
00427         map->registerCompute(i,c);
00428         c->initialize();
00429         break;
00430     case computeCylindricalBCType:
00431         c = new ComputeCylindricalBC(i,map->computeData[i].pids[0].pid); // unknown delete
00432         map->registerCompute(i,c);
00433         c->initialize();
00434         break;
00435     case computeTclBCType:
00436         c = new ComputeTclBC(i); // unknown delete
00437         map->registerCompute(i,c);
00438         c->initialize();
00439         break;
00440     case computeRestraintsType:
00441         c = new ComputeRestraints(i,map->computeData[i].pids[0].pid); // unknown delete
00442         map->registerCompute(i,c);
00443         c->initialize();
00444         break;
00445     case computeConsForceType:
00446         c = new ComputeConsForce(i,map->computeData[i].pids[0].pid);
00447         map->registerCompute(i,c);
00448         c->initialize();
00449         break;
00450     case computeConsTorqueType:
00451         c = new ComputeConsTorque(i,map->computeData[i].pids[0].pid);
00452         map->registerCompute(i,c);
00453         c->initialize();
00454         break;
00455     default:
00456         NAMD_bug("Unknown compute type in ComputeMgr::createCompute().");
00457         break;
00458     }
00459 }
00460 
00461 void registerUserEventsForAllComputeObjs()
00462 {
00463 #ifdef TRACE_COMPUTE_OBJECTS
00464     ComputeMap *map = ComputeMap::Object();
00465     char user_des[50];
00466     for (int i=0; i<map->numComputes(); i++)
00467     {
00468         memset(user_des, 0, 50);
00469         switch ( map->type(i) )
00470         {
00471         case computeNonbondedSelfType:
00472             sprintf(user_des, "computeNonBondedSelfType_%d", i);
00473             break;
00474         case computeNonbondedPairType:
00475             sprintf(user_des, "computeNonBondedPairType_%d", i);
00476             break;
00477         case computeBondsType:
00478             sprintf(user_des, "computeBondsType_%d", i);
00479             break;
00480         case computeAnglesType:
00481             sprintf(user_des, "computeAnglesType_%d", i);
00482             break;
00483         case computeDihedralsType:
00484             sprintf(user_des, "computeDihedralsType_%d", i);
00485             break;
00486         case computeImpropersType:
00487             sprintf(user_des, "computeImpropersType_%d", i);
00488             break;
00489         case computeCrosstermsType:
00490             sprintf(user_des, "computeCrosstermsType_%d", i);
00491             break;
00492         case computeSelfBondsType:
00493             sprintf(user_des, "computeSelfBondsType_%d", i);
00494             break;
00495         case computeSelfAnglesType:
00496             sprintf(user_des, "computeSelfAnglesType_%d", i);
00497             break;
00498         case computeSelfDihedralsType:
00499             sprintf(user_des, "computeSelfDihedralsType_%d", i);
00500             break;
00501         case computeSelfImpropersType:
00502             sprintf(user_des, "computeSelfImpropersType_%d", i);
00503             break;
00504         case computeSelfCrosstermsType:
00505             sprintf(user_des, "computeSelfCrosstermsType_%d", i);
00506             break;
00507 #ifdef DPMTA
00508         case computeDPMTAType:
00509             sprintf(user_des, "computeDPMTAType_%d", i);
00510             break;
00511 #endif
00512 #ifdef DPME
00513         case computeDPMEType:
00514             sprintf(user_des, "computeDPMEType_%d", i);
00515             break;
00516 #endif
00517         case computePmeType:
00518             sprintf(user_des, "computePMEType_%d", i);
00519             break;
00520         case computeEwaldType:
00521             sprintf(user_des, "computeEwaldType_%d", i);
00522             break;
00523         case computeFullDirectType:
00524             sprintf(user_des, "computeFullDirectType_%d", i);
00525             break;
00526         case computeGlobalType:
00527             sprintf(user_des, "computeGlobalType_%d", i);
00528             break;
00529         case computeStirType:
00530             sprintf(user_des, "computeStirType_%d", i);
00531             break;
00532         case computeExtType:
00533             sprintf(user_des, "computeExtType_%d", i);
00534             break;
00535         case computeEFieldType:
00536             sprintf(user_des, "computeEFieldType_%d", i);
00537             break;
00538             /* BEGIN gf */
00539         case computeGridForceType:
00540             sprintf(user_des, "computeGridForceType_%d", i);
00541             break;
00542             /* END gf */
00543         case computeSphericalBCType:
00544             sprintf(user_des, "computeSphericalBCType_%d", i);
00545             break;
00546         case computeCylindricalBCType:
00547             sprintf(user_des, "computeCylindricalBCType_%d", i);
00548             break;
00549         case computeTclBCType:
00550             sprintf(user_des, "computeTclBCType_%d", i);
00551             break;
00552         case computeRestraintsType:
00553             sprintf(user_des, "computeRestraintsType_%d", i);
00554             break;
00555         case computeConsForceType:
00556             sprintf(user_des, "computeConsForceType_%d", i);
00557             break;
00558         case computeConsTorqueType:
00559             sprintf(user_des, "computeConsTorqueType_%d", i);
00560             break;
00561         default:
00562             NAMD_bug("Unknown compute type in ComputeMgr::registerUserEventForAllComputeObjs().");
00563             break;
00564         }
00565         int user_des_len = strlen(user_des);
00566         char *user_des_cst = new char[user_des_len+1];
00567         memcpy(user_des_cst, user_des, user_des_len);
00568         user_des_cst[user_des_len] = 0;
00569         //Since the argument in traceRegisterUserEvent is supposed
00570         //to be a const string which will not be copied inside the
00571         //function when a new user event is created, user_des_cst 
00572         //has to be allocated in heap.
00573         int reEvenId = traceRegisterUserEvent(user_des_cst, TRACE_COMPOBJ_IDOFFSET+i);
00574         //printf("Register user event (%s) with id (%d)\n", user_des, reEvenId);
00575     }
00576 #else
00577     return;
00578 #endif
00579 }
00580 
00581 void
00582 ComputeMgr::createComputes(ComputeMap *map)
00583 {
00584     Node *node = Node::Object();
00585     SimParameters *simParams = node->simParameters;
00586     int myNode = node->myid();
00587 
00588     numNonbondedSelf = 0;
00589     numNonbondedPair = 0;
00590     ComputeNonbondedUtil::select();
00591 
00592     if ( simParams->globalForcesOn && !myNode )
00593     {
00594         DebugM(4,"Mgr running on Node "<<CkMyPe()<<"\n");
00595         /* create a master server to allow multiple masters */
00596         masterServerObject = new GlobalMasterServer(this,
00597                 PatchMap::Object()->numNodesWithPatches());
00598 
00599         /* create the individual global masters */
00600         // masterServerObject->addClient(new GlobalMasterTest());
00601         if (simParams->tclForcesOn)
00602             masterServerObject->addClient(new GlobalMasterTcl());
00603         if (simParams->IMDon)
00604             masterServerObject->addClient(new GlobalMasterIMD());
00605 
00606         if (simParams->SMDOn)
00607             masterServerObject->addClient(
00608                 new GlobalMasterSMD(simParams->SMDk, simParams->SMDk2,
00609                                     simParams->SMDVel,
00610                                     simParams->SMDDir, simParams->SMDOutputFreq,
00611                                     simParams->firstTimestep, simParams->SMDFile,
00612                                     node->molecule->numAtoms)
00613             );
00614         if (simParams->TMDOn)
00615             masterServerObject->addClient(new GlobalMasterTMD());
00616         if (simParams->miscForcesOn)
00617             masterServerObject->addClient(new GlobalMasterMisc());
00618         if ( simParams->freeEnergyOn )
00619             masterServerObject->addClient(new GlobalMasterFreeEnergy());
00620                 if ( simParams->colvarsOn )
00621                         masterServerObject->addClient(new GlobalMasterColvars());
00622 
00623     }
00624 
00625     for (int i=0; i < map->nComputes; i++)
00626     {
00627         if ( ! ( i % 100 ) )
00628         {
00629         }
00630         if ( map->computeData[i].node != myNode ) continue;
00631         DebugM(1,"Compute " << i << '\n');
00632         DebugM(1,"  node = " << map->computeData[i].node << '\n');
00633         DebugM(1,"  type = " << map->computeData[i].type << '\n');
00634         DebugM(1,"  patchBased = " << map->computeData[i].patchBased << '\n');
00635         DebugM(1,"  numPids = " << map->computeData[i].numPids << '\n');
00636         DebugM(1,"  numPidsAllocated = " << map->computeData[i].numPidsAllocated << '\n');
00637         for (int j=0; j < map->computeData[i].numPids; j++)
00638         {
00639             //      DebugM(1,"  pid " << map->computeData[i].pids[j] << '\n');
00640             if (!((j+1) % 6))
00641                 DebugM(1,'\n');
00642         }
00643         DebugM(1,"\n---------------------------------------");
00644         DebugM(1,"---------------------------------------\n");
00645 
00646         createCompute(i, map);
00647 
00648     }
00649 
00650 }
00651 
00652 
00653 void ComputeMgr:: sendComputeGlobalConfig(ComputeGlobalConfigMsg *msg)
00654 {
00655     (CProxy_ComputeMgr(CkpvAccess(BOCclass_group).computeMgr)).recvComputeGlobalConfig(msg);
00656 }
00657 
00658 void ComputeMgr:: recvComputeGlobalConfig(ComputeGlobalConfigMsg *msg)
00659 {
00660     if ( computeGlobalObject )
00661     {
00662         computeGlobalObject->recvConfig(msg);
00663     }
00664     else if ( ! (PatchMap::Object())->numHomePatches() ) delete msg;
00665     else NAMD_die("ComputeMgr::computeGlobalObject is NULL!");
00666 }
00667 
00668 void ComputeMgr:: sendComputeGlobalData(ComputeGlobalDataMsg *msg)
00669 {
00670     CProxy_ComputeMgr cm(CkpvAccess(BOCclass_group).computeMgr);
00671 #if CHARM_VERSION > 050402
00672     cm[0].recvComputeGlobalData(msg);
00673 #else
00674     cm.recvComputeGlobalData(msg, 0);
00675 #endif
00676 }
00677 
00678 void ComputeMgr:: recvComputeGlobalData(ComputeGlobalDataMsg *msg)
00679 {
00680     if (masterServerObject)  // make sure it has been initialized
00681     {
00682         masterServerObject->recvData(msg);
00683     }
00684     else NAMD_die("ComputeMgr::masterServerObject is NULL!");
00685 }
00686 
00687 void ComputeMgr:: sendComputeGlobalResults(ComputeGlobalResultsMsg *msg)
00688 {
00689     (CProxy_ComputeMgr(CkpvAccess(BOCclass_group).computeMgr)).recvComputeGlobalResults(msg);
00690 }
00691 
00692 void ComputeMgr:: recvComputeGlobalResults(ComputeGlobalResultsMsg *msg)
00693 {
00694     if ( computeGlobalObject )
00695     {
00696         computeGlobalObject->recvResults(msg);
00697     }
00698     else if ( ! (PatchMap::Object())->numHomePatches() ) delete msg;
00699     else NAMD_die("ComputeMgr::computeGlobalObject is NULL!");
00700 }
00701 
00702 /*
00703  * Begin Ewald messages
00704  */
00705 void ComputeMgr:: sendComputeEwaldData(ComputeEwaldMsg *msg)
00706 {
00707     if (computeEwaldObject)
00708     {
00709         int node = computeEwaldObject->getMasterNode();
00710         CProxy_ComputeMgr cm(CkpvAccess(BOCclass_group).computeMgr);
00711 #if CHARM_VERSION > 050402
00712         cm[node].recvComputeEwaldData(msg);
00713 #else
00714         cm.recvComputeEwaldData(msg, node);
00715 #endif
00716     }
00717     else if (!PatchMap::Object()->numHomePatches())
00718     {
00719         CkPrintf("skipping message on Pe(%d)\n", CkMyPe());
00720         delete msg;
00721     }
00722     else NAMD_die("ComputeMgr::computeEwaldObject is NULL!");
00723 }
00724 
00725 void ComputeMgr:: recvComputeEwaldData(ComputeEwaldMsg *msg)
00726 {
00727     if (computeEwaldObject)
00728         computeEwaldObject->recvData(msg);
00729     else NAMD_die("ComputeMgr::computeEwaldObject in recvData is NULL!");
00730 }
00731 
00732 void ComputeMgr:: sendComputeEwaldResults(ComputeEwaldMsg *msg)
00733 {
00734     (CProxy_ComputeMgr(CkpvAccess(BOCclass_group).computeMgr)).recvComputeEwaldResults(msg);
00735 }
00736 
00737 void ComputeMgr::recvComputeEwaldResults(ComputeEwaldMsg *msg)
00738 {
00739     if (computeEwaldObject)
00740         computeEwaldObject->recvResults(msg);
00741     else if ( ! (PatchMap::Object())->numHomePatches() ) delete msg;
00742     else NAMD_die("ComputeMgr::computeEwaldObject in recvResults is NULL!");
00743 }
00744 
00745 void ComputeMgr:: sendComputeDPMEData(ComputeDPMEDataMsg *msg)
00746 {
00747     if ( computeDPMEObject )
00748     {
00749 #ifdef DPME
00750         int node = computeDPMEObject->getMasterNode();
00751         CProxy_ComputeMgr cm(CkpvAccess(BOCclass_group).computeMgr);
00752         cm.recvComputeDPMEData(msg,node);
00753 #endif
00754     }
00755     else if ( ! (PatchMap::Object())->numHomePatches() ) delete msg;
00756     else NAMD_die("ComputeMgr::computeDPMEObject is NULL!");
00757 }
00758 
00759 void ComputeMgr:: recvComputeDPMEData(ComputeDPMEDataMsg *msg)
00760 {
00761     if ( computeDPMEObject )
00762     {
00763 #ifdef DPME
00764         computeDPMEObject->recvData(msg);
00765 #endif
00766     }
00767     else if ( ! (PatchMap::Object())->numHomePatches() ) delete msg;
00768     else NAMD_die("ComputeMgr::computeDPMEObject is NULL!");
00769 }
00770 
00771 void ComputeMgr:: sendComputeDPMEResults(ComputeDPMEResultsMsg *msg, int node)
00772 {
00773     CProxy_ComputeMgr cm(CkpvAccess(BOCclass_group).computeMgr);
00774 #if CHARM_VERSION > 050402
00775     cm[node].recvComputeDPMEResults(msg);
00776 #else
00777     cm.recvComputeDPMEResults(msg, node);
00778 #endif
00779 }
00780 
00781 void ComputeMgr:: recvComputeDPMEResults(ComputeDPMEResultsMsg *msg)
00782 {
00783     if ( computeDPMEObject )
00784     {
00785 #ifdef DPME
00786         computeDPMEObject->recvResults(msg);
00787 #endif
00788     }
00789     else if ( ! (PatchMap::Object())->numHomePatches() ) delete msg;
00790     else NAMD_die("ComputeMgr::computeDPMEObject is NULL!");
00791 }
00792 
00793 void ComputeMgr::recvComputeConsForceMsg(ComputeConsForceMsg *msg)
00794 {
00795     Molecule *m = Node::Object()->molecule;
00796     delete [] m->consForceIndexes;
00797     delete [] m->consForce;
00798     int n = msg->aid.size();
00799     if (n > 0)
00800     {
00801         m->consForceIndexes = new int32[m->numAtoms];
00802         m->consForce = new Vector[n];
00803         int i;
00804         for (i=0; i<m->numAtoms; i++) m->consForceIndexes[i] = -1;
00805         for (i=0; i<msg->aid.size(); i++)
00806         {
00807             m->consForceIndexes[msg->aid[i]] = i;
00808             m->consForce[i] = msg->f[i];
00809         }
00810     }
00811     else
00812     {
00813         m->consForceIndexes = NULL;
00814         m->consForce = NULL;
00815     }
00816     delete msg;
00817 }
00818 
00819 #include "ComputeMgr.def.h"
00820 

Generated on Sat Oct 11 04:07:41 2008 for NAMD by  doxygen 1.3.9.1