From bf2bb81f009f5e806fe8d76559bff2cf2a194c71 Mon Sep 17 00:00:00 2001 From: "Kurt A. O'Hearn" <ohearnk@msu.edu> Date: Tue, 29 May 2018 12:33:53 -0400 Subject: [PATCH] PG-PuReMD: update build system for LAPACKE. Conditionally include LAPACKE header based on results of compilation. --- PG-PuReMD/configure.ac | 33 +++++++++++++++++++++++++++++++-- PG-PuReMD/src/lin_alg.c | 8 ++++++++ 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/PG-PuReMD/configure.ac b/PG-PuReMD/configure.ac index b0e53e5f..7694620e 100644 --- a/PG-PuReMD/configure.ac +++ b/PG-PuReMD/configure.ac @@ -132,14 +132,43 @@ fi AC_SUBST(MPI_CFLAGS) AC_SUBST(MPI_LIBS) +# Check for LAPACKE +AC_CHECK_HEADERS([mkl.h], [MKL_FOUND_HEADERS="yes"]) +if test "x${MKL_FOUND_HEADERS}" = "xyes" +then + AC_SEARCH_LIBS([LAPACKE_dgels], [mkl_intel_ilp64], + [MKL_FOUND_LIBS="yes"], [MKL_FOUND_LIBS="no"], + [-lmkl_sequential -lmkl_core -lpthread -lm -ldl]) + AS_IF([test "x${MKL_FOUND_LIBS}" != "xyes"], + [AC_MSG_ERROR([Unable to find MKL LAPACKE library.])]) + LIBS="${LIBS} -lmkl_intel_ilp64 -lmkl_sequential -lmkl_core -lpthread -lm -ldl" + AC_DEFINE([HAVE_LAPACKE_MKL], [1], [Define to 1 if you have MKL LAPACKE support enabled.]) +else + AC_CHECK_HEADERS([lapacke.h], [LAPACKE_FOUND_HEADERS="yes"]) + if test "x${LAPACKE_FOUND_HEADERS}" = "xyes" + then + AC_SEARCH_LIBS([LAPACKE_dgels], [lapacke], + [LAPACKE_FOUND_LIBS="yes"], [LAPACKE_FOUND_LIBS="no"], + [-llapack]) + AS_IF([test "x${LAPACKE_FOUND_LIBS}" != "xyes"], + [AC_MSG_ERROR([Unable to find LAPACKE library.])]) + LIBS="${LIBS} -llapack" + AC_DEFINE([HAVE_LAPACKE], [1], [Define to 1 if you have LAPACKE support enabled.]) + else + AC_MSG_WARN([ + ----------------------------------------------- + Unable to find LAPACKE on this system. + Disabling support for dependent methods. + -----------------------------------------------]) + fi +fi + AC_LANG([C++]) # Checks for programs. AC_PROG_CXX([icpc g++ clang++ c++]) AC_PROG_CXXCPP -AX_COMPILER_VENDOR - # Check for CUDA support. if test "x${BUILD_GPU}" = "xyes"; then CONFIGURE_HEADLINE([ CUDA support ]) diff --git a/PG-PuReMD/src/lin_alg.c b/PG-PuReMD/src/lin_alg.c index 33c2c6a8..178efee2 100644 --- a/PG-PuReMD/src/lin_alg.c +++ b/PG-PuReMD/src/lin_alg.c @@ -28,6 +28,14 @@ #include "tool_box.h" #include "vector.h" +/* Intel MKL */ +#if defined(HAVE_LAPACKE_MKL) + #include "mkl.h" +/* reference LAPACK */ +#elif defined(HAVE_LAPACKE) + #include "lapacke.h" +#endif + #if defined(HAVE_CUDA) && defined(DEBUG) #include "cuda/cuda_validation.h" #endif -- GitLab