• R/O
  • HTTP
  • SSH
  • HTTPS

提交

標籤
無標籤

Frequently used words (click to add to your profile)

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

Commit MetaInfo

修訂66df4046f4b537c3a7f37039aabfd067a83529bd (tree)
時間2013-08-06 19:01:27
作者Mikiya Fujii <mikiya.fujii@gmai...>
CommiterMikiya Fujii

Log Message

Refactoring of Mndo::RotateDiatomicTwoElecTwoCoreToSpaceFrame to avoid huge number of call the critical section in MallocerFreer::AddCurrentMalloced. #31814

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

Change Summary

差異

--- a/src/mndo/Mndo.cpp
+++ b/src/mndo/Mndo.cpp
@@ -3730,49 +3730,39 @@ void Mndo::RotateDiatomicTwoElecTwoCoreToSpaceFrame(double**** matrix,
37303730 MolDS_wrappers::Blas::GetInstance()->Dcopy(dxy*dxy*dxy*dxy, &matrix[0][0][0][0], &oldMatrix[0][0][0][0]);
37313731
37323732 // rotate (fast algorithm, see also slow algorithm shown later)
3733- double** twiceRotatingMatrix = NULL;
3734- double** ptrOldMatrix = NULL;
3735- double** ptrMatrix = NULL;
3736- try{
3737- MallocTempMatricesRotateDiatomicTwoElecTwoCore(&twiceRotatingMatrix,
3738- &ptrOldMatrix,
3739- &ptrMatrix);
3740- for(int mu=0; mu<dxy; mu++){
3741- for(int nu=0; nu<dxy; nu++){
3742- int i=mu*dxy+nu;
3743- for(int lambda=0; lambda<dxy; lambda++){
3744- for(int sigma=0; sigma<dxy; sigma++){
3745- int j=lambda*dxy+sigma;
3746- twiceRotatingMatrix[i][j] = rotatingMatrix[mu][lambda]*rotatingMatrix[nu][sigma];
3747- }
3733+ double twiceRotatingMatrix[dxy*dxy][dxy*dxy];
3734+ double* ptrTwiceRotatingMatrix[dxy*dxy];
3735+ double* ptrOldMatrix[dxy*dxy];
3736+ double* ptrMatrix[dxy*dxy];
3737+ for(int mu=0; mu<dxy; mu++){
3738+ for(int nu=0; nu<dxy; nu++){
3739+ int i=mu*dxy+nu;
3740+ for(int lambda=0; lambda<dxy; lambda++){
3741+ for(int sigma=0; sigma<dxy; sigma++){
3742+ int j=lambda*dxy+sigma;
3743+ twiceRotatingMatrix[i][j] = rotatingMatrix[mu][lambda]*rotatingMatrix[nu][sigma];
37483744 }
3749- ptrOldMatrix[i] = &oldMatrix[mu][nu][0][0];
3750- ptrMatrix [i] = &matrix [mu][nu][0][0];
37513745 }
3746+ ptrTwiceRotatingMatrix[i] = &twiceRotatingMatrix[i][0];
3747+ ptrOldMatrix[i] = &oldMatrix[mu][nu][0][0];
3748+ ptrMatrix [i] = &matrix [mu][nu][0][0];
37523749 }
3753- bool isColumnMajorTwiceRotatingMatrix = false;
3754- bool isColumnMajorPtrOldMatrix = false;
3755- double alpha = 1.0;
3756- double beta = 0.0;
3757- MolDS_wrappers::Blas::GetInstance()->Dgemmm(isColumnMajorTwiceRotatingMatrix,
3758- isColumnMajorPtrOldMatrix,
3759- !isColumnMajorTwiceRotatingMatrix,
3760- dxy*dxy, dxy*dxy, dxy*dxy, dxy*dxy,
3761- alpha,
3762- twiceRotatingMatrix,
3763- ptrOldMatrix,
3764- twiceRotatingMatrix,
3765- beta,
3766- ptrMatrix);
37673750 }
3768- catch(MolDSException ex){
3769- FreeTempMatricesRotateDiatomicTwoElecTwoCore(&twiceRotatingMatrix,
3770- &ptrOldMatrix,
3771- &ptrMatrix);
3772- }
3773- FreeTempMatricesRotateDiatomicTwoElecTwoCore(&twiceRotatingMatrix,
3774- &ptrOldMatrix,
3775- &ptrMatrix);
3751+ bool isColumnMajorTwiceRotatingMatrix = false;
3752+ bool isColumnMajorPtrOldMatrix = false;
3753+ double alpha = 1.0;
3754+ double beta = 0.0;
3755+ MolDS_wrappers::Blas::GetInstance()->Dgemmm(isColumnMajorTwiceRotatingMatrix,
3756+ isColumnMajorPtrOldMatrix,
3757+ !isColumnMajorTwiceRotatingMatrix,
3758+ dxy*dxy, dxy*dxy, dxy*dxy, dxy*dxy,
3759+ alpha,
3760+ &ptrTwiceRotatingMatrix[0],
3761+ &ptrOldMatrix[0],
3762+ &ptrTwiceRotatingMatrix[0],
3763+ beta,
3764+ &ptrMatrix[0]);
3765+
37763766 /*
37773767 // rotate (slow algorithm)
37783768 for(int mu=0; mu<dxy; mu++){
@@ -3800,22 +3790,6 @@ void Mndo::RotateDiatomicTwoElecTwoCoreToSpaceFrame(double**** matrix,
38003790 */
38013791 }
38023792
3803-void Mndo::MallocTempMatricesRotateDiatomicTwoElecTwoCore(double*** twiceRotatingMatrix,
3804- double*** ptrOldMatrix,
3805- double*** ptrMatrix) const{
3806- MallocerFreer::GetInstance()->Malloc<double>(twiceRotatingMatrix, dxy*dxy, dxy*dxy);
3807- MallocerFreer::GetInstance()->Malloc<double*>(ptrOldMatrix, dxy*dxy);
3808- MallocerFreer::GetInstance()->Malloc<double*>(ptrMatrix, dxy*dxy);
3809-}
3810-
3811-void Mndo::FreeTempMatricesRotateDiatomicTwoElecTwoCore(double*** twiceRotatingMatrix,
3812- double*** ptrOldMatrix,
3813- double*** ptrMatrix) const{
3814- MallocerFreer::GetInstance()->Free<double>(twiceRotatingMatrix, dxy*dxy, dxy*dxy);
3815- MallocerFreer::GetInstance()->Free<double*>(ptrOldMatrix, dxy*dxy);
3816- MallocerFreer::GetInstance()->Free<double*>(ptrMatrix, dxy*dxy);
3817-}
3818-
38193793 // Rotate 5-dimensional matrix from diatomic frame to space frame
38203794 // Note tha in this method d-orbitals can not be treatable.
38213795 void Mndo::RotateDiatomicTwoElecTwoCore1stDerivativesToSpaceFrame(
--- a/src/mndo/Mndo.h
+++ b/src/mndo/Mndo.h
@@ -323,12 +323,6 @@ private:
323323 double const* const* rotatingMatrix,
324324 double const* const* const* rotMat1stDerivatives,
325325 double const* const* const* const* rotMat2ndDerivatives) const;
326- void MallocTempMatricesRotateDiatomicTwoElecTwoCore(double*** twiceRotatingMatrix,
327- double*** ptrOldMatrix,
328- double*** ptrMatrix) const;
329- void FreeTempMatricesRotateDiatomicTwoElecTwoCore(double*** twiceRotatingMatrix,
330- double*** ptrOldMatrix,
331- double*** ptrMatrix) const;
332326 void MallocTempMatricesRotateDiatomicTwoElecTwoCore1stDerivs(double*** twiceRotatingMatrix,
333327 double*** twiceRotatingMatrixDerivA,
334328 double*** twiceRotatingMatrixDerivB,