• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Aucun tag

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

Révision70d59b6c069f93f404b1f0fe3034cd72b8ad0929 (tree)
l'heure2013-08-05 03:52:28
AuteurMikiya Fujii <mikiya.fujii@gmai...>
CommiterMikiya Fujii

Message de Log

MpiProcess::GetHeadRank() is added. #31814

git-svn-id: https://svn.sourceforge.jp/svnroot/molds/trunk@1453 1136aad2-a195-0410-b898-f5ea1d11b9d8

Change Summary

Modification

--- a/src/base/PrintController.cpp
+++ b/src/base/PrintController.cpp
@@ -41,8 +41,9 @@ PrintController::~PrintController(){
4141
4242 void PrintController::OutputLog(string log) const{
4343 if(this->canOutputLogs){
44+ int mpiHeadRank = MolDS_mpi::MpiProcess::GetInstance()->GetHeadRank();
4445 #ifndef MOLDS_DBG
45- if(MolDS_mpi::MpiProcess::GetInstance()->GetRank()!=0){return;}
46+ if(MolDS_mpi::MpiProcess::GetInstance()->GetRank()!=mpiHeadRank){return;}
4647 #endif
4748 bool endl = false;
4849 string::reverse_iterator iter;
--- a/src/mc/MC.cpp
+++ b/src/mc/MC.cpp
@@ -139,7 +139,7 @@ void MC::DoMC(int totalSteps, int elecState, double temperature, double stepWidt
139139 }
140140
141141 // Broadcast to all processes
142- int root=0;
142+ int root = MolDS_mpi::MpiProcess::GetInstance()->GetHeadRank();
143143 this->molecule->BroadcastConfigurationToAllProcesses(root);
144144 trialMolecule.BroadcastConfigurationToAllProcesses(root);
145145
--- a/src/md/MD.cpp
+++ b/src/md/MD.cpp
@@ -116,7 +116,7 @@ void MD::DoMD(){
116116 this->UpdateMomenta(*this->molecule, matrixForce, dt);
117117
118118 // Broadcast to all processes
119- int root=0;
119+ int root = MolDS_mpi::MpiProcess::GetInstance()->GetHeadRank();
120120 this->molecule->BroadcastPhaseSpacePointToAllProcesses(root);
121121
122122 // output results
--- a/src/mndo/Mndo.cpp
+++ b/src/mndo/Mndo.cpp
@@ -894,10 +894,11 @@ void Mndo::CalcCISMatrix(double** matrixCIS) const{
894894 } // end of k-loop
895895
896896 // communication to collect all matrix data on rank 0
897- if(mpiRank == 0){
897+ int mpiHeadRank = MolDS_mpi::MpiProcess::GetInstance()->GetHeadRank();
898+ if(mpiRank == mpiHeadRank){
898899 // receive the matrix data from other ranks
899900 for(int k=0; k<this->matrixCISdimension; k++){
900- if(k%mpiSize == 0){continue;}
901+ if(k%mpiSize == mpiHeadRank){continue;}
901902 int source = k%mpiSize;
902903 int tag = k;
903904 MolDS_mpi::MpiProcess::GetInstance()->Recv(source, tag, matrixCIS[k], this->matrixCISdimension);
@@ -907,13 +908,13 @@ void Mndo::CalcCISMatrix(double** matrixCIS) const{
907908 // send the matrix data to rank-0
908909 for(int k=0; k<this->matrixCISdimension; k++){
909910 if(k%mpiSize != mpiRank){continue;}
910- int dest = 0;
911+ int dest = mpiHeadRank;
911912 int tag = k;
912913 MolDS_mpi::MpiProcess::GetInstance()->Send(dest, tag, matrixCIS[k], this->matrixCISdimension);
913914 }
914915 }
915916 // broadcast all matrix data to all rank
916- int root=0;
917+ int root=mpiHeadRank;
917918 MolDS_mpi::MpiProcess::GetInstance()->Broadcast(&matrixCIS[0][0], this->matrixCISdimension*this->matrixCISdimension, root);
918919
919920
--- a/src/mpi/MpiProcess.h
+++ b/src/mpi/MpiProcess.h
@@ -27,6 +27,7 @@ public:
2727 static void CreateInstance(int argc, char *argv[]);
2828 static void DeleteInstance();
2929 static MpiProcess* GetInstance();
30+ int GetHeadRank() const{return 0;}
3031 int GetRank() const{return this->communicator->rank();}
3132 int GetSize() const{return this->communicator->size();}
3233 template<typename T> void Send(int dest, int tag, const T* values, intptr_t num) const{
--- a/src/optimization/BFGS.cpp
+++ b/src/optimization/BFGS.cpp
@@ -190,7 +190,7 @@ void BFGS::SearchMinimum(boost::shared_ptr<ElectronicStructure> electronicStruct
190190 this->UpdateMolecularCoordinates(molecule, matrixStep);
191191
192192 // Broadcast to all processes
193- int root=0;
193+ int root = MolDS_mpi::MpiProcess::GetInstance()->GetHeadRank();
194194 molecule.BroadcastConfigurationToAllProcesses(root);
195195
196196 this->UpdateElectronicStructure(electronicStructure, molecule, requireGuess, tempCanOutputLogs);
--- a/src/optimization/Optimizer.cpp
+++ b/src/optimization/Optimizer.cpp
@@ -210,7 +210,7 @@ void Optimizer::LineSearch(boost::shared_ptr<ElectronicStructure> electronicStru
210210 this->UpdateMolecularCoordinates(molecule, matrixForce, -0.5*dt);
211211
212212 // Broadcast to all processes
213- int root=0;
213+ int root = MolDS_mpi::MpiProcess::GetInstance()->GetHeadRank();
214214 molecule.BroadcastConfigurationToAllProcesses(root);
215215
216216 // update and output electronic structure
--- a/src/rpmd/RPMD.cpp
+++ b/src/rpmd/RPMD.cpp
@@ -202,7 +202,7 @@ void RPMD::DoRPMD(const Molecule& refferenceMolecule){
202202 this->UpdateMomenta(molecularBeads, electronicStructureBeads, elecState, dt, temperature);
203203
204204 // Broadcast coordinates and momenta of beads to all processes
205- int root=0;
205+ int root = MolDS_mpi::MpiProcess::GetInstance()->GetHeadRank();
206206 this->BroadcastPhaseSpacepointsToAllProcesses(molecularBeads, root);
207207
208208 // output energy
--- a/src/zindo/ZindoS.cpp
+++ b/src/zindo/ZindoS.cpp
@@ -1241,29 +1241,30 @@ void ZindoS::CalcCISProperties(){
12411241 MallocerFreer::GetInstance()->Free<double>(&dipoleMOs, CartesianType_end, totalNumberAOs, totalNumberAOs);
12421242 MallocerFreer::GetInstance()->Free<double>(&overlapMOs, totalNumberAOs, totalNumberAOs);
12431243
1244- // communication to collect all matrix data on rank 0
1244+ // communication to collect all matrix data on head-rank
1245+ int mpiHeadRank = MolDS_mpi::MpiProcess::GetInstance()->GetHeadRank();
12451246 int numTransported = (Parameters::GetInstance()->GetNumberExcitedStatesCIS()+1)*CartesianType_end;
1246- if(mpiRank == 0){
1247+ if(mpiRank == mpiHeadRank){
12471248 // receive the matrix data from other ranks
12481249 for(int k=0; k<Parameters::GetInstance()->GetNumberExcitedStatesCIS()+1; k++){
1249- if(k%mpiSize == 0){continue;}
1250+ if(k%mpiSize == mpiHeadRank){continue;}
12501251 int source = k%mpiSize;
12511252 int tag = k;
12521253 MolDS_mpi::MpiProcess::GetInstance()->Recv(source, tag, &this->electronicTransitionDipoleMoments[k][0][0], numTransported);
12531254 }
12541255 }
12551256 else{
1256- // send the matrix data to rank-0
1257+ // send the matrix data to head-rank
12571258 for(int k=0; k<Parameters::GetInstance()->GetNumberExcitedStatesCIS()+1; k++){
12581259 if(k%mpiSize != mpiRank){continue;}
1259- int dest = 0;
1260+ int dest = mpiHeadRank;
12601261 int tag = k;
12611262 MolDS_mpi::MpiProcess::GetInstance()->Send(dest, tag, &this->electronicTransitionDipoleMoments[k][0][0], numTransported);
12621263 }
12631264 }
12641265
12651266 // right upper part of the matrix is copied from left lower part.
1266- if(mpiRank == 0 && Parameters::GetInstance()->RequiresAllTransitionDipoleMomentsCIS()){
1267+ if(mpiRank == mpiHeadRank && Parameters::GetInstance()->RequiresAllTransitionDipoleMomentsCIS()){
12671268 for(int k=0; k<Parameters::GetInstance()->GetNumberExcitedStatesCIS()+1; k++){
12681269 for(int l=k+1; l<Parameters::GetInstance()->GetNumberExcitedStatesCIS()+1; l++){
12691270 for(int axis=0; axis<CartesianType_end; axis++){
@@ -1276,7 +1277,7 @@ void ZindoS::CalcCISProperties(){
12761277
12771278 // broadcast all matrix data to all ranks
12781279 numTransported *= (Parameters::GetInstance()->GetNumberExcitedStatesCIS()+1);
1279- int root=0;
1280+ int root=mpiHeadRank;
12801281 MolDS_mpi::MpiProcess::GetInstance()->Broadcast(&this->electronicTransitionDipoleMoments[0][0][0], numTransported, root);
12811282
12821283
@@ -2393,28 +2394,29 @@ void ZindoS::CalcCISMatrix(double** matrixCIS) const{
23932394 } // end of k-loop
23942395
23952396
2396- // communication to collect all matrix data on rank 0
2397- if(mpiRank == 0){
2397+ // communication to collect all matrix data on head-rank
2398+ int mpiHeadRank = MolDS_mpi::MpiProcess::GetInstance()->GetHeadRank();
2399+ if(mpiRank == mpiHeadRank){
23982400 // receive the matrix data from other ranks
23992401 for(int k=0; k<this->matrixCISdimension; k++){
2400- if(k%mpiSize == 0){continue;}
2402+ if(k%mpiSize == mpiHeadRank){continue;}
24012403 int source = k%mpiSize;
24022404 int tag = k;
24032405 MolDS_mpi::MpiProcess::GetInstance()->Recv(source, tag, matrixCIS[k], this->matrixCISdimension);
24042406 }
24052407 }
24062408 else{
2407- // send the matrix data to rank-0
2409+ // send the matrix data to head-rank
24082410 for(int k=0; k<this->matrixCISdimension; k++){
24092411 if(k%mpiSize != mpiRank){continue;}
2410- int dest = 0;
2412+ int dest = mpiHeadRank;
24112413 int tag = k;
24122414 MolDS_mpi::MpiProcess::GetInstance()->Send(dest, tag, matrixCIS[k], this->matrixCISdimension);
24132415 }
24142416 }
24152417
24162418 // broadcast all matrix data to all rank
2417- int root=0;
2419+ int root=mpiHeadRank;
24182420 MolDS_mpi::MpiProcess::GetInstance()->Broadcast(&matrixCIS[0][0], this->matrixCISdimension*this->matrixCISdimension, root);
24192421
24202422 double ompEndTime = omp_get_wtime();