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

|
|
Definition at line 29 of file ParallelIOMgr.C. References sendAtomsThread, Vector::x, Vector::y, and Vector::z. 00030 {
00031 CkpvAccess(BOCclass_group).ioMgr = thisgroup;
00032
00033 numInputProcs=-1;
00034 inputProcArray = NULL;
00035 numOutputProcs=-1;
00036 outputProcArray = NULL;
00037
00038 procsReceived=0;
00039 hydroMsgRecved=0;
00040
00041 totalMV.x = totalMV.y = totalMV.z = 0.0;
00042 totalMass = 0.0;
00043 totalCharge = 0.0;
00044
00045 isOKToRecvHPAtoms = false;
00046 hpAtomsList = NULL;
00047
00048 clusterID = NULL;
00049 clusterSize = NULL;
00050
00051 #ifdef MEM_OPT_VERSION
00052 midCM = NULL;
00053 #endif
00054
00055 isWater = NULL;
00056
00057 numCSMAck = 0;
00058 numReqRecved = 0;
00059
00060 sendAtomsThread = 0;
00061
00062 #if COLLECT_PERFORMANCE_DATA
00063 numFixedAtomLookup = 0;
00064 #endif
00065 }
|
|
|
Definition at line 67 of file ParallelIOMgr.C. 00068 {
00069 delete [] inputProcArray;
00070 delete [] outputProcArray;
00071 delete [] clusterID;
00072 delete [] clusterSize;
00073
00074 #ifdef MEM_OPT_VERSION
00075 delete midCM;
00076 #endif
00077
00078 delete [] isWater;
00079 }
|
|
|
Definition at line 1236 of file ParallelIOMgr.C. References sendAtomsThread. 01237 {
01238 --numAcksOutstanding;
01239 if ( sendAtomsThread ) {
01240 CthAwaken(sendAtomsThread);
01241 sendAtomsThread = 0;
01242 }
01243 }
|
|
|
Definition at line 936 of file ParallelIOMgr.C. References BigReal, SimParameters::fixedAtomsOn, iINFO(), iout, SimParameters::lattice, Molecule::maxHydrogenGroupSize, Molecule::maxMigrationGroupSize, Molecule::num_deg_freedom(), Molecule::numAngles, Molecule::numAtoms, Molecule::numBonds, Molecule::numCrossterms, Molecule::numDihedrals, Molecule::numExclusions, Molecule::numFixedAtoms, HydroBasedMsg::numFixedGroups, Molecule::numFixedGroups, HydroBasedMsg::numFixedRigidBonds, Molecule::numFixedRigidBonds, Molecule::numHydrogenGroups, Molecule::numImpropers, Molecule::numMigrationGroups, Molecule::numMultipleDihedrals, Molecule::numMultipleImpropers, Molecule::numRigidBonds, SimParameters::paraTypeCharmmOn, SimParameters::paraTypeXplorOn, SimParameters::rigidBonds, and Lattice::volume(). 00936 {
00937 #ifdef MEM_OPT_VERSION
00938 //only the rank 0 in the SMP node update the Molecule object
00939 if(CmiMyRank()) {
00940 delete msg;
00941 return;
00942 }
00943 molecule->numFixedRigidBonds = msg->numFixedRigidBonds;
00944 molecule->numFixedGroups = msg->numFixedGroups;
00945 delete msg;
00946
00947 if(!CkMyPe()) {
00948 iout << iINFO << "****************************\n";
00949 iout << iINFO << "STRUCTURE SUMMARY:\n";
00950 iout << iINFO << molecule->numAtoms << " ATOMS\n";
00951 iout << iINFO << molecule->numBonds << " BONDS\n";
00952 iout << iINFO << molecule->numAngles << " ANGLES\n";
00953 iout << iINFO << molecule->numDihedrals << " DIHEDRALS\n";
00954 iout << iINFO << molecule->numImpropers << " IMPROPERS\n";
00955 iout << iINFO << molecule->numCrossterms << " CROSSTERMS\n";
00956 iout << iINFO << molecule->numExclusions << " EXCLUSIONS\n";
00957
00958 //****** BEGIN CHARMM/XPLOR type changes
00959 if ((molecule->numMultipleDihedrals) && (simParameters->paraTypeXplorOn)){
00960 iout << iINFO << molecule->numMultipleDihedrals
00961 << " DIHEDRALS WITH MULTIPLE PERIODICITY (BASED ON PSF FILE)\n";
00962 }
00963 if ((molecule->numMultipleDihedrals) && (simParameters->paraTypeCharmmOn)){
00964 iout << iINFO << molecule->numMultipleDihedrals
00965 << " DIHEDRALS WITH MULTIPLE PERIODICITY IGNORED (BASED ON PSF FILE) \n";
00966 iout << iINFO
00967 << " CHARMM MULTIPLICITIES BASED ON PARAMETER FILE INFO! \n";
00968 }
00969 //****** END CHARMM/XPLOR type changes
00970
00971 if (molecule->numMultipleImpropers){
00972 iout << iINFO << molecule->numMultipleImpropers
00973 << " IMPROPERS WITH MULTIPLE PERIODICITY\n";
00974 }
00975
00976 if (simParameters->fixedAtomsOn)
00977 iout << iINFO << molecule->numFixedAtoms << " FIXED ATOMS\n";
00978
00979
00980 if (simParameters->rigidBonds)
00981 iout << iINFO << molecule->numRigidBonds << " RIGID BONDS\n";
00982
00983 if (simParameters->fixedAtomsOn && simParameters->rigidBonds)
00984 iout << iINFO << molecule->numFixedRigidBonds <<
00985 " RIGID BONDS BETWEEN FIXED ATOMS\n";
00986
00987 iout << iINFO << molecule->num_deg_freedom(1)
00988 << " DEGREES OF FREEDOM\n";
00989
00990 iout << iINFO << molecule->numHydrogenGroups << " HYDROGEN GROUPS\n";
00991 iout << iINFO << molecule->maxHydrogenGroupSize
00992 << " ATOMS IN LARGEST HYDROGEN GROUP\n";
00993 iout << iINFO << molecule->numMigrationGroups << " MIGRATION GROUPS\n";
00994 iout << iINFO << molecule->maxMigrationGroupSize
00995 << " ATOMS IN LARGEST MIGRATION GROUP\n";
00996 if (simParameters->fixedAtomsOn)
00997 {
00998 iout << iINFO << molecule->numFixedGroups <<
00999 " HYDROGEN GROUPS WITH ALL ATOMS FIXED\n";
01000 }
01001
01002 iout << iINFO << "TOTAL MASS = " << totalMass << " amu\n";
01003 iout << iINFO << "TOTAL CHARGE = " << totalCharge << " e\n";
01004
01005 BigReal volume = simParameters->lattice.volume();
01006 if ( volume ) {
01007 iout << iINFO << "MASS DENSITY = "
01008 << ((totalMass/volume) / 0.6022) << " g/cm^3\n";
01009 iout << iINFO << "ATOM DENSITY = "
01010 << (molecule->numAtoms/volume) << " atoms/A^3\n";
01011 }
01012
01013 iout << iINFO << "*****************************\n";
01014 iout << endi;
01015 fflush(stdout);
01016 }
01017 #endif
01018 }
|
|
|
|
Definition at line 1020 of file ParallelIOMgr.C. References PatchMap::assignToPatch(), AtomsCntPerPatchMsg::atomsCntList, AtomsCntPerPatchMsg::fixedAtomsCntList, SimParameters::fixedAtomsOn, PatchMap::getTmpPatchAtomsList(), PatchMap::initTmpPatchAtomsList(), InputAtom::isMP, InputAtom::isValid, j, SimParameters::lattice, AtomsCntPerPatchMsg::length, NAMD_die(), PatchMap::numPatches(), PatchMap::Object(), AtomsCntPerPatchMsg::pidList, CompAtom::position, and ResizeArray< Elem >::size(). 01021 {
01022 if(myInputRank==-1) return;
01023
01024 PatchMap *patchMap = PatchMap::Object();
01025 int numPatches = patchMap->numPatches();
01026
01027 patchMap->initTmpPatchAtomsList();
01028
01029 //each list contains the atom index to the initAtoms
01030 vector<int> *eachPatchAtomList = patchMap->getTmpPatchAtomsList();
01031
01032 CProxy_PatchMgr pm(CkpvAccess(BOCclass_group).patchMgr);
01033 PatchMgr *patchMgr = pm.ckLocalBranch();
01034
01035 int pid=0;
01036 const Lattice lattice = simParameters->lattice;
01037 for(int i=0; i<initAtoms.size(); i++) {
01038 InputAtom *atom = &(initAtoms[i]);
01039 if(!atom->isValid) continue;
01040 if(atom->isMP) {
01041 pid = patchMap->assignToPatch(atom->position, lattice);
01042 }
01043 eachPatchAtomList[pid].push_back(i);
01044 }
01045
01046 CProxy_ParallelIOMgr pIO(thisgroup);
01047
01048 int patchCnt = 0;
01049 for(int i=0; i<numPatches; i++) {
01050 int cursize = eachPatchAtomList[i].size();
01051 if(cursize>0) patchCnt++;
01052 }
01053
01054 AtomsCntPerPatchMsg *msg = NULL;
01055 if(simParameters->fixedAtomsOn) {
01056 msg = new (patchCnt, patchCnt, patchCnt, 0)AtomsCntPerPatchMsg;
01057 } else {
01058 msg = new (patchCnt, patchCnt, 0, 0)AtomsCntPerPatchMsg;
01059 }
01060
01061 msg->length = patchCnt;
01062 patchCnt = 0;
01063 for(int i=0; i<numPatches; i++) {
01064 int cursize = eachPatchAtomList[i].size();
01065 if(cursize>0) {
01066 if ( cursize > USHRT_MAX ) {
01067 char errstr[512];
01068 sprintf(errstr, "Patch %d exceeds %d atoms.", i, USHRT_MAX);
01069 NAMD_die(errstr);
01070 }
01071 msg->pidList[patchCnt] = i;
01072 msg->atomsCntList[patchCnt] = cursize;
01073 patchCnt++;
01074 }
01075 }
01076
01077 if(simParameters->fixedAtomsOn) {
01078 patchCnt = 0;
01079 for(int i=0; i<numPatches; i++) {
01080 int cursize = eachPatchAtomList[i].size();
01081 if(cursize>0) {
01082 int fixedCnt = 0;
01083 for(int j=0; j<cursize; j++) {
01084 int aid = eachPatchAtomList[i][j];
01085 //atomFixed is either 0 or 1
01086 fixedCnt += initAtoms[aid].atomFixed;
01087 }
01088 msg->fixedAtomsCntList[patchCnt] = fixedCnt;
01089 patchCnt++;
01090 }
01091 }
01092 }
01093
01094 pIO[0].recvAtomsCntPerPatch(msg);
01095
01096 }
|
|
|
Definition at line 1309 of file ParallelIOMgr.C. References ResizeArray< Elem >::clear(), PatchMgr::createHomePatch(), FullAtomList, PatchMap::node(), PatchMap::numPatches(), PatchMap::numPatchesOnNode(), Node::Object(), PatchMap::Object(), ResizeArray< Elem >::size(), and Node::workDistrib. 01310 {
01311 #ifdef MEM_OPT_VERSION
01312
01313 int assignedPids = PatchMap::Object()->numPatchesOnNode(CkMyPe());
01314 int numPids = hpIDList.size();
01315 if(numPids==0){
01316 //this node actually contains no homepatches
01317 if(assignedPids == 0) return;
01318
01319 //Entering the rare condition that all the homepatches this node has
01320 //are empty so that "recvAtomsToHomePatchProcs" is never called!
01321 //But we still need to create those empty homepatches!
01322 CmiAssert(isOKToRecvHPAtoms == false);
01323 PatchMap *patchMap = PatchMap::Object();
01324 CProxy_PatchMgr pm(CkpvAccess(BOCclass_group).patchMgr);
01325 PatchMgr *patchMgr = pm.ckLocalBranch();
01326 for(int i=0; i<patchMap->numPatches(); i++) {
01327 if(patchMap->node(i)==CkMyPe()) {
01328 FullAtomList emptyone;
01329 patchMgr->createHomePatch(i, emptyone);
01330 }
01331 }
01332 return;
01333 }
01334
01335 CProxy_PatchMgr pm(CkpvAccess(BOCclass_group).patchMgr);
01336 PatchMgr *patchMgr = pm.ckLocalBranch();
01337
01338 //go through the home patch list
01339 for(int i=0; i<numPids; i++) {
01340 int pid = hpIDList[i];
01341
01342 //re-sort the atom list of this patch
01343 std::sort(hpAtomsList[i].begin(), hpAtomsList[i].end());
01344 Node::Object()->workDistrib->fillAtomListForOnePatch(pid, hpAtomsList[i]);
01345 patchMgr->createHomePatch(pid, hpAtomsList[i]);
01346 }
01347
01348 hpIDList.clear();
01349 delete [] hpAtomsList;
01350
01351 hpAtomsList = NULL;
01352 #endif
01353 }
|
|
||||||||||||
|
Definition at line 1506 of file ParallelIOMgr.C. 01507 {
01508 #ifdef MEM_OPT_VERSION
01509 double iotime = CmiWallTimer();
01510 midCM->disposeForces(seq);
01511 iotime = CmiWallTimer()-iotime+prevT;
01512
01513 #if OUTPUT_SINGLE_FILE
01514 //Token-based file output
01515 if(myOutputRank==getMyOutputGroupHighestRank()) {
01516 //notify the CollectionMaster to start the next round
01517 CProxy_CollectionMaster cm(mainMaster);
01518 cm.startNextRoundOutputForce(iotime);
01519 } else {
01520 CProxy_ParallelIOMgr io(thisgroup);
01521 io[outputProcArray[myOutputRank+1]].disposeForces(seq, iotime);
01522 }
01523 #else
01524 //notify the CollectionMaster to start the next round
01525 CProxy_CollectionMaster cm(mainMaster);
01526 cm.startNextRoundOutputForce(iotime);
01527 #endif
01528
01529 #endif
01530 }
|
|
||||||||||||
|
Definition at line 1454 of file ParallelIOMgr.C. Referenced by CollectionMaster::wrapCoorFinished(). 01455 {
01456 #ifdef MEM_OPT_VERSION
01457 double iotime = CmiWallTimer();
01458 midCM->disposePositions(seq);
01459 iotime = CmiWallTimer()-iotime+prevT;
01460
01461 #if OUTPUT_SINGLE_FILE
01462 //Token-based file output
01463 if(myOutputRank == getMyOutputGroupHighestRank()) {
01464 //notify the CollectionMaster to start the next round
01465 CProxy_CollectionMaster cm(mainMaster);
01466 cm.startNextRoundOutputPos(iotime);
01467 } else {
01468 CProxy_ParallelIOMgr io(thisgroup);
01469 io[outputProcArray[myOutputRank+1]].disposePositions(seq, iotime);
01470 }
01471 #else
01472 //notify the CollectionMaster to start the next round
01473 CProxy_CollectionMaster cm(mainMaster);
01474 cm.startNextRoundOutputPos(iotime);
01475 #endif
01476
01477 #endif
01478 }
|
|
||||||||||||
|
Definition at line 1480 of file ParallelIOMgr.C. 01481 {
01482 #ifdef MEM_OPT_VERSION
01483 double iotime = CmiWallTimer();
01484 midCM->disposeVelocities(seq);
01485 iotime = CmiWallTimer()-iotime+prevT;
01486
01487 #if OUTPUT_SINGLE_FILE
01488 //Token-based file output
01489 if(myOutputRank==getMyOutputGroupHighestRank()) {
01490 //notify the CollectionMaster to start the next round
01491 CProxy_CollectionMaster cm(mainMaster);
01492 cm.startNextRoundOutputVel(iotime);
01493 } else {
01494 CProxy_ParallelIOMgr io(thisgroup);
01495 io[outputProcArray[myOutputRank+1]].disposeVelocities(seq, iotime);
01496 }
01497 #else
01498 //notify the CollectionMaster to start the next round
01499 CProxy_CollectionMaster cm(mainMaster);
01500 cm.startNextRoundOutputVel(iotime);
01501 #endif
01502
01503 #endif
01504 }
|
|
|
Definition at line 1355 of file ParallelIOMgr.C. References SimParameters::freeEnergyOn. 01356 {
01357 #ifdef MEM_OPT_VERSION
01358 molecule->delAtomNames();
01359 molecule->delChargeSpace();
01360
01361 //???TODO NOT SURE WHETHER freeEnergyOn is support in MEM_OPT_VERSION
01362 //-CHAOMEI
01363 if(!CkMyPe() && !simParameters->freeEnergyOn)
01364 molecule->delMassSpace();
01365
01366 molecule->delFixedAtoms();
01367 #endif
01368 }
|
|
|
Definition at line 369 of file ParallelIOMgr.h. 00369 { return numOutputProcs; }
|
|
|
Definition at line 83 of file ParallelIOMgr.C. References UniqueSet< Elem >::clear(), CollectionMgr::getMasterChareID(), iINFO(), iout, Node::molecule, NAMD_bug(), SimParameters::numinputprocs, SimParameters::numoutputprocs, SimParameters::numoutputwrts, CollectionMgr::Object(), ResizeArray< Elem >::resize(), ResizeArray< Elem >::setParams(), and Node::simParameters. 00084 {
00085 simParameters = node->simParameters;
00086 molecule = node->molecule;
00087
00088 numInputProcs = simParameters->numinputprocs;
00089 numOutputProcs = simParameters->numoutputprocs;
00090 numOutputWrts = simParameters->numoutputwrts;
00091
00092
00093 if(!CkMyPe()) {
00094 iout << iINFO << "Running with " <<numInputProcs<<" input processors.\n"<<endi;
00095 #if OUTPUT_SINGLE_FILE
00096 iout << iINFO << "Running with " <<numOutputProcs<<" output processors ("<<numOutputWrts<<" of them will output simultaneously).\n"<<endi;
00097 #else
00098 iout << iINFO << "Running with " <<numOutputProcs<<" output processors, and each of them will output to its own separate file.\n"<<endi;
00099 #endif
00100 }
00101
00102 //build inputProcArray
00103 {
00104 inputProcArray = new int[numInputProcs];
00105 myInputRank = -1;
00106 int stride = (numInputProcs > 1) ? (CkNumPes()-1)/(numInputProcs-1) : 1;
00107 int startpe = 0;
00108 for(int i=0; i<numInputProcs; i++) {
00109 int pe = inputProcArray[i] = startpe + i*stride;
00110 if ( pe < 0 || pe >= CkNumPes() ) NAMD_bug("Input proc out of range");
00111 if ( pe == CkMyPe() ) {
00112 if ( myInputRank != -1 ) NAMD_bug("Duplicate input proc");
00113 myInputRank = i;
00114 }
00115 }
00116 }
00117
00118 if(myInputRank!=-1) {
00119 //NOTE: this could further be optimized by pre-allocate the memory
00120 //for incoming atoms --Chao Mei
00121 int numMyAtoms = numInitMyAtomsOnInput();
00122 float growthRate = 100.0f/numMyAtoms;
00123 initAtoms.setParams(numMyAtoms+100, growthRate);
00124 initAtoms.resize(numMyAtoms);
00125 tmpRecvAtoms.resize(0);
00126 } else {
00127 initAtoms.resize(0);
00128 tmpRecvAtoms.resize(0);
00129 }
00130 hpIDList.resize(0);
00131
00132 //build outputProcArray
00133 //spread the output processors across all the processors
00134 {
00135 outputProcArray = new int[numOutputProcs];
00136 int stride = CkNumPes()/numOutputProcs;
00137 int startpe = 0;
00138 for(int i=0; i<numOutputProcs; i++) {
00139 outputProcArray[i] = startpe + i*stride;
00140 }
00141 //The special setting because of the current otputProcArray initialization
00142 int residue = (CkMyPe()-startpe)%stride;
00143 if(residue==0) {
00144 int rank = (CkMyPe()-startpe)/stride;
00145 myOutputRank = rank<numOutputProcs ? rank : -1;
00146 } else {
00147 myOutputRank = -1;
00148 }
00149 }
00150
00151 #ifdef MEM_OPT_VERSION
00152 if(myOutputRank!=-1) {
00153 midCM = new CollectionMidMaster(this);
00154 }
00155 remoteClusters.clear();
00156 csmBuf.resize(0);
00157 remoteCoors.clear();
00158 ccmBuf.resize(0);
00159
00160 mainMaster = CollectionMgr::Object()->getMasterChareID();
00161 #endif
00162 }
|
|
|
Definition at line 431 of file ParallelIOMgr.C. References ClusterSizeMsg::atomsCnt, ClusterSizeMsg::clusterId, recvFinalClusterSize(), ResizeArray< Elem >::resize(), ResizeArray< Elem >::size(), ClusterSizeMsg::srcRank, SimParameters::wrapAll, and SimParameters::wrapWater. 00432 {
00433 if(myOutputRank==-1) return;
00434 if(!(simParameters->wrapAll || simParameters->wrapWater)) return;
00435
00436 int fromIdx, toIdx; //atoms' range
00437 getMyAtomsRangeOnOutput(fromIdx,toIdx);
00438
00439 //calculated the final cluster size
00440 for(int i=0; i<csmBuf.size(); i++) {
00441 ClusterSizeMsg *msg = csmBuf[i];
00442 int lidx = msg->clusterId - fromIdx;
00443 clusterSize[lidx] += msg->atomsCnt;
00444 }
00445
00446 CProxy_ParallelIOMgr pIO(thisgroup);
00447 for(int i=0; i<csmBuf.size(); i++) {
00448 ClusterSizeMsg *msg = csmBuf[i];
00449 int lidx = msg->clusterId - fromIdx;
00450 msg->atomsCnt = clusterSize[lidx];
00451 pIO[outputProcArray[msg->srcRank]].recvFinalClusterSize(msg);
00452 }
00453 numRemoteReqs = csmBuf.size();
00454 csmBuf.resize(0);
00455
00456 //There's a possible msg race problem here that recvFinalClusterSize
00457 //executes before integrateClusterSize because other proc finishes faster
00458 //in calculating the cluster size. The recvFinalClusterSize should be
00459 //executed after integrateClusterSize. To avoid this, a self message is
00460 //sent to participate the reduction.
00461 if(numRemoteClusters!=0){
00462 recvFinalClusterSize(NULL);
00463 }else{
00464 //this output proc already has the final cluster size for each atom
00465 int numMyAtoms = toIdx-fromIdx+1;
00466 for(int i=0; i<numMyAtoms; i++) {
00467 int lidx = clusterID[i]-fromIdx;
00468 clusterSize[i] = clusterSize[lidx];
00469 }
00470
00471 #if 0 //write out cluster debug info
00472 char fname[128];
00473 sprintf(fname, "cluster.par.%d", CkMyPe());
00474 FILE *ofp = fopen(fname, "w");
00475 for(int i=0; i<numMyAtoms; i++) {
00476 fprintf(ofp, "%d: %d: %d\n", i+fromIdx, clusterID[i], clusterSize[i]);
00477 }
00478 fclose(ofp);
00479 #endif
00480 }
00481 }
|
|
|
Definition at line 590 of file ParallelIOMgr.C. References ResizeArray< Elem >::add(), ResizeArray< Elem >::begin(), ResizeArray< Elem >::clear(), ResizeArray< Elem >::end(), CompAtom::hydrogenGroupSize, InputAtom::isGP, InputAtom::isValid, j, Molecule::numFixedAtoms, HydroBasedMsg::numFixedGroups, HydroBasedMsg::numFixedRigidBonds, Molecule::numRigidBonds, FullAtom::rigidBondLength, and ResizeArray< Elem >::size(). 00591 {
00592 if(myInputRank==-1) return;
00593
00594 for(int i=0; i<tmpRecvAtoms.size(); i++) {
00595 tmpRecvAtoms[i].isValid = true;
00596 initAtoms.add(tmpRecvAtoms[i]);
00597 }
00598 tmpRecvAtoms.clear();
00599
00600 //sort atom list based on hydrogenList value
00601 std::sort(initAtoms.begin(), initAtoms.end());
00602
00603 //now compute the counters inside Molecule such as numFixedRigidBonds
00604 //which is based on the hydrogen group info
00605
00606 int numFixedRigidBonds = 0;
00607 if(molecule->numRigidBonds){
00608 int parentIsFixed = 0;
00609 for(int i=0; i<initAtoms.size(); i++) {
00610 InputAtom *one = &(initAtoms[i]);
00611 if(!one->isValid) continue;
00612 if(one->isGP) {
00613 parentIsFixed = one->atomFixed;
00614 InputAtom *a1 = &(initAtoms[i+1]);
00615 InputAtom *a2 = &(initAtoms[i+2]);
00616 if((one->rigidBondLength>0.0) &&
00617 a1->atomFixed && a2->atomFixed) {
00618 numFixedRigidBonds++;
00619 }
00620 }else{
00621 if((one->rigidBondLength>0.0) &&
00622 one->atomFixed && parentIsFixed) {
00623 numFixedRigidBonds++;
00624 }
00625 }
00626 }
00627 }
00628
00629 int numFixedGroups = 0;
00630 if(molecule->numFixedAtoms){
00631 for(int i=0; i<initAtoms.size();) {
00632 InputAtom *one = &(initAtoms[i]);
00633 if(!one->isValid){
00634 i++;
00635 continue;
00636 }
00637 if(one->isGP) {
00638 int allFixed = 1;
00639 for(int j=0; j<one->hydrogenGroupSize; j++){
00640 InputAtom *a1 = &(initAtoms[i+j]);
00641 allFixed = allFixed & a1->atomFixed;
00642 if(!allFixed) break;
00643 }
00644 if(allFixed) numFixedGroups++;
00645 i += one->hydrogenGroupSize;
00646 }
00647 }
00648 }
00649
00650 CProxy_ParallelIOMgr pIO(thisgroup);
00651 HydroBasedMsg *msg = new HydroBasedMsg;
00652 msg->numFixedGroups = numFixedGroups;
00653 msg->numFixedRigidBonds = numFixedRigidBonds;
00654 pIO[0].recvHydroBasedCounter(msg);
00655 }
|
|
|
Definition at line 530 of file ParallelIOMgr.C. References ResizeArray< Elem >::add(), AtomIDList, MoveInputAtomsMsg::atomList, ResizeArray< Elem >::begin(), ResizeArray< Elem >::clear(), InputAtomList, MoveInputAtomsMsg::length, and ResizeArray< Elem >::size(). 00531 {
00532 if(myInputRank==-1) return;
00533
00534 //1. first get the list of atoms to be migrated
00535 //which should be few compared with the number of atoms
00536 //initially assigned to this input proc.
00537 AtomIDList toMigrateList; //the list of atoms to be migrated
00538 //the max distance from this processor of atoms to be sent
00539 int maxOffset = 0;
00540 for(int i=0; i<initAtoms.size(); i++) {
00541 //returns the proc id on which atom MPID resides on
00542 int parentRank = atomInitRankOnInput(initAtoms[i].MPID);
00543 if(parentRank != myInputRank) {
00544 toMigrateList.add(i);
00545 initAtoms[i].isValid = false;
00546 int tmp = parentRank - myInputRank;
00547 tmp = tmp>0 ? tmp : -tmp;
00548 if(tmp > maxOffset) maxOffset = tmp;
00549 }
00550 }
00551
00552 //2. prepare atom migration messages
00553 //the messages are indexed as [-maxOffset,..., -1,0,1,..., maxOffset]
00554 //where the "0" is not used at all. It is added for the sake of
00555 //computing the index easily.
00556 InputAtomList *migLists = new InputAtomList[2*maxOffset+1];
00557 for(int i=0; i<toMigrateList.size(); i++) {
00558 int idx = toMigrateList[i];
00559 int parentRank = atomInitRankOnInput(initAtoms[idx].MPID);
00560 //decide which migList to put this atom
00561 int offset = parentRank - myInputRank + maxOffset;
00562 migLists[offset].add(initAtoms[idx]);
00563 }
00564
00565 CProxy_ParallelIOMgr pIO(thisgroup);
00566 for(int i=0; i<2*maxOffset+1; i++) {
00567 int migLen = migLists[i].size();
00568 if(migLen>0) {
00569 MoveInputAtomsMsg *msg = new (migLen, 0)MoveInputAtomsMsg;
00570 msg->length = migLen;
00571 memcpy(msg->atomList, migLists[i].begin(), sizeof(InputAtom)*migLen);
00572 int destRank = i-maxOffset+myInputRank;
00573 pIO[inputProcArray[destRank]].recvAtomsMGrp(msg);
00574 migLists[i].clear();
00575 }
00576 }
00577
00578 toMigrateList.clear();
00579 delete [] migLists;
00580 }
|
|
|
Definition at line 164 of file ParallelIOMgr.C. References j, SimParameters::wrapAll, and SimParameters::wrapWater. 00165 {
00166 #ifdef MEM_OPT_VERSION
00167 if(myInputRank!=-1) {
00168 int myAtomLIdx, myAtomUIdx;
00169 getMyAtomsInitRangeOnInput(myAtomLIdx, myAtomUIdx);
00170
00171 //1. read the file that contains per-atom info such as signature index
00172 molecule->read_binary_atom_info(myAtomLIdx, myAtomUIdx, initAtoms);
00173
00174 //2. read coordinates and velocities of each atom if the velocity file
00175 //exists, otherwise, the velocity of each atom is randomly generated.
00176 //This has to be DONE AFTER THE FIRST STEP as the atom mass is required
00177 //if the velocity is generated randomly.
00178 readCoordinatesAndVelocity();
00179
00180 //3. set every atom's output processor rank, i.e. the dest pe this
00181 //atom will be sent for writing positions and velocities etc.
00182 int oRank=atomRankOnOutput(myAtomLIdx);
00183 for(int i=oRank; i<numOutputProcs; i++) {
00184 int lIdx, uIdx; //indicates the range of atom ids outputProcArray[i] has
00185 getAtomsRangeOnOutput(lIdx, uIdx, i);
00186 if(lIdx > myAtomUIdx) break;
00187 int fid = lIdx>myAtomLIdx?lIdx:myAtomLIdx;
00188 int tid = uIdx>myAtomUIdx?myAtomUIdx:uIdx;
00189 for(int j=fid; j<=tid; j++) initAtoms[j-myAtomLIdx].outputRank = i;
00190 }
00191 }
00192
00193 //read clusters
00194 if(myOutputRank!=-1) {
00195 //only when wrapAll or wrapWater is set, cluster info is required
00196 if(!(simParameters->wrapAll || simParameters->wrapWater)) return;
00197 readInfoForParOutput();
00198 }
00199 #endif
00200 }
|
|
|
Definition at line 1441 of file ParallelIOMgr.C. References CollectVectorVarMsg::seq. 01442 {
01443 #ifdef MEM_OPT_VERSION
01444 int ready = midCM->receiveForces(msg);
01445 if(ready) {
01446 CProxy_CollectionMaster cm(mainMaster);
01447 cm.receiveOutputForceReady(msg->seq);
01448 }
01449 delete msg;
01450 #endif
01451 }
|
|
|
Definition at line 1417 of file ParallelIOMgr.C. References CollectVectorVarMsg::seq. 01418 {
01419 #ifdef MEM_OPT_VERSION
01420 int ready = midCM->receivePositions(msg);
01421 if(ready) {
01422 CProxy_CollectionMaster cm(mainMaster);
01423 cm.receiveOutputPosReady(msg->seq);
01424 }
01425 delete msg;
01426 #endif
01427 }
|
|
|
Definition at line 1429 of file ParallelIOMgr.C. References CollectVectorVarMsg::seq. 01430 {
01431 #ifdef MEM_OPT_VERSION
01432 int ready = midCM->receiveVelocities(msg);
01433 if(ready) {
01434 CProxy_CollectionMaster cm(mainMaster);
01435 cm.receiveOutputVelReady(msg->seq);
01436 }
01437 delete msg;
01438 #endif
01439 }
|
|
|
Definition at line 1098 of file ParallelIOMgr.C. References AtomsCntPerPatchMsg::atomsCntList, AtomsCntPerPatchMsg::fixedAtomsCntList, SimParameters::fixedAtomsOn, iINFO(), iout, AtomsCntPerPatchMsg::length, Node::molecule, NAMD_die(), Molecule::numAtoms, PatchMap::numPatches(), Node::Object(), PatchMap::Object(), and AtomsCntPerPatchMsg::pidList. 01099 {
01100 #ifdef MEM_OPT_VERSION
01101 PatchMap *patchMap = PatchMap::Object();
01102 for(int i=0; i<msg->length; i++) {
01103 int pid = msg->pidList[i];
01104 int oldNum = patchMap->numAtoms(pid);
01105 if ( oldNum + msg->atomsCntList[i] > USHRT_MAX ) {
01106 char errstr[512];
01107 sprintf(errstr, "Patch %d exceeds %d atoms.", pid, USHRT_MAX);
01108 NAMD_die(errstr);
01109 }
01110 patchMap->setNumAtoms(pid, oldNum+msg->atomsCntList[i]);
01111 if(simParameters->fixedAtomsOn) {
01112 oldNum = patchMap->numFixedAtoms(pid);
01113 patchMap->setNumFixedAtoms(pid, oldNum+msg->fixedAtomsCntList[i]);
01114 }
01115 }
01116 delete msg;
01117
01118 if(++procsReceived == numInputProcs) {
01119 //print max PATCH info
01120 int maxAtoms = -1;
01121 int maxPatch = -1;
01122 int totalAtoms = 0;
01123 for(int i=0; i<patchMap->numPatches(); i++) {
01124 int cnt = patchMap->numAtoms(i);
01125 totalAtoms += cnt;
01126 if(cnt>maxAtoms) {
01127 maxAtoms = cnt;
01128 maxPatch = i;
01129 }
01130 }
01131 procsReceived = 0;
01132 iout << iINFO << "LARGEST PATCH (" << maxPatch <<
01133 ") HAS " << maxAtoms << " ATOMS\n" << endi;
01134 if ( totalAtoms != Node::Object()->molecule->numAtoms ) {
01135 char errstr[512];
01136 sprintf(errstr, "Incorrect atom count in void ParallelIOMgr::recvAtomsCntPerPatch: %d vs %d", totalAtoms, Node::Object()->molecule->numAtoms);
01137 NAMD_die(errstr);
01138 }
01139 }
01140 #endif
01141 }
|
|
|
Definition at line 582 of file ParallelIOMgr.C. References ResizeArray< Elem >::add(), MoveInputAtomsMsg::atomList, and MoveInputAtomsMsg::length. 00583 {
00584 for(int i=0; i<msg->length; i++) {
00585 tmpRecvAtoms.add((msg->atomList)[i]);
00586 }
00587 delete msg;
00588 }
|
|
|
Definition at line 1245 of file ParallelIOMgr.C. References ResizeArray< Elem >::add(), MovePatchAtomsMsg::allAtoms, MovePatchAtomsMsg::from, j, MovePatchAtomsMsg::patchCnt, MovePatchAtomsMsg::pidList, and MovePatchAtomsMsg::sizeList. 01246 {
01247 CProxy_ParallelIOMgr pIO(thisgroup);
01248 pIO[msg->from].ackAtomsToHomePatchProcs();
01249
01250 if(!isOKToRecvHPAtoms) {
01251 prepareHomePatchAtomList();
01252 isOKToRecvHPAtoms = true;
01253 }
01254
01255 int numRecvPatches = msg->patchCnt;
01256 int aid = 0;
01257 for(int i=0; i<numRecvPatches; i++) {
01258 int pid = msg->pidList[i];
01259 int size = msg->sizeList[i];
01260 int idx = binaryFindHPID(pid);
01261 for(int j=0; j<size; j++, aid++) {
01262 hpAtomsList[idx].add(msg->allAtoms[aid]);
01263 }
01264 }
01265 //CkPrintf("Pe %d recvAtomsToHomePatchProcs for %d patches %d atoms\n",CkMyPe(),numRecvPatches,aid);
01266 delete msg;
01267 }
|
|
|
Definition at line 1607 of file ParallelIOMgr.C. References ResizeArray< Elem >::add(). Referenced by wrapCoor(). 01607 {
01608 //only add the msg from remote procs
01609 if(msg!=NULL) ccmBuf.add(msg);
01610
01611 //include a msg sent by itself
01612 if(++numReqRecved == (numRemoteReqs+1)){
01613 numReqRecved = 0;
01614 integrateClusterCoor();
01615 }
01616 }
|
|
|
Definition at line 423 of file ParallelIOMgr.C. References ResizeArray< Elem >::add(). 00424 {
00425 csmBuf.add(msg); //added to buffer for reuse to send back to src
00426
00427 //update cluster size has to be delayed to integration to prevent
00428 //data racing where the clusterSize has not been created!
00429 }
|
|
|
Definition at line 1679 of file ParallelIOMgr.C. References UniqueSet< Elem >::clear(), ClusterCoorElem::clusterId, ClusterCoorMsg::clusterId, ClusterCoorMsg::dsum, ClusterCoorElem::dsum, UniqueSet< Elem >::find(), ResizeArray< Elem >::size(), Lattice::wrap_delta(), Lattice::wrap_nearest_delta(), SimParameters::wrapAll, and SimParameters::wrapNearest. 01679 {
01680 #ifdef MEM_OPT_VERSION
01681 if(msg!=NULL){
01682 //only process the message sent from other procs!
01683 ClusterCoorElem one(msg->clusterId);
01684 ClusterCoorElem *ret = remoteCoors.find(one);
01685 ret->dsum = msg->dsum;
01686 delete msg;
01687 }
01688
01689 if(++numCSMAck == (numRemoteClusters+1)){
01690 //final wrap coor computation
01691 int fromIdx = coorInstance->fromAtomID;
01692 int toIdx = coorInstance->toAtomID;
01693 int numMyAtoms = toIdx-fromIdx+1;
01694 ResizeArray<Vector> data = coorInstance->data;
01695 ResizeArray<FloatVector> fdata = coorInstance->fdata;
01696 ClusterCoorElem tmp;
01697 for(int i=0; i<numMyAtoms; i++){
01698 if(!simParameters->wrapAll && !isWater[i]) continue;
01699 int cid = clusterID[i];
01700 int lidx = cid-fromIdx;
01701 if(lidx<0){
01702 //this cid should be inside remoteCoors
01703 tmp.clusterId = cid;
01704 ClusterCoorElem *fone = remoteCoors.find(tmp);
01705 if(data.size()) data[i] += fone->dsum;
01706 if(fdata.size()) fdata[i] = fdata[i] + fone->dsum;
01707 }else{
01708 if(lidx==i){
01709 Lattice *lat = &(coorInstance->lattice);
01710 Vector coni = tmpCoorCon[lidx]/clusterSize[lidx];
01711 tmpCoorCon[lidx] = (simParameters->wrapNearest ?
01712 lat->wrap_nearest_delta(coni) : lat->wrap_delta(coni));
01713 }
01714 if(data.size()) data[i] += tmpCoorCon[lidx];
01715 if(fdata.size()) fdata[i] = fdata[i] + tmpCoorCon[lidx];
01716 }
01717 }
01718
01719 delete [] tmpCoorCon;
01720 tmpCoorCon = NULL;
01721 CProxy_CollectionMaster cm(mainMaster);
01722 cm.wrapCoorFinished();
01723 numCSMAck = 0;
01724 remoteCoors.clear();
01725 }
01726 #endif
01727 }
|
|
|
Definition at line 483 of file ParallelIOMgr.C. References ClusterSizeMsg::atomsCnt, ClusterElem::atomsCnt, UniqueSet< Elem >::clear(), ClusterElem::clusterId, ClusterSizeMsg::clusterId, and UniqueSet< Elem >::find(). Referenced by integrateClusterSize(). 00484 {
00485 //only process the message sent by other procs
00486 if(msg!=NULL) {
00487 //indicating a message from other procs
00488 ClusterElem one(msg->clusterId);
00489 ClusterElem *ret = remoteClusters.find(one);
00490 CmiAssert(ret!=NULL);
00491 ret->atomsCnt = msg->atomsCnt;
00492 }
00493 delete msg;
00494
00495 //include a msg sent by itself for reduction
00496 if(++numCSMAck == (numRemoteClusters+1)) {
00497 //recved all the msgs needed to update the cluster size for each atom finally
00498 int fromIdx, toIdx; //atoms' range
00499 getMyAtomsRangeOnOutput(fromIdx,toIdx);
00500 int numMyAtoms = toIdx-fromIdx+1;
00501 ClusterElem tmp;
00502 for(int i=0; i<numMyAtoms; i++) {
00503 int cid = clusterID[i];
00504 int lidx = cid-fromIdx;
00505 if(lidx<0) {
00506 //this cid should be inside remoteClusters
00507 tmp.clusterId = cid;
00508 ClusterElem *fone = remoteClusters.find(tmp);
00509 clusterSize[i] = fone->atomsCnt;
00510 } else {
00511 clusterSize[i] = clusterSize[lidx];
00512 }
00513 }
00514 numCSMAck = 0;
00515 remoteClusters.clear();
00516
00517 #if 0 //write out cluster debug info
00518 char fname[128];
00519 sprintf(fname, "cluster.par.%d", CkMyPe());
00520 FILE *ofp = fopen(fname, "w");
00521 for(int i=0; i<numMyAtoms; i++) {
00522 fprintf(ofp, "%d: %d: %d\n", i+fromIdx, clusterID[i], clusterSize[i]);
00523 }
00524 fclose(ofp);
00525 #endif
00526
00527 }
00528 }
|
|
|
Definition at line 923 of file ParallelIOMgr.C. References HydroBasedMsg::numFixedGroups, Molecule::numFixedGroups, HydroBasedMsg::numFixedRigidBonds, and Molecule::numFixedRigidBonds. 00923 {
00924 molecule->numFixedRigidBonds += msg->numFixedRigidBonds;
00925 molecule->numFixedGroups += msg->numFixedGroups;
00926
00927 if(++hydroMsgRecved == numInputProcs){
00928 msg->numFixedRigidBonds = molecule->numFixedRigidBonds;
00929 msg->numFixedGroups = molecule->numFixedGroups;
00930 CProxy_ParallelIOMgr pIO(thisgroup);
00931 pIO.bcastHydroBasedCounter(msg);
00932 hydroMsgRecved = 0;
00933 }else delete msg;
00934 }
|
|
|
|
Definition at line 1148 of file ParallelIOMgr.C. References ResizeArray< Elem >::add(), MovePatchAtomsMsg::allAtoms, ResizeArray< Elem >::begin(), call_sendAtomsToHomePatchProcs(), ResizeArray< Elem >::clear(), PatchMap::delTmpPatchAtomsList(), MovePatchAtomsMsg::from, PatchMap::getTmpPatchAtomsList(), j, PatchMap::node(), numAcksOutstanding, PatchMap::numPatches(), PatchMap::Object(), MovePatchAtomsMsg::patchCnt, MovePatchAtomsMsg::pidList, sendAtomsThread, ResizeArray< Elem >::size(), and MovePatchAtomsMsg::sizeList. 01149 {
01150 #ifdef MEM_OPT_VERSION
01151 if(myInputRank==-1) return;
01152
01153 if ( sendAtomsThread == 0 ) {
01154 sendAtomsThread = CthCreate((CthVoidFn)call_sendAtomsToHomePatchProcs,this,0);
01155 CthAwaken(sendAtomsThread);
01156 return;
01157 }
01158 sendAtomsThread = 0;
01159 numAcksOutstanding = 0;
01160
01161 PatchMap *patchMap = PatchMap::Object();
01162 int numPatches = patchMap->numPatches();
01163 vector<int> *eachPatchAtomList = patchMap->getTmpPatchAtomsList();
01164
01165 //each element (proc) contains the list of ids of patches which will stay
01166 //on that processor
01167 ResizeArray<int> *procList = new ResizeArray<int>[CkNumPes()];
01168 ResizeArray<int> pesToSend;
01169 for(int i=0; i<numPatches; i++) {
01170 if(eachPatchAtomList[i].size()==0) continue;
01171 int onPE = patchMap->node(i);
01172 if ( procList[onPE].size() == 0 ) pesToSend.add(onPE);
01173 procList[onPE].add(i);
01174 }
01175
01176 Random(CkMyPe()).reorder(pesToSend.begin(),pesToSend.size());
01177 //CkPrintf("Pe %d ParallelIOMgr::sendAtomsToHomePatchProcs sending to %d pes\n",CkMyPe(),pesToSend.size());
01178
01179 //go over every processor to send a message if necessary
01180 //TODO: Optimization for local home patches to save temp memory usage??? -CHAOMEI
01181 CProxy_ParallelIOMgr pIO(thisgroup);
01182 for(int k=0; k<pesToSend.size(); k++) {
01183 const int i = pesToSend[k];
01184 int len = procList[i].size();
01185 if(len==0) continue;
01186
01187 if ( numAcksOutstanding >= 10 ) {
01188 //CkPrintf("Pe %d ParallelIOMgr::sendAtomsToHomePatchProcs suspending at %d of %d pes\n",CkMyPe(),k,pesToSend.size());
01189 //fflush(stdout);
01190 sendAtomsThread = CthSelf();
01191 CthSuspend();
01192 }
01193 ++numAcksOutstanding;
01194
01195 //prepare a message to send
01196 int patchCnt = len;
01197 int totalAtomCnt = 0;
01198 for(int j=0; j<len; j++) {
01199 int pid = procList[i][j];
01200 int atomCnt = eachPatchAtomList[pid].size();
01201 totalAtomCnt += atomCnt;
01202 }
01203
01204 MovePatchAtomsMsg *msg = new (patchCnt, patchCnt, totalAtomCnt, 0)MovePatchAtomsMsg;
01205 msg->from = CkMyPe();
01206 msg->patchCnt = patchCnt;
01207 int atomIdx = 0;
01208 for(int j=0; j<len; j++) {
01209 int pid = procList[i][j];
01210 int atomCnt = eachPatchAtomList[pid].size();
01211 msg->pidList[j] = pid;
01212 msg->sizeList[j] = atomCnt;
01213 for(int k=0; k<atomCnt; k++, atomIdx++) {
01214 int aid = eachPatchAtomList[pid][k];
01215 FullAtom one = initAtoms[aid];
01216 //HACK to re-sort the atom list after receiving the atom list on
01217 //home patch processor -Chao Mei
01218 one.hydVal = initAtoms[aid].hydList;
01219 msg->allAtoms[atomIdx] = one;
01220 }
01221 }
01222 pIO[i].recvAtomsToHomePatchProcs(msg);
01223
01224 procList[i].clear();
01225 }
01226
01227 //clean up to free space
01228 delete [] procList;
01229 patchMap->delTmpPatchAtomsList();
01230
01231 //free the space occupied by the list that contains the input atoms
01232 initAtoms.clear();
01233 #endif
01234 }
|
|
|
Definition at line 657 of file ParallelIOMgr.C. References AtomSignature::angleCnt, AtomSignature::angleSigs, atomSigPool, AtomSignature::bondCnt, AtomSignature::bondSigs, SimParameters::comMove, AtomSignature::crosstermCnt, AtomSignature::crosstermSigs, AtomSignature::dihedralCnt, AtomSignature::dihedralSigs, ExclusionSignature::fullExclCnt, ExclusionSignature::fullOffset, AtomSignature::improperCnt, AtomSignature::improperSigs, j, ExclusionSignature::modExclCnt, ExclusionSignature::modOffset, MolInfoMsg::numAngles, MolInfoMsg::numBonds, MolInfoMsg::numCalcAngles, MolInfoMsg::numCalcBonds, MolInfoMsg::numCalcCrossterms, MolInfoMsg::numCalcDihedrals, MolInfoMsg::numCalcExclusions, MolInfoMsg::numCalcImpropers, MolInfoMsg::numCrossterms, MolInfoMsg::numDihedrals, MolInfoMsg::numExclusions, Molecule::numFixedAtoms, MolInfoMsg::numImpropers, MolInfoMsg::numRigidBonds, TupleSignature::offset, ResizeArray< Elem >::size(), MolInfoMsg::totalCharge, MolInfoMsg::totalMass, and MolInfoMsg::totalMV. 00658 {
00659 #ifdef MEM_OPT_VERSION
00660 if(myInputRank==-1) return;
00661
00662 CProxy_ParallelIOMgr pIO(thisgroup);
00663
00664 MolInfoMsg *msg = new MolInfoMsg;
00665 msg->numBonds = msg->numCalcBonds = 0;
00666 msg->numAngles = msg->numCalcAngles = 0;
00667 msg->numDihedrals = msg->numCalcDihedrals = 0;
00668 msg->numImpropers = msg->numCalcImpropers = 0;
00669 msg->numCrossterms = msg->numCalcCrossterms = 0;
00670 msg->numExclusions = msg->numCalcExclusions = 0;
00671 msg->numRigidBonds = 0;
00672 msg->totalMass = 0.0;
00673 msg->totalCharge = 0.0;
00674
00675 //calculate the tuples this input processor have
00676 AtomSignature *atomSigPool = molecule->atomSigPool;
00677 ExclusionSignature *exclSigPool = molecule->exclSigPool;
00678 for(int i=0; i<initAtoms.size(); i++) {
00679 AtomSignature *thisSig = &atomSigPool[initAtoms[i].sigId];
00680 msg->numBonds += thisSig->bondCnt;
00681 msg->numAngles += thisSig->angleCnt;
00682 msg->numDihedrals += thisSig->dihedralCnt;
00683 msg->numImpropers += thisSig->improperCnt;
00684 msg->numCrossterms += thisSig->crosstermCnt;
00685
00686 ExclusionSignature *exclSig = &exclSigPool[initAtoms[i].exclId];
00687 msg->numExclusions += (exclSig->fullExclCnt + exclSig->modExclCnt);
00688
00689 if(initAtoms[i].rigidBondLength > 0.0) msg->numRigidBonds++;
00690
00691 msg->totalMass += initAtoms[i].mass;
00692 msg->totalCharge += initAtoms[i].charge;
00693 }
00694
00695 //deal with numCalc* which is related with fixed atoms!
00696 if(molecule->numFixedAtoms>0) {
00697 //if there's fixed atoms, calcExclusions needs to be calculated
00698 //Since it's possible the atom inside the this exclusion set is on
00699 //another input processor, we have to resort to the global fixed atoms
00700 //info inside the Molecule object. The number of such accesses should
00701 //be very small! --Chao Mei
00702 int sAId = initAtoms[0].id;
00703 int remoteCnt=0; //stats info
00704 for(int i=0; i<initAtoms.size(); i++) {
00705 //When all the atoms in the set are fixed, the elem (Bond etc.)
00706 //is not counted as a calc*.
00707 int myAId = initAtoms[i].id;
00708 AtomSignature *thisSig = &atomSigPool[initAtoms[i].sigId];
00709 ExclusionSignature *exclSig = &exclSigPool[initAtoms[i].exclId];
00710 if(!initAtoms[i].atomFixed) {
00711 msg->numCalcBonds += thisSig->bondCnt;
00712 msg->numCalcAngles += thisSig->angleCnt;
00713 msg->numCalcDihedrals += thisSig->dihedralCnt;
00714 msg->numCalcImpropers += thisSig->improperCnt;
00715 msg->numCalcCrossterms += thisSig->crosstermCnt;
00716 msg->numCalcExclusions+=(exclSig->fullExclCnt+exclSig->modExclCnt);
00717 continue;
00718 }
00719
00720 //1. Bonds
00721 for(int j=0; j<thisSig->bondCnt; j++) {
00722 TupleSignature *bsig = &(thisSig->bondSigs[j]);
00723 int a1 = myAId + bsig->offset[0];
00724 if(!isAtomFixed(sAId, a1)) msg->numCalcBonds++;
00725 }
00726
00727 //2. Angles
00728 for(int j=0; j<thisSig->angleCnt; j++) {
00729 TupleSignature *bsig = &(thisSig->angleSigs[j]);
00730 int a1 = myAId + bsig->offset[0];
00731 int a2 = myAId + bsig->offset[1];
00732 if(!isAtomFixed(sAId, a1) || !isAtomFixed(sAId, a2))
00733 msg->numCalcAngles++;
00734 }
00735
00736 //3. Dihedrals
00737 for(int j=0; j<thisSig->dihedralCnt; j++) {
00738 TupleSignature *bsig = &(thisSig->dihedralSigs[j]);
00739 int a1 = myAId + bsig->offset[0];
00740 int a2 = myAId + bsig->offset[1];
00741 int a3 = myAId + bsig->offset[2];
00742 if(!isAtomFixed(sAId, a1) ||
00743 !isAtomFixed(sAId, a2) ||
00744 !isAtomFixed(sAId, a3))
00745 msg->numCalcDihedrals++;
00746 }
00747
00748 //4. Impropers
00749 for(int j=0; j<thisSig->improperCnt; j++) {
00750 TupleSignature *bsig = &(thisSig->improperSigs[j]);
00751 int a1 = myAId + bsig->offset[0];
00752 int a2 = myAId + bsig->offset[1];
00753 int a3 = myAId + bsig->offset[2];
00754 if(!isAtomFixed(sAId, a1) ||
00755 !isAtomFixed(sAId, a2) ||
00756 !isAtomFixed(sAId, a3))
00757 msg->numCalcImpropers++;
00758 }
00759
00760 //5. Crossterms
00761 for(int j=0; j<thisSig->crosstermCnt; j++) {
00762 TupleSignature *bsig = &(thisSig->crosstermSigs[j]);
00763 int a1 = myAId + bsig->offset[0];
00764 int a2 = myAId + bsig->offset[1];
00765 int a3 = myAId + bsig->offset[2];
00766 int a4 = myAId + bsig->offset[3];
00767 int a5 = myAId + bsig->offset[4];
00768 int a6 = myAId + bsig->offset[5];
00769 int a7 = myAId + bsig->offset[6];
00770
00771 if(!isAtomFixed(sAId, a1) ||
00772 !isAtomFixed(sAId, a2) ||
00773 !isAtomFixed(sAId, a3) ||
00774 !isAtomFixed(sAId, a4) ||
00775 !isAtomFixed(sAId, a5) ||
00776 !isAtomFixed(sAId, a6) ||
00777 !isAtomFixed(sAId, a7))
00778 msg->numCalcDihedrals++;
00779 }
00780
00781 //6: Exclusions
00782 //this atom is fixed, check atoms in the exclusion set
00783 for(int j=0; j<exclSig->fullExclCnt; j++) {
00784 int thisAId = exclSig->fullOffset[j]+myAId;
00785 if(!isAtomFixed(sAId, thisAId)) msg->numCalcExclusions++;
00786 }
00787 for(int j=0; j<exclSig->modExclCnt; j++) {
00788 int thisAId = exclSig->modOffset[j]+myAId;
00789 if(!isAtomFixed(sAId, thisAId)) msg->numCalcExclusions++;
00790 }
00791 }
00792 #if COLLECT_PERFORMANCE_DATA
00793 printf("Num fixedAtom lookup on proc %d is %d\n", CkMyPe(), numFixedAtomLookup);
00794 #endif
00795 } else {
00796 //no fixed atoms, numCalc* is same with numExclusions
00797 msg->numCalcBonds = msg->numBonds;
00798 msg->numCalcAngles = msg->numAngles;
00799 msg->numCalcDihedrals = msg->numDihedrals;
00800 msg->numCalcImpropers = msg->numImpropers;
00801 msg->numCalcCrossterms = msg->numCrossterms;
00802 msg->numCalcExclusions = msg->numExclusions;
00803 }
00804
00805
00806 if(!simParameters->comMove) {
00807 //to remove the center of mass motion from a molecule.
00808 //first calculate the values on every input proc, then reduce.
00809 //For more info, refer to WorkDistrib::remove_com_motion
00810 //-Chao Mei
00811 (msg->totalMV).x = 0.0;
00812 (msg->totalMV).y = 0.0;
00813 (msg->totalMV).z = 0.0;
00814 for (int i=0; i<initAtoms.size(); i++) {
00815 msg->totalMV += initAtoms[i].mass * initAtoms[i].velocity;
00816 }
00817 }
00818
00819 //always send to the master processor (proc 0)
00820 pIO[0].recvMolInfo(msg);
00821 #endif
00822 }
|
|
||||||||||||
|
Definition at line 1533 of file ParallelIOMgr.C. References UniqueSet< Elem >::add(), UniqueSetIter< T >::begin(), ClusterCoorSetIter, ClusterCoorMsg::clusterId, ClusterCoorElem::clusterId, ClusterCoorMsg::dsum, ClusterCoorElem::dsum, UniqueSetIter< T >::end(), UniqueSet< Elem >::find(), recvClusterCoor(), UniqueSet< Elem >::size(), ResizeArray< Elem >::size(), and ClusterCoorMsg::srcRank. 01534 {
01535 #ifdef MEM_OPT_VERSION
01536 coorInstance = midCM->getReadyPositions(seq);
01537
01538 coorInstance->lattice = lat; //record the lattice to use for wrapAll/Water!
01539 int fromAtomID = coorInstance->fromAtomID;
01540 int toAtomID = coorInstance->toAtomID;
01541
01542 //only reference copies
01543 ResizeArray<Vector> data = coorInstance->data;
01544 ResizeArray<FloatVector> fdata = coorInstance->fdata;
01545 //if both data and fdata are not empty, they contain exact values, the only
01546 //difference lies in their precisions. Therefore, we only need to compute
01547 //the higher precision coordinate array. -Chao Mei
01548 int dsize = data.size();
01549 int numMyAtoms = toAtomID-fromAtomID+1;
01550 tmpCoorCon = new Vector[numMyAtoms];
01551 ClusterCoorElem one;
01552 //1. compute wrapped coordinates locally
01553 for(int i=0; i<numMyAtoms; i++){
01554 tmpCoorCon[i] = 0.0;
01555 int cid = clusterID[i];
01556 if(cid<fromAtomID){
01557 //on output procs ahead of me
01558 one.clusterId = cid;
01559 ClusterCoorElem *ret = remoteCoors.find(one);
01560 if(ret==NULL){
01561 if(dsize==0)
01562 one.dsum = fdata[i];
01563 else
01564 one.dsum = data[i];
01565
01566 remoteCoors.add(one);
01567 }else{
01568 if(dsize==0)
01569 ret->dsum += fdata[i];
01570 else
01571 ret->dsum += data[i];
01572 }
01573 }else{
01574 if(dsize==0)
01575 tmpCoorCon[cid-fromAtomID] += fdata[i];
01576 else
01577 tmpCoorCon[cid-fromAtomID] += data[i];
01578 }
01579 }
01580
01581 //2. Prepare to send msgs to remote output procs to reduce coordinates
01582 //values of a cluster
01583 CmiAssert(numRemoteClusters == remoteCoors.size());
01584 numCSMAck = 0; //set to 0 to prepare recving the final coor update
01585 CProxy_ParallelIOMgr pIO(thisgroup);
01586 ClusterCoorSetIter iter(remoteCoors);
01587 for(iter=iter.begin(); iter!=iter.end(); iter++){
01588 ClusterCoorMsg *msg = new ClusterCoorMsg;
01589 msg->srcRank = myOutputRank;
01590 msg->clusterId = iter->clusterId;
01591 msg->dsum = iter->dsum;
01592 int dstRank = atomRankOnOutput(iter->clusterId);
01593 pIO[outputProcArray[dstRank]].recvClusterCoor(msg);
01594 }
01595
01596 //Just send a local NULL msg to indicate the local wrapping
01597 //coordinates has finished.
01598 recvClusterCoor(NULL);
01599 #endif
01600 }
|
|
|
Definition at line 358 of file ParallelIOMgr.h. Referenced by sendAtomsToHomePatchProcs(). |
|
|
Definition at line 356 of file ParallelIOMgr.h. Referenced by ackAtomsToHomePatchProcs(), ParallelIOMgr(), and sendAtomsToHomePatchProcs(). |
1.3.9.1