void ComputePatchPair::initialize() { // How can we tell if BoxOwner has packed up and left? Need a mechanism // to handle this or do we assume the Boxes have been dumped? for (int i=0; i<2; i++) { if (positionBox[i] == NULL) { // We have yet to get boxes if (!(patch[i] = PatchMap::Object()->patch(patchID[i]))) { DebugM(5,"invalid patch(" << patchID[i] << ") pointer!\n"); } positionBox[i] = patch[i]->registerPositionPickup(this); forceBox[i] = patch[i]->registerForceDeposit(this); } numAtoms[i] = patch[i]->getNumAtoms(); } DebugM(4, "initialize("<<cid<<") numAtoms("<<patchID[0]<<") = " << numAtoms[0] << " numAtoms(" <<patchID[1]<<") = " << numAtoms[1] << "\n" ); Compute::initialize(); // proxies are more urgent (lower priority) than patches int myNode = CkMyPe(); int p0 = PATCH_PRIORITY(patchID[0]); if ( PatchMap::Object()->node(patchID[0]) == myNode ) { p0 += GB1_COMPUTE_HOME_PRIORITY; } else { p0 += GB1_COMPUTE_PROXY_PRIORITY; } int p1 = PATCH_PRIORITY(patchID[1]); if ( PatchMap::Object()->node(patchID[1]) == myNode ) { p1 += GB1_COMPUTE_HOME_PRIORITY; } else { p1 += GB1_COMPUTE_PROXY_PRIORITY; } if (p0<p1) { //base phase priorities off of p0 if ( PatchMap::Object()->node(patchID[0]) == myNode ) { gbisPhasePriority[0] = 0; gbisPhasePriority[1] = GB2_COMPUTE_HOME_PRIORITY-GB1_COMPUTE_HOME_PRIORITY; gbisPhasePriority[2] = COMPUTE_HOME_PRIORITY-GB1_COMPUTE_HOME_PRIORITY; } else { gbisPhasePriority[0] = 0; gbisPhasePriority[1] = GB2_COMPUTE_PROXY_PRIORITY-GB1_COMPUTE_PROXY_PRIORITY; gbisPhasePriority[2] = COMPUTE_PROXY_PRIORITY-GB1_COMPUTE_PROXY_PRIORITY; } } else { //base phase priorities off of p1 if ( PatchMap::Object()->node(patchID[1]) == myNode ) { gbisPhasePriority[0] = 0; gbisPhasePriority[1] = GB2_COMPUTE_HOME_PRIORITY-GB1_COMPUTE_HOME_PRIORITY; gbisPhasePriority[2] = COMPUTE_HOME_PRIORITY-GB1_COMPUTE_HOME_PRIORITY; } else { gbisPhasePriority[0] = 0; gbisPhasePriority[1] = GB2_COMPUTE_PROXY_PRIORITY-GB1_COMPUTE_PROXY_PRIORITY; gbisPhasePriority[2] = COMPUTE_PROXY_PRIORITY-GB1_COMPUTE_PROXY_PRIORITY; } } basePriority = ((p0<p1)?p0:p1); // most urgent wins }
void ProxyPatch::boxClosed(int box) { if (box == 1) { // force Box // Note: delay the deletion of proxyDataMsg (of the // current step) until the next step. This is done // for the sake of atom migration (ProxyDataMsg) // as the ProxyPatch has to unregister the atoms // of the previous step in the AtomMap data structure // also denotes end of gbis phase 3 sendResults(); } else if ( box == 5) {//end phase 1 } else if ( box == 8) {//end phase 2 } else if (box == 9) { //nothing } else if (box == 10) { // LCPO do nothing } if ( ! --boxesOpen ) { DebugM(2,patchID << ": " << "Checking message buffer.\n"); if(proxyMsgBufferStatus == PROXYALLMSGBUFFERED) { CmiAssert(curProxyMsg != NULL); DebugM(3,"Patch " << patchID << " processing buffered proxy ALL data.\n"); receiveAll(curProxyMsg); }else if(proxyMsgBufferStatus == PROXYDATAMSGBUFFERED) { CmiAssert(curProxyMsg != NULL); DebugM(3,"Patch " << patchID << " processing buffered proxy data.\n"); receiveData(curProxyMsg); } } else { DebugM(3,"ProxyPatch " << patchID << ": " << boxesOpen << " boxes left to close.\n"); } }
int NamdState::status() { int ret=0; if (configList != NULL) { DebugM(1, "Config List exists\n"); } else ret++; if (simParameters != NULL) { DebugM(1, "SimParameters exists\n"); } else ret++; if (parameters != NULL) { DebugM(1,"Parameters exists\n"); } else ret++; if (molecule != NULL) { DebugM(1, "Molecule exists\n"); } else ret++; if (pdb != NULL) { DebugM(1,"PDB exists \n"); } else ret++; return(ret); }
Box<Patch,GBReal>* Patch::registerDEdaSumDeposit(Compute *cid) { if (dEdaSumComputeList.add(cid) < 0) { DebugM(7, "registerDEdaSumDeposit() failed for cid " << cid->cid << std::endl); DebugM(7, " size of dEdaSumCompueList " << dEdaSumComputeList.size() << std::endl); return NULL; } return dEdaSumBox.checkOut(cid->cid); }
void ProxyPatch::boxClosed(int box) { ProxyGBISP1ResultMsg *msg1; ProxyGBISP2ResultMsg *msg2; if (box == 1) { // force Box // Note: delay the deletion of proxyDataMsg (of the // current step) until the next step. This is done // for the sake of atom migration (ProxyDataMsg) // as the ProxyPatch has to unregister the atoms // of the previous step in the AtomMap data structure // also denotes end of gbis phase 3 sendResults(); } else if (box == 5) { //end phase 1 //this msg should only have nonzero atoms if flags.doNonbonded int msgAtoms = (flags.doNonbonded) ? numAtoms : 0; msg1 = new (msgAtoms, PRIORITY_SIZE) ProxyGBISP1ResultMsg; for (int i = 0; i < msgAtoms; i++) { msg1->psiSum[i] = psiSum[i]; } msg1->patch = patchID; msg1->psiSumLen = msgAtoms; msg1->origPe = CkMyPe(); SET_PRIORITY(msg1, flags.sequence, GB1_PROXY_RESULTS_PRIORITY + PATCH_PRIORITY(patchID)); ProxyMgr::Object()->sendResult(msg1); } else if (box == 8) { //end phase 2 //this msg should only have nonzero atoms if flags.doFullElectrostatics int msgAtoms = (flags.doFullElectrostatics) ? numAtoms : 0; msg2 = new (msgAtoms, PRIORITY_SIZE) ProxyGBISP2ResultMsg; for (int i = 0; i < msgAtoms; i++) { msg2->dEdaSum[i] = dEdaSum[i]; } msg2->patch = patchID; msg2->dEdaSumLen = msgAtoms; msg2->origPe = CkMyPe(); SET_PRIORITY(msg2, flags.sequence, GB2_PROXY_RESULTS_PRIORITY + PATCH_PRIORITY(patchID)); ProxyMgr::Object()->sendResult(msg2); } else if (box == 9) { //nothing } else if (box == 10) { // LCPO do nothing } if (!--boxesOpen) { DebugM(2, patchID << ": " << "Checking message buffer.\n"); if (proxyMsgBufferStatus == PROXYALLMSGBUFFERED) { CmiAssert(curProxyMsg != NULL); DebugM(3, "Patch " << patchID << " processing buffered proxy ALL data.\n"); receiveAll(curProxyMsg); } else if (proxyMsgBufferStatus == PROXYDATAMSGBUFFERED) { CmiAssert(curProxyMsg != NULL); DebugM(3, "Patch " << patchID << " processing buffered proxy data.\n"); receiveData(curProxyMsg); } } else { DebugM(3, "ProxyPatch " << patchID << ": " << boxesOpen << " boxes left to close.\n"); } }
Box<Patch,Results>* Patch::registerForceDeposit(Compute *cid) { if (forceComputeList.add(cid) < 0) { DebugM(7, "registerForceDeposit() failed for cid " << cid->cid << std::endl); DebugM(7, " size of forceCompueList " << forceComputeList.size() << std::endl); return NULL; } return forceBox.checkOut(cid->cid); }
void ComputeGlobal::doWork() { DebugM(2,"doWork\n"); if(!firsttime) sendData(); else { ComputeGlobalDataMsg *msg = new ComputeGlobalDataMsg; comm->sendComputeGlobalData(msg); firsttime = 0; } DebugM(2,"done with doWork\n"); }
void ComputeGridForce::doForce(FullAtom* p, Results* r) { SimParameters *simParams = Node::Object()->simParameters; Molecule *mol = Node::Object()->molecule; Force *forces = r->f[Results::normal]; BigReal energy = 0; Force extForce = 0.; Tensor extVirial; int numAtoms = homePatch->getNumAtoms(); if ( mol->numGridforceGrids < 1 ) NAMD_bug("No grids loaded in ComputeGridForce::doForce()"); for (int gridnum = 0; gridnum < mol->numGridforceGrids; gridnum++) { GridforceGrid *grid = mol->get_gridfrc_grid(gridnum); if (homePatch->flags.step % GF_OVERLAPCHECK_FREQ == 0) { // only check on node 0 and every GF_OVERLAPCHECK_FREQ steps if (simParams->langevinPistonOn || simParams->berendsenPressureOn) { // check for grid overlap if pressure control is on // not needed without pressure control, since the check is also performed on startup if (!grid->fits_lattice(homePatch->lattice)) { char errmsg[512]; if (simParams->gridforcechecksize) { sprintf(errmsg, "Warning: Periodic cell basis too small for Gridforce grid %d. Set gridforcechecksize off in configuration file to ignore.\n", gridnum); NAMD_die(errmsg); } } } } Position center = grid->get_center(); if (homePatch->flags.step % 100 == 1) { DebugM(3, "center = " << center << "\n" << endi); DebugM(3, "e = " << grid->get_e() << "\n" << endi); } if (grid->get_grid_type() == GridforceGrid::GridforceGridTypeFull) { GridforceFullMainGrid *g = (GridforceFullMainGrid *)grid; do_calc(g, gridnum, p, numAtoms, mol, forces, energy, extForce, extVirial); } else if (grid->get_grid_type() == GridforceGrid::GridforceGridTypeLite) { GridforceLiteGrid *g = (GridforceLiteGrid *)grid; do_calc(g, gridnum, p, numAtoms, mol, forces, energy, extForce, extVirial); } } reduction->item(REDUCTION_MISC_ENERGY) += energy; ADD_VECTOR_OBJECT(reduction,REDUCTION_EXT_FORCE_NORMAL,extForce); ADD_TENSOR_OBJECT(reduction,REDUCTION_VIRIAL_NORMAL,extVirial); reduction->submit(); }
void ComputeMap::checkMap(void) { int computeCount = nComputes; for (int i=0; i<nComputes; i++) { if (computePtrs[i]) { computeCount++; if (! (computePtrs[i]->cid == i)) { DebugM(4, "ComputeID("<<computePtrs[i]->cid<<") != ComputeID(" << i <<")\n"); } } } DebugM(4, "Compute Count = " << computeCount << "\n"); }
void Patch::unregisterForceDeposit(Compute *cid, Box<Patch,Results> **const box) { DebugM(4, "unregisterForceDeposit() computeID("<<cid<<")"<<std::endl); forceComputeList.del(cid); forceBox.checkIn(*box); *box = 0; }
void Patch::unregisterPositionPickup(Compute *cid, Box<Patch,CompAtom> **const box) { DebugM(4, "UnregisterPositionPickup from " << cid->cid << "\n"); positionComputeList.del(cid); positionBox.checkIn(*box); *box = 0; }
void ScriptTcl::run() { #else void ScriptTcl::run(char *scriptFile) { if ( NULL == scriptFile || NULL == (config = new ConfigList(scriptFile)) ) { NAMD_die("Simulation config file is empty."); } #endif if (initWasCalled == 0) { initcheck(); SimParameters *simParams = Node::Object()->simParameters; if ( simParams->minimizeCGOn ) runController(SCRIPT_MINIMIZE); else runController(SCRIPT_RUN); runWasCalled = 1; } #if CMK_HAS_PARTITION replica_barrier(); #endif runController(SCRIPT_END); } ScriptTcl::~ScriptTcl() { DebugM(3,"Destructing ScriptTcl\n"); #ifdef NAMD_TCL if ( interp ) Tcl_DeleteInterp(interp); delete [] callbackname; #endif molfile_dcdplugin_fini(); }
void ComputeGlobal::configure(AtomIDList &newaid, AtomIDList &newgdef) { DebugM(4,"Receiving configuration (" << newaid.size() << " atoms and " << newgdef.size() << " atoms/groups) on client\n"); AtomIDList::iterator a, a_e; for (a=aid.begin(),a_e=aid.end(); a!=a_e; ++a) isRequested[*a] = 0; // store data aid.swap(newaid); gdef.swap(newgdef); for (a=aid.begin(),a_e=aid.end(); a!=a_e; ++a) isRequested[*a] = 1; // calculate group masses Molecule *mol = Node::Object()->molecule; gmass.resize(0); AtomIDList::iterator g_i, g_e; g_i = gdef.begin(); g_e = gdef.end(); for ( ; g_i != g_e; ++g_i ) { BigReal mass = 0; for ( ; *g_i != -1; ++g_i ) { mass += mol->atommass(*g_i); } gmass.add(mass); } }
void LdbCoordinator::resumeReady(CkQdMsg *msg) { iout << "LDB: =============== DONE WITH MIGRATION ================ " << CmiWallTimer() << "\n" << endi; DebugM(3,"resumeReady()\n"); delete msg; CProxy_LdbCoordinator(thisgroup).resume2(); }
int GlobalMasterFreeEnergy::addForce(int atomid, Force force) { DebugM(2,"Forcing "<<atomid<<" with "<<force<<"\n"); if ( atomid < 0 || atomid >= molecule->numAtoms ) return -1; // failure modifyForcedAtoms().add(atomid); modifyAppliedForces().add(force); return 0; // success }
CollectionMgr::CollectionMgr(SlaveInitMsg *msg) : master(msg->master) { delete msg; if (CkpvAccess(CollectionMgr_instance) == 0) { CkpvAccess(CollectionMgr_instance) = this; } else { DebugM(1, "CollectionMgr::CollectionMgr() - another instance of CollectionMgr exists!\n"); } }
void ComputeMgr::doneUpdateLocalComputes() { // if (!--updateComputesCount) { DebugM(4, "doneUpdateLocalComputes on Pe("<<CkMyPe()<<")\n"); void *msg = CkAllocMsg(0,0,0); CkSendMsgBranch(updateComputesReturnEP,msg,0,updateComputesReturnChareID); // } }
void Patch::forceBoxClosed(void) { DebugM(4, "patchID("<<patchID<<") forceBoxClosed! call\n"); for (int j = 0; j < Results::maxNumForces; ++j ) { results.f[j] = 0; } this->boxClosed(1); }
GlobalMasterFreeEnergy::GlobalMasterFreeEnergy() : GlobalMaster() { DebugM(3,"Constructing GlobalMasterFreeEnergy\n"); molecule = Node::Object()->molecule; simParams = Node::Object()->simParameters; // now set up the free energy stuff initialize(); }
void LdbCoordinator::resume2(void) { DebugM(3,"resume2()\n"); #if CONVERSE_VERSION_ELAN // enableBlockingReceives(); #endif awakenSequencers(); }
void LdbCoordinator::resume(void) { DebugM(3,"resume()\n"); // printLocalLdbReport(); ldbCycleNum++; initialize(PatchMap::Object(),ComputeMap::Object(),1); Sync::Object()->openSync(); }
Box<Patch,CompAtom>* Patch::registerPositionPickup(Compute *cid) { //DebugM(4, "registerPositionPickupa("<<patchID<<") from " << cid->cid << "\n"); if (positionComputeList.add(cid) < 0) { DebugM(7, "registerPositionPickup() failed for cid " << cid->cid << std::endl); return NULL; } return positionBox.checkOut(cid->cid); }
ComputePatchPair::~ComputePatchPair() { DebugM(4, "~ComputePatchPair("<<cid<<") numAtoms("<<patchID[0]<<") = " << numAtoms[0] << " numAtoms("<<patchID[1]<<") = " << numAtoms[1] << "\n" ); DebugM(4, "~ComputePatchPair("<<cid<<") addr("<<patchID[0]<<") = " << PatchMap::Object()->patch(patchID[0]) << " addr("<<patchID[1]<<") = " << PatchMap::Object()->patch(patchID[1]) << "\n"); for (int i=0; i<2; i++) { if (positionBox[i] != NULL) { PatchMap::Object()->patch(patchID[i])->unregisterPositionPickup(this, &positionBox[i]); } if (forceBox[i] != NULL) { PatchMap::Object()->patch(patchID[i])->unregisterForceDeposit(this, &forceBox[i]); } } }
void LdbCoordinator::patchLoad(PatchID id, int nAtoms, int /* timestep */) { CmiAssert( id >=0 && id < nPatches); if (patchNAtoms[id] != -1) { patchNAtoms[id] = nAtoms; nPatchesReported++; } else { DebugM(10, "::patchLoad() Unexpected patch reporting in\n"); } }
void ComputeMap::unpack (int n, ComputeData *ptr) { DebugM(4,"Unpacking ComputeMap\n"); if ( nComputes && n != nComputes ) { NAMD_bug("number of computes in new ComputeMap has changed!\n"); } nComputes = n; computeData.resize(nComputes); memcpy(computeData.begin(), ptr, nComputes * sizeof(ComputeData)); }
void GlobalMasterFreeEnergy::calculate() { DebugM(4,"Calculating forces on master\n"); /* zero out the forces */ modifyForcedAtoms().resize(0); modifyAppliedForces().resize(0); /* XXX is this line needed at all? */ modifyGroupForces().resize(getGroupMassEnd() - getGroupMassBegin()); modifyGroupForces().setall(Vector(0,0,0)); // iout << iDEBUG << "Free energy perturbation - calculate()\n" << endi; user_calculate(); // Send results to clients DebugM(3,"Sending results (" << forcedAtoms().size() << " forces) on master\n"); if ( changedAtoms() || changedGroups() ) { DebugM(4,"Sending new configuration (" << requestedAtoms().size() << " atoms) on master\n"); } }
// constructor ReductionMgr::ReductionMgr() { if (CkpvAccess(ReductionMgr_instance) == 0) { CkpvAccess(ReductionMgr_instance) = this; } else { DebugM(1, "ReductionMgr::ReductionMgr() - another instance exists!\n"); } buildSpanTree(CkMyPe(),REDUCTION_MAX_CHILDREN,REDUCTION_MAX_CHILDREN, &myParent,&numChildren,&children); // CkPrintf("TREE [%d] parent %d %d children\n", // CkMyPe(),myParent,numChildren); // if (numChildren > 0) { // for(int i=0; i < numChildren; i++) { // CkPrintf("TREE [%d] child %d %d\n",CkMyPe(),i,children[i]); // } // } // fill in the spanning tree fields #if 0 // Old spanning tree if (CkMyPe() == 0) { myParent = -1; } else { myParent = (CkMyPe()-1)/REDUCTION_MAX_CHILDREN; } firstChild = CkMyPe()*REDUCTION_MAX_CHILDREN + 1; if (firstChild > CkNumPes()) firstChild = CkNumPes(); lastChild = firstChild + REDUCTION_MAX_CHILDREN; if (lastChild > CkNumPes()) lastChild = CkNumPes(); #endif // initialize data for(int i=0; i<REDUCTION_MAX_SET_ID; i++) { reductionSets[i] = 0; } DebugM(1,"ReductionMgr() instantiated.\n"); }
void LdbCoordinator::rebalance(Controller *c) { if (Node::Object()->simParameters->ldBalancer == LDBAL_NONE) return; iout << "LDB: ============= START OF LOAD BALANCING ============== " << CmiWallTimer() << "\n" << endi; DebugM(3, "Controller reached load balance barrier.\n"); controllerReported = 1; controllerThread = c; CProxy_LdbCoordinator(thisgroup).barrier(); CthSuspend(); }
ComputeDPME::ComputeDPME(ComputeID c, ComputeMgr *m) : ComputeHomePatches(c), comm(m) { DebugM(4,"ComputeDPME created.\n"); useAvgPositions = 1; int numWorkingPes = (PatchMap::Object())->numNodesWithPatches(); masterNode = numWorkingPes - 1; if ( CkMyPe() == masterNode ) { master = new ComputeDPMEMaster(this); master->numWorkingPes = numWorkingPes; } else master = 0; }
void ProxyPatch::sendResults(void) { DebugM(3, "sendResults(" << patchID << ")\n"); register int i = 0; register ForceList::iterator f_i, f_e, f2_i; for (i = Results::normal + 1; i <= flags.maxForceMerged; ++i) { f_i = f[Results::normal].begin(); f_e = f[Results::normal].end(); f2_i = f[i].begin(); for (; f_i != f_e; ++f_i, ++f2_i) { *f_i += *f2_i; } f[i].resize(0); //lyk!!!!!!!! } for (i = flags.maxForceUsed + 1; i < Results::maxNumForces; ++i) f[i].resize(0); #if CMK_PERSISTENT_COMM && USE_PERSISTENT_TREE CmiUsePersistentHandle(&localphs, 1); #endif if (proxyRecvSpanning == 0) { #ifdef REMOVE_PROXYRESULTMSG_EXTRACOPY ProxyResultVarsizeMsg *msg = ProxyResultVarsizeMsg::getANewMsg(CkMyPe(), patchID, PRIORITY_SIZE, f); #else ProxyResultMsg *msg = new (PRIORITY_SIZE) ProxyResultMsg; msg->node = CkMyPe(); msg->patch = patchID; for (i = 0; i < Results::maxNumForces; ++i) msg->forceList[i] = &(f[i]); #endif SET_PRIORITY(msg, flags.sequence, PROXY_RESULTS_PRIORITY + PATCH_PRIORITY(patchID)); //sending results to HomePatch ProxyMgr::Object()->sendResults(msg); } else { ProxyCombinedResultMsg *msg = new (PRIORITY_SIZE) ProxyCombinedResultMsg; SET_PRIORITY(msg, flags.sequence, PROXY_RESULTS_PRIORITY + PATCH_PRIORITY(patchID)); msg->nodes.add(CkMyPe()); msg->patch = patchID; for (i = 0; i < Results::maxNumForces; ++i) msg->forceList[i] = &(f[i]); //sending results to HomePatch ProxyMgr::Object()->sendResults(msg); } #if CMK_PERSISTENT_COMM && USE_PERSISTENT_TREE CmiUsePersistentHandle(NULL, 0); #endif }