diff options
author | Hubertus van Dam <hvandam@bnl.gov> | 2018-08-28 18:33:25 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2018-08-30 14:52:59 (GMT) |
commit | 8cdff15ef7b3077af6b7315f73355d06adaeeafe (patch) | |
tree | afa298f265e23ec017fae1d319ff07e622c7c551 /Modules/FindBLAS.cmake | |
parent | 608de88f2973975b85e059e67b93fbefa2911082 (diff) | |
download | CMake-8cdff15ef7b3077af6b7315f73355d06adaeeafe.zip CMake-8cdff15ef7b3077af6b7315f73355d06adaeeafe.tar.gz CMake-8cdff15ef7b3077af6b7315f73355d06adaeeafe.tar.bz2 |
FindBLAS: Make Intel MKL the most preferred explicit BLAS library again
By adding the "if (NOT BLAS_LIBRARIES)" statement to the Intel MKL
detection code block we have unintentionally turned Intel MKL from
the most preferred into the least preferred BLAS library. To fix
this issue the Intel MKL detection code block needs to be moved
forward to make it the first explicit BLAS library we test for.
This is change does just that and re-instates Intel MKL as the
most preferred explicit BLAS library.
Diffstat (limited to 'Modules/FindBLAS.cmake')
-rw-r--r-- | Modules/FindBLAS.cmake | 360 |
1 files changed, 180 insertions, 180 deletions
diff --git a/Modules/FindBLAS.cmake b/Modules/FindBLAS.cmake index d5fc4b6..39b9b74 100644 --- a/Modules/FindBLAS.cmake +++ b/Modules/FindBLAS.cmake @@ -199,6 +199,186 @@ if (BLA_VENDOR STREQUAL "All") endif() endif () +#BLAS in intel mkl 10 library? (em64t 64bit) +if (BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All") + if (NOT BLAS_LIBRARIES) + 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) + else() + find_package(Threads REQUIRED) + endif() + + set(BLAS_SEARCH_LIBS "") + + if(BLA_F95) + set(BLAS_mkl_SEARCH_SYMBOL SGEMM) + 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") + list(APPEND BLAS_SEARCH_LIBS_WIN_MAIN + "mkl_blas95${BLAS_mkl_DLL_SUFFIX} mkl_intel_c${BLAS_mkl_DLL_SUFFIX}") + endif() + if (BLA_VENDOR MATCHES "^Intel10_64lp" OR BLA_VENDOR STREQUAL "All") + list(APPEND BLAS_SEARCH_LIBS_WIN_MAIN + "mkl_blas95_lp64${BLAS_mkl_DLL_SUFFIX} mkl_intel_lp64${BLAS_mkl_DLL_SUFFIX}") + endif () + + # Add threading/sequential libs + set(BLAS_SEARCH_LIBS_WIN_THREAD "") + if (BLA_VENDOR MATCHES "_seq$" OR BLA_VENDOR STREQUAL "All") + list(APPEND BLAS_SEARCH_LIBS_WIN_THREAD + "mkl_sequential${BLAS_mkl_DLL_SUFFIX}") + endif() + if (NOT BLA_VENDOR MATCHES "_seq$" OR BLA_VENDOR STREQUAL "All") + # old version + list(APPEND BLAS_SEARCH_LIBS_WIN_THREAD + "libguide40 mkl_intel_thread${BLAS_mkl_DLL_SUFFIX}") + # mkl >= 10.3 + list(APPEND BLAS_SEARCH_LIBS_WIN_THREAD + "libiomp5md mkl_intel_thread${BLAS_mkl_DLL_SUFFIX}") + endif() + + # Cartesian product of the above + foreach (MAIN ${BLAS_SEARCH_LIBS_WIN_MAIN}) + foreach (THREAD ${BLAS_SEARCH_LIBS_WIN_THREAD}) + list(APPEND BLAS_SEARCH_LIBS + "${MAIN} ${THREAD} mkl_core${BLAS_mkl_DLL_SUFFIX}") + endforeach() + endforeach() + 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") + endif () + if (BLA_VENDOR STREQUAL "Intel10_64lp" OR BLA_VENDOR STREQUAL "All") + # old version + list(APPEND BLAS_SEARCH_LIBS + "mkl_blas95 mkl_intel_lp64 mkl_intel_thread mkl_core guide") + + # mkl >= 10.3 + if (CMAKE_C_COMPILER MATCHES ".+gcc") + list(APPEND BLAS_SEARCH_LIBS + "mkl_blas95_lp64 mkl_intel_lp64 mkl_gnu_thread mkl_core gomp") + else () + list(APPEND BLAS_SEARCH_LIBS + "mkl_blas95_lp64 mkl_intel_lp64 mkl_intel_thread mkl_core iomp5") + endif () + endif () + if (BLA_VENDOR STREQUAL "Intel10_64lp_seq" OR BLA_VENDOR STREQUAL "All") + list(APPEND BLAS_SEARCH_LIBS + "mkl_intel_lp64 mkl_sequential mkl_core") + endif () + endif () + else () + 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") + list(APPEND BLAS_SEARCH_LIBS_WIN_MAIN + "mkl_intel_c${BLAS_mkl_DLL_SUFFIX}") + endif() + if (BLA_VENDOR MATCHES "^Intel10_64lp" OR BLA_VENDOR STREQUAL "All") + list(APPEND BLAS_SEARCH_LIBS_WIN_MAIN + "mkl_intel_lp64${BLAS_mkl_DLL_SUFFIX}") + endif () + + # Add threading/sequential libs + set(BLAS_SEARCH_LIBS_WIN_THREAD "") + if (NOT BLA_VENDOR MATCHES "_seq$" OR BLA_VENDOR STREQUAL "All") + # old version + list(APPEND BLAS_SEARCH_LIBS_WIN_THREAD + "libguide40 mkl_intel_thread${BLAS_mkl_DLL_SUFFIX}") + # mkl >= 10.3 + list(APPEND BLAS_SEARCH_LIBS_WIN_THREAD + "libiomp5md mkl_intel_thread${BLAS_mkl_DLL_SUFFIX}") + endif() + if (BLA_VENDOR MATCHES "_seq$" OR BLA_VENDOR STREQUAL "All") + list(APPEND BLAS_SEARCH_LIBS_WIN_THREAD + "mkl_sequential${BLAS_mkl_DLL_SUFFIX}") + endif() + + # Cartesian product of the above + foreach (MAIN ${BLAS_SEARCH_LIBS_WIN_MAIN}) + foreach (THREAD ${BLAS_SEARCH_LIBS_WIN_THREAD}) + list(APPEND BLAS_SEARCH_LIBS + "${MAIN} ${THREAD} mkl_core${BLAS_mkl_DLL_SUFFIX}") + endforeach() + endforeach() + 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") + endif () + if (BLA_VENDOR STREQUAL "Intel10_64lp" OR BLA_VENDOR STREQUAL "All") + + # old version + list(APPEND BLAS_SEARCH_LIBS + "mkl_intel_lp64 mkl_intel_thread mkl_core guide") + + # mkl >= 10.3 + if (CMAKE_C_COMPILER MATCHES ".+gcc") + list(APPEND BLAS_SEARCH_LIBS + "mkl_intel_lp64 mkl_gnu_thread mkl_core gomp") + else () + list(APPEND BLAS_SEARCH_LIBS + "mkl_intel_lp64 mkl_intel_thread mkl_core iomp5") + endif () + endif () + if (BLA_VENDOR STREQUAL "Intel10_64lp_seq" OR BLA_VENDOR STREQUAL "All") + list(APPEND BLAS_SEARCH_LIBS + "mkl_intel_lp64 mkl_sequential mkl_core") + endif () + + #older vesions of intel mkl libs + if (BLA_VENDOR STREQUAL "Intel" OR BLA_VENDOR STREQUAL "All") + list(APPEND BLAS_SEARCH_LIBS + "mkl") + list(APPEND BLAS_SEARCH_LIBS + "mkl_ia32") + list(APPEND BLAS_SEARCH_LIBS + "mkl_em64t") + endif () + endif () + endif () + + foreach (IT ${BLAS_SEARCH_LIBS}) + string(REPLACE " " ";" SEARCH_LIBS ${IT}) + if (NOT ${_LIBRARIES}) + check_fortran_libraries( + ${_LIBRARIES} + BLAS + ${BLAS_mkl_SEARCH_SYMBOL} + "" + "${SEARCH_LIBS}" + "${CMAKE_THREAD_LIBS_INIT};${LM}" + ) + endif () + endforeach () + + endif () + 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) @@ -534,186 +714,6 @@ if (BLA_VENDOR STREQUAL "Generic" OR BLA_VENDOR STREQUAL "All") endif() endif () -#BLAS in intel mkl 10 library? (em64t 64bit) -if (BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All") - if (NOT BLAS_LIBRARIES) - 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) - else() - find_package(Threads REQUIRED) - endif() - - set(BLAS_SEARCH_LIBS "") - - if(BLA_F95) - set(BLAS_mkl_SEARCH_SYMBOL SGEMM) - 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") - list(APPEND BLAS_SEARCH_LIBS_WIN_MAIN - "mkl_blas95${BLAS_mkl_DLL_SUFFIX} mkl_intel_c${BLAS_mkl_DLL_SUFFIX}") - endif() - if (BLA_VENDOR MATCHES "^Intel10_64lp" OR BLA_VENDOR STREQUAL "All") - list(APPEND BLAS_SEARCH_LIBS_WIN_MAIN - "mkl_blas95_lp64${BLAS_mkl_DLL_SUFFIX} mkl_intel_lp64${BLAS_mkl_DLL_SUFFIX}") - endif () - - # Add threading/sequential libs - set(BLAS_SEARCH_LIBS_WIN_THREAD "") - if (BLA_VENDOR MATCHES "_seq$" OR BLA_VENDOR STREQUAL "All") - list(APPEND BLAS_SEARCH_LIBS_WIN_THREAD - "mkl_sequential${BLAS_mkl_DLL_SUFFIX}") - endif() - if (NOT BLA_VENDOR MATCHES "_seq$" OR BLA_VENDOR STREQUAL "All") - # old version - list(APPEND BLAS_SEARCH_LIBS_WIN_THREAD - "libguide40 mkl_intel_thread${BLAS_mkl_DLL_SUFFIX}") - # mkl >= 10.3 - list(APPEND BLAS_SEARCH_LIBS_WIN_THREAD - "libiomp5md mkl_intel_thread${BLAS_mkl_DLL_SUFFIX}") - endif() - - # Cartesian product of the above - foreach (MAIN ${BLAS_SEARCH_LIBS_WIN_MAIN}) - foreach (THREAD ${BLAS_SEARCH_LIBS_WIN_THREAD}) - list(APPEND BLAS_SEARCH_LIBS - "${MAIN} ${THREAD} mkl_core${BLAS_mkl_DLL_SUFFIX}") - endforeach() - endforeach() - 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") - endif () - if (BLA_VENDOR STREQUAL "Intel10_64lp" OR BLA_VENDOR STREQUAL "All") - # old version - list(APPEND BLAS_SEARCH_LIBS - "mkl_blas95 mkl_intel_lp64 mkl_intel_thread mkl_core guide") - - # mkl >= 10.3 - if (CMAKE_C_COMPILER MATCHES ".+gcc") - list(APPEND BLAS_SEARCH_LIBS - "mkl_blas95_lp64 mkl_intel_lp64 mkl_gnu_thread mkl_core gomp") - else () - list(APPEND BLAS_SEARCH_LIBS - "mkl_blas95_lp64 mkl_intel_lp64 mkl_intel_thread mkl_core iomp5") - endif () - endif () - if (BLA_VENDOR STREQUAL "Intel10_64lp_seq" OR BLA_VENDOR STREQUAL "All") - list(APPEND BLAS_SEARCH_LIBS - "mkl_intel_lp64 mkl_sequential mkl_core") - endif () - endif () - else () - 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") - list(APPEND BLAS_SEARCH_LIBS_WIN_MAIN - "mkl_intel_c${BLAS_mkl_DLL_SUFFIX}") - endif() - if (BLA_VENDOR MATCHES "^Intel10_64lp" OR BLA_VENDOR STREQUAL "All") - list(APPEND BLAS_SEARCH_LIBS_WIN_MAIN - "mkl_intel_lp64${BLAS_mkl_DLL_SUFFIX}") - endif () - - # Add threading/sequential libs - set(BLAS_SEARCH_LIBS_WIN_THREAD "") - if (NOT BLA_VENDOR MATCHES "_seq$" OR BLA_VENDOR STREQUAL "All") - # old version - list(APPEND BLAS_SEARCH_LIBS_WIN_THREAD - "libguide40 mkl_intel_thread${BLAS_mkl_DLL_SUFFIX}") - # mkl >= 10.3 - list(APPEND BLAS_SEARCH_LIBS_WIN_THREAD - "libiomp5md mkl_intel_thread${BLAS_mkl_DLL_SUFFIX}") - endif() - if (BLA_VENDOR MATCHES "_seq$" OR BLA_VENDOR STREQUAL "All") - list(APPEND BLAS_SEARCH_LIBS_WIN_THREAD - "mkl_sequential${BLAS_mkl_DLL_SUFFIX}") - endif() - - # Cartesian product of the above - foreach (MAIN ${BLAS_SEARCH_LIBS_WIN_MAIN}) - foreach (THREAD ${BLAS_SEARCH_LIBS_WIN_THREAD}) - list(APPEND BLAS_SEARCH_LIBS - "${MAIN} ${THREAD} mkl_core${BLAS_mkl_DLL_SUFFIX}") - endforeach() - endforeach() - 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") - endif () - if (BLA_VENDOR STREQUAL "Intel10_64lp" OR BLA_VENDOR STREQUAL "All") - - # old version - list(APPEND BLAS_SEARCH_LIBS - "mkl_intel_lp64 mkl_intel_thread mkl_core guide") - - # mkl >= 10.3 - if (CMAKE_C_COMPILER MATCHES ".+gcc") - list(APPEND BLAS_SEARCH_LIBS - "mkl_intel_lp64 mkl_gnu_thread mkl_core gomp") - else () - list(APPEND BLAS_SEARCH_LIBS - "mkl_intel_lp64 mkl_intel_thread mkl_core iomp5") - endif () - endif () - if (BLA_VENDOR STREQUAL "Intel10_64lp_seq" OR BLA_VENDOR STREQUAL "All") - list(APPEND BLAS_SEARCH_LIBS - "mkl_intel_lp64 mkl_sequential mkl_core") - endif () - - #older vesions of intel mkl libs - if (BLA_VENDOR STREQUAL "Intel" OR BLA_VENDOR STREQUAL "All") - list(APPEND BLAS_SEARCH_LIBS - "mkl") - list(APPEND BLAS_SEARCH_LIBS - "mkl_ia32") - list(APPEND BLAS_SEARCH_LIBS - "mkl_em64t") - endif () - endif () - endif () - - foreach (IT ${BLAS_SEARCH_LIBS}) - string(REPLACE " " ";" SEARCH_LIBS ${IT}) - if (NOT ${_LIBRARIES}) - check_fortran_libraries( - ${_LIBRARIES} - BLAS - ${BLAS_mkl_SEARCH_SYMBOL} - "" - "${SEARCH_LIBS}" - "${CMAKE_THREAD_LIBS_INIT};${LM}" - ) - endif () - endforeach () - - endif () - endif () -endif () - if(BLA_F95) find_package_handle_standard_args(BLAS REQUIRED_VARS BLAS95_LIBRARIES) set(BLAS95_FOUND ${BLAS_FOUND}) |