• R/O
  • HTTP
  • SSH
  • HTTPS

提交

标签
No Tags

Frequently used words (click to add to your profile)

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

Commit MetaInfo

修订版748479b4f5705859d117caa2d7c03ee0a26d07c6 (tree)
时间2013-08-01 10:51:52
作者Mikiya Fujii <mikiya.fujii@gmai...>
CommiterMikiya Fujii

Log Message

Calculation of force on ground state for MNDO-series is MPI parallelized. #31814

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

更改概述

差异

--- a/src/mndo/Mndo.cpp
+++ b/src/mndo/Mndo.cpp
@@ -2267,23 +2267,29 @@ void Mndo::CalcForceExcitedTwoElecPart(double* force,
22672267 // electronicStateIndex is index of the electroinc eigen state.
22682268 // "electronicStateIndex = 0" means electronic ground state.
22692269 void Mndo::CalcForce(const vector<int>& elecStates){
2270+ int mpiRank = MolDS_mpi::MpiProcess::GetInstance()->GetRank();
2271+ int mpiSize = MolDS_mpi::MpiProcess::GetInstance()->GetSize();
22702272 this->CheckMatrixForce(elecStates);
22712273 if(this->RequiresExcitedStatesForce(elecStates)){
22722274 this->CalcEtaMatrixForce(elecStates);
22732275 this->CalcZMatrixForce(elecStates);
22742276 }
2275- stringstream ompErrors;
2277+
2278+ // this loop is MPI-parallelized
2279+ for(int a=0; a<this->molecule->GetNumberAtoms(); a++){
2280+ if(a%mpiSize != mpiRank){continue;}
2281+ const Atom& atomA = *molecule->GetAtom(a);
2282+ int firstAOIndexA = atomA.GetFirstAOIndex();
2283+ int lastAOIndexA = atomA.GetLastAOIndex();
2284+ stringstream ompErrors;
22762285 #pragma omp parallel
2277- {
2278- double***** diatomicTwoElecTwoCore1stDerivs = NULL;
2279- double*** diatomicOverlapAOs1stDerivs = NULL;
2280- try{
2281- this->MallocTempMatricesCalcForce(&diatomicOverlapAOs1stDerivs, &diatomicTwoElecTwoCore1stDerivs);
2286+ {
2287+ double***** diatomicTwoElecTwoCore1stDerivs = NULL;
2288+ double*** diatomicOverlapAOs1stDerivs = NULL;
2289+ try{
2290+ this->MallocTempMatricesCalcForce(&diatomicOverlapAOs1stDerivs, &diatomicTwoElecTwoCore1stDerivs);
2291+
22822292 #pragma omp for schedule(auto)
2283- for(int a=0; a<this->molecule->GetNumberAtoms(); a++){
2284- const Atom& atomA = *molecule->GetAtom(a);
2285- int firstAOIndexA = atomA.GetFirstAOIndex();
2286- int lastAOIndexA = atomA.GetLastAOIndex();
22872293 for(int b=0; b<this->molecule->GetNumberAtoms(); b++){
22882294 if(a == b){continue;}
22892295 const Atom& atomB = *molecule->GetAtom(b);
@@ -2393,19 +2399,25 @@ void Mndo::CalcForce(const vector<int>& elecStates){
23932399 }
23942400 }
23952401 } // end of excited state force
2396- } // end of for(int b)
2397- } // end of for(int a)
2398- } // end of try
2399- catch(MolDSException ex){
2402+ } // end of for(int b) with omp parallelization
2403+
2404+ } // end of try for omp-for
2405+ catch(MolDSException ex){
24002406 #pragma omp critical
2401- ex.Serialize(ompErrors);
2407+ ex.Serialize(ompErrors);
2408+ }
2409+ this->FreeTempMatricesCalcForce(&diatomicOverlapAOs1stDerivs, &diatomicTwoElecTwoCore1stDerivs);
2410+ } // end of omp-parallelized region
2411+ // Exception throwing for omp-region
2412+ if(!ompErrors.str().empty()){
2413+ throw MolDSException::Deserialize(ompErrors);
24022414 }
2403- this->FreeTempMatricesCalcForce(&diatomicOverlapAOs1stDerivs, &diatomicTwoElecTwoCore1stDerivs);
2404- }
2405- // Exception throwing for omp-region
2406- if(!ompErrors.str().empty()){
2407- throw MolDSException::Deserialize(ompErrors);
2408- }
2415+ }// end of for(int a) with MPI parallelization
2416+
2417+ // communication to reduce thsi->matrixForce on all node (namely, all_reduce)
2418+ int numTransported = elecStates.size()*this->molecule->GetNumberAtoms()*CartesianType_end;
2419+ MolDS_mpi::MpiProcess::GetInstance()->AllReduce(&this->matrixForce[0][0][0], numTransported, std::plus<double>());
2420+
24092421 }
24102422
24112423 void Mndo::MallocTempMatricesCalcForce(double**** diatomicOverlapAOs1stDerivs, double****** diatomicTwoElecTwoCore1stDerivs) const{
--- a/src/zindo/ZindoS.cpp
+++ b/src/zindo/ZindoS.cpp
@@ -3731,7 +3731,7 @@ void ZindoS::CalcForce(const vector<int>& elecStates){
37313731 OrbitalType_end,
37323732 OrbitalType_end,
37333733 CartesianType_end);
3734- } //end of parallelized region
3734+ } //end of omp-parallelized region
37353735 // Exception throwing for omp-region
37363736 if(!ompErrors.str().empty()){
37373737 throw MolDSException::Deserialize(ompErrors);