• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Keine Tags

Frequently used words (click to add to your profile)

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

Commit MetaInfo

Revisionb4e5826854ddd5010842a47cda7368e657b121b8 (tree)
Zeit2013-06-18 14:37:25
AutorMikiya Fujii <mikiya.fujii@gmai...>
CommiterMikiya Fujii

Log Message

ZindoS::CalcCISMatrix is MPI-parallelized. #31588

git-svn-id: https://svn.sourceforge.jp/svnroot/molds/branches/mpi-cis@1366 1136aad2-a195-0410-b898-f5ea1d11b9d8

Ändern Zusammenfassung

Diff

--- a/src/zindo/ZindoS.cpp
+++ b/src/zindo/ZindoS.cpp
@@ -2280,16 +2280,18 @@ void ZindoS::DoCISDirect(){
22802280 void ZindoS::CalcCISMatrix(double** matrixCIS) const{
22812281 this->OutputLog(this->messageStartCalcCISMatrix);
22822282 double ompStartTime = omp_get_wtime();
2283+ boost::mpi::communicator* world = MolDS_mpi::MpiProcess::GetInstance()->GetCommunicator();
22832284
2284- stringstream ompErrors;
2285-#pragma omp parallel for schedule(auto)
22862285 for(int k=0; k<this->matrixCISdimension; k++){
2287- try{
2288- // single excitation from I-th (occupied)MO to A-th (virtual)MO
2289- int moI = this->GetActiveOccIndex(*this->molecule, k);
2290- int moA = this->GetActiveVirIndex(*this->molecule, k);
2286+ // single excitation from I-th (occupied)MO to A-th (virtual)MO
2287+ int moI = this->GetActiveOccIndex(*this->molecule, k);
2288+ int moA = this->GetActiveVirIndex(*this->molecule, k);
2289+ if(k%world->size() != world->rank()){continue;}
22912290
2292- for(int l=k; l<this->matrixCISdimension; l++){
2291+ stringstream ompErrors;
2292+#pragma omp parallel for schedule(auto)
2293+ for(int l=k; l<this->matrixCISdimension; l++){
2294+ try{
22932295 // single excitation from J-th (occupied)MO to B-th (virtual)MO
22942296 int moJ = this->GetActiveOccIndex(*this->molecule, l);
22952297 int moB = this->GetActiveVirIndex(*this->molecule, l);
@@ -2321,16 +2323,38 @@ void ZindoS::CalcCISMatrix(double** matrixCIS) const{
23212323 matrixCIS[k][l] = value;
23222324 // End of the slow algorith. */
23232325 }
2324- }
2325- catch(MolDSException ex){
2326+ catch(MolDSException ex){
23262327 #pragma omp critical
2327- ompErrors << ex.what() << endl ;
2328+ ompErrors << ex.what() << endl ;
2329+ }
2330+ } // end of l-loop
2331+ // Exception throwing for omp-region
2332+ if(!ompErrors.str().empty()){
2333+ throw MolDSException(ompErrors.str());
23282334 }
23292335 } // end of k-loop
2330- // Exception throwing for omp-region
2331- if(!ompErrors.str().empty()){
2332- throw MolDSException(ompErrors.str());
2336+
2337+
2338+ // communication to collect all matrix data on rank 0
2339+ if(world->rank() == 0){
2340+ // receive the matrix data from other ranks
2341+ for(int k=0; k<this->matrixCISdimension; k++){
2342+ if(k%world->size() == 0){continue;}
2343+ int source = k%world->size();
2344+ int tag = k;
2345+ world->recv(source, tag, matrixCIS[k], this->matrixCISdimension);
2346+ }
2347+ }
2348+ else{
2349+ // send the matrix data to rank-0
2350+ for(int k=0; k<this->matrixCISdimension; k++){
2351+ if(k%world->size() != world->rank()){continue;}
2352+ int dest = 0;
2353+ int tag = k;
2354+ world->send(dest, tag, matrixCIS[k], this->matrixCISdimension);
2355+ }
23332356 }
2357+
23342358 double ompEndTime = omp_get_wtime();
23352359 this->OutputLog(boost::format("%s%lf%s\n%s") % this->messageOmpElapsedTimeCalcCISMarix.c_str()
23362360 % (ompEndTime - ompStartTime)