#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 1321 of file ParallelIOMgr.C. References sendAtomsThread. 01322 {
01323 --numAcksOutstanding;
01324 if ( sendAtomsThread ) {
01325 CthAwaken(sendAtomsThread);
01326 sendAtomsThread = 0;
01327 }
01328 }
|
|
|
Definition at line 1021 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(). 01021 {
01022 #ifdef MEM_OPT_VERSION
01023 //only the rank 0 in the SMP node update the Molecule object
01024 if(CmiMyRank()) {
01025 delete msg;
01026 return;
01027 }
01028 molecule->numFixedRigidBonds = msg->numFixedRigidBonds;
01029 molecule->numFixedGroups = msg->numFixedGroups;
01030 delete msg;
01031
01032 if(!CkMyPe()) {
01033 iout << iINFO << "****************************\n";
01034 iout << iINFO << "STRUCTURE SUMMARY:\n";
01035 iout << iINFO << molecule->numAtoms << " ATOMS\n";
01036 iout << iINFO << molecule->numBonds << " BONDS\n";
01037 iout << iINFO << molecule->numAngles << " ANGLES\n";
01038 iout << iINFO << molecule->numDihedrals << " DIHEDRALS\n";
01039 iout << iINFO << molecule->numImpropers << " IMPROPERS\n";
01040 iout << iINFO << molecule->numCrossterms << " CROSSTERMS\n";
01041 iout << iINFO << molecule->numExclusions << " EXCLUSIONS\n";
01042
01043 //****** BEGIN CHARMM/XPLOR type changes
01044 if ((molecule->numMultipleDihedrals) && (simParameters->paraTypeXplorOn)){
01045 iout << iINFO << molecule->numMultipleDihedrals
01046 << " DIHEDRALS WITH MULTIPLE PERIODICITY (BASED ON PSF FILE)\n";
01047 }
01048 if ((molecule->numMultipleDihedrals) && (simParameters->paraTypeCharmmOn)){
01049 iout << iINFO << molecule->numMultipleDihedrals
01050 << " DIHEDRALS WITH MULTIPLE PERIODICITY IGNORED (BASED ON PSF FILE) \n";
01051 iout << iINFO
01052 << " CHARMM MULTIPLICITIES BASED ON PARAMETER FILE INFO! \n";
01053 }
01054 //****** END CHARMM/XPLOR type changes
01055
01056 if (molecule->numMultipleImpropers){
01057 iout << iINFO << molecule->numMultipleImpropers
01058 << " IMPROPERS WITH MULTIPLE PERIODICITY\n";
01059 }
01060
01061 if (simParameters->fixedAtomsOn)
01062 iout << iINFO << molecule->numFixedAtoms << " FIXED ATOMS\n";
01063
01064
01065 if (simParameters->rigidBonds)
01066 iout << iINFO << molecule->numRigidBonds << " RIGID BONDS\n";
01067
01068 if (simParameters->fixedAtomsOn && simParameters->rigidBonds)
01069 iout << iINFO << molecule->numFixedRigidBonds <<
01070 " RIGID BONDS BETWEEN FIXED ATOMS\n";
01071
01072 iout << iINFO << molecule->num_deg_freedom(1)
01073 << " DEGREES OF FREEDOM\n";
01074
01075 iout << iINFO << molecule->numHydrogenGroups << " HYDROGEN GROUPS\n";
01076 iout << iINFO << molecule->maxHydrogenGroupSize
01077 << " ATOMS IN LARGEST HYDROGEN GROUP\n";
01078 iout << iINFO << molecule->numMigrationGroups << " MIGRATION GROUPS\n";
01079 iout << iINFO << molecule->maxMigrationGroupSize
01080 << " ATOMS IN LARGEST MIGRATION GROUP\n";
01081 if (simParameters->fixedAtomsOn)
01082 {
01083 iout << iINFO << molecule->numFixedGroups <<
01084 " HYDROGEN GROUPS WITH ALL ATOMS FIXED\n";
01085 }
01086
01087 iout << iINFO << "TOTAL MASS = " << totalMass << " amu\n";
01088 iout << iINFO << "TOTAL CHARGE = " << totalCharge << " e\n";
01089
01090 BigReal volume = simParameters->lattice.volume();
01091 if ( volume ) {
01092 iout << iINFO << "MASS DENSITY = "
01093 << ((totalMass/volume) / 0.6022) << " g/cm^3\n";
01094 iout << iINFO << "ATOM DENSITY = "
01095 << (molecule->numAtoms/volume) << " atoms/A^3\n";
01096 }
01097
01098 iout << iINFO << "*****************************\n";
01099 iout << endi;
01100 fflush(stdout);
01101 }
01102 #endif
01103 }
|
|
|
|
Definition at line 1105 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(). 01106 {
01107 if(myInputRank==-1) return;
01108
01109 PatchMap *patchMap = PatchMap::Object();
01110 int numPatches = patchMap->numPatches();
01111
01112 patchMap->initTmpPatchAtomsList();
01113
01114 //each list contains the atom index to the initAtoms
01115 vector<int> *eachPatchAtomList = patchMap->getTmpPatchAtomsList();
01116
01117 CProxy_PatchMgr pm(CkpvAccess(BOCclass_group).patchMgr);
01118 PatchMgr *patchMgr = pm.ckLocalBranch();
01119
01120 int pid=0;
01121 const Lattice lattice = simParameters->lattice;
01122 for(int i=0; i<initAtoms.size(); i++) {
01123 InputAtom *atom = &(initAtoms[i]);
01124 if(!atom->isValid) continue;
01125 if(atom->isMP) {
01126 pid = patchMap->assignToPatch(atom->position, lattice);
01127 }
01128 eachPatchAtomList[pid].push_back(i);
01129 }
01130
01131 CProxy_ParallelIOMgr pIO(thisgroup);
01132
01133 int patchCnt = 0;
01134 for(int i=0; i<numPatches; i++) {
01135 int cursize = eachPatchAtomList[i].size();
01136 if(cursize>0) patchCnt++;
01137 }
01138
01139 AtomsCntPerPatchMsg *msg = NULL;
01140 if(simParameters->fixedAtomsOn) {
01141 msg = new (patchCnt, patchCnt, patchCnt, 0)AtomsCntPerPatchMsg;
01142 } else {
01143 msg = new (patchCnt, patchCnt, 0, 0)AtomsCntPerPatchMsg;
01144 }
01145
01146 msg->length = patchCnt;
01147 patchCnt = 0;
01148 for(int i=0; i<numPatches; i++) {
01149 int cursize = eachPatchAtomList[i].size();
01150 if(cursize>0) {
01151 if ( cursize > USHRT_MAX ) {
01152 char errstr[512];
01153 sprintf(errstr, "Patch %d exceeds %d atoms.", i, USHRT_MAX);
01154 NAMD_die(errstr);
01155 }
01156 msg->pidList[patchCnt] = i;
01157 msg->atomsCntList[patchCnt] = cursize;
01158 patchCnt++;
01159 }
01160 }
01161
01162 if(simParameters->fixedAtomsOn) {
01163 patchCnt = 0;
01164 for(int i=0; i<numPatches; i++) {
01165 int cursize = eachPatchAtomList[i].size();
01166 if(cursize>0) {
01167 int fixedCnt = 0;
01168 for(int j=0; j<cursize; j++) {
01169 int aid = eachPatchAtomList[i][j];
01170 //atomFixed is either 0 or 1
01171 fixedCnt += initAtoms[aid].atomFixed;
01172 }
01173 msg->fixedAtomsCntList[patchCnt] = fixedCnt;
01174 patchCnt++;
01175 }
01176 }
01177 }
01178
01179 pIO[0].recvAtomsCntPerPatch(msg);
01180
01181 }
|
|
|
Definition at line 1394 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. 01395 {
01396 #ifdef MEM_OPT_VERSION
01397
01398 int assignedPids = PatchMap::Object()->numPatchesOnNode(CkMyPe());
01399 int numPids = hpIDList.size();
01400 if(numPids==0){
01401 //this node actually contains no homepatches
01402 if(assignedPids == 0) return;
01403
01404 //Entering the rare condition that all the homepatches this node has
01405 //are empty so that "recvAtomsToHomePatchProcs" is never called!
01406 //But we still need to create those empty homepatches!
01407 CmiAssert(isOKToRecvHPAtoms == false);
01408 PatchMap *patchMap = PatchMap::Object();
01409 CProxy_PatchMgr pm(CkpvAccess(BOCclass_group).patchMgr);
01410 PatchMgr *patchMgr = pm.ckLocalBranch();
01411 for(int i=0; i<patchMap->numPatches(); i++) {
01412 if(patchMap->node(i)==CkMyPe()) {
01413 FullAtomList emptyone;
01414 patchMgr->createHomePatch(i, emptyone);
01415 }
01416 }
01417 return;
01418 }
01419
01420 CProxy_PatchMgr pm(CkpvAccess(BOCclass_group).patchMgr);
01421 PatchMgr *patchMgr = pm.ckLocalBranch();
01422
01423 //go through the home patch list
01424 for(int i=0; i<numPids; i++) {
01425 int pid = hpIDList[i];
01426
01427 //re-sort the atom list of this patch
01428 std::sort(hpAtomsList[i].begin(), hpAtomsList[i].end());
01429 Node::Object()->workDistrib->fillAtomListForOnePatch(pid, hpAtomsList[i]);
01430 patchMgr->createHomePatch(pid, hpAtomsList[i]);
01431 }
01432
01433 hpIDList.clear();
01434 delete [] hpAtomsList;
01435
01436 hpAtomsList = NULL;
01437 #endif
01438 }
|
|
||||||||||||
|
Definition at line 1591 of file ParallelIOMgr.C. 01592 {
01593 #ifdef MEM_OPT_VERSION
01594 double iotime = CmiWallTimer();
01595 midCM->disposeForces(seq);
01596 iotime = CmiWallTimer()-iotime+prevT;
01597
01598 #if OUTPUT_SINGLE_FILE
01599 //Token-based file output
01600 if(myOutputRank==getMyOutputGroupHighestRank()) {
01601 //notify the CollectionMaster to start the next round
01602 CProxy_CollectionMaster cm(mainMaster);
01603 cm.startNextRoundOutputForce(iotime);
01604 } else {
01605 CProxy_ParallelIOMgr io(thisgroup);
01606 io[outputProcArray[myOutputRank+1]].disposeForces(seq, iotime);
01607 }
01608 #else
01609 //notify the CollectionMaster to start the next round
01610 CProxy_CollectionMaster cm(mainMaster);
01611 cm.startNextRoundOutputForce(iotime);
01612 #endif
01613
01614 #endif
01615 }
|
|
||||||||||||
|
Definition at line 1539 of file ParallelIOMgr.C. Referenced by CollectionMaster::wrapCoorFinished(). 01540 {
01541 #ifdef MEM_OPT_VERSION
01542 double iotime = CmiWallTimer();
01543 midCM->disposePositions(seq);
01544 iotime = CmiWallTimer()-iotime+prevT;
01545
01546 #if OUTPUT_SINGLE_FILE
01547 //Token-based file output
01548 if(myOutputRank == getMyOutputGroupHighestRank()) {
01549 //notify the CollectionMaster to start the next round
01550 CProxy_CollectionMaster cm(mainMaster);
01551 cm.startNextRoundOutputPos(iotime);
01552 } else {
01553 CProxy_ParallelIOMgr io(thisgroup);
01554 io[outputProcArray[myOutputRank+1]].disposePositions(seq, iotime);
01555 }
01556 #else
01557 //notify the CollectionMaster to start the next round
01558 CProxy_CollectionMaster cm(mainMaster);
01559 cm.startNextRoundOutputPos(iotime);
01560 #endif
01561
01562 #endif
01563 }
|
|
||||||||||||
|
Definition at line 1565 of file ParallelIOMgr.C. 01566 {
01567 #ifdef MEM_OPT_VERSION
01568 double iotime = CmiWallTimer();
01569 midCM->disposeVelocities(seq);
01570 iotime = CmiWallTimer()-iotime+prevT;
01571
01572 #if OUTPUT_SINGLE_FILE
01573 //Token-based file output
01574 if(myOutputRank==getMyOutputGroupHighestRank()) {
01575 //notify the CollectionMaster to start the next round
01576 CProxy_CollectionMaster cm(mainMaster);
01577 cm.startNextRoundOutputVel(iotime);
01578 } else {
01579 CProxy_ParallelIOMgr io(thisgroup);
01580 io[outputProcArray[myOutputRank+1]].disposeVelocities(seq, iotime);
01581 }
01582 #else
01583 //notify the CollectionMaster to start the next round
01584 CProxy_CollectionMaster cm(mainMaster);
01585 cm.startNextRoundOutputVel(iotime);
01586 #endif
01587
01588 #endif
01589 }
|
|
|
Definition at line 1440 of file ParallelIOMgr.C. References SimParameters::freeEnergyOn. 01441 {
01442 #ifdef MEM_OPT_VERSION
01443 molecule->delAtomNames();
01444 molecule->delChargeSpace();
01445
01446 //???TODO NOT SURE WHETHER freeEnergyOn is support in MEM_OPT_VERSION
01447 //-CHAOMEI
01448 if(!CkMyPe() && !simParameters->freeEnergyOn)
01449 molecule->delMassSpace();
01450
01451 molecule->delFixedAtoms();
01452 #endif
01453 }
|
|
|
Definition at line 370 of file ParallelIOMgr.h. 00370 { 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(), 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 for(int i=0; i<numInputProcs; ++i) {
00107 inputProcArray[i] = WorkDistrib::peDiffuseOrdering[(1+numOutputProcs+i)%CkNumPes()];
00108 }
00109 std::sort(inputProcArray, inputProcArray+numInputProcs);
00110 for(int i=0; i<numInputProcs; ++i) {
00111 if ( CkMyPe() == inputProcArray[i] ) {
00112 if ( myInputRank != -1 ) NAMD_bug("Duplicate input proc");
00113 myInputRank = i;
00114 }
00115 }
00116
00117 if(!CkMyPe()) {
00118 iout << iINFO << "INPUT PROC LOCATIONS:";
00119 int i;
00120 for ( i=0; i<numInputProcs && i < 10; ++i ) {
00121 iout << " " << inputProcArray[i];
00122 }
00123 if ( i<numInputProcs ) iout << " ... " << inputProcArray[numInputProcs-1];
00124 iout << "\n" << endi;
00125 }
00126 }
00127
00128 if(myInputRank!=-1) {
00129 //NOTE: this could further be optimized by pre-allocate the memory
00130 //for incoming atoms --Chao Mei
00131 int numMyAtoms = numInitMyAtomsOnInput();
00132 initAtoms.resize(numMyAtoms+100); // extra space for orphan hydrogens
00133 initAtoms.resize(numMyAtoms);
00134 tmpRecvAtoms.resize(0);
00135 } else {
00136 initAtoms.resize(0);
00137 tmpRecvAtoms.resize(0);
00138 }
00139 hpIDList.resize(0);
00140
00141 //build outputProcArray
00142 //spread the output processors across all the processors
00143 {
00144 outputProcArray = new int[numOutputProcs];
00145 outputProcFlags = new char[CkNumPes()];
00146 myOutputRank = -1;
00147 for(int i=0; i<numOutputProcs; ++i) {
00148 outputProcArray[i] = WorkDistrib::peDiffuseOrdering[(1+i)%CkNumPes()];
00149 }
00150 std::sort(outputProcArray, outputProcArray+numOutputProcs);
00151 for(int i=0; i<CkNumPes(); ++i) {
00152 outputProcFlags[i] = 0;
00153 }
00154 for(int i=0; i<numOutputProcs; ++i) {
00155 outputProcFlags[outputProcArray[i]] = 1;
00156 if ( CkMyPe() == outputProcArray[i] ) {
00157 if ( myOutputRank != -1 ) NAMD_bug("Duplicate output proc");
00158 myOutputRank = i;
00159 }
00160 }
00161
00162 if(!CkMyPe()) {
00163 iout << iINFO << "OUTPUT PROC LOCATIONS:";
00164 int i;
00165 for ( i=0; i<numOutputProcs && i < 10; ++i ) {
00166 iout << " " << outputProcArray[i];
00167 }
00168 if ( i<numOutputProcs ) iout << " ... " << outputProcArray[numOutputProcs-1];
00169 iout << "\n" << endi;
00170 }
00171 }
00172
00173 #ifdef MEM_OPT_VERSION
00174 if(myOutputRank!=-1) {
00175 midCM = new CollectionMidMaster(this);
00176 }
00177 remoteClusters.clear();
00178 csmBuf.resize(0);
00179 remoteCoors.clear();
00180 ccmBuf.resize(0);
00181
00182 mainMaster = CollectionMgr::Object()->getMasterChareID();
00183 #endif
00184 }
|
|
|
Definition at line 515 of file ParallelIOMgr.C. References ClusterSizeMsg::atomsCnt, ClusterSizeMsg::clusterId, recvFinalClusterSize(), ResizeArray< Elem >::resize(), ResizeArray< Elem >::size(), ClusterSizeMsg::srcRank, SimParameters::wrapAll, and SimParameters::wrapWater. 00516 {
00517 if(myOutputRank==-1) return;
00518 if(!(simParameters->wrapAll || simParameters->wrapWater)) return;
00519
00520 int fromIdx, toIdx; //atoms' range
00521 getMyAtomsRangeOnOutput(fromIdx,toIdx);
00522
00523 //calculated the final cluster size
00524 for(int i=0; i<csmBuf.size(); i++) {
00525 ClusterSizeMsg *msg = csmBuf[i];
00526 int lidx = msg->clusterId - fromIdx;
00527 clusterSize[lidx] += msg->atomsCnt;
00528 }
00529
00530 CProxy_ParallelIOMgr pIO(thisgroup);
00531 for(int i=0; i<csmBuf.size(); i++) {
00532 ClusterSizeMsg *msg = csmBuf[i];
00533 int lidx = msg->clusterId - fromIdx;
00534 msg->atomsCnt = clusterSize[lidx];
00535 pIO[outputProcArray[msg->srcRank]].recvFinalClusterSize(msg);
00536 }
00537 numRemoteReqs = csmBuf.size();
00538 csmBuf.resize(0);
00539
00540 //There's a possible msg race problem here that recvFinalClusterSize
00541 //executes before integrateClusterSize because other proc finishes faster
00542 //in calculating the cluster size. The recvFinalClusterSize should be
00543 //executed after integrateClusterSize. To avoid this, a self message is
00544 //sent to participate the reduction.
00545 if(numRemoteClusters!=0){
00546 recvFinalClusterSize(NULL);
00547 }else{
00548 //this output proc already has the final cluster size for each atom
00549 int numMyAtoms = toIdx-fromIdx+1;
00550 for(int i=0; i<numMyAtoms; i++) {
00551 int lidx = clusterID[i]-fromIdx;
00552 clusterSize[i] = clusterSize[lidx];
00553 }
00554
00555 #if 0 //write out cluster debug info
00556 char fname[128];
00557 sprintf(fname, "cluster.par.%d", CkMyPe());
00558 FILE *ofp = fopen(fname, "w");
00559 for(int i=0; i<numMyAtoms; i++) {
00560 fprintf(ofp, "%d: %d: %d\n", i+fromIdx, clusterID[i], clusterSize[i]);
00561 }
00562 fclose(ofp);
00563 #endif
00564 }
00565 }
|
|
|
Definition at line 674 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(). 00675 {
00676 if(myInputRank==-1) return;
00677
00678 for(int i=0; i<tmpRecvAtoms.size(); i++) {
00679 tmpRecvAtoms[i].isValid = true;
00680 initAtoms.add(tmpRecvAtoms[i]);
00681 }
00682 tmpRecvAtoms.clear();
00683
00684 //sort atom list based on hydrogenList value
00685 std::sort(initAtoms.begin(), initAtoms.end());
00686
00687 //now compute the counters inside Molecule such as numFixedRigidBonds
00688 //which is based on the hydrogen group info
00689
00690 int numFixedRigidBonds = 0;
00691 if(molecule->numRigidBonds){
00692 int parentIsFixed = 0;
00693 for(int i=0; i<initAtoms.size(); i++) {
00694 InputAtom *one = &(initAtoms[i]);
00695 if(!one->isValid) continue;
00696 if(one->isGP) {
00697 parentIsFixed = one->atomFixed;
00698 InputAtom *a1 = &(initAtoms[i+1]);
00699 InputAtom *a2 = &(initAtoms[i+2]);
00700 if((one->rigidBondLength>0.0) &&
00701 a1->atomFixed && a2->atomFixed) {
00702 numFixedRigidBonds++;
00703 }
00704 }else{
00705 if((one->rigidBondLength>0.0) &&
00706 one->atomFixed && parentIsFixed) {
00707 numFixedRigidBonds++;
00708 }
00709 }
00710 }
00711 }
00712
00713 int numFixedGroups = 0;
00714 if(molecule->numFixedAtoms){
00715 for(int i=0; i<initAtoms.size();) {
00716 InputAtom *one = &(initAtoms[i]);
00717 if(!one->isValid){
00718 i++;
00719 continue;
00720 }
00721 if(one->isGP) {
00722 int allFixed = 1;
00723 for(int j=0; j<one->hydrogenGroupSize; j++){
00724 InputAtom *a1 = &(initAtoms[i+j]);
00725 allFixed = allFixed & a1->atomFixed;
00726 if(!allFixed) break;
00727 }
00728 if(allFixed) numFixedGroups++;
00729 i += one->hydrogenGroupSize;
00730 }
00731 }
00732 }
00733
00734 CProxy_ParallelIOMgr pIO(thisgroup);
00735 HydroBasedMsg *msg = new HydroBasedMsg;
00736 msg->numFixedGroups = numFixedGroups;
00737 msg->numFixedRigidBonds = numFixedRigidBonds;
00738 pIO[0].recvHydroBasedCounter(msg);
00739 }
|
|
|
Definition at line 186 of file ParallelIOMgr.C. 00186 {
00187 return outputProcFlags[pe];
00188 }
|
|
|
Definition at line 614 of file ParallelIOMgr.C. References ResizeArray< Elem >::add(), AtomIDList, MoveInputAtomsMsg::atomList, ResizeArray< Elem >::begin(), ResizeArray< Elem >::clear(), InputAtomList, MoveInputAtomsMsg::length, and ResizeArray< Elem >::size(). 00615 {
00616 if(myInputRank==-1) return;
00617
00618 //1. first get the list of atoms to be migrated
00619 //which should be few compared with the number of atoms
00620 //initially assigned to this input proc.
00621 AtomIDList toMigrateList; //the list of atoms to be migrated
00622 //the max distance from this processor of atoms to be sent
00623 int maxOffset = 0;
00624 for(int i=0; i<initAtoms.size(); i++) {
00625 //returns the proc id on which atom MPID resides on
00626 int parentRank = atomInitRankOnInput(initAtoms[i].MPID);
00627 if(parentRank != myInputRank) {
00628 toMigrateList.add(i);
00629 initAtoms[i].isValid = false;
00630 int tmp = parentRank - myInputRank;
00631 tmp = tmp>0 ? tmp : -tmp;
00632 if(tmp > maxOffset) maxOffset = tmp;
00633 }
00634 }
00635
00636 //2. prepare atom migration messages
00637 //the messages are indexed as [-maxOffset,..., -1,0,1,..., maxOffset]
00638 //where the "0" is not used at all. It is added for the sake of
00639 //computing the index easily.
00640 InputAtomList *migLists = new InputAtomList[2*maxOffset+1];
00641 for(int i=0; i<toMigrateList.size(); i++) {
00642 int idx = toMigrateList[i];
00643 int parentRank = atomInitRankOnInput(initAtoms[idx].MPID);
00644 //decide which migList to put this atom
00645 int offset = parentRank - myInputRank + maxOffset;
00646 migLists[offset].add(initAtoms[idx]);
00647 }
00648
00649 CProxy_ParallelIOMgr pIO(thisgroup);
00650 for(int i=0; i<2*maxOffset+1; i++) {
00651 int migLen = migLists[i].size();
00652 if(migLen>0) {
00653 MoveInputAtomsMsg *msg = new (migLen, 0)MoveInputAtomsMsg;
00654 msg->length = migLen;
00655 memcpy(msg->atomList, migLists[i].begin(), sizeof(InputAtom)*migLen);
00656 int destRank = i-maxOffset+myInputRank;
00657 pIO[inputProcArray[destRank]].recvAtomsMGrp(msg);
00658 migLists[i].clear();
00659 }
00660 }
00661
00662 toMigrateList.clear();
00663 delete [] migLists;
00664 }
|
|
|
Definition at line 196 of file ParallelIOMgr.C. References j, SimParameters::wrapAll, and SimParameters::wrapWater. 00197 {
00198 #ifdef MEM_OPT_VERSION
00199 if(myInputRank!=-1) {
00200 int myAtomLIdx, myAtomUIdx;
00201 getMyAtomsInitRangeOnInput(myAtomLIdx, myAtomUIdx);
00202
00203 //1. read the file that contains per-atom info such as signature index
00204 molecule->read_binary_atom_info(myAtomLIdx, myAtomUIdx, initAtoms);
00205
00206 //2. read coordinates and velocities of each atom if the velocity file
00207 //exists, otherwise, the velocity of each atom is randomly generated.
00208 //This has to be DONE AFTER THE FIRST STEP as the atom mass is required
00209 //if the velocity is generated randomly.
00210 readCoordinatesAndVelocity();
00211
00212 //3. set every atom's output processor rank, i.e. the dest pe this
00213 //atom will be sent for writing positions and velocities etc.
00214 int oRank=atomRankOnOutput(myAtomLIdx);
00215 for(int i=oRank; i<numOutputProcs; i++) {
00216 int lIdx, uIdx; //indicates the range of atom ids outputProcArray[i] has
00217 getAtomsRangeOnOutput(lIdx, uIdx, i);
00218 if(lIdx > myAtomUIdx) break;
00219 int fid = lIdx>myAtomLIdx?lIdx:myAtomLIdx;
00220 int tid = uIdx>myAtomUIdx?myAtomUIdx:uIdx;
00221 for(int j=fid; j<=tid; j++) initAtoms[j-myAtomLIdx].outputRank = i;
00222 }
00223 }
00224
00225 //read clusters
00226 if(myOutputRank!=-1) {
00227 //only when wrapAll or wrapWater is set, cluster info is required
00228 if(!(simParameters->wrapAll || simParameters->wrapWater)) return;
00229 readInfoForParOutput();
00230 }
00231 #endif
00232 }
|
|
|
Definition at line 1526 of file ParallelIOMgr.C. References CollectVectorVarMsg::seq. 01527 {
01528 #ifdef MEM_OPT_VERSION
01529 int ready = midCM->receiveForces(msg);
01530 if(ready) {
01531 CProxy_CollectionMaster cm(mainMaster);
01532 cm.receiveOutputForceReady(msg->seq);
01533 }
01534 delete msg;
01535 #endif
01536 }
|
|
|
Definition at line 1502 of file ParallelIOMgr.C. References CollectVectorVarMsg::seq. 01503 {
01504 #ifdef MEM_OPT_VERSION
01505 int ready = midCM->receivePositions(msg);
01506 if(ready) {
01507 CProxy_CollectionMaster cm(mainMaster);
01508 cm.receiveOutputPosReady(msg->seq);
01509 }
01510 delete msg;
01511 #endif
01512 }
|
|
|
Definition at line 1514 of file ParallelIOMgr.C. References CollectVectorVarMsg::seq. 01515 {
01516 #ifdef MEM_OPT_VERSION
01517 int ready = midCM->receiveVelocities(msg);
01518 if(ready) {
01519 CProxy_CollectionMaster cm(mainMaster);
01520 cm.receiveOutputVelReady(msg->seq);
01521 }
01522 delete msg;
01523 #endif
01524 }
|
|
|
Definition at line 1183 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. 01184 {
01185 #ifdef MEM_OPT_VERSION
01186 PatchMap *patchMap = PatchMap::Object();
01187 for(int i=0; i<msg->length; i++) {
01188 int pid = msg->pidList[i];
01189 int oldNum = patchMap->numAtoms(pid);
01190 if ( oldNum + msg->atomsCntList[i] > USHRT_MAX ) {
01191 char errstr[512];
01192 sprintf(errstr, "Patch %d exceeds %d atoms.", pid, USHRT_MAX);
01193 NAMD_die(errstr);
01194 }
01195 patchMap->setNumAtoms(pid, oldNum+msg->atomsCntList[i]);
01196 if(simParameters->fixedAtomsOn) {
01197 oldNum = patchMap->numFixedAtoms(pid);
01198 patchMap->setNumFixedAtoms(pid, oldNum+msg->fixedAtomsCntList[i]);
01199 }
01200 }
01201 delete msg;
01202
01203 if(++procsReceived == numInputProcs) {
01204 //print max PATCH info
01205 int maxAtoms = -1;
01206 int maxPatch = -1;
01207 int totalAtoms = 0;
01208 for(int i=0; i<patchMap->numPatches(); i++) {
01209 int cnt = patchMap->numAtoms(i);
01210 totalAtoms += cnt;
01211 if(cnt>maxAtoms) {
01212 maxAtoms = cnt;
01213 maxPatch = i;
01214 }
01215 }
01216 procsReceived = 0;
01217 iout << iINFO << "LARGEST PATCH (" << maxPatch <<
01218 ") HAS " << maxAtoms << " ATOMS\n" << endi;
01219 if ( totalAtoms != Node::Object()->molecule->numAtoms ) {
01220 char errstr[512];
01221 sprintf(errstr, "Incorrect atom count in void ParallelIOMgr::recvAtomsCntPerPatch: %d vs %d", totalAtoms, Node::Object()->molecule->numAtoms);
01222 NAMD_die(errstr);
01223 }
01224 }
01225 #endif
01226 }
|
|
|
Definition at line 666 of file ParallelIOMgr.C. References ResizeArray< Elem >::add(), MoveInputAtomsMsg::atomList, and MoveInputAtomsMsg::length. 00667 {
00668 for(int i=0; i<msg->length; i++) {
00669 tmpRecvAtoms.add((msg->atomList)[i]);
00670 }
00671 delete msg;
00672 }
|
|
|
Definition at line 1330 of file ParallelIOMgr.C. References ResizeArray< Elem >::add(), MovePatchAtomsMsg::allAtoms, MovePatchAtomsMsg::from, j, MovePatchAtomsMsg::patchCnt, MovePatchAtomsMsg::pidList, and MovePatchAtomsMsg::sizeList. 01331 {
01332 CProxy_ParallelIOMgr pIO(thisgroup);
01333 pIO[msg->from].ackAtomsToHomePatchProcs();
01334
01335 if(!isOKToRecvHPAtoms) {
01336 prepareHomePatchAtomList();
01337 isOKToRecvHPAtoms = true;
01338 }
01339
01340 int numRecvPatches = msg->patchCnt;
01341 int aid = 0;
01342 for(int i=0; i<numRecvPatches; i++) {
01343 int pid = msg->pidList[i];
01344 int size = msg->sizeList[i];
01345 int idx = binaryFindHPID(pid);
01346 for(int j=0; j<size; j++, aid++) {
01347 hpAtomsList[idx].add(msg->allAtoms[aid]);
01348 }
01349 }
01350 //CkPrintf("Pe %d recvAtomsToHomePatchProcs for %d patches %d atoms\n",CkMyPe(),numRecvPatches,aid);
01351 delete msg;
01352 }
|
|
|
Definition at line 1692 of file ParallelIOMgr.C. References ResizeArray< Elem >::add(). Referenced by wrapCoor(). 01692 {
01693 //only add the msg from remote procs
01694 if(msg!=NULL) ccmBuf.add(msg);
01695
01696 //include a msg sent by itself
01697 if(++numReqRecved == (numRemoteReqs+1)){
01698 numReqRecved = 0;
01699 integrateClusterCoor();
01700 }
01701 }
|
|
|
Definition at line 507 of file ParallelIOMgr.C. References ResizeArray< Elem >::add(). 00508 {
00509 csmBuf.add(msg); //added to buffer for reuse to send back to src
00510
00511 //update cluster size has to be delayed to integration to prevent
00512 //data racing where the clusterSize has not been created!
00513 }
|
|
|
Definition at line 1764 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. 01764 {
01765 #ifdef MEM_OPT_VERSION
01766 if(msg!=NULL){
01767 //only process the message sent from other procs!
01768 ClusterCoorElem one(msg->clusterId);
01769 ClusterCoorElem *ret = remoteCoors.find(one);
01770 ret->dsum = msg->dsum;
01771 delete msg;
01772 }
01773
01774 if(++numCSMAck == (numRemoteClusters+1)){
01775 //final wrap coor computation
01776 int fromIdx = coorInstance->fromAtomID;
01777 int toIdx = coorInstance->toAtomID;
01778 int numMyAtoms = toIdx-fromIdx+1;
01779 ResizeArray<Vector> &data = coorInstance->data;
01780 ResizeArray<FloatVector> &fdata = coorInstance->fdata;
01781 ClusterCoorElem tmp;
01782 for(int i=0; i<numMyAtoms; i++){
01783 if(!simParameters->wrapAll && !isWater[i]) continue;
01784 int cid = clusterID[i];
01785 int lidx = cid-fromIdx;
01786 if(lidx<0){
01787 //this cid should be inside remoteCoors
01788 tmp.clusterId = cid;
01789 ClusterCoorElem *fone = remoteCoors.find(tmp);
01790 if(data.size()) data[i] += fone->dsum;
01791 if(fdata.size()) fdata[i] = fdata[i] + fone->dsum;
01792 }else{
01793 if(lidx==i){
01794 Lattice *lat = &(coorInstance->lattice);
01795 Vector coni = tmpCoorCon[lidx]/clusterSize[lidx];
01796 tmpCoorCon[lidx] = (simParameters->wrapNearest ?
01797 lat->wrap_nearest_delta(coni) : lat->wrap_delta(coni));
01798 }
01799 if(data.size()) data[i] += tmpCoorCon[lidx];
01800 if(fdata.size()) fdata[i] = fdata[i] + tmpCoorCon[lidx];
01801 }
01802 }
01803
01804 delete [] tmpCoorCon;
01805 tmpCoorCon = NULL;
01806 CProxy_CollectionMaster cm(mainMaster);
01807 cm.wrapCoorFinished();
01808 numCSMAck = 0;
01809 remoteCoors.clear();
01810 }
01811 #endif
01812 }
|
|
|
Definition at line 567 of file ParallelIOMgr.C. References ClusterSizeMsg::atomsCnt, ClusterElem::atomsCnt, UniqueSet< Elem >::clear(), ClusterElem::clusterId, ClusterSizeMsg::clusterId, and UniqueSet< Elem >::find(). Referenced by integrateClusterSize(). 00568 {
00569 //only process the message sent by other procs
00570 if(msg!=NULL) {
00571 //indicating a message from other procs
00572 ClusterElem one(msg->clusterId);
00573 ClusterElem *ret = remoteClusters.find(one);
00574 CmiAssert(ret!=NULL);
00575 ret->atomsCnt = msg->atomsCnt;
00576 }
00577 delete msg;
00578
00579 //include a msg sent by itself for reduction
00580 if(++numCSMAck == (numRemoteClusters+1)) {
00581 //recved all the msgs needed to update the cluster size for each atom finally
00582 int fromIdx, toIdx; //atoms' range
00583 getMyAtomsRangeOnOutput(fromIdx,toIdx);
00584 int numMyAtoms = toIdx-fromIdx+1;
00585 ClusterElem tmp;
00586 for(int i=0; i<numMyAtoms; i++) {
00587 int cid = clusterID[i];
00588 int lidx = cid-fromIdx;
00589 if(lidx<0) {
00590 //this cid should be inside remoteClusters
00591 tmp.clusterId = cid;
00592 ClusterElem *fone = remoteClusters.find(tmp);
00593 clusterSize[i] = fone->atomsCnt;
00594 } else {
00595 clusterSize[i] = clusterSize[lidx];
00596 }
00597 }
00598 numCSMAck = 0;
00599 remoteClusters.clear();
00600
00601 #if 0 //write out cluster debug info
00602 char fname[128];
00603 sprintf(fname, "cluster.par.%d", CkMyPe());
00604 FILE *ofp = fopen(fname, "w");
00605 for(int i=0; i<numMyAtoms; i++) {
00606 fprintf(ofp, "%d: %d: %d\n", i+fromIdx, clusterID[i], clusterSize[i]);
00607 }
00608 fclose(ofp);
00609 #endif
00610
00611 }
00612 }
|
|
|
Definition at line 1008 of file ParallelIOMgr.C. References HydroBasedMsg::numFixedGroups, Molecule::numFixedGroups, HydroBasedMsg::numFixedRigidBonds, and Molecule::numFixedRigidBonds. 01008 {
01009 molecule->numFixedRigidBonds += msg->numFixedRigidBonds;
01010 molecule->numFixedGroups += msg->numFixedGroups;
01011
01012 if(++hydroMsgRecved == numInputProcs){
01013 msg->numFixedRigidBonds = molecule->numFixedRigidBonds;
01014 msg->numFixedGroups = molecule->numFixedGroups;
01015 CProxy_ParallelIOMgr pIO(thisgroup);
01016 pIO.bcastHydroBasedCounter(msg);
01017 hydroMsgRecved = 0;
01018 }else delete msg;
01019 }
|
|
|
|
Definition at line 1233 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. 01234 {
01235 #ifdef MEM_OPT_VERSION
01236 if(myInputRank==-1) return;
01237
01238 if ( sendAtomsThread == 0 ) {
01239 sendAtomsThread = CthCreate((CthVoidFn)call_sendAtomsToHomePatchProcs,this,0);
01240 CthAwaken(sendAtomsThread);
01241 return;
01242 }
01243 sendAtomsThread = 0;
01244 numAcksOutstanding = 0;
01245
01246 PatchMap *patchMap = PatchMap::Object();
01247 int numPatches = patchMap->numPatches();
01248 vector<int> *eachPatchAtomList = patchMap->getTmpPatchAtomsList();
01249
01250 //each element (proc) contains the list of ids of patches which will stay
01251 //on that processor
01252 ResizeArray<int> *procList = new ResizeArray<int>[CkNumPes()];
01253 ResizeArray<int> pesToSend;
01254 for(int i=0; i<numPatches; i++) {
01255 if(eachPatchAtomList[i].size()==0) continue;
01256 int onPE = patchMap->node(i);
01257 if ( procList[onPE].size() == 0 ) pesToSend.add(onPE);
01258 procList[onPE].add(i);
01259 }
01260
01261 Random(CkMyPe()).reorder(pesToSend.begin(),pesToSend.size());
01262 //CkPrintf("Pe %d ParallelIOMgr::sendAtomsToHomePatchProcs sending to %d pes\n",CkMyPe(),pesToSend.size());
01263
01264 //go over every processor to send a message if necessary
01265 //TODO: Optimization for local home patches to save temp memory usage??? -CHAOMEI
01266 CProxy_ParallelIOMgr pIO(thisgroup);
01267 for(int k=0; k<pesToSend.size(); k++) {
01268 const int i = pesToSend[k];
01269 int len = procList[i].size();
01270 if(len==0) continue;
01271
01272 if ( numAcksOutstanding >= 10 ) {
01273 //CkPrintf("Pe %d ParallelIOMgr::sendAtomsToHomePatchProcs suspending at %d of %d pes\n",CkMyPe(),k,pesToSend.size());
01274 //fflush(stdout);
01275 sendAtomsThread = CthSelf();
01276 CthSuspend();
01277 }
01278 ++numAcksOutstanding;
01279
01280 //prepare a message to send
01281 int patchCnt = len;
01282 int totalAtomCnt = 0;
01283 for(int j=0; j<len; j++) {
01284 int pid = procList[i][j];
01285 int atomCnt = eachPatchAtomList[pid].size();
01286 totalAtomCnt += atomCnt;
01287 }
01288
01289 MovePatchAtomsMsg *msg = new (patchCnt, patchCnt, totalAtomCnt, 0)MovePatchAtomsMsg;
01290 msg->from = CkMyPe();
01291 msg->patchCnt = patchCnt;
01292 int atomIdx = 0;
01293 for(int j=0; j<len; j++) {
01294 int pid = procList[i][j];
01295 int atomCnt = eachPatchAtomList[pid].size();
01296 msg->pidList[j] = pid;
01297 msg->sizeList[j] = atomCnt;
01298 for(int k=0; k<atomCnt; k++, atomIdx++) {
01299 int aid = eachPatchAtomList[pid][k];
01300 FullAtom one = initAtoms[aid];
01301 //HACK to re-sort the atom list after receiving the atom list on
01302 //home patch processor -Chao Mei
01303 one.hydVal = initAtoms[aid].hydList;
01304 msg->allAtoms[atomIdx] = one;
01305 }
01306 }
01307 pIO[i].recvAtomsToHomePatchProcs(msg);
01308
01309 procList[i].clear();
01310 }
01311
01312 //clean up to free space
01313 delete [] procList;
01314 patchMap->delTmpPatchAtomsList();
01315
01316 //free the space occupied by the list that contains the input atoms
01317 initAtoms.clear();
01318 #endif
01319 }
|
|
|
Definition at line 741 of file ParallelIOMgr.C. References AtomSignature::angleCnt, AtomSignature::angleSigs, atomSigPool, AtomSignature::bondCnt, AtomSignature::bondSigs, SimParameters::comMove, AtomSignature::crosstermCnt, AtomSignature::crosstermSigs, AtomSignature::dihedralCnt, AtomSignature::dihedralSigs, SimParameters::fixedAtomsForces, 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. 00742 {
00743 #ifdef MEM_OPT_VERSION
00744 if(myInputRank==-1) return;
00745
00746 CProxy_ParallelIOMgr pIO(thisgroup);
00747
00748 MolInfoMsg *msg = new MolInfoMsg;
00749 msg->numBonds = msg->numCalcBonds = 0;
00750 msg->numAngles = msg->numCalcAngles = 0;
00751 msg->numDihedrals = msg->numCalcDihedrals = 0;
00752 msg->numImpropers = msg->numCalcImpropers = 0;
00753 msg->numCrossterms = msg->numCalcCrossterms = 0;
00754 msg->numExclusions = msg->numCalcExclusions = 0;
00755 msg->numRigidBonds = 0;
00756 msg->totalMass = 0.0;
00757 msg->totalCharge = 0.0;
00758
00759 //calculate the tuples this input processor have
00760 AtomSignature *atomSigPool = molecule->atomSigPool;
00761 ExclusionSignature *exclSigPool = molecule->exclSigPool;
00762 for(int i=0; i<initAtoms.size(); i++) {
00763 AtomSignature *thisSig = &atomSigPool[initAtoms[i].sigId];
00764 msg->numBonds += thisSig->bondCnt;
00765 msg->numAngles += thisSig->angleCnt;
00766 msg->numDihedrals += thisSig->dihedralCnt;
00767 msg->numImpropers += thisSig->improperCnt;
00768 msg->numCrossterms += thisSig->crosstermCnt;
00769
00770 ExclusionSignature *exclSig = &exclSigPool[initAtoms[i].exclId];
00771 msg->numExclusions += (exclSig->fullExclCnt + exclSig->modExclCnt);
00772
00773 if(initAtoms[i].rigidBondLength > 0.0) msg->numRigidBonds++;
00774
00775 msg->totalMass += initAtoms[i].mass;
00776 msg->totalCharge += initAtoms[i].charge;
00777 }
00778
00779 //deal with numCalc* which is related with fixed atoms!
00780 if(molecule->numFixedAtoms>0 && ! simParameters->fixedAtomsForces) {
00781 //if there's fixed atoms, calcExclusions needs to be calculated
00782 //Since it's possible the atom inside the this exclusion set is on
00783 //another input processor, we have to resort to the global fixed atoms
00784 //info inside the Molecule object. The number of such accesses should
00785 //be very small! --Chao Mei
00786 int sAId = initAtoms[0].id;
00787 int remoteCnt=0; //stats info
00788 for(int i=0; i<initAtoms.size(); i++) {
00789 //When all the atoms in the set are fixed, the elem (Bond etc.)
00790 //is not counted as a calc*.
00791 int myAId = initAtoms[i].id;
00792 AtomSignature *thisSig = &atomSigPool[initAtoms[i].sigId];
00793 ExclusionSignature *exclSig = &exclSigPool[initAtoms[i].exclId];
00794 if(!initAtoms[i].atomFixed) {
00795 msg->numCalcBonds += thisSig->bondCnt;
00796 msg->numCalcAngles += thisSig->angleCnt;
00797 msg->numCalcDihedrals += thisSig->dihedralCnt;
00798 msg->numCalcImpropers += thisSig->improperCnt;
00799 msg->numCalcCrossterms += thisSig->crosstermCnt;
00800 msg->numCalcExclusions+=(exclSig->fullExclCnt+exclSig->modExclCnt);
00801 continue;
00802 }
00803
00804 //1. Bonds
00805 for(int j=0; j<thisSig->bondCnt; j++) {
00806 TupleSignature *bsig = &(thisSig->bondSigs[j]);
00807 int a1 = myAId + bsig->offset[0];
00808 if(!isAtomFixed(sAId, a1)) msg->numCalcBonds++;
00809 }
00810
00811 //2. Angles
00812 for(int j=0; j<thisSig->angleCnt; j++) {
00813 TupleSignature *bsig = &(thisSig->angleSigs[j]);
00814 int a1 = myAId + bsig->offset[0];
00815 int a2 = myAId + bsig->offset[1];
00816 if(!isAtomFixed(sAId, a1) || !isAtomFixed(sAId, a2))
00817 msg->numCalcAngles++;
00818 }
00819
00820 //3. Dihedrals
00821 for(int j=0; j<thisSig->dihedralCnt; j++) {
00822 TupleSignature *bsig = &(thisSig->dihedralSigs[j]);
00823 int a1 = myAId + bsig->offset[0];
00824 int a2 = myAId + bsig->offset[1];
00825 int a3 = myAId + bsig->offset[2];
00826 if(!isAtomFixed(sAId, a1) ||
00827 !isAtomFixed(sAId, a2) ||
00828 !isAtomFixed(sAId, a3))
00829 msg->numCalcDihedrals++;
00830 }
00831
00832 //4. Impropers
00833 for(int j=0; j<thisSig->improperCnt; j++) {
00834 TupleSignature *bsig = &(thisSig->improperSigs[j]);
00835 int a1 = myAId + bsig->offset[0];
00836 int a2 = myAId + bsig->offset[1];
00837 int a3 = myAId + bsig->offset[2];
00838 if(!isAtomFixed(sAId, a1) ||
00839 !isAtomFixed(sAId, a2) ||
00840 !isAtomFixed(sAId, a3))
00841 msg->numCalcImpropers++;
00842 }
00843
00844 //5. Crossterms
00845 for(int j=0; j<thisSig->crosstermCnt; j++) {
00846 TupleSignature *bsig = &(thisSig->crosstermSigs[j]);
00847 int a1 = myAId + bsig->offset[0];
00848 int a2 = myAId + bsig->offset[1];
00849 int a3 = myAId + bsig->offset[2];
00850 int a4 = myAId + bsig->offset[3];
00851 int a5 = myAId + bsig->offset[4];
00852 int a6 = myAId + bsig->offset[5];
00853 int a7 = myAId + bsig->offset[6];
00854
00855 if(!isAtomFixed(sAId, a1) ||
00856 !isAtomFixed(sAId, a2) ||
00857 !isAtomFixed(sAId, a3) ||
00858 !isAtomFixed(sAId, a4) ||
00859 !isAtomFixed(sAId, a5) ||
00860 !isAtomFixed(sAId, a6) ||
00861 !isAtomFixed(sAId, a7))
00862 msg->numCalcDihedrals++;
00863 }
00864
00865 //6: Exclusions
00866 //this atom is fixed, check atoms in the exclusion set
00867 for(int j=0; j<exclSig->fullExclCnt; j++) {
00868 int thisAId = exclSig->fullOffset[j]+myAId;
00869 if(!isAtomFixed(sAId, thisAId)) msg->numCalcExclusions++;
00870 }
00871 for(int j=0; j<exclSig->modExclCnt; j++) {
00872 int thisAId = exclSig->modOffset[j]+myAId;
00873 if(!isAtomFixed(sAId, thisAId)) msg->numCalcExclusions++;
00874 }
00875 }
00876 #if COLLECT_PERFORMANCE_DATA
00877 printf("Num fixedAtom lookup on proc %d is %d\n", CkMyPe(), numFixedAtomLookup);
00878 #endif
00879 } else {
00880 //no fixed atoms, numCalc* is same with numExclusions
00881 msg->numCalcBonds = msg->numBonds;
00882 msg->numCalcAngles = msg->numAngles;
00883 msg->numCalcDihedrals = msg->numDihedrals;
00884 msg->numCalcImpropers = msg->numImpropers;
00885 msg->numCalcCrossterms = msg->numCrossterms;
00886 msg->numCalcExclusions = msg->numExclusions;
00887 }
00888
00889
00890 if(!simParameters->comMove) {
00891 //to remove the center of mass motion from a molecule.
00892 //first calculate the values on every input proc, then reduce.
00893 //For more info, refer to WorkDistrib::remove_com_motion
00894 //-Chao Mei
00895 (msg->totalMV).x = 0.0;
00896 (msg->totalMV).y = 0.0;
00897 (msg->totalMV).z = 0.0;
00898 for (int i=0; i<initAtoms.size(); i++) {
00899 msg->totalMV += initAtoms[i].mass * initAtoms[i].velocity;
00900 }
00901 }
00902
00903 //always send to the master processor (proc 0)
00904 pIO[0].recvMolInfo(msg);
00905 #endif
00906 }
|
|
||||||||||||
|
Definition at line 1618 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. 01619 {
01620 #ifdef MEM_OPT_VERSION
01621 coorInstance = midCM->getReadyPositions(seq);
01622
01623 coorInstance->lattice = lat; //record the lattice to use for wrapAll/Water!
01624 int fromAtomID = coorInstance->fromAtomID;
01625 int toAtomID = coorInstance->toAtomID;
01626
01627 //only reference copies
01628 ResizeArray<Vector> &data = coorInstance->data;
01629 ResizeArray<FloatVector> &fdata = coorInstance->fdata;
01630 //if both data and fdata are not empty, they contain exact values, the only
01631 //difference lies in their precisions. Therefore, we only need to compute
01632 //the higher precision coordinate array. -Chao Mei
01633 int dsize = data.size();
01634 int numMyAtoms = toAtomID-fromAtomID+1;
01635 tmpCoorCon = new Vector[numMyAtoms];
01636 ClusterCoorElem one;
01637 //1. compute wrapped coordinates locally
01638 for(int i=0; i<numMyAtoms; i++){
01639 tmpCoorCon[i] = 0.0;
01640 int cid = clusterID[i];
01641 if(cid<fromAtomID){
01642 //on output procs ahead of me
01643 one.clusterId = cid;
01644 ClusterCoorElem *ret = remoteCoors.find(one);
01645 if(ret==NULL){
01646 if(dsize==0)
01647 one.dsum = fdata[i];
01648 else
01649 one.dsum = data[i];
01650
01651 remoteCoors.add(one);
01652 }else{
01653 if(dsize==0)
01654 ret->dsum += fdata[i];
01655 else
01656 ret->dsum += data[i];
01657 }
01658 }else{
01659 if(dsize==0)
01660 tmpCoorCon[cid-fromAtomID] += fdata[i];
01661 else
01662 tmpCoorCon[cid-fromAtomID] += data[i];
01663 }
01664 }
01665
01666 //2. Prepare to send msgs to remote output procs to reduce coordinates
01667 //values of a cluster
01668 CmiAssert(numRemoteClusters == remoteCoors.size());
01669 numCSMAck = 0; //set to 0 to prepare recving the final coor update
01670 CProxy_ParallelIOMgr pIO(thisgroup);
01671 ClusterCoorSetIter iter(remoteCoors);
01672 for(iter=iter.begin(); iter!=iter.end(); iter++){
01673 ClusterCoorMsg *msg = new ClusterCoorMsg;
01674 msg->srcRank = myOutputRank;
01675 msg->clusterId = iter->clusterId;
01676 msg->dsum = iter->dsum;
01677 int dstRank = atomRankOnOutput(iter->clusterId);
01678 pIO[outputProcArray[dstRank]].recvClusterCoor(msg);
01679 }
01680
01681 //Just send a local NULL msg to indicate the local wrapping
01682 //coordinates has finished.
01683 recvClusterCoor(NULL);
01684 #endif
01685 }
|
|
|
Definition at line 359 of file ParallelIOMgr.h. Referenced by sendAtomsToHomePatchProcs(). |
|
|
Definition at line 357 of file ParallelIOMgr.h. Referenced by ackAtomsToHomePatchProcs(), ParallelIOMgr(), and sendAtomsToHomePatchProcs(). |
1.3.9.1