修訂 | 66df4046f4b537c3a7f37039aabfd067a83529bd (tree) |
---|---|
時間 | 2013-08-06 19:01:27 |
作者 | Mikiya Fujii <mikiya.fujii@gmai...> |
Commiter | Mikiya Fujii |
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
@@ -3730,49 +3730,39 @@ void Mndo::RotateDiatomicTwoElecTwoCoreToSpaceFrame(double**** matrix, | ||
3730 | 3730 | MolDS_wrappers::Blas::GetInstance()->Dcopy(dxy*dxy*dxy*dxy, &matrix[0][0][0][0], &oldMatrix[0][0][0][0]); |
3731 | 3731 | |
3732 | 3732 | // 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]; | |
3748 | 3744 | } |
3749 | - ptrOldMatrix[i] = &oldMatrix[mu][nu][0][0]; | |
3750 | - ptrMatrix [i] = &matrix [mu][nu][0][0]; | |
3751 | 3745 | } |
3746 | + ptrTwiceRotatingMatrix[i] = &twiceRotatingMatrix[i][0]; | |
3747 | + ptrOldMatrix[i] = &oldMatrix[mu][nu][0][0]; | |
3748 | + ptrMatrix [i] = &matrix [mu][nu][0][0]; | |
3752 | 3749 | } |
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); | |
3767 | 3750 | } |
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 | + | |
3776 | 3766 | /* |
3777 | 3767 | // rotate (slow algorithm) |
3778 | 3768 | for(int mu=0; mu<dxy; mu++){ |
@@ -3800,22 +3790,6 @@ void Mndo::RotateDiatomicTwoElecTwoCoreToSpaceFrame(double**** matrix, | ||
3800 | 3790 | */ |
3801 | 3791 | } |
3802 | 3792 | |
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 | - | |
3819 | 3793 | // Rotate 5-dimensional matrix from diatomic frame to space frame |
3820 | 3794 | // Note tha in this method d-orbitals can not be treatable. |
3821 | 3795 | void Mndo::RotateDiatomicTwoElecTwoCore1stDerivativesToSpaceFrame( |
@@ -323,12 +323,6 @@ private: | ||
323 | 323 | double const* const* rotatingMatrix, |
324 | 324 | double const* const* const* rotMat1stDerivatives, |
325 | 325 | 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; | |
332 | 326 | void MallocTempMatricesRotateDiatomicTwoElecTwoCore1stDerivs(double*** twiceRotatingMatrix, |
333 | 327 | double*** twiceRotatingMatrixDerivA, |
334 | 328 | double*** twiceRotatingMatrixDerivB, |