Révision | d51d744f71173991e4a401f4d94e6f436f3045ec (tree) |
---|---|
l'heure | 2013-08-06 19:14:34 |
Auteur | Mikiya Fujii <mikiya.fujii@gmai...> |
Commiter | Mikiya Fujii |
Refactoring of Mndo::CalcDiatomicTwoElecTwoCore to avoid huge number of calling the critical section in MallocerFreer::AddCurrentMalloced. #31814
git-svn-id: https://svn.sourceforge.jp/svnroot/molds/trunk@1459 1136aad2-a195-0410-b898-f5ea1d11b9d8
@@ -3430,13 +3430,15 @@ void Mndo::CalcTwoElecTwoCore(double****** twoElecTwoCore, | ||
3430 | 3430 | #pragma omp parallel |
3431 | 3431 | { |
3432 | 3432 | double**** diatomicTwoElecTwoCore = NULL; |
3433 | + double** tmpRotMat = NULL; | |
3433 | 3434 | try{ |
3434 | 3435 | MallocerFreer::GetInstance()->Malloc<double>(&diatomicTwoElecTwoCore, dxy, dxy, dxy, dxy); |
3436 | + MallocerFreer::GetInstance()->Malloc<double>(&tmpRotMat, OrbitalType_end, OrbitalType_end); | |
3435 | 3437 | // note that terms with condition a==b are not needed to calculate. |
3436 | 3438 | #pragma omp for schedule(auto) |
3437 | 3439 | for(int a=0; a<molecule.GetNumberAtoms(); a++){ |
3438 | 3440 | for(int b=a+1; b<molecule.GetNumberAtoms(); b++){ |
3439 | - this->CalcDiatomicTwoElecTwoCore(diatomicTwoElecTwoCore, a, b); | |
3441 | + this->CalcDiatomicTwoElecTwoCore(diatomicTwoElecTwoCore, tmpRotMat, a, b); | |
3440 | 3442 | for(int mu=0; mu<dxy; mu++){ |
3441 | 3443 | for(int nu=mu; nu<dxy; nu++){ |
3442 | 3444 | for(int lambda=0; lambda<dxy; lambda++){ |
@@ -3462,6 +3464,7 @@ void Mndo::CalcTwoElecTwoCore(double****** twoElecTwoCore, | ||
3462 | 3464 | ex.Serialize(ompErrors); |
3463 | 3465 | } |
3464 | 3466 | MallocerFreer::GetInstance()->Free<double>(&diatomicTwoElecTwoCore, dxy, dxy, dxy, dxy); |
3467 | + MallocerFreer::GetInstance()->Free<double>(&tmpRotMat, OrbitalType_end, OrbitalType_end); | |
3465 | 3468 | } |
3466 | 3469 | // Exception throwing for omp-region |
3467 | 3470 | if(!ompErrors.str().empty()){ |
@@ -3476,7 +3479,7 @@ void Mndo::CalcTwoElecTwoCore(double****** twoElecTwoCore, | ||
3476 | 3479 | // Note that atomA != atomB. |
3477 | 3480 | // Note taht d-orbital cannot be treated, |
3478 | 3481 | // that is, matrix[dxy][dxy][dxy][dxy] cannot be treatable. |
3479 | -void Mndo::CalcDiatomicTwoElecTwoCore(double**** matrix, int indexAtomA, int indexAtomB) const{ | |
3482 | +void Mndo::CalcDiatomicTwoElecTwoCore(double**** matrix, double** tmpRotMat, int indexAtomA, int indexAtomB) const{ | |
3480 | 3483 | const Atom& atomA = *this->molecule->GetAtom(indexAtomA); |
3481 | 3484 | const Atom& atomB = *this->molecule->GetAtom(indexAtomB); |
3482 | 3485 | if(indexAtomA == indexAtomB){ |
@@ -3513,20 +3516,9 @@ void Mndo::CalcDiatomicTwoElecTwoCore(double**** matrix, int indexAtomA, int ind | ||
3513 | 3516 | } |
3514 | 3517 | } |
3515 | 3518 | } |
3516 | - | |
3517 | 3519 | // rotate matirix into the space frame |
3518 | - double** rotatingMatrix = NULL; | |
3519 | - try{ | |
3520 | - MallocerFreer::GetInstance()->Malloc<double>(&rotatingMatrix, | |
3521 | - OrbitalType_end, OrbitalType_end); | |
3522 | - this->CalcRotatingMatrix(rotatingMatrix, atomA, atomB); | |
3523 | - this->RotateDiatomicTwoElecTwoCoreToSpaceFrame(matrix, rotatingMatrix); | |
3524 | - } | |
3525 | - catch(MolDSException ex){ | |
3526 | - MallocerFreer::GetInstance()->Free<double>(&rotatingMatrix, OrbitalType_end, OrbitalType_end); | |
3527 | - throw ex; | |
3528 | - } | |
3529 | - MallocerFreer::GetInstance()->Free<double>(&rotatingMatrix, OrbitalType_end, OrbitalType_end); | |
3520 | + this->CalcRotatingMatrix(tmpRotMat, atomA, atomB); | |
3521 | + this->RotateDiatomicTwoElecTwoCoreToSpaceFrame(matrix, tmpRotMat); | |
3530 | 3522 | |
3531 | 3523 | /* |
3532 | 3524 | this->OutputLog("(mu, nu | lambda, sigma) matrix\n"); |
@@ -296,7 +296,10 @@ private: | ||
296 | 296 | int nu, |
297 | 297 | double const* const* const* const* const* diatomicTwoElecTwoCore1stDerivatives, |
298 | 298 | MolDS_base::CartesianType axisA) const; |
299 | - void CalcDiatomicTwoElecTwoCore(double**** matrix, int indexAtomA, int indexAtomB) const; | |
299 | + void CalcDiatomicTwoElecTwoCore(double**** matrix, | |
300 | + double** tmpRotMat, | |
301 | + int indexAtomA, | |
302 | + int indexAtomB) const; | |
300 | 303 | void CalcDiatomicTwoElecTwoCore1stDerivatives(double***** matrix, |
301 | 304 | double** tmpRotMat, |
302 | 305 | double*** tmpRotMat1stDerivs, |