From 00124f28dbaf1e8e30deb29a2c6992f96e4470d6 Mon Sep 17 00:00:00 2001 From: Salvatore Filippone Date: Fri, 21 Apr 2017 09:08:08 +0000 Subject: [PATCH] psblas3: config/pac.m4 configure Fixes for MKL. --- config/pac.m4 | 77 +++++++++++++++++++++ configure | 186 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 263 insertions(+) diff --git a/config/pac.m4 b/config/pac.m4 index e4d8c454..d45d7ffd 100644 --- a/config/pac.m4 +++ b/config/pac.m4 @@ -1038,7 +1038,41 @@ dnl Modified with new name to handle Fortran compilers (such as NAG) dnl for which the linking MUST be done with the compiler (i.e.: dnl trying to link the Fortran version of the BLAS with the C compiler dnl would fail even when linking in the compiler's library) +dnl +dnl Modified by salvatore.filippone@cranfield.ac.uk to include +dnl new tests for MKL from the 2008 version (see license below) +dnl +# LICENSE +# +# Copyright (c) 2008 Steven G. Johnson +# +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation, either version 3 of the License, or (at your +# option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +# Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program. If not, see . +# +# As a special exception, the respective Autoconf Macro's copyright owner +# gives unlimited permission to copy, distribute and modify the configure +# scripts that are the output of Autoconf when processing the Macro. You +# need not follow the terms of the GNU General Public License when using +# or distributing such scripts, even though portions of the text of the +# Macro appear in them. The GNU General Public License (GPL) does govern +# all other use of the material that constitutes the Autoconf Macro. +# +# This special exception to the GPL applies to versions of the Autoconf +# Macro released by the Autoconf Archive. When you make and distribute a +# modified version of the Autoconf Macro, you may extend this special +# exception to the GPL to apply to your modified version as well. + AC_DEFUN([PAC_BLAS], [ AC_PREREQ(2.50) dnl AC_REQUIRE([AC_FC_LIBRARY_LDFLAGS]) @@ -1125,6 +1159,49 @@ if test $pac_blas_ok = no; then AC_LANG([Fortran]) AC_CHECK_LIB(openblas, sgemm, [pac_blas_ok=yes;BLAS_LIBS="-lopenblas $BLAS_LIBDIR"]) fi +# BLAS in Intel MKL library? +if test $pac_blas_ok = no; then + # MKL for gfortran + if test x"$ac_cv_fc_compiler_gnu" = xyes; then + # 64 bit + if test $host_cpu = x86_64; then + AC_CHECK_LIB(mkl_gf_lp64, $sgemm, + [pac_blas_ok=yes;BLAS_LIBS="-lmkl_gf_lp64 -lmkl_sequential -lmkl_core -lpthread"],, + [-lmkl_gf_lp64 -lmkl_sequential -lmkl_core -lpthread]) + # 32 bit + elif test $host_cpu = i686; then + AC_CHECK_LIB(mkl_gf, $sgemm, + [pac_blas_ok=yes;BLAS_LIBS="-lmkl_gf -lmkl_sequential -lmkl_core -lpthread"],, + [-lmkl_gf -lmkl_sequential -lmkl_core -lpthread]) + fi + # MKL for other compilers (Intel, PGI, ...?) + else + # 64-bit + if test $host_cpu = x86_64; then + AC_CHECK_LIB(mkl_intel_lp64, $sgemm, + [pac_blas_ok=yes;BLAS_LIBS="-lmkl_intel_lp64 -lmkl_sequential -lmkl_core -lpthread"],, + [-lmkl_intel_lp64 -lmkl_sequential -lmkl_core -lpthread]) + # 32-bit + elif test $host_cpu = i686; then + AC_CHECK_LIB(mkl_intel, $sgemm, + [pac_blas_ok=yes;BLAS_LIBS="-lmkl_intel -lmkl_sequential -lmkl_core -lpthread"],, + [-lmkl_intel -lmkl_sequential -lmkl_core -lpthread]) + fi + fi +fi +# Old versions of MKL +if test $pac_blas_ok = no; then + AC_CHECK_LIB(mkl, $sgemm, [pac_blas_ok=yes;BLAS_LIBS="-lmkl -lguide -lpthread"],,[-lguide -lpthread]) +fi + +# BLAS in Apple vecLib library? +if test $pac_blas_ok = no; then + save_LIBS="$LIBS"; LIBS="-framework vecLib $LIBS" + AC_MSG_CHECKING([for $sgemm in -framework vecLib]) + AC_TRY_LINK_FUNC($sgemm, [pac_blas_ok=yes;BLAS_LIBS="-framework vecLib"]) + AC_MSG_RESULT($pac_blas_ok) + LIBS="$save_LIBS" +fi # BLAS in Alpha CXML library? if test $pac_blas_ok = no; then AC_CHECK_LIB(cxml, sgemm, [pac_blas_ok=yes;BLAS_LIBS="-lcxml $BLAS_LIBDIR"]) diff --git a/configure b/configure index 337519e5..908e4cc6 100755 --- a/configure +++ b/configure @@ -7423,6 +7423,192 @@ if test "x$ac_cv_lib_openblas_sgemm" = xyes; then : pac_blas_ok=yes;BLAS_LIBS="-lopenblas $BLAS_LIBDIR" fi +fi +# BLAS in Intel MKL library? +if test $pac_blas_ok = no; then + # MKL for gfortran + if test x"$ac_cv_fc_compiler_gnu" = xyes; then + # 64 bit + if test $host_cpu = x86_64; then + as_ac_Lib=`$as_echo "ac_cv_lib_mkl_gf_lp64_$sgemm" | $as_tr_sh` +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $sgemm in -lmkl_gf_lp64" >&5 +$as_echo_n "checking for $sgemm in -lmkl_gf_lp64... " >&6; } +if eval \${$as_ac_Lib+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lmkl_gf_lp64 -lmkl_gf_lp64 -lmkl_sequential -lmkl_core -lpthread $LIBS" +cat > conftest.$ac_ext <<_ACEOF + program main + call $sgemm + end +_ACEOF +if ac_fn_fc_try_link "$LINENO"; then : + eval "$as_ac_Lib=yes" +else + eval "$as_ac_Lib=no" +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +eval ac_res=\$$as_ac_Lib + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +if eval test \"x\$"$as_ac_Lib"\" = x"yes"; then : + pac_blas_ok=yes;BLAS_LIBS="-lmkl_gf_lp64 -lmkl_sequential -lmkl_core -lpthread" +fi + + # 32 bit + elif test $host_cpu = i686; then + as_ac_Lib=`$as_echo "ac_cv_lib_mkl_gf_$sgemm" | $as_tr_sh` +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $sgemm in -lmkl_gf" >&5 +$as_echo_n "checking for $sgemm in -lmkl_gf... " >&6; } +if eval \${$as_ac_Lib+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lmkl_gf -lmkl_gf -lmkl_sequential -lmkl_core -lpthread $LIBS" +cat > conftest.$ac_ext <<_ACEOF + program main + call $sgemm + end +_ACEOF +if ac_fn_fc_try_link "$LINENO"; then : + eval "$as_ac_Lib=yes" +else + eval "$as_ac_Lib=no" +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +eval ac_res=\$$as_ac_Lib + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +if eval test \"x\$"$as_ac_Lib"\" = x"yes"; then : + pac_blas_ok=yes;BLAS_LIBS="-lmkl_gf -lmkl_sequential -lmkl_core -lpthread" +fi + + fi + # MKL for other compilers (Intel, PGI, ...?) + else + # 64-bit + if test $host_cpu = x86_64; then + as_ac_Lib=`$as_echo "ac_cv_lib_mkl_intel_lp64_$sgemm" | $as_tr_sh` +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $sgemm in -lmkl_intel_lp64" >&5 +$as_echo_n "checking for $sgemm in -lmkl_intel_lp64... " >&6; } +if eval \${$as_ac_Lib+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lmkl_intel_lp64 -lmkl_intel_lp64 -lmkl_sequential -lmkl_core -lpthread $LIBS" +cat > conftest.$ac_ext <<_ACEOF + program main + call $sgemm + end +_ACEOF +if ac_fn_fc_try_link "$LINENO"; then : + eval "$as_ac_Lib=yes" +else + eval "$as_ac_Lib=no" +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +eval ac_res=\$$as_ac_Lib + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +if eval test \"x\$"$as_ac_Lib"\" = x"yes"; then : + pac_blas_ok=yes;BLAS_LIBS="-lmkl_intel_lp64 -lmkl_sequential -lmkl_core -lpthread" +fi + + # 32-bit + elif test $host_cpu = i686; then + as_ac_Lib=`$as_echo "ac_cv_lib_mkl_intel_$sgemm" | $as_tr_sh` +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $sgemm in -lmkl_intel" >&5 +$as_echo_n "checking for $sgemm in -lmkl_intel... " >&6; } +if eval \${$as_ac_Lib+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lmkl_intel -lmkl_intel -lmkl_sequential -lmkl_core -lpthread $LIBS" +cat > conftest.$ac_ext <<_ACEOF + program main + call $sgemm + end +_ACEOF +if ac_fn_fc_try_link "$LINENO"; then : + eval "$as_ac_Lib=yes" +else + eval "$as_ac_Lib=no" +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +eval ac_res=\$$as_ac_Lib + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +if eval test \"x\$"$as_ac_Lib"\" = x"yes"; then : + pac_blas_ok=yes;BLAS_LIBS="-lmkl_intel -lmkl_sequential -lmkl_core -lpthread" +fi + + fi + fi +fi +# Old versions of MKL +if test $pac_blas_ok = no; then + as_ac_Lib=`$as_echo "ac_cv_lib_mkl_$sgemm" | $as_tr_sh` +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $sgemm in -lmkl" >&5 +$as_echo_n "checking for $sgemm in -lmkl... " >&6; } +if eval \${$as_ac_Lib+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lmkl -lguide -lpthread $LIBS" +cat > conftest.$ac_ext <<_ACEOF + program main + call $sgemm + end +_ACEOF +if ac_fn_fc_try_link "$LINENO"; then : + eval "$as_ac_Lib=yes" +else + eval "$as_ac_Lib=no" +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +eval ac_res=\$$as_ac_Lib + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +if eval test \"x\$"$as_ac_Lib"\" = x"yes"; then : + pac_blas_ok=yes;BLAS_LIBS="-lmkl -lguide -lpthread" +fi + +fi + +# BLAS in Apple vecLib library? +if test $pac_blas_ok = no; then + save_LIBS="$LIBS"; LIBS="-framework vecLib $LIBS" + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $sgemm in -framework vecLib" >&5 +$as_echo_n "checking for $sgemm in -framework vecLib... " >&6; } + cat > conftest.$ac_ext <<_ACEOF + program main + call $sgemm + end +_ACEOF +if ac_fn_fc_try_link "$LINENO"; then : + pac_blas_ok=yes;BLAS_LIBS="-framework vecLib" +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $pac_blas_ok" >&5 +$as_echo "$pac_blas_ok" >&6; } + LIBS="$save_LIBS" fi # BLAS in Alpha CXML library? if test $pac_blas_ok = no; then