589 |
|
MPI_Bcast(&molToProcMap[0], nGlobalMols, MPI_INT, 0, MPI_COMM_WORLD); |
590 |
|
} |
591 |
|
|
592 |
– |
cerr << "molToProcMap:\n"; |
593 |
– |
for (int i = 0; i < molToProcMap.size(); i++) { |
594 |
– |
cerr << "m = " << i << " mtpr[m] = " << molToProcMap[i] <<"\n"; |
595 |
– |
} |
596 |
– |
|
592 |
|
info->setMolToProcMap(molToProcMap); |
593 |
|
sprintf(checkPointMsg, |
594 |
|
"Successfully divided the molecules among the processors.\n"); |
609 |
|
#endif |
610 |
|
|
611 |
|
stampId = info->getMoleculeStampId(i); |
612 |
< |
Molecule * mol = molCreator.createMolecule(info->getForceField(), info->getMoleculeStamp(stampId), |
613 |
< |
stampId, i, info->getLocalIndexManager()); |
612 |
> |
Molecule * mol = molCreator.createMolecule(info->getForceField(), |
613 |
> |
info->getMoleculeStamp(stampId), |
614 |
> |
stampId, i, |
615 |
> |
info->getLocalIndexManager()); |
616 |
|
|
617 |
|
info->addMolecule(mol); |
618 |
|
|
639 |
|
int beginRigidBodyIndex; |
640 |
|
int beginCutoffGroupIndex; |
641 |
|
int nGlobalAtoms = info->getNGlobalAtoms(); |
645 |
– |
|
646 |
– |
/**@todo fixme */ |
647 |
– |
#ifndef IS_MPI |
648 |
– |
|
649 |
– |
beginAtomIndex = 0; |
650 |
– |
beginRigidBodyIndex = 0; |
651 |
– |
beginCutoffGroupIndex = 0; |
652 |
– |
|
653 |
– |
#else |
654 |
– |
|
655 |
– |
int nproc; |
656 |
– |
int myNode; |
657 |
– |
|
658 |
– |
myNode = worldRank; |
659 |
– |
MPI_Comm_size(MPI_COMM_WORLD, &nproc); |
660 |
– |
|
661 |
– |
std::vector < int > tmpAtomsInProc(nproc, 0); |
662 |
– |
std::vector < int > tmpRigidBodiesInProc(nproc, 0); |
663 |
– |
std::vector < int > tmpCutoffGroupsInProc(nproc, 0); |
664 |
– |
std::vector < int > NumAtomsInProc(nproc, 0); |
665 |
– |
std::vector < int > NumRigidBodiesInProc(nproc, 0); |
666 |
– |
std::vector < int > NumCutoffGroupsInProc(nproc, 0); |
667 |
– |
|
668 |
– |
tmpAtomsInProc[myNode] = info->getNAtoms(); |
669 |
– |
tmpRigidBodiesInProc[myNode] = info->getNRigidBodies(); |
670 |
– |
tmpCutoffGroupsInProc[myNode] = info->getNCutoffGroups(); |
642 |
|
|
672 |
– |
//do MPI_ALLREDUCE to exchange the total number of atoms, rigidbodies and cutoff groups |
673 |
– |
MPI_Allreduce(&tmpAtomsInProc[0], &NumAtomsInProc[0], nproc, MPI_INT, |
674 |
– |
MPI_SUM, MPI_COMM_WORLD); |
675 |
– |
MPI_Allreduce(&tmpRigidBodiesInProc[0], &NumRigidBodiesInProc[0], nproc, |
676 |
– |
MPI_INT, MPI_SUM, MPI_COMM_WORLD); |
677 |
– |
MPI_Allreduce(&tmpCutoffGroupsInProc[0], &NumCutoffGroupsInProc[0], nproc, |
678 |
– |
MPI_INT, MPI_SUM, MPI_COMM_WORLD); |
679 |
– |
|
643 |
|
beginAtomIndex = 0; |
644 |
|
beginRigidBodyIndex = 0; |
645 |
|
beginCutoffGroupIndex = 0; |
646 |
< |
|
647 |
< |
for(int i = 0; i < myNode; i++) { |
685 |
< |
beginAtomIndex += NumAtomsInProc[i]; |
686 |
< |
beginRigidBodyIndex += NumRigidBodiesInProc[i]; |
687 |
< |
beginCutoffGroupIndex += NumCutoffGroupsInProc[i]; |
688 |
< |
} |
689 |
< |
|
690 |
< |
#endif |
691 |
< |
|
692 |
< |
//rigidbody's index begins right after atom's |
693 |
< |
beginRigidBodyIndex += info->getNGlobalAtoms(); |
694 |
< |
|
695 |
< |
for(mol = info->beginMolecule(mi); mol != NULL; |
696 |
< |
mol = info->nextMolecule(mi)) { |
646 |
> |
|
647 |
> |
for(int i = 0; i < info->getNGlobalMolecules(); i++) { |
648 |
|
|
649 |
< |
//local index(index in DataStorge) of atom is important |
650 |
< |
for(atom = mol->beginAtom(ai); atom != NULL; atom = mol->nextAtom(ai)) { |
651 |
< |
atom->setGlobalIndex(beginAtomIndex++); |
649 |
> |
#ifdef IS_MPI |
650 |
> |
if (info->getMolToProc(i) == worldRank) { |
651 |
> |
#endif |
652 |
> |
// stuff to do if I own this molecule |
653 |
> |
mol = info->getMoleculeByGlobalIndex(i); |
654 |
> |
|
655 |
> |
//local index(index in DataStorge) of atom is important |
656 |
> |
for(atom = mol->beginAtom(ai); atom != NULL; atom = mol->nextAtom(ai)) { |
657 |
> |
atom->setGlobalIndex(beginAtomIndex++); |
658 |
> |
} |
659 |
> |
|
660 |
> |
for(rb = mol->beginRigidBody(ri); rb != NULL; |
661 |
> |
rb = mol->nextRigidBody(ri)) { |
662 |
> |
rb->setGlobalIndex(beginRigidBodyIndex++); |
663 |
> |
} |
664 |
> |
|
665 |
> |
//local index of cutoff group is trivial, it only depends on |
666 |
> |
//the order of travesing |
667 |
> |
for(cg = mol->beginCutoffGroup(ci); cg != NULL; |
668 |
> |
cg = mol->nextCutoffGroup(ci)) { |
669 |
> |
cg->setGlobalIndex(beginCutoffGroupIndex++); |
670 |
> |
} |
671 |
> |
|
672 |
> |
#ifdef IS_MPI |
673 |
> |
} else { |
674 |
> |
|
675 |
> |
// stuff to do if I don't own this molecule |
676 |
> |
|
677 |
> |
int stampId = info->getMoleculeStampId(i); |
678 |
> |
MoleculeStamp* stamp = info->getMoleculeStamp(stampId); |
679 |
> |
|
680 |
> |
beginAtomIndex += stamp->getNAtoms(); |
681 |
> |
beginRigidBodyIndex += stamp->getNRigidBodies(); |
682 |
> |
beginCutoffGroupIndex += stamp->getNCutoffGroups() + stamp->getNFreeAtoms(); |
683 |
|
} |
684 |
< |
|
685 |
< |
for(rb = mol->beginRigidBody(ri); rb != NULL; |
686 |
< |
rb = mol->nextRigidBody(ri)) { |
687 |
< |
rb->setGlobalIndex(beginRigidBodyIndex++); |
706 |
< |
} |
707 |
< |
|
708 |
< |
//local index of cutoff group is trivial, it only depends on the order of travesing |
709 |
< |
for(cg = mol->beginCutoffGroup(ci); cg != NULL; |
710 |
< |
cg = mol->nextCutoffGroup(ci)) { |
711 |
< |
cg->setGlobalIndex(beginCutoffGroupIndex++); |
712 |
< |
} |
713 |
< |
} |
714 |
< |
|
684 |
> |
#endif |
685 |
> |
|
686 |
> |
} //end for(int i=0) |
687 |
> |
|
688 |
|
//fill globalGroupMembership |
689 |
< |
std::vector<int> globalGroupMembership(info->getNGlobalAtoms(), -1); |
689 |
> |
std::vector<int> globalGroupMembership(info->getNGlobalAtoms(), 0); |
690 |
|
for(mol = info->beginMolecule(mi); mol != NULL; mol = info->nextMolecule(mi)) { |
691 |
|
for (cg = mol->beginCutoffGroup(ci); cg != NULL; cg = mol->nextCutoffGroup(ci)) { |
692 |
|
|
705 |
|
// docs said we could. |
706 |
|
std::vector<int> tmpGroupMembership(info->getNGlobalAtoms(), 0); |
707 |
|
MPI_Allreduce(&globalGroupMembership[0], &tmpGroupMembership[0], nGlobalAtoms, |
708 |
< |
MPI_INT, MPI_MAX, MPI_COMM_WORLD); |
708 |
> |
MPI_INT, MPI_SUM, MPI_COMM_WORLD); |
709 |
|
info->setGlobalGroupMembership(tmpGroupMembership); |
737 |
– |
|
738 |
– |
cerr << "ggm:\n"; |
739 |
– |
for (int i = 0; i < tmpGroupMembership.size(); i++) |
740 |
– |
cerr << "i = " << i << "\t ggm(i) = " << tmpGroupMembership[i] << "\n"; |
741 |
– |
|
710 |
|
#else |
711 |
|
info->setGlobalGroupMembership(globalGroupMembership); |
712 |
|
#endif |
766 |
|
globalIO++; |
767 |
|
} |
768 |
|
} |
801 |
– |
cerr << "ioi2io:\n"; |
802 |
– |
for (int i = 0; i < IOIndexToIntegrableObject.size(); i++) { |
803 |
– |
if (IOIndexToIntegrableObject[i] != NULL) { |
804 |
– |
cerr << "i = " << i << "globalIOindex = " << IOIndexToIntegrableObject[i]->getGlobalIntegrableObjectIndex() << "\n"; |
805 |
– |
} |
806 |
– |
} |
769 |
|
|
770 |
|
info->setIOIndexToIntegrableObject(IOIndexToIntegrableObject); |
771 |
|
|