summaryrefslogtreecommitdiffstats
path: root/Modules/FindBLAS.cmake
diff options
context:
space:
mode:
Diffstat (limited to 'Modules/FindBLAS.cmake')
-rw-r--r--Modules/FindBLAS.cmake173
1 files changed, 103 insertions, 70 deletions
diff --git a/Modules/FindBLAS.cmake b/Modules/FindBLAS.cmake
index b4650b2..024ff14 100644
--- a/Modules/FindBLAS.cmake
+++ b/Modules/FindBLAS.cmake
@@ -55,6 +55,8 @@ The following variables may be set to influence this module's behavior:
* ``Arm_ilp64_mp``
* ``EML``
* ``EML_mt``
+ * ``Fujitsu_SSL2`` (Fujitsu serial blas / lapack)
+ * ``Fujitsu_SSL2BLAMP`` (Fujitsu parallel blas / lapack)
* ``Generic``
.. versionadded:: 3.6
@@ -78,6 +80,7 @@ The following variables may be set to influence this module's behavior:
.. versionadded:: 3.20
Elbrus Math Library support (``EML``, ``EML_mt``).
+ Fujitsu SSL2 Library support (``Fujitsu_SSL2``, ``Fujitsu_SSL2BLAMP``)
``BLA_F95``
if ``ON`` tries to find the BLAS95 interfaces
@@ -153,13 +156,18 @@ if(NOT (CMAKE_C_COMPILER_LOADED OR CMAKE_CXX_COMPILER_LOADED OR CMAKE_Fortran_CO
endif()
function(_add_blas_target)
- if(NOT TARGET BLAS::BLAS)
+ if(BLAS_FOUND AND NOT TARGET BLAS::BLAS)
add_library(BLAS::BLAS INTERFACE IMPORTED)
if(BLAS_LIBRARIES)
set_target_properties(BLAS::BLAS PROPERTIES
INTERFACE_LINK_LIBRARIES "${BLAS_LIBRARIES}"
)
endif()
+ if(BLAS_LINKER_FLAGS)
+ set_target_properties(BLAS::BLAS PROPERTIES
+ INTERFACE_LINK_OPTIONS "${BLAS_LINKER_FLAGS}"
+ )
+ endif()
endif()
endfunction()
@@ -168,10 +176,7 @@ if(CMAKE_Fortran_COMPILER_LOADED)
else()
include(${CMAKE_CURRENT_LIST_DIR}/CheckFunctionExists.cmake)
endif()
-include(${CMAKE_CURRENT_LIST_DIR}/CMakePushCheckState.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
-cmake_push_check_state()
-set(CMAKE_REQUIRED_QUIET ${BLAS_FIND_QUIETLY})
if(BLA_PREFER_PKGCONFIG)
find_package(PkgConfig)
@@ -184,40 +189,33 @@ if(BLA_PREFER_PKGCONFIG)
endif()
endif()
-set(_blas_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
-if(BLA_STATIC)
- if(WIN32)
- set(CMAKE_FIND_LIBRARY_SUFFIXES .lib ${CMAKE_FIND_LIBRARY_SUFFIXES})
- else()
- set(CMAKE_FIND_LIBRARY_SUFFIXES .a ${CMAKE_FIND_LIBRARY_SUFFIXES})
- endif()
-else()
- if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
- # for ubuntu's libblas3gf and liblapack3gf packages
- set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES} .so.3gf)
- endif()
-endif()
-
# TODO: move this stuff to a separate module
-macro(CHECK_BLAS_LIBRARIES LIBRARIES _prefix _name _flags _list _threadlibs _addlibdir _subdirs)
- # This macro checks for the existence of the combination of fortran libraries
- # given by _list. If the combination is found, this macro checks (using the
- # Check_Fortran_Function_Exists macro) whether can link against that library
- # combination using the name of a routine given by _name using the linker
- # flags given by _flags. If the combination of libraries is found and passes
- # the link test, LIBRARIES is set to the list of complete library paths that
- # have been found. Otherwise, LIBRARIES is set to FALSE.
-
- # N.B. _prefix is the prefix applied to the names of all cached variables that
- # are generated internally and marked advanced by this macro.
- # _addlibdir is a list of additional search paths. _subdirs is a list of path
- # suffixes to be used by find_library().
+function(CHECK_BLAS_LIBRARIES LIBRARIES _prefix _name _flags _list _deps _addlibdir _subdirs)
+ # This function checks for the existence of the combination of libraries
+ # given by _list. If the combination is found, this checks whether can link
+ # against that library combination using the name of a routine given by _name
+ # using the linker flags given by _flags. If the combination of libraries is
+ # found and passes the link test, ${LIBRARIES} is set to the list of complete
+ # library paths that have been found. Otherwise, ${LIBRARIES} is set to FALSE.
set(_libraries_work TRUE)
- set(${LIBRARIES})
+ set(_libraries)
set(_combined_name)
+ if(BLA_STATIC)
+ if(WIN32)
+ set(CMAKE_FIND_LIBRARY_SUFFIXES .lib ${CMAKE_FIND_LIBRARY_SUFFIXES})
+ else()
+ set(CMAKE_FIND_LIBRARY_SUFFIXES .a ${CMAKE_FIND_LIBRARY_SUFFIXES})
+ endif()
+ else()
+ if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
+ # for ubuntu's libblas3gf and liblapack3gf packages
+ set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES} .so.3gf)
+ endif()
+ endif()
+
set(_extaddlibdir "${_addlibdir}")
if(WIN32)
list(APPEND _extaddlibdir ENV LIB)
@@ -229,33 +227,37 @@ macro(CHECK_BLAS_LIBRARIES LIBRARIES _prefix _name _flags _list _threadlibs _add
list(APPEND _extaddlibdir "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}")
foreach(_library ${_list})
- if(_library MATCHES "^-Wl,--(start|end)-group$")
- # Respect linker flags like --start/end-group (required by MKL)
- set(${LIBRARIES} ${${LIBRARIES}} "${_library}")
+ if(_library MATCHES "^-")
+ # Respect linker flags as-is (required by MKL)
+ list(APPEND _libraries "${_library}")
else()
- set(_combined_name ${_combined_name}_${_library})
- if(NOT "${_threadlibs}" STREQUAL "")
- set(_combined_name ${_combined_name}_threadlibs)
+ string(REGEX REPLACE "[^A-Za-z0-9]" "_" _lib_var "${_library}")
+ set(_combined_name ${_combined_name}_${_lib_var})
+ if(NOT "${_deps}" STREQUAL "")
+ set(_combined_name ${_combined_name}_deps)
endif()
if(_libraries_work)
- find_library(${_prefix}_${_library}_LIBRARY
+ find_library(${_prefix}_${_lib_var}_LIBRARY
NAMES ${_library}
NAMES_PER_DIR
PATHS ${_extaddlibdir}
PATH_SUFFIXES ${_subdirs}
)
- #message("DEBUG: find_library(${_library}) got ${${_prefix}_${_library}_LIBRARY}")
- mark_as_advanced(${_prefix}_${_library}_LIBRARY)
- set(${LIBRARIES} ${${LIBRARIES}} ${${_prefix}_${_library}_LIBRARY})
- set(_libraries_work ${${_prefix}_${_library}_LIBRARY})
+ mark_as_advanced(${_prefix}_${_lib_var}_LIBRARY)
+ list(APPEND _libraries ${${_prefix}_${_lib_var}_LIBRARY})
+ set(_libraries_work ${${_prefix}_${_lib_var}_LIBRARY})
endif()
endif()
endforeach()
+ foreach(_flag ${_flags})
+ string(REGEX REPLACE "[^A-Za-z0-9]" "_" _flag_var "${_flag}")
+ set(_combined_name ${_combined_name}_${_flag_var})
+ endforeach()
if(_libraries_work)
# Test this combination of libraries.
- set(CMAKE_REQUIRED_LIBRARIES ${_flags} ${${LIBRARIES}} ${_threadlibs})
- #message("DEBUG: CMAKE_REQUIRED_LIBRARIES = ${CMAKE_REQUIRED_LIBRARIES}")
+ set(CMAKE_REQUIRED_LIBRARIES ${_flags} ${_libraries} ${_deps})
+ set(CMAKE_REQUIRED_QUIET ${BLAS_FIND_QUIETLY})
if(CMAKE_Fortran_COMPILER_LOADED)
check_fortran_function_exists("${_name}" ${_prefix}${_combined_name}_WORKS)
else()
@@ -267,19 +269,20 @@ macro(CHECK_BLAS_LIBRARIES LIBRARIES _prefix _name _flags _list _threadlibs _add
if(_libraries_work)
if("${_list}" STREQUAL "")
- set(${LIBRARIES} "${LIBRARIES}-PLACEHOLDER-FOR-EMPTY-LIBRARIES")
+ set(_libraries "${LIBRARIES}-PLACEHOLDER-FOR-EMPTY-LIBRARIES")
else()
- set(${LIBRARIES} ${${LIBRARIES}} ${_threadlibs})
+ list(APPEND _libraries ${_deps})
endif()
else()
- set(${LIBRARIES} FALSE)
+ set(_libraries FALSE)
endif()
- #message("DEBUG: ${LIBRARIES} = ${${LIBRARIES}}")
-endmacro()
+ set(${LIBRARIES} "${_libraries}" PARENT_SCOPE)
+endfunction()
set(BLAS_LINKER_FLAGS)
set(BLAS_LIBRARIES)
set(BLAS95_LIBRARIES)
+set(_blas_fphsa_req_var BLAS_LIBRARIES)
if(NOT $ENV{BLA_VENDOR} STREQUAL "")
set(BLA_VENDOR $ENV{BLA_VENDOR})
else()
@@ -302,6 +305,9 @@ if(BLA_VENDOR STREQUAL "All")
""
)
endif()
+ if(BLAS_WORKS)
+ set(_blas_fphsa_req_var BLAS_WORKS)
+ endif()
endif()
# BLAS in the Intel MKL 10+ library?
@@ -327,12 +333,21 @@ if(BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All")
if(CMAKE_Fortran_COMPILER_LOADED AND CMAKE_Fortran_COMPILER_ID STREQUAL "GNU" AND NOT APPLE)
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()
+
+ foreach(lang IN ITEMS C CXX Fortran)
+ if(CMAKE_${lang}_COMPILER_LOADED)
+ find_package(OpenMP COMPONENTS ${lang})
+ if(${OpenMP_${lang}_FOUND})
+ set(BLAS_mkl_OMP ${OpenMP_${lang}_LIBRARIES})
+ break()
+ endif()
+ endif()
+ endforeach()
+
set(BLAS_mkl_LM "-lm")
set(BLAS_mkl_LDL "-ldl")
endif()
@@ -397,7 +412,7 @@ if(BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All")
# mkl >= 10.3
list(APPEND BLAS_SEARCH_LIBS
- "${BLAS_mkl_START_GROUP} mkl_blas95 mkl_${BLAS_mkl_INTFACE} mkl_${BLAS_mkl_THREADING}_thread mkl_core ${BLAS_mkl_END_GROUP} ${BLAS_mkl_OMP}")
+ "${BLAS_mkl_START_GROUP} mkl_blas95 mkl_${BLAS_mkl_INTFACE} mkl_${BLAS_mkl_THREADING}_thread mkl_core ${BLAS_mkl_END_GROUP}")
endif()
if(BLA_VENDOR MATCHES "^Intel10_64i?lp$" OR BLA_VENDOR STREQUAL "All")
# old version
@@ -406,7 +421,7 @@ if(BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All")
# mkl >= 10.3
list(APPEND BLAS_SEARCH_LIBS
- "${BLAS_mkl_START_GROUP} mkl_blas95_${BLAS_mkl_ILP_MODE} mkl_${BLAS_mkl_INTFACE}_${BLAS_mkl_ILP_MODE} mkl_${BLAS_mkl_THREADING}_thread mkl_core ${BLAS_mkl_END_GROUP} ${BLAS_mkl_OMP}")
+ "${BLAS_mkl_START_GROUP} mkl_blas95_${BLAS_mkl_ILP_MODE} mkl_${BLAS_mkl_INTFACE}_${BLAS_mkl_ILP_MODE} mkl_${BLAS_mkl_THREADING}_thread mkl_core ${BLAS_mkl_END_GROUP}")
endif()
if(BLA_VENDOR MATCHES "^Intel10_64i?lp_seq$" OR BLA_VENDOR STREQUAL "All")
list(APPEND BLAS_SEARCH_LIBS
@@ -462,7 +477,7 @@ if(BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All")
# mkl >= 10.3
list(APPEND BLAS_SEARCH_LIBS
- "${BLAS_mkl_START_GROUP} mkl_${BLAS_mkl_INTFACE} mkl_${BLAS_mkl_THREADING}_thread mkl_core ${BLAS_mkl_END_GROUP} ${BLAS_mkl_OMP}")
+ "${BLAS_mkl_START_GROUP} mkl_${BLAS_mkl_INTFACE} mkl_${BLAS_mkl_THREADING}_thread mkl_core ${BLAS_mkl_END_GROUP}")
endif()
if(BLA_VENDOR MATCHES "^Intel10_64i?lp$" OR BLA_VENDOR STREQUAL "All")
# old version
@@ -471,7 +486,7 @@ if(BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All")
# mkl >= 10.3
list(APPEND BLAS_SEARCH_LIBS
- "${BLAS_mkl_START_GROUP} mkl_${BLAS_mkl_INTFACE}_${BLAS_mkl_ILP_MODE} mkl_${BLAS_mkl_THREADING}_thread mkl_core ${BLAS_mkl_END_GROUP} ${BLAS_mkl_OMP}")
+ "${BLAS_mkl_START_GROUP} mkl_${BLAS_mkl_INTFACE}_${BLAS_mkl_ILP_MODE} mkl_${BLAS_mkl_THREADING}_thread mkl_core ${BLAS_mkl_END_GROUP}")
endif()
if(BLA_VENDOR MATCHES "^Intel10_64i?lp_seq$" OR BLA_VENDOR STREQUAL "All")
list(APPEND BLAS_SEARCH_LIBS
@@ -534,7 +549,7 @@ if(BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All")
${BLAS_mkl_SEARCH_SYMBOL}
""
"${SEARCH_LIBS}"
- "${CMAKE_THREAD_LIBS_INIT};${BLAS_mkl_LM};${BLAS_mkl_LDL}"
+ "${BLAS_mkl_OMP};${CMAKE_THREAD_LIBS_INIT};${BLAS_mkl_LM};${BLAS_mkl_LDL}"
"${BLAS_mkl_MKLROOT}"
"${BLAS_mkl_LIB_PATH_SUFFIXES}"
)
@@ -619,8 +634,6 @@ if(BLA_VENDOR STREQUAL "OpenBLAS" OR BLA_VENDOR STREQUAL "All")
endif()
set(_threadlibs "${CMAKE_THREAD_LIBS_INIT}")
if(BLA_STATIC)
- set(_blas_STATIC_CMAKE_FIND_LIBRARY_SUFFIXES "${CMAKE_FIND_LIBRARY_SUFFIXES}")
- set(CMAKE_FIND_LIBRARY_SUFFIXES "${_blas_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES}")
if (CMAKE_C_COMPILER_LOADED)
find_package(OpenMP COMPONENTS C)
list(PREPEND _threadlibs "${OpenMP_C_LIBRARIES}")
@@ -628,8 +641,6 @@ if(BLA_VENDOR STREQUAL "OpenBLAS" OR BLA_VENDOR STREQUAL "All")
find_package(OpenMP COMPONENTS CXX)
list(PREPEND _threadlibs "${OpenMP_CXX_LIBRARIES}")
endif()
- set(CMAKE_FIND_LIBRARY_SUFFIXES "${_blas_STATIC_CMAKE_FIND_LIBRARY_SUFFIXES}")
- unset(_blas_STATIC_CMAKE_FIND_LIBRARY_SUFFIXES)
endif()
check_blas_libraries(
BLAS_LIBRARIES
@@ -1025,6 +1036,31 @@ if(BLA_VENDOR MATCHES "EML" OR BLA_VENDOR STREQUAL "All")
endif()
+# Fujitsu SSL2 Library?
+if(NOT BLAS_LIBRARIES AND
+ BLA_VENDOR MATCHES "Fujitsu_SSL2" OR BLA_VENDOR STREQUAL "All")
+ if(BLA_VENDOR STREQUAL "Fujitsu_SSL2BLAMP")
+ set(_ssl2_suffix BLAMP)
+ else()
+ set(_ssl2_suffix)
+ endif()
+ check_blas_libraries(
+ BLAS_LIBRARIES
+ BLAS
+ sgemm
+ "-SSL2${_ssl2_suffix}"
+ ""
+ ""
+ ""
+ ""
+ )
+ if(BLAS_LIBRARIES)
+ set(BLAS_LINKER_FLAGS "-SSL2${_ssl2_suffix}")
+ set(_blas_fphsa_req_var BLAS_LINKER_FLAGS)
+ endif()
+ unset(_ssl2_suffix)
+endif()
+
# Generic BLAS library?
if(BLA_VENDOR STREQUAL "Generic" OR BLA_VENDOR STREQUAL "All")
if(NOT BLAS_LIBRARIES)
@@ -1041,17 +1077,14 @@ if(BLA_VENDOR STREQUAL "Generic" OR BLA_VENDOR STREQUAL "All")
endif()
endif()
-if(NOT BLA_F95)
- find_package_handle_standard_args(BLAS REQUIRED_VARS BLAS_LIBRARIES)
-endif()
-
-
-# On compilers that implicitly link BLAS (such as ftn, cc, and CC on Cray HPC machines)
-# we used a placeholder for empty BLAS_LIBRARIES to get through our logic above.
+# On compilers that implicitly link BLAS (i.e. CrayPrgEnv) we used a
+# placeholder for empty BLAS_LIBRARIES to get through our logic above.
if(BLAS_LIBRARIES STREQUAL "BLAS_LIBRARIES-PLACEHOLDER-FOR-EMPTY-LIBRARIES")
set(BLAS_LIBRARIES "")
endif()
+if(NOT BLA_F95)
+ find_package_handle_standard_args(BLAS REQUIRED_VARS ${_blas_fphsa_req_var})
+endif()
+
_add_blas_target()
-cmake_pop_check_state()
-set(CMAKE_FIND_LIBRARY_SUFFIXES ${_blas_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES})