From f0d52f55f155ac3f3e2bafa072a4e0d7f1431d76 Mon Sep 17 00:00:00 2001 From: Jakub Benda Date: Sun, 18 Nov 2018 14:52:13 +0000 Subject: FindBLAS: Consolidate duplicated code related to MKL on Windows The code that decides which library suffix to use for MKL libraries in Windows was in two places. This commit consolidates it in one place. --- Modules/FindBLAS.cmake | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/Modules/FindBLAS.cmake b/Modules/FindBLAS.cmake index d150826..369bf06 100644 --- a/Modules/FindBLAS.cmake +++ b/Modules/FindBLAS.cmake @@ -205,6 +205,13 @@ endif () #BLAS in intel mkl 10+ library? (em64t 64bit) if (BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All") if (NOT BLAS_LIBRARIES) + if (WIN32) + if (BLA_STATIC) + set(BLAS_mkl_DLL_SUFFIX "") + else() + set(BLAS_mkl_DLL_SUFFIX "_dll") + endif() + endif() if (BLA_VENDOR MATCHES "_64ilp") set(BLAS_mkl_ILP_MODE "ilp64") else () @@ -226,12 +233,6 @@ if (BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All") set(BLAS_mkl_SEARCH_SYMBOL sgemm_f95) set(_LIBRARIES BLAS95_LIBRARIES) if (WIN32) - if (BLA_STATIC) - set(BLAS_mkl_DLL_SUFFIX "") - else() - set(BLAS_mkl_DLL_SUFFIX "_dll") - endif() - # Find the main file (32-bit or 64-bit) set(BLAS_SEARCH_LIBS_WIN_MAIN "") if (BLA_VENDOR STREQUAL "Intel10_32" OR BLA_VENDOR STREQUAL "All") @@ -293,12 +294,6 @@ if (BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All") set(BLAS_mkl_SEARCH_SYMBOL sgemm) set(_LIBRARIES BLAS_LIBRARIES) if (WIN32) - if (BLA_STATIC) - set(BLAS_mkl_DLL_SUFFIX "") - else() - set(BLAS_mkl_DLL_SUFFIX "_dll") - endif() - # Find the main file (32-bit or 64-bit) set(BLAS_SEARCH_LIBS_WIN_MAIN "") if (BLA_VENDOR STREQUAL "Intel10_32" OR BLA_VENDOR STREQUAL "All") -- cgit v0.12 From fc149a72f7e9128c0ad54014d745500fd31eea36 Mon Sep 17 00:00:00 2001 From: Jakub Benda Date: Sun, 18 Nov 2018 15:05:28 +0000 Subject: FindBLAS: Support combination of gfortran and Intel MKL The module FindBLAS now correctly chooses MKL BLAS libraries to search, based on the compiler ID. The MKL libraries needed for BLAS functionality are the following: libmkl_{gf|intel}_{lp64|ilp64}.{a|so} libmkl_{gnu|intel}_thread.{a|so} (or libmkl_sequential.{a|so}) libmkl_core.{a|so} libm libdl lib{gomp|iomp5}.{a|so} (only with libmkl_*_thread.*) To achieve the goal, the following internal variables are defined and used: BLAS_mkl_INTFACE = "gf" or "intel" (based on compiler ID) BLAS_mkl_THREADING = "gnu" or "intel" (based on compiler ID) BLAS_mkl_OMP = "gomp" or "iomp5" (based on compiler ID) BLAS_mkl_LM = "-lm" (not set on Windows) BLAS_mkl_DL = "-ldl" (not set on Windows) The default values for the first three of them are "intel" and "iomp5", unless a Fortran compiler is loaded with CMAKE_Fortran_COMPILER_ID equal to "GNU"; in such case the "gf", "gnu" and "gomp" values are used. In non-Windows systems, the thread library as well as libm and libdl are now added to the linker line to allow static linking of libgomp. --- Modules/FindBLAS.cmake | 61 ++++++++++++++++++++++++++++++-------------------- 1 file changed, 37 insertions(+), 24 deletions(-) diff --git a/Modules/FindBLAS.cmake b/Modules/FindBLAS.cmake index 369bf06..d113579 100644 --- a/Modules/FindBLAS.cmake +++ b/Modules/FindBLAS.cmake @@ -126,6 +126,8 @@ macro(Check_Fortran_Libraries LIBRARIES _prefix _name _flags _list _thread) endif () endif () + list(APPEND _libdir "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}") + foreach(_library ${_list}) set(_combined_name ${_combined_name}_${_library}) @@ -170,6 +172,8 @@ macro(Check_Fortran_Libraries LIBRARIES _prefix _name _flags _list _thread) if(_libraries_work) if("${_list}" STREQUAL "") set(${LIBRARIES} "${LIBRARIES}-PLACEHOLDER-FOR-EMPTY-LIBRARIES") + else() + set(${LIBRARIES} ${${LIBRARIES}} ${_thread}) # for static link endif() else() set(${LIBRARIES} FALSE) @@ -205,21 +209,34 @@ endif () #BLAS in intel mkl 10+ library? (em64t 64bit) if (BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All") if (NOT BLAS_LIBRARIES) + + # System-specific settings if (WIN32) if (BLA_STATIC) set(BLAS_mkl_DLL_SUFFIX "") else() set(BLAS_mkl_DLL_SUFFIX "_dll") endif() + else() + if(CMAKE_Fortran_COMPILER_LOADED AND CMAKE_Fortran_COMPILER_ID STREQUAL "GNU") + set(BLAS_mkl_INTFACE "gf") + set(BLAS_mkl_THREADING "gnu") + set(BLAS_mkl_OMP "gomp") + else() + set(BLAS_mkl_INTFACE "intel") + set(BLAS_mkl_THREADING "intel") + set(BLAS_mkl_OMP "iomp5") + endif() + set(BLAS_mkl_LM "-lm") + set(BLAS_mkl_LDL "-ldl") endif() + if (BLA_VENDOR MATCHES "_64ilp") set(BLAS_mkl_ILP_MODE "ilp64") else () set(BLAS_mkl_ILP_MODE "lp64") endif () - if (NOT WIN32) - set(LM "-lm") - endif () + if (CMAKE_C_COMPILER_LOADED OR CMAKE_CXX_COMPILER_LOADED) if(BLAS_FIND_QUIETLY OR NOT BLAS_FIND_REQUIRED) find_package(Threads) @@ -269,25 +286,20 @@ if (BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All") else () if (BLA_VENDOR STREQUAL "Intel10_32" OR BLA_VENDOR STREQUAL "All") list(APPEND BLAS_SEARCH_LIBS - "mkl_blas95 mkl_intel mkl_intel_thread mkl_core guide") + "mkl_blas95 mkl_${BLAS_mkl_INTFACE} mkl_${BLAS_mkl_THREADING}_thread mkl_core guide") endif () if (BLA_VENDOR MATCHES "^Intel10_64i?lp$" OR BLA_VENDOR STREQUAL "All") # old version list(APPEND BLAS_SEARCH_LIBS - "mkl_blas95 mkl_intel_${BLAS_mkl_ILP_MODE} mkl_intel_thread mkl_core guide") + "mkl_blas95 mkl_${BLAS_mkl_INTFACE}_${BLAS_mkl_ILP_MODE} mkl_${BLAS_mkl_THREADING}_thread mkl_core guide") # mkl >= 10.3 - if (CMAKE_C_COMPILER MATCHES ".+gcc") - list(APPEND BLAS_SEARCH_LIBS - "mkl_blas95_${BLAS_mkl_ILP_MODE} mkl_intel_${BLAS_mkl_ILP_MODE} mkl_gnu_thread mkl_core gomp") - else () - list(APPEND BLAS_SEARCH_LIBS - "mkl_blas95_${BLAS_mkl_ILP_MODE} mkl_intel_${BLAS_mkl_ILP_MODE} mkl_intel_thread mkl_core iomp5") - endif () + list(APPEND BLAS_SEARCH_LIBS + "mkl_blas95_${BLAS_mkl_ILP_MODE} mkl_${BLAS_mkl_INTFACE}_${BLAS_mkl_ILP_MODE} mkl_${BLAS_mkl_THREADING}_thread mkl_core ${BLAS_mkl_OMP}") endif () if (BLA_VENDOR MATCHES "^Intel10_64i?lp_seq$" OR BLA_VENDOR STREQUAL "All") list(APPEND BLAS_SEARCH_LIBS - "mkl_blas95_${BLAS_mkl_ILP_MODE} mkl_intel_${BLAS_mkl_ILP_MODE} mkl_sequential mkl_core") + "mkl_blas95_${BLAS_mkl_ILP_MODE} mkl_${BLAS_mkl_INTFACE}_${BLAS_mkl_ILP_MODE} mkl_sequential mkl_core") endif () endif () else () @@ -330,26 +342,21 @@ if (BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All") else () if (BLA_VENDOR STREQUAL "Intel10_32" OR BLA_VENDOR STREQUAL "All") list(APPEND BLAS_SEARCH_LIBS - "mkl_intel mkl_intel_thread mkl_core guide") + "mkl_${BLAS_mkl_INTFACE} mkl_${BLAS_mkl_THREADING}_thread mkl_core guide") endif () if (BLA_VENDOR MATCHES "^Intel10_64i?lp$" OR BLA_VENDOR STREQUAL "All") # old version list(APPEND BLAS_SEARCH_LIBS - "mkl_intel_${BLAS_mkl_ILP_MODE} mkl_intel_thread mkl_core guide") + "mkl_${BLAS_mkl_INTFACE}_${BLAS_mkl_ILP_MODE} mkl_${BLAS_mkl_THREADING}_thread mkl_core guide") # mkl >= 10.3 - if (CMAKE_C_COMPILER MATCHES ".+gcc") - list(APPEND BLAS_SEARCH_LIBS - "mkl_intel_${BLAS_mkl_ILP_MODE} mkl_gnu_thread mkl_core gomp") - else () - list(APPEND BLAS_SEARCH_LIBS - "mkl_intel_${BLAS_mkl_ILP_MODE} mkl_intel_thread mkl_core iomp5") - endif () + list(APPEND BLAS_SEARCH_LIBS + "mkl_${BLAS_mkl_INTFACE}_${BLAS_mkl_ILP_MODE} mkl_${BLAS_mkl_THREADING}_thread mkl_core ${BLAS_mkl_OMP}") endif () if (BLA_VENDOR MATCHES "^Intel10_64i?lp_seq$" OR BLA_VENDOR STREQUAL "All") list(APPEND BLAS_SEARCH_LIBS - "mkl_intel_${BLAS_mkl_ILP_MODE} mkl_sequential mkl_core") + "mkl_${BLAS_mkl_INTFACE}_${BLAS_mkl_ILP_MODE} mkl_sequential mkl_core") endif () #older vesions of intel mkl libs @@ -373,13 +380,19 @@ if (BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All") ${BLAS_mkl_SEARCH_SYMBOL} "" "${SEARCH_LIBS}" - "${CMAKE_THREAD_LIBS_INIT};${LM}" + "${CMAKE_THREAD_LIBS_INIT};${BLAS_mkl_LM};${BLAS_mkl_LDL}" ) endif () endforeach () endif () unset(BLAS_mkl_ILP_MODE) + unset(BLAS_mkl_INTFACE) + unset(BLAS_mkl_THREADING) + unset(BLAS_mkl_OMP) + unset(BLAS_mkl_DLL_SUFFIX) + unset(BLAS_mkl_LM) + unset(BLAS_mkl_LDL) endif () endif () -- cgit v0.12 From b4edf7b5d2b2ba8eccfa0230dad98d0815a17d5d Mon Sep 17 00:00:00 2001 From: Jakub Benda Date: Sun, 18 Nov 2018 16:14:39 +0000 Subject: FindBLAS: Support 32bit Intel MKL 10.3+ The module FindBLAS now correctly finds Intel MKL distributions that do not have the (long deprecated) library "libguide", but use "libiomp5" instead. --- Modules/FindBLAS.cmake | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Modules/FindBLAS.cmake b/Modules/FindBLAS.cmake index d113579..c286a4d 100644 --- a/Modules/FindBLAS.cmake +++ b/Modules/FindBLAS.cmake @@ -285,8 +285,13 @@ if (BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All") endforeach() else () if (BLA_VENDOR STREQUAL "Intel10_32" OR BLA_VENDOR STREQUAL "All") + # old version list(APPEND BLAS_SEARCH_LIBS "mkl_blas95 mkl_${BLAS_mkl_INTFACE} mkl_${BLAS_mkl_THREADING}_thread mkl_core guide") + + # mkl >= 10.3 + list(APPEND BLAS_SEARCH_LIBS + "mkl_blas95 mkl_${BLAS_mkl_INTFACE} mkl_${BLAS_mkl_THREADING}_thread mkl_core ${BLAS_mkl_OMP}") endif () if (BLA_VENDOR MATCHES "^Intel10_64i?lp$" OR BLA_VENDOR STREQUAL "All") # old version @@ -341,11 +346,15 @@ if (BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All") endforeach() else () if (BLA_VENDOR STREQUAL "Intel10_32" OR BLA_VENDOR STREQUAL "All") + # old version list(APPEND BLAS_SEARCH_LIBS "mkl_${BLAS_mkl_INTFACE} mkl_${BLAS_mkl_THREADING}_thread mkl_core guide") + + # mkl >= 10.3 + list(APPEND BLAS_SEARCH_LIBS + "mkl_${BLAS_mkl_INTFACE} mkl_${BLAS_mkl_THREADING}_thread mkl_core ${BLAS_mkl_OMP}") endif () if (BLA_VENDOR MATCHES "^Intel10_64i?lp$" OR BLA_VENDOR STREQUAL "All") - # old version list(APPEND BLAS_SEARCH_LIBS "mkl_${BLAS_mkl_INTFACE}_${BLAS_mkl_ILP_MODE} mkl_${BLAS_mkl_THREADING}_thread mkl_core guide") -- cgit v0.12 From 03879b11af0b2179d879358df3cce3c2b7acb047 Mon Sep 17 00:00:00 2001 From: Jakub Benda Date: Sun, 18 Nov 2018 19:48:23 +0000 Subject: FindLAPACK: Prioritize Intel MKL As in FindBLAS, the Intel Math Kernel Library is now the preferred LAPACK vendor. (The corresponding section of the code has been moved upwards.) --- Modules/FindLAPACK.cmake | 152 ++++++++++++++++++++++++----------------------- 1 file changed, 77 insertions(+), 75 deletions(-) diff --git a/Modules/FindLAPACK.cmake b/Modules/FindLAPACK.cmake index 62ff94c..d8daef2 100644 --- a/Modules/FindLAPACK.cmake +++ b/Modules/FindLAPACK.cmake @@ -175,6 +175,83 @@ if(BLAS_FOUND) endif() endif () +#intel lapack +if (BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All") + if (NOT WIN32) + set(LM "-lm") + endif () + if (CMAKE_C_COMPILER_LOADED OR CMAKE_CXX_COMPILER_LOADED) + if(LAPACK_FIND_QUIETLY OR NOT LAPACK_FIND_REQUIRED) + find_PACKAGE(Threads) + else() + find_package(Threads REQUIRED) + endif() + + if (BLA_VENDOR MATCHES "_64ilp") + set(BLAS_mkl_ILP_MODE "ilp64") + else () + set(BLAS_mkl_ILP_MODE "lp64") + endif () + + set(LAPACK_SEARCH_LIBS "") + + if (BLA_F95) + set(LAPACK_mkl_SEARCH_SYMBOL "cheev_f95") + set(_LIBRARIES LAPACK95_LIBRARIES) + set(_BLAS_LIBRARIES ${BLAS95_LIBRARIES}) + + # old + list(APPEND LAPACK_SEARCH_LIBS + "mkl_lapack95") + # new >= 10.3 + list(APPEND LAPACK_SEARCH_LIBS + "mkl_intel_c") + list(APPEND LAPACK_SEARCH_LIBS + "mkl_lapack95_${BLAS_mkl_ILP_MODE}") + else() + set(LAPACK_mkl_SEARCH_SYMBOL "cheev") + set(_LIBRARIES LAPACK_LIBRARIES) + set(_BLAS_LIBRARIES ${BLAS_LIBRARIES}) + + # old + list(APPEND LAPACK_SEARCH_LIBS + "mkl_lapack") + # new >= 10.3 + list(APPEND LAPACK_SEARCH_LIBS + "mkl_gf_${BLAS_mkl_ILP_MODE}") + endif() + + # First try empty lapack libs + if (NOT ${_LIBRARIES}) + check_lapack_libraries( + ${_LIBRARIES} + BLAS + ${LAPACK_mkl_SEARCH_SYMBOL} + "" + "" + "${_BLAS_LIBRARIES}" + "${CMAKE_THREAD_LIBS_INIT};${LM}" + ) + endif () + # Then try the search libs + foreach (IT ${LAPACK_SEARCH_LIBS}) + if (NOT ${_LIBRARIES}) + check_lapack_libraries( + ${_LIBRARIES} + BLAS + ${LAPACK_mkl_SEARCH_SYMBOL} + "" + "${IT}" + "${_BLAS_LIBRARIES}" + "${CMAKE_THREAD_LIBS_INIT};${LM}" + ) + endif () + endforeach () + + unset(BLAS_mkl_ILP_MODE) + endif () +endif() + if (BLA_VENDOR STREQUAL "Goto" OR BLA_VENDOR STREQUAL "All") if(NOT LAPACK_LIBRARIES) check_lapack_libraries( @@ -267,82 +344,7 @@ if (BLA_VENDOR STREQUAL "Generic" OR ) endif () endif () -#intel lapack -if (BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All") - if (NOT WIN32) - set(LM "-lm") - endif () - if (CMAKE_C_COMPILER_LOADED OR CMAKE_CXX_COMPILER_LOADED) - if(LAPACK_FIND_QUIETLY OR NOT LAPACK_FIND_REQUIRED) - find_PACKAGE(Threads) - else() - find_package(Threads REQUIRED) - endif() - - if (BLA_VENDOR MATCHES "_64ilp") - set(BLAS_mkl_ILP_MODE "ilp64") - else () - set(BLAS_mkl_ILP_MODE "lp64") - endif () - - set(LAPACK_SEARCH_LIBS "") - - if (BLA_F95) - set(LAPACK_mkl_SEARCH_SYMBOL "cheev_f95") - set(_LIBRARIES LAPACK95_LIBRARIES) - set(_BLAS_LIBRARIES ${BLAS95_LIBRARIES}) - - # old - list(APPEND LAPACK_SEARCH_LIBS - "mkl_lapack95") - # new >= 10.3 - list(APPEND LAPACK_SEARCH_LIBS - "mkl_intel_c") - list(APPEND LAPACK_SEARCH_LIBS - "mkl_lapack95_${BLAS_mkl_ILP_MODE}") - else() - set(LAPACK_mkl_SEARCH_SYMBOL "cheev") - set(_LIBRARIES LAPACK_LIBRARIES) - set(_BLAS_LIBRARIES ${BLAS_LIBRARIES}) - # old - list(APPEND LAPACK_SEARCH_LIBS - "mkl_lapack") - # new >= 10.3 - list(APPEND LAPACK_SEARCH_LIBS - "mkl_gf_${BLAS_mkl_ILP_MODE}") - endif() - - # First try empty lapack libs - if (NOT ${_LIBRARIES}) - check_lapack_libraries( - ${_LIBRARIES} - BLAS - ${LAPACK_mkl_SEARCH_SYMBOL} - "" - "" - "${_BLAS_LIBRARIES}" - "${CMAKE_THREAD_LIBS_INIT};${LM}" - ) - endif () - # Then try the search libs - foreach (IT ${LAPACK_SEARCH_LIBS}) - if (NOT ${_LIBRARIES}) - check_lapack_libraries( - ${_LIBRARIES} - BLAS - ${LAPACK_mkl_SEARCH_SYMBOL} - "" - "${IT}" - "${_BLAS_LIBRARIES}" - "${CMAKE_THREAD_LIBS_INIT};${LM}" - ) - endif () - endforeach () - - unset(BLAS_mkl_ILP_MODE) - endif () -endif() else() message(STATUS "LAPACK requires BLAS") endif() -- cgit v0.12 From ede1715c1d4f35e806e3dabddd09c39eeed9a628 Mon Sep 17 00:00:00 2001 From: Jakub Benda Date: Sun, 18 Nov 2018 19:53:32 +0000 Subject: FindLAPACK: Remove MKL components already provided by MKL BLAS A surplus library libmkl_gf_... has been removed from the LAPACK libraries serach path (when relevant, it is already provided by BLAS). Similarly, the thread libraries do not need to be explicitly added to the implicit LAPACK libraries, as they are already included in the list (via BLAS libraries provided by FindBLAS). --- Modules/FindLAPACK.cmake | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Modules/FindLAPACK.cmake b/Modules/FindLAPACK.cmake index d8daef2..ad1cd45 100644 --- a/Modules/FindLAPACK.cmake +++ b/Modules/FindLAPACK.cmake @@ -216,9 +216,6 @@ if (BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All") # old list(APPEND LAPACK_SEARCH_LIBS "mkl_lapack") - # new >= 10.3 - list(APPEND LAPACK_SEARCH_LIBS - "mkl_gf_${BLAS_mkl_ILP_MODE}") endif() # First try empty lapack libs @@ -230,7 +227,7 @@ if (BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All") "" "" "${_BLAS_LIBRARIES}" - "${CMAKE_THREAD_LIBS_INIT};${LM}" + "" ) endif () # Then try the search libs -- cgit v0.12 From 8b63265ea53dbd2e035a6b616ba0e82bfc0decc0 Mon Sep 17 00:00:00 2001 From: Jakub Benda Date: Sun, 18 Nov 2018 20:00:14 +0000 Subject: FindLAPACK: Unify internal variables related to MKL Auxiliary internal variables related to MKL are now consistently prefixed with LAPACK_mkl_ and unset at the end of the MKL section. --- Modules/FindLAPACK.cmake | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/Modules/FindLAPACK.cmake b/Modules/FindLAPACK.cmake index ad1cd45..89a1430 100644 --- a/Modules/FindLAPACK.cmake +++ b/Modules/FindLAPACK.cmake @@ -178,7 +178,7 @@ if(BLAS_FOUND) #intel lapack if (BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All") if (NOT WIN32) - set(LM "-lm") + set(LAPACK_mkl_LM "-lm") endif () if (CMAKE_C_COMPILER_LOADED OR CMAKE_CXX_COMPILER_LOADED) if(LAPACK_FIND_QUIETLY OR NOT LAPACK_FIND_REQUIRED) @@ -188,9 +188,9 @@ if (BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All") endif() if (BLA_VENDOR MATCHES "_64ilp") - set(BLAS_mkl_ILP_MODE "ilp64") + set(LAPACK_mkl_ILP_MODE "ilp64") else () - set(BLAS_mkl_ILP_MODE "lp64") + set(LAPACK_mkl_ILP_MODE "lp64") endif () set(LAPACK_SEARCH_LIBS "") @@ -207,7 +207,7 @@ if (BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All") list(APPEND LAPACK_SEARCH_LIBS "mkl_intel_c") list(APPEND LAPACK_SEARCH_LIBS - "mkl_lapack95_${BLAS_mkl_ILP_MODE}") + "mkl_lapack95_${LAPACK_mkl_ILP_MODE}") else() set(LAPACK_mkl_SEARCH_SYMBOL "cheev") set(_LIBRARIES LAPACK_LIBRARIES) @@ -222,7 +222,7 @@ if (BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All") if (NOT ${_LIBRARIES}) check_lapack_libraries( ${_LIBRARIES} - BLAS + LAPACK ${LAPACK_mkl_SEARCH_SYMBOL} "" "" @@ -235,17 +235,19 @@ if (BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All") if (NOT ${_LIBRARIES}) check_lapack_libraries( ${_LIBRARIES} - BLAS + LAPACK ${LAPACK_mkl_SEARCH_SYMBOL} "" "${IT}" "${_BLAS_LIBRARIES}" - "${CMAKE_THREAD_LIBS_INIT};${LM}" + "${CMAKE_THREAD_LIBS_INIT};${LAPACK_mkl_LM}" ) endif () endforeach () - unset(BLAS_mkl_ILP_MODE) + unset(LAPACK_mkl_ILP_MODE) + unset(LAPACK_mkl_SEARCH_SYMBOL) + unset(LAPACK_mkl_LM) endif () endif() -- cgit v0.12 From d5f691be0b78a48e836dc42b97d000ba151c44d6 Mon Sep 17 00:00:00 2001 From: Jakub Benda Date: Sun, 18 Nov 2018 20:16:39 +0000 Subject: FindLAPACK: Additional libraries for MKL+gfortran combination As per Intel MKL command line advisor, "libdl" is added to the list of libraries that provide LAPACK functionality. Furthermore, the implicit link directories are added to the searched libraries to allow finding of "libgomp". --- Modules/FindLAPACK.cmake | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Modules/FindLAPACK.cmake b/Modules/FindLAPACK.cmake index 89a1430..7619664 100644 --- a/Modules/FindLAPACK.cmake +++ b/Modules/FindLAPACK.cmake @@ -96,6 +96,9 @@ if (NOT _libdir) set(_libdir ENV LD_LIBRARY_PATH) endif () endif () + +list(APPEND _libdir "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}") + foreach(_library ${_list}) set(_combined_name ${_combined_name}_${_library}) @@ -179,6 +182,7 @@ if(BLAS_FOUND) if (BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All") if (NOT WIN32) set(LAPACK_mkl_LM "-lm") + set(LAPACK_mkl_LDL "-ldl") endif () if (CMAKE_C_COMPILER_LOADED OR CMAKE_CXX_COMPILER_LOADED) if(LAPACK_FIND_QUIETLY OR NOT LAPACK_FIND_REQUIRED) @@ -240,7 +244,7 @@ if (BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All") "" "${IT}" "${_BLAS_LIBRARIES}" - "${CMAKE_THREAD_LIBS_INIT};${LAPACK_mkl_LM}" + "${CMAKE_THREAD_LIBS_INIT};${LAPACK_mkl_LM};${LAPACK_mkl_LDL}" ) endif () endforeach () @@ -248,6 +252,7 @@ if (BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All") unset(LAPACK_mkl_ILP_MODE) unset(LAPACK_mkl_SEARCH_SYMBOL) unset(LAPACK_mkl_LM) + unset(LAPACK_mkl_LDL) endif () endif() -- cgit v0.12 From c259912b14fc63db0441c30c33b79ebbef058e06 Mon Sep 17 00:00:00 2001 From: Jakub Benda Date: Sun, 18 Nov 2018 21:37:14 +0000 Subject: FindBLAS: Do not look for BLAS once BLAS95 has been found When BLA_F95 is ON, FindBLAS looks for BLAS95_LIBRARIES (in Intel MKL). As this is a superset of BLAS_LIBRARIES, if they are found, no further search in other vendors is necessary. --- Modules/FindBLAS.cmake | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/Modules/FindBLAS.cmake b/Modules/FindBLAS.cmake index c286a4d..cd6ed8f 100644 --- a/Modules/FindBLAS.cmake +++ b/Modules/FindBLAS.cmake @@ -405,6 +405,14 @@ if (BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All") endif () endif () +if(BLA_F95) + find_package_handle_standard_args(BLAS REQUIRED_VARS BLAS95_LIBRARIES) + set(BLAS95_FOUND ${BLAS_FOUND}) + if(BLAS_FOUND) + set(BLAS_LIBRARIES "${BLAS95_LIBRARIES}") + endif() +endif() + if (BLA_VENDOR STREQUAL "Goto" OR BLA_VENDOR STREQUAL "All") if(NOT BLAS_LIBRARIES) # gotoblas (http://www.tacc.utexas.edu/tacc-projects/gotoblas2) @@ -740,13 +748,7 @@ if (BLA_VENDOR STREQUAL "Generic" OR BLA_VENDOR STREQUAL "All") endif() endif () -if(BLA_F95) - find_package_handle_standard_args(BLAS REQUIRED_VARS BLAS95_LIBRARIES) - set(BLAS95_FOUND ${BLAS_FOUND}) - if(BLAS_FOUND) - set(BLAS_LIBRARIES "${BLAS95_LIBRARIES}") - endif() -else() +if(NOT BLA_F95) find_package_handle_standard_args(BLAS REQUIRED_VARS BLAS_LIBRARIES) endif() -- cgit v0.12