Unverified Commit 5d29b362 authored by Lucas Hosseini's avatar Lucas Hosseini Committed by GitHub

Use multi-threaded MKL by default (#509)

* Configure script use threaded MKL instead of sequential.

* Do not link against GNU OpenMP when linking against Intel OpenMP.
parent 6880286e
...@@ -81,6 +81,8 @@ case $with_blas in ...@@ -81,6 +81,8 @@ case $with_blas in
*) BLAS_LIBS="-l$with_blas" ;; *) BLAS_LIBS="-l$with_blas" ;;
esac esac
OPENMP_LDFLAGS="$OPENMP_CXXFLAGS"
# Get fortran linker names of BLAS functions to check for. # Get fortran linker names of BLAS functions to check for.
# AC_F77_FUNC(sgemm) # AC_F77_FUNC(sgemm)
# AC_F77_FUNC(dgemm) # AC_F77_FUNC(dgemm)
...@@ -112,33 +114,24 @@ fi ...@@ -112,33 +114,24 @@ fi
# BLAS in Intel MKL library? # BLAS in Intel MKL library?
if test $ax_blas_ok = no; then if test $ax_blas_ok = no; then
# MKL for gfortran case $host_os in
if test x"$ac_cv_fc_compiler_gnu" = xyes; then darwin*)
# 64 bit AC_CHECK_LIB(mkl_intel_lp64, $sgemm,
if test $host_cpu = x86_64; then [ax_blas_ok=yes;BLAS_LIBS="-lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core -liomp5 -lpthread"; OPENMP_LDFLAGS=""],,
AC_CHECK_LIB(mkl_gf_lp64, $sgemm, [-lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core -liomp5 -lpthread])
[ax_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,
[ax_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 if test $host_cpu = x86_64; then
AC_CHECK_LIB(mkl_intel_lp64, $sgemm, AC_CHECK_LIB(mkl_intel_lp64, $sgemm,
[ax_blas_ok=yes;BLAS_LIBS="-lmkl_intel_lp64 -lmkl_sequential -lmkl_core -lpthread"],, [ax_blas_ok=yes;BLAS_LIBS="-lmkl_intel_lp64 -lmkl_gnu_thread -lmkl_core -lgomp -lpthread -lm -ldl"],,
[-lmkl_intel_lp64 -lmkl_sequential -lmkl_core -lpthread]) [-lmkl_intel_lp64 -lmkl_gnu_thread -lmkl_core -lgomp -lpthread -lm -ldl])
# 32-bit
elif test $host_cpu = i686; then elif test $host_cpu = i686; then
AC_CHECK_LIB(mkl_intel, $sgemm, AC_CHECK_LIB(mkl_intel, $sgemm,
[ax_blas_ok=yes;BLAS_LIBS="-lmkl_intel -lmkl_sequential -lmkl_core -lpthread"],, [ax_blas_ok=yes;BLAS_LIBS="-lmkl_intel -lmkl_gnu_thread -lmkl_core -lgomp -lpthread -lm -ldl"],,
[-lmkl_intel -lmkl_sequential -lmkl_core -lpthread]) [-lmkl_intel -lmkl_gnu_thread -lmkl_core -lgomp -lpthread -lm -ldl])
fi
fi fi
;;
esac
fi fi
# Old versions of MKL # Old versions of MKL
if test $ax_blas_ok = no; then if test $ax_blas_ok = no; then
...@@ -226,6 +219,7 @@ if test $ax_blas_ok = no; then ...@@ -226,6 +219,7 @@ if test $ax_blas_ok = no; then
fi fi
AC_SUBST(BLAS_LIBS) AC_SUBST(BLAS_LIBS)
AC_SUBST(OPENMP_LDFLAGS)
LIBS="$ax_blas_save_LIBS" LIBS="$ax_blas_save_LIBS"
......
...@@ -627,6 +627,7 @@ ac_includes_default="\ ...@@ -627,6 +627,7 @@ ac_includes_default="\
ac_header_list= ac_header_list=
ac_subst_vars='LTLIBOBJS ac_subst_vars='LTLIBOBJS
LAPACK_LIBS LAPACK_LIBS
OPENMP_LDFLAGS
BLAS_LIBS BLAS_LIBS
host_os host_os
host_vendor host_vendor
...@@ -5646,6 +5647,8 @@ case $with_blas in ...@@ -5646,6 +5647,8 @@ case $with_blas in
*) BLAS_LIBS="-l$with_blas" ;; *) BLAS_LIBS="-l$with_blas" ;;
esac esac
OPENMP_LDFLAGS="$OPENMP_CXXFLAGS"
# Get fortran linker names of BLAS functions to check for. # Get fortran linker names of BLAS functions to check for.
# AC_F77_FUNC(sgemm) # AC_F77_FUNC(sgemm)
# AC_F77_FUNC(dgemm) # AC_F77_FUNC(dgemm)
...@@ -5727,62 +5730,16 @@ fi ...@@ -5727,62 +5730,16 @@ fi
# BLAS in Intel MKL library? # BLAS in Intel MKL library?
if test $ax_blas_ok = no; then if test $ax_blas_ok = no; then
# MKL for gfortran case $host_os in
if test x"$ac_cv_fc_compiler_gnu" = xyes; then darwin*)
# 64 bit as_ac_Lib=`$as_echo "ac_cv_lib_mkl_intel_lp64_$sgemm" | $as_tr_sh`
if test $host_cpu = x86_64; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $sgemm in -lmkl_intel_lp64" >&5
as_ac_Lib=`$as_echo "ac_cv_lib_mkl_gf_lp64_$sgemm" | $as_tr_sh` $as_echo_n "checking for $sgemm in -lmkl_intel_lp64... " >&6; }
{ $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 confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char $sgemm ();
int
main ()
{
return $sgemm ();
;
return 0;
}
_ACEOF
if ac_fn_cxx_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 :
ax_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 : if eval \${$as_ac_Lib+:} false; then :
$as_echo_n "(cached) " >&6 $as_echo_n "(cached) " >&6
else else
ac_check_lib_save_LIBS=$LIBS ac_check_lib_save_LIBS=$LIBS
LIBS="-lmkl_gf -lmkl_gf -lmkl_sequential -lmkl_core -lpthread $LIBS" LIBS="-lmkl_intel_lp64 -lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core -liomp5 -lpthread $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */ /* end confdefs.h. */
...@@ -5814,13 +5771,11 @@ eval ac_res=\$$as_ac_Lib ...@@ -5814,13 +5771,11 @@ eval ac_res=\$$as_ac_Lib
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
$as_echo "$ac_res" >&6; } $as_echo "$ac_res" >&6; }
if eval test \"x\$"$as_ac_Lib"\" = x"yes"; then : if eval test \"x\$"$as_ac_Lib"\" = x"yes"; then :
ax_blas_ok=yes;BLAS_LIBS="-lmkl_gf -lmkl_sequential -lmkl_core -lpthread" ax_blas_ok=yes;BLAS_LIBS="-lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core -liomp5 -lpthread"; OPENMP_LDFLAGS=""
fi fi
fi ;;
# MKL for other compilers (Intel, PGI, ...?) *)
else
# 64-bit
if test $host_cpu = x86_64; then if test $host_cpu = x86_64; then
as_ac_Lib=`$as_echo "ac_cv_lib_mkl_intel_lp64_$sgemm" | $as_tr_sh` 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 "$as_me:${as_lineno-$LINENO}: checking for $sgemm in -lmkl_intel_lp64" >&5
...@@ -5829,7 +5784,7 @@ if eval \${$as_ac_Lib+:} false; then : ...@@ -5829,7 +5784,7 @@ if eval \${$as_ac_Lib+:} false; then :
$as_echo_n "(cached) " >&6 $as_echo_n "(cached) " >&6
else else
ac_check_lib_save_LIBS=$LIBS ac_check_lib_save_LIBS=$LIBS
LIBS="-lmkl_intel_lp64 -lmkl_intel_lp64 -lmkl_sequential -lmkl_core -lpthread $LIBS" LIBS="-lmkl_intel_lp64 -lmkl_intel_lp64 -lmkl_gnu_thread -lmkl_core -lgomp -lpthread -lm -ldl $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */ /* end confdefs.h. */
...@@ -5861,10 +5816,9 @@ eval ac_res=\$$as_ac_Lib ...@@ -5861,10 +5816,9 @@ eval ac_res=\$$as_ac_Lib
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
$as_echo "$ac_res" >&6; } $as_echo "$ac_res" >&6; }
if eval test \"x\$"$as_ac_Lib"\" = x"yes"; then : if eval test \"x\$"$as_ac_Lib"\" = x"yes"; then :
ax_blas_ok=yes;BLAS_LIBS="-lmkl_intel_lp64 -lmkl_sequential -lmkl_core -lpthread" ax_blas_ok=yes;BLAS_LIBS="-lmkl_intel_lp64 -lmkl_gnu_thread -lmkl_core -lgomp -lpthread -lm -ldl"
fi fi
# 32-bit
elif test $host_cpu = i686; then elif test $host_cpu = i686; then
as_ac_Lib=`$as_echo "ac_cv_lib_mkl_intel_$sgemm" | $as_tr_sh` 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 "$as_me:${as_lineno-$LINENO}: checking for $sgemm in -lmkl_intel" >&5
...@@ -5873,7 +5827,7 @@ if eval \${$as_ac_Lib+:} false; then : ...@@ -5873,7 +5827,7 @@ if eval \${$as_ac_Lib+:} false; then :
$as_echo_n "(cached) " >&6 $as_echo_n "(cached) " >&6
else else
ac_check_lib_save_LIBS=$LIBS ac_check_lib_save_LIBS=$LIBS
LIBS="-lmkl_intel -lmkl_intel -lmkl_sequential -lmkl_core -lpthread $LIBS" LIBS="-lmkl_intel -lmkl_intel -lmkl_gnu_thread -lmkl_core -lgomp -lpthread -lm -ldl $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */ /* end confdefs.h. */
...@@ -5905,11 +5859,12 @@ eval ac_res=\$$as_ac_Lib ...@@ -5905,11 +5859,12 @@ eval ac_res=\$$as_ac_Lib
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
$as_echo "$ac_res" >&6; } $as_echo "$ac_res" >&6; }
if eval test \"x\$"$as_ac_Lib"\" = x"yes"; then : if eval test \"x\$"$as_ac_Lib"\" = x"yes"; then :
ax_blas_ok=yes;BLAS_LIBS="-lmkl_intel -lmkl_sequential -lmkl_core -lpthread" ax_blas_ok=yes;BLAS_LIBS="-lmkl_intel -lmkl_gnu_thread -lmkl_core -lgomp -lpthread -lm -ldl"
fi fi
fi fi
fi ;;
esac
fi fi
# Old versions of MKL # Old versions of MKL
if test $ax_blas_ok = no; then if test $ax_blas_ok = no; then
...@@ -6697,6 +6652,7 @@ fi ...@@ -6697,6 +6652,7 @@ fi
LIBS="$ax_blas_save_LIBS" LIBS="$ax_blas_save_LIBS"
# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND: # Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
......
...@@ -11,7 +11,7 @@ CXXCPP = @CXXCPP@ ...@@ -11,7 +11,7 @@ CXXCPP = @CXXCPP@
CPPFLAGS = -DFINTEGER=int @CPPFLAGS@ CPPFLAGS = -DFINTEGER=int @CPPFLAGS@
CXXFLAGS = -fPIC @OPENMP_CXXFLAGS@ -m64 -Wno-sign-compare @CXXFLAGS@ CXXFLAGS = -fPIC @OPENMP_CXXFLAGS@ -m64 -Wno-sign-compare @CXXFLAGS@
CPUFLAGS = -msse4 -mpopcnt CPUFLAGS = -msse4 -mpopcnt
LDFLAGS = @OPENMP_CXXFLAGS@ @LDFLAGS@ LDFLAGS = @OPENMP_LDFLAGS@ @LDFLAGS@
LIBS = @BLAS_LIBS@ @LAPACK_LIBS@ @LIBS@ LIBS = @BLAS_LIBS@ @LAPACK_LIBS@ @LIBS@
PYTHONCFLAGS = @PYTHON_CFLAGS@ -I@NUMPY_INCLUDE@ PYTHONCFLAGS = @PYTHON_CFLAGS@ -I@NUMPY_INCLUDE@
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment