diff --git a/cmake/Dependencies.cmake b/cmake/Dependencies.cmake index 36e1ab7682..0f02f51c47 100644 --- a/cmake/Dependencies.cmake +++ b/cmake/Dependencies.cmake @@ -114,7 +114,7 @@ else() set(AT_MKLDNN_ENABLED 0) set(AT_MKL_ENABLED 0) endif() -set_property(CACHE BLAS PROPERTY STRINGS "Eigen;ATLAS;OpenBLAS;MKL;vecLib;FLAME;Generic") +set_property(CACHE BLAS PROPERTY STRINGS "Eigen;ATLAS;OpenBLAS;MKL;vecLib;SSL2;FLAME;Generic") message(STATUS "Trying to find preferred BLAS backend of choice: " ${BLAS}) if(BLAS STREQUAL "Eigen") @@ -154,6 +154,20 @@ elseif(BLAS STREQUAL "vecLib") find_package(vecLib REQUIRED) include_directories(SYSTEM ${vecLib_INCLUDE_DIR}) list(APPEND Caffe2_PUBLIC_DEPENDENCY_LIBS ${vecLib_LINKER_LIBS}) +elseif(BLAS STREQUAL "SSL2") + if(CMAKE_CXX_COMPILER MATCHES ".*/FCC$" + AND CMAKE_C_COMPILER MATCHES ".*/fcc$") + message(STATUS "SSL2 Selected BLAS library") + list(APPEND Caffe2_PUBLIC_DEPENDENCY_LIBS "fjlapackexsve.so") + set(SSL2_FOUND ON) + message(STATUS "set CMAKE_SHARED_LINKER_FLAGS: -SSL2 --linkfortran") + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -SSL2 --linkfortran") + set(WITH_BLAS "ssl2") + else() + message(STATUS "Not built using fcc and FCC.") + message(STATUS "CMAKE_C_COMPILER: ${CMAKE_C_COMPILER}") + message(STATUS "CMAKE_CXX_COMPILER: ${CMAKE_CXX_COMPILER}") + endif() elseif(BLAS STREQUAL "Generic") # On Debian family, the CBLAS ABIs have been merged into libblas.so find_library(BLAS_LIBRARIES blas) @@ -168,7 +182,7 @@ if(NOT INTERN_BUILD_MOBILE) set(AT_MKL_ENABLED 0) set(AT_MKL_MT 0) set(USE_BLAS 1) - if(NOT (ATLAS_FOUND OR OpenBLAS_FOUND OR MKL_FOUND OR VECLIB_FOUND OR GENERIC_BLAS_FOUND)) + if(NOT (ATLAS_FOUND OR OpenBLAS_FOUND OR MKL_FOUND OR VECLIB_FOUND OR SSL2_FOUND OR GENERIC_BLAS_FOUND)) message(WARNING "Preferred BLAS (" ${BLAS} ") cannot be found, now searching for a general BLAS library") find_package(BLAS) if(NOT BLAS_FOUND) diff --git a/cmake/Modules/FindBLAS.cmake b/cmake/Modules/FindBLAS.cmake index e93e98a609..d43a6c40bd 100644 --- a/cmake/Modules/FindBLAS.cmake +++ b/cmake/Modules/FindBLAS.cmake @@ -239,6 +239,28 @@ if((NOT BLAS_LIBRARIES) endif (BLAS_LIBRARIES) endif() +# BLAS in SSL2 library? +if((NOT BLAS_LIBRARIES) + AND ((NOT WITH_BLAS) OR (WITH_BLAS STREQUAL "ssl2"))) + if(CMAKE_CXX_COMPILER MATCHES ".*/FCC$" + AND CMAKE_C_COMPILER MATCHES ".*/fcc$") + check_fortran_libraries( + BLAS_LIBRARIES + BLAS + sgemm + "-SSL2;--linkfortran" + "fjlapackexsve") + if (BLAS_LIBRARIES) + set(BLAS_INFO "ssl2") + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -SSL2 --linkfortran") + endif (BLAS_LIBRARIES) + else() + message(STATUS "Not built using fcc and FCC.") + message(STATUS "CMAKE_C_COMPILER: ${CMAKE_C_COMPILER}") + message(STATUS "CMAKE_CXX_COMPILER: ${CMAKE_CXX_COMPILER}") + endif() +endif() + # Generic BLAS library? if((NOT BLAS_LIBRARIES) AND ((NOT WITH_BLAS) OR (WITH_BLAS STREQUAL "generic")))