1
0
mirror of https://github.com/TREX-CoE/qmckl.git synced 2024-11-19 20:42:50 +01:00

Merge pull request #86 from v1j4y/qmckl_dgemm_integration

qmckl dgemm integration
This commit is contained in:
Anthony Scemama 2022-09-22 12:20:17 +02:00 committed by GitHub
commit a1e5410dd4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 67 additions and 0 deletions

View File

@ -190,6 +190,24 @@ AS_IF([test "x$with_trexio" != xno], [
PKG_CFLAGS="$PKG_CFLAGS $TREXIO_CFLAGS"
PKG_LIBS="$PKG_LIBS $TREXIO_LIBS"
# QMCKL_DGEMM
AC_ARG_WITH(qmckldgemm, [AS_HELP_STRING([--without-qmckldgemm],[disable support for QMCKLDGEMM])],
with_qmckldgemm=$withval, with_qmckldgemm=no)
AS_IF([test "x$with_qmckldgemm" != xno], [
AC_DEFINE([HAVE_QMCKLDGEMM], [1], [Define if your have libqmckldgemm])
ARGS="${ARGS} qmckldgemm"
AC_CHECK_LIB([qmckldgemm], [qmckl_packed_matrix_create],
[],
[AS_IF([test "x$with_qmckldgemm" != xcheck],
[PKG_CHECK_MODULES([QMCKLDGEMM], [qmckldgemm]) ])
])
])
PKG_CFLAGS="$PKG_CFLAGS $QMCKLDGEMM_CFLAGS"
PKG_LIBS="$PKG_LIBS $QMCKLDGEMM_LIBS"
## BLAS
AX_BLAS([], [AC_MSG_ERROR([BLAS was not found.])])

View File

@ -889,6 +889,9 @@ integer function qmckl_dgemm_f(context, TransA, TransB, &
m, n, k, alpha, A, LDA, B, LDB, beta, C, LDC) &
result(info)
use qmckl
#ifdef HAVE_LIBQMCKLDGEMM
use qmckl_dgemm_tiled_module
#endif
implicit none
integer(qmckl_context), intent(in) :: context
character , intent(in) :: TransA, TransB
@ -900,6 +903,10 @@ integer function qmckl_dgemm_f(context, TransA, TransB, &
double precision , intent(in) :: B(ldb,*)
integer*8 , intent(in) :: ldc
double precision , intent(out) :: C(ldc,*)
double precision,allocatable,dimension(:,:) :: A1
double precision,allocatable,dimension(:,:) :: B1
double precision,allocatable,dimension(:,:) :: C1
integer*8 :: i, j, LDA1, LDB1, LDC1
info = QMCKL_SUCCESS
@ -938,8 +945,50 @@ integer function qmckl_dgemm_f(context, TransA, TransB, &
return
endif
#ifdef HAVE_LIBQMCKLDGEMM
! Copy A to A1
allocate(A1(k,m))
do j=1,m
do i=1,k
A1(i,j) = A(j,i)
end do
end do
! Copy B to B1
allocate(B1(n,k))
do j=1,k
do i=1,n
B1(i,j) = B(j,i)
end do
end do
! Copy C to C1
allocate(C1(n,m))
do j=1,m
do i=1,n
C1(i,j) = C(j,i)
end do
end do
LDA1 = size(A1,1)
LDB1 = size(B1,1)
LDC1 = size(C1,1)
info = qmckl_dgemm_tiled_avx2(int(m,8), int(n,8), int(k,8), &
A1, int(LDA1,8), B1, int(LDB1,8), C1, int(LDC1,8))
do j=1,n
do i=1,m
C(i,j) = alpha*C1(j,i) + beta*C(i,j)
end do
end do
deallocate(A1,B1,C1)
#else
call dgemm(transA, transB, int(m,4), int(n,4), int(k,4), &
alpha, A, int(LDA,4), B, int(LDB,4), beta, C, int(LDC,4))
#endif
end function qmckl_dgemm_f
#+end_src