10
1
mirror of https://gitlab.com/scemama/qmcchem.git synced 2024-12-23 04:43:30 +01:00

Fix DGEMM

This commit is contained in:
Anthony Scemama 2021-05-31 13:57:11 +02:00
parent 1239c79262
commit df2559cf1f
2 changed files with 213 additions and 226 deletions

View File

@ -44,6 +44,6 @@ export C_INCLUDE_PATH="\${QMCCHEM_PATH}/include:\${C_INCLUDE_PATH}"
#export QMCCHEM_NIC=ib0
source \${QMCCHEM_PATH}/irpf90/bin/irpman
#source \${QMCCHEM_PATH}/EZFIO/Bash/ezfio.sh
eval $(opam env)
eval \$(opam env)
EOF

View File

@ -323,7 +323,7 @@ subroutine det_update$n(n,LDS,m,l,S,S_inv,d)
double precision :: zj, zj1, zj2, zj3
!DIR$ NOPREFETCH
!DIR$ SIMD NOVECREMAINDER
!OMP$ SIMD NOVECREMAINDER
do i=1,$n
u(i) = m(i) - S(i,l)
enddo
@ -331,7 +331,7 @@ subroutine det_update$n(n,LDS,m,l,S,S_inv,d)
zj = 0.d0
!DIR$ VECTOR ALIGNED
!DIR$ NOPREFETCH
!DIR$ SIMD REDUCTION(+:zj) NOVECREMAINDER
!OMP$ SIMD REDUCTION(+:zj) NOVECREMAINDER
do i=1,$n-1,4
zj = zj + S_inv(i,l)*u(i) + S_inv(i+1,l)*u(i+1) &
+ S_inv(i+2,l)*u(i+2) + S_inv(i+3,l)*u(i+3)
@ -353,7 +353,7 @@ subroutine det_update$n(n,LDS,m,l,S,S_inv,d)
zj3 = 0.d0
!DIR$ VECTOR ALIGNED
!DIR$ NOPREFETCH
!DIR$ SIMD REDUCTION(+:zj,zj1,zj2,zj3) NOVECREMAINDER
!OMP$ SIMD REDUCTION(+:zj,zj1,zj2,zj3) NOVECREMAINDER
do i=1,$n
zj = zj + S_inv(i,j )*u(i)
zj1 = zj1 + S_inv(i,j+1)*u(i)
@ -367,7 +367,7 @@ subroutine det_update$n(n,LDS,m,l,S,S_inv,d)
enddo
!DIR$ NOPREFETCH
!DIR$ SIMD FIRSTPRIVATE(d_inv) NOVECREMAINDER
!OMP$ SIMD FIRSTPRIVATE(d_inv) NOVECREMAINDER
do i=1,$n
w(i) = S_inv(i,l)*d_inv
S(i,l) = m(i)
@ -380,7 +380,7 @@ subroutine det_update$n(n,LDS,m,l,S,S_inv,d)
zj3 = z(i+3)
!DIR$ VECTOR ALIGNED
!DIR$ NOPREFETCH
!DIR$ SIMD FIRSTPRIVATE(lambda,zj,zj1,zj2,zj3) NOVECREMAINDER
!OMP$ SIMD FIRSTPRIVATE(lambda,zj,zj1,zj2,zj3) NOVECREMAINDER
do j=1,$n
S_inv(j,i ) = S_inv(j,i )*lambda - w(j)*zj
S_inv(j,i+1) = S_inv(j,i+1)*lambda - w(j)*zj1
@ -459,7 +459,7 @@ subroutine det_update$n(n,LDS,m,l,S,S_inv,d)
zj = 0.d0
!DIR$ NOPREFETCH
!DIR$ SIMD REDUCTION(+:zj)
!OMP$ SIMD REDUCTION(+:zj)
do i=1,$n-1,4
zj = zj + S_inv(i,l)*u(i) + S_inv(i+1,l)*u(i+1) &
+ S_inv(i+2,l)*u(i+2) + S_inv(i+3,l)*u(i+3)
@ -482,7 +482,7 @@ subroutine det_update$n(n,LDS,m,l,S,S_inv,d)
zj3 = 0.d0
!DIR$ VECTOR ALIGNED
!DIR$ NOPREFETCH
!DIR$ SIMD REDUCTION(+:zj,zj1,zj2,zj3) NOVECREMAINDER
!OMP$ SIMD REDUCTION(+:zj,zj1,zj2,zj3) NOVECREMAINDER
do i=1,$n-1
zj = zj + S_inv(i,j )*u(i)
zj1 = zj1 + S_inv(i,j+1)*u(i)
@ -498,14 +498,14 @@ subroutine det_update$n(n,LDS,m,l,S,S_inv,d)
zj = 0.d0
!DIR$ VECTOR ALIGNED
!DIR$ NOPREFETCH
!DIR$ SIMD REDUCTION(+:zj) NOVECREMAINDER
!OMP$ SIMD REDUCTION(+:zj) NOVECREMAINDER
do i=1,$n-1
zj = zj + S_inv(i,$n)*u(i)
enddo
z($n) = zj + S_inv($n,$n)*u($n)
!DIR$ NOPREFETCH
!DIR$ SIMD FIRSTPRIVATE(d_inv) NOVECREMAINDER
!OMP$ SIMD FIRSTPRIVATE(d_inv) NOVECREMAINDER
do i=1,$n
w(i) = S_inv(i,l)*d_inv
S(i,l) = m(i)
@ -518,7 +518,7 @@ subroutine det_update$n(n,LDS,m,l,S,S_inv,d)
zj3 = z(i+3)
!DIR$ VECTOR ALIGNED
!DIR$ NOPREFETCH
!DIR$ SIMD FIRSTPRIVATE(lambda,zj,zj1,zj2,zj3) NOVECREMAINDER
!OMP$ SIMD FIRSTPRIVATE(lambda,zj,zj1,zj2,zj3) NOVECREMAINDER
do j=1,$n-1
S_inv(j,i ) = S_inv(j,i )*lambda - w(j)*zj
S_inv(j,i+1) = S_inv(j,i+1)*lambda - w(j)*zj1
@ -534,7 +534,7 @@ subroutine det_update$n(n,LDS,m,l,S,S_inv,d)
zj = z($n)
!DIR$ VECTOR ALIGNED
!DIR$ NOPREFETCH
!DIR$ SIMD FIRSTPRIVATE(lambda,zj) NOVECREMAINDER
!OMP$ SIMD FIRSTPRIVATE(lambda,zj) NOVECREMAINDER
do i=1,$n
S_inv(i,$n) = S_inv(i,$n)*lambda -w(i)*zj
enddo
@ -607,7 +607,7 @@ subroutine det_update$n(n,LDS,m,l,S,S_inv,d)
double precision :: zj, zj1, zj2, zj3
!DIR$ NOPREFETCH
!DIR$ SIMD NOVECREMAINDER
!OMP$ SIMD NOVECREMAINDER
do i=1,$n
u(i) = m(i) - S(i,l)
enddo
@ -615,7 +615,7 @@ subroutine det_update$n(n,LDS,m,l,S,S_inv,d)
zj = 0.d0
!DIR$ VECTOR ALIGNED
!DIR$ NOPREFETCH
!DIR$ SIMD REDUCTION(+:zj) NOVECREMAINDER
!OMP$ SIMD REDUCTION(+:zj) NOVECREMAINDER
do i=1,$n-2,4
zj = zj + S_inv(i,l)*u(i) + S_inv(i+1,l)*u(i+1) &
+ S_inv(i+2,l)*u(i+2) + S_inv(i+3,l)*u(i+3)
@ -638,7 +638,7 @@ subroutine det_update$n(n,LDS,m,l,S,S_inv,d)
zj2 = 0.d0
zj3 = 0.d0
!DIR$ VECTOR ALIGNED
!DIR$ SIMD REDUCTION(+:zj,zj1,zj2,zj3) NOVECREMAINDER
!OMP$ SIMD REDUCTION(+:zj,zj1,zj2,zj3) NOVECREMAINDER
do i=1,$n-2
zj = zj + S_inv(i,j )*u(i)
zj1 = zj1 + S_inv(i,j+1)*u(i)
@ -660,7 +660,7 @@ subroutine det_update$n(n,LDS,m,l,S,S_inv,d)
zj1 = 0.d0
!DIR$ VECTOR ALIGNED
!DIR$ NOPREFETCH
!DIR$ SIMD REDUCTION(+:zj,zj1) NOVECREMAINDER
!OMP$ SIMD REDUCTION(+:zj,zj1) NOVECREMAINDER
do i=1,$n-2
zj = zj + S_inv(i,j )*u(i)
zj1 = zj1 + S_inv(i,j+1)*u(i)
@ -671,7 +671,7 @@ subroutine det_update$n(n,LDS,m,l,S,S_inv,d)
z(j+1) = z(j+1) + S_inv($n,j+1)*u($n)
!DIR$ NOPREFETCH
!DIR$ SIMD FIRSTPRIVATE(d_inv) NOVECREMAINDER
!OMP$ SIMD FIRSTPRIVATE(d_inv) NOVECREMAINDER
do i=1,$n
w(i) = S_inv(i,l)*d_inv
S(i,l) = m(i)
@ -683,7 +683,7 @@ subroutine det_update$n(n,LDS,m,l,S,S_inv,d)
zj2 = z(i+2)
zj3 = z(i+3)
!DIR$ VECTOR ALIGNED
!DIR$ SIMD FIRSTPRIVATE(lambda,zj,zj1,zj2,zj3) NOVECREMAINDER
!OMP$ SIMD FIRSTPRIVATE(lambda,zj,zj1,zj2,zj3) NOVECREMAINDER
do j=1,$n-2
S_inv(j,i ) = S_inv(j,i )*lambda -zj *w(j)
S_inv(j,i+1) = S_inv(j,i+1)*lambda -zj1*w(j)
@ -704,7 +704,7 @@ subroutine det_update$n(n,LDS,m,l,S,S_inv,d)
zj = z(i)
zj1= z(i+1)
!DIR$ VECTOR ALIGNED
!DIR$ SIMD FIRSTPRIVATE(lambda,zj,zj1)
!OMP$ SIMD FIRSTPRIVATE(lambda,zj,zj1)
do j=1,$n-2
S_inv(j,i ) = S_inv(j,i )*lambda -zj*w(j)
S_inv(j,i+1) = S_inv(j,i+1)*lambda -zj1*w(j)
@ -780,7 +780,7 @@ subroutine det_update$n(n,LDS,m,l,S,S_inv,d)
double precision :: zj, zj1, zj2, zj3
!DIR$ SIMD
!OMP$ SIMD
do i=1,$n
u(i) = m(i) - S(i,l)
enddo
@ -788,7 +788,7 @@ subroutine det_update$n(n,LDS,m,l,S,S_inv,d)
zj = 0.d0
!DIR$ VECTOR ALIGNED
!DIR$ NOPREFETCH
!DIR$ SIMD REDUCTION(+:zj) NOVECREMAINDER
!OMP$ SIMD REDUCTION(+:zj) NOVECREMAINDER
do i=1,$n-3,4
zj = zj + S_inv(i,l)*u(i) + S_inv(i+1,l)*u(i+1) &
+ S_inv(i+2,l)*u(i+2) + S_inv(i+3,l)*u(i+3)
@ -812,7 +812,7 @@ subroutine det_update$n(n,LDS,m,l,S,S_inv,d)
zj2 = 0.d0
zj3 = 0.d0
!DIR$ VECTOR ALIGNED
!DIR$ SIMD REDUCTION(+:zj,zj1,zj2,zj3)
!OMP$ SIMD REDUCTION(+:zj,zj1,zj2,zj3)
do i=1,$n-3
zj = zj + S_inv(i,j )*u(i)
zj1 = zj1 + S_inv(i,j+1)*u(i)
@ -839,7 +839,7 @@ subroutine det_update$n(n,LDS,m,l,S,S_inv,d)
zj2 = 0.d0
!DIR$ VECTOR ALIGNED
!DIR$ NOPREFETCH
!DIR$ SIMD REDUCTION(+:zj,zj1,zj2)
!OMP$ SIMD REDUCTION(+:zj,zj1,zj2)
do i=1,$n-3
zj = zj + S_inv(i,j )*u(i)
zj1 = zj1 + S_inv(i,j+1)*u(i)
@ -856,7 +856,7 @@ subroutine det_update$n(n,LDS,m,l,S,S_inv,d)
z(j+2) = z(j+2) + S_inv($n,j+2)*u($n)
!DIR$ NOPREFETCH
!DIR$ SIMD FIRSTPRIVATE(d_inv)
!OMP$ SIMD FIRSTPRIVATE(d_inv)
do i=1,$n
w(i) = S_inv(i,l)*d_inv
S(i,l) = m(i)
@ -869,7 +869,7 @@ subroutine det_update$n(n,LDS,m,l,S,S_inv,d)
zj3 = z(i+3)
!DIR$ VECTOR ALIGNED
!DIR$ NOPREFETCH
!DIR$ SIMD FIRSTPRIVATE(lambda,zj,zj1,zj2,zj3)
!OMP$ SIMD FIRSTPRIVATE(lambda,zj,zj1,zj2,zj3)
do j=1,$n-3
S_inv(j,i ) = S_inv(j,i )*lambda - w(j)*zj
S_inv(j,i+1) = S_inv(j,i+1)*lambda - w(j)*zj1
@ -896,7 +896,7 @@ subroutine det_update$n(n,LDS,m,l,S,S_inv,d)
zj2 = z(i+2)
!DIR$ VECTOR ALIGNED
!DIR$ NOPREFETCH
!DIR$ SIMD FIRSTPRIVATE(lambda,zj,zj1,zj2)
!OMP$ SIMD FIRSTPRIVATE(lambda,zj,zj1,zj2)
do j=1,$n
S_inv(j,i ) = S_inv(j,i )*lambda - w(j)*zj
S_inv(j,i+1) = S_inv(j,i+1)*lambda - w(j)*zj1
@ -980,7 +980,7 @@ subroutine det_update_general(n,LDS,m,l,S,S_inv,d)
zl = 0.d0
!DIR$ VECTOR ALIGNED
!DIR$ NOPREFETCH
!DIR$ SIMD REDUCTION(+:zl)
!OMP$ SIMD REDUCTION(+:zl)
do i=1,n
zl = zl + S_inv(i,l)*u(i)
enddo
@ -1006,7 +1006,7 @@ subroutine det_update_general(n,LDS,m,l,S,S_inv,d)
zj3 = 0.d0
!DIR$ VECTOR ALIGNED
!DIR$ NOPREFETCH
!DIR$ SIMD REDUCTION(+:zj,zj1,zj2,zj3)
!OMP$ SIMD REDUCTION(+:zj,zj1,zj2,zj3)
do i=1,n
zj = zj + S_inv(i,j )*u(i)
zj1 = zj1 + S_inv(i,j+1)*u(i)
@ -1023,7 +1023,7 @@ subroutine det_update_general(n,LDS,m,l,S,S_inv,d)
zj = 0.d0
!DIR$ VECTOR ALIGNED
!DIR$ NOPREFETCH
!DIR$ SIMD REDUCTION(+:zj)
!OMP$ SIMD REDUCTION(+:zj)
do i=1,n
zj = zj + S_inv(i,j)*u(i)
enddo
@ -1031,14 +1031,14 @@ subroutine det_update_general(n,LDS,m,l,S,S_inv,d)
enddo
!DIR$ NOPREFETCH
!DIR$ SIMD FIRSTPRIVATE(d_inv)
!OMP$ SIMD FIRSTPRIVATE(d_inv)
do i=1,n
w(i) = S_inv(i,l)*d_inv
S(i,l) = m(i)
enddo
!DIR$ NOPREFETCH
!DIR$ SIMD FIRSTPRIVATE(d_inv)
!OMP$ SIMD FIRSTPRIVATE(d_inv)
do i=1,n
w(i) = S_inv(i,l)*d_inv
S(i,l) = m(i)
@ -1051,7 +1051,7 @@ subroutine det_update_general(n,LDS,m,l,S,S_inv,d)
zj3 = z(i+3)
!DIR$ VECTOR ALIGNED
!DIR$ NOPREFETCH
!DIR$ SIMD FIRSTPRIVATE(lambda,zj,zj1,zj2,zj3)
!OMP$ SIMD FIRSTPRIVATE(lambda,zj,zj1,zj2,zj3)
do j=1,n
S_inv(j,i ) = S_inv(j,i )*lambda -zj *w(j)
S_inv(j,i+1) = S_inv(j,i+1)*lambda -zj1*w(j)
@ -1064,7 +1064,7 @@ subroutine det_update_general(n,LDS,m,l,S,S_inv,d)
zj = z(i)
!DIR$ VECTOR ALIGNED
!DIR$ NOPREFETCH
!DIR$ SIMD FIRSTPRIVATE(lambda,zj)
!OMP$ SIMD FIRSTPRIVATE(lambda,zj)
do j=1,n
S_inv(j,i) = S_inv(j,i)*lambda -zj*w(j)
enddo
@ -1703,30 +1703,20 @@ END_PROVIDER
, 1.d0, psi_svd_beta_unique(:,:,1), size(psi_svd_beta_unique,1), det_beta_value, 1 &
, 0.d0, det_beta_value_SVD_unique, 1)
do mm = 1, 4
call dgemm('N', 'N', elec_alpha_num, n_svd_coefs_unique, det_alpha_num, 1.d0 &
, det_alpha_grad_lapl(mm,:,:), size(det_alpha_grad_lapl,2) &
, psi_svd_alpha_unique(:,:,1), size(psi_svd_alpha_unique,1) &
, 0.d0, det_alpha_grad_lapl_SVD_unique(mm,:,:), size(det_alpha_grad_lapl_SVD_unique,2) )
if (elec_beta_num /= 0) then
call dgemm('N', 'N', elec_beta_num, n_svd_coefs_unique, det_beta_num, 1.d0 &
, det_beta_grad_lapl(mm,:,:), size(det_beta_grad_lapl,2) &
, psi_svd_beta_unique(:,:,1), size(psi_svd_beta_unique,1) &
, 0.d0, det_beta_grad_lapl_SVD_unique(mm,:,:), size(det_beta_grad_lapl_SVD_unique,2) )
endif
enddo
call dgemm('N', 'N', 4*elec_alpha_num, n_svd_coefs_unique, det_alpha_num, 1.d0 &
, det_alpha_grad_lapl, 4*size(det_alpha_grad_lapl,2) &
, psi_svd_alpha_unique, size(psi_svd_alpha_unique,1) &
, 0.d0, det_alpha_grad_lapl_SVD_unique, 4*size(det_alpha_grad_lapl_SVD_unique,2) )
if (elec_beta_num /= 0) then
call dgemm('N', 'N', 4*elec_beta_num, n_svd_coefs_unique, det_beta_num, 1.d0 &
, det_beta_grad_lapl, 4*size(det_beta_grad_lapl,2) &
, psi_svd_beta_unique, size(psi_svd_beta_unique,1) &
, 0.d0, det_beta_grad_lapl_SVD_unique, 4*size(det_beta_grad_lapl_SVD_unique,2) )
endif
END_PROVIDER
BEGIN_PROVIDER [ logical, utilise_SVD ]
&BEGIN_PROVIDER [ integer, n_svd_coefs ]
implicit none
@ -1853,14 +1843,15 @@ END_PROVIDER
! !!!
if (do_pseudo) then
! det_alpha_pseudo_SVD = det_alpha_pseudo @ psi_svd_alpha * psidet_inv_SVD
call dgemm('N', 'N', elec_alpha_num, n_svd_coefs , det_alpha_num, psidet_inv_SVD &
, det_alpha_pseudo, size(det_alpha_pseudo,1), psi_svd_alpha(:,:,1), size(psi_svd_alpha,1) &
, 0.d0, det_alpha_pseudo_SVD, size(det_alpha_pseudo_SVD,1) )
call dgemm('N', 'N', 4*elec_alpha_num, n_svd_coefs , det_alpha_num, psidet_inv_SVD &
, det_alpha_pseudo, size(det_alpha_pseudo,1), psi_svd_alpha(1,1,1) &
, size(psi_svd_alpha,1), 0.d0, det_alpha_pseudo_SVD, size(det_alpha_pseudo_SVD,1) )
! !!!
if (elec_beta_num /= 0) then
! det_beta_pseudo_SVD = det_beta_pseudo @ psi_svd_beta * psidet_inv_SVD
call dgemm('N', 'N', elec_beta_num, n_svd_coefs , det_beta_num, psidet_inv_SVD &
, det_beta_pseudo(elec_alpha_num+1,1), size(det_beta_pseudo,1), psi_svd_beta(:,:,1), size(psi_svd_beta,1) &
call dgemm('N', 'N', 4*elec_beta_num, n_svd_coefs , det_beta_num, psidet_inv_SVD &
, det_beta_pseudo(elec_alpha_num+1,1), size(det_beta_pseudo,1) &
, psi_svd_beta(1,1,1), size(psi_svd_beta,1) &
, 0.d0, det_beta_pseudo_SVD(elec_alpha_num+1,1), size(det_beta_pseudo_SVD,1) )
endif
endif
@ -1909,21 +1900,17 @@ END_PROVIDER
! -~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
! !!!
do mm = 1, 4
! !!!
call dgemm('N', 'N', elec_alpha_num, n_svd_coefs, det_alpha_num, 1.d0 &
, det_alpha_grad_lapl(mm,:,:), size(det_alpha_grad_lapl,2) &
, psi_svd_alpha(:,:,1), size(psi_svd_alpha,1) &
, 0.d0, det_alpha_grad_lapl_SVD(mm,:,:), size(det_alpha_grad_lapl_SVD,2) )
! !!!
if (elec_beta_num /= 0) then
call dgemm('N', 'N', elec_beta_num, n_svd_coefs, det_beta_num, 1.d0 &
, det_beta_grad_lapl(mm,:,:), size(det_beta_grad_lapl,2) &
, psi_svd_beta(:,:,1), size(psi_svd_beta,1) &
, 0.d0, det_beta_grad_lapl_SVD(mm,:,:), size(det_beta_grad_lapl_SVD,2) )
endif
! !!!
enddo
call dgemm('N', 'N', 4*elec_alpha_num, n_svd_coefs, det_alpha_num, 1.d0 &
, det_alpha_grad_lapl, 4*size(det_alpha_grad_lapl,2) &
, psi_svd_alpha, size(psi_svd_alpha,1) &
, 0.d0, det_alpha_grad_lapl_SVD, 4*size(det_alpha_grad_lapl_SVD,2) )
! !!!
if (elec_beta_num /= 0) then
call dgemm('N', 'N', 4*elec_beta_num, n_svd_coefs, det_beta_num, 1.d0 &
, det_beta_grad_lapl, 4*size(det_beta_grad_lapl,2) &
, psi_svd_beta, size(psi_svd_beta,1) &
, 0.d0, det_beta_grad_lapl_SVD, 4*size(det_beta_grad_lapl_SVD,2) )
endif
! !!!
! -~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~