Skip to content

Commit

Permalink
explicitly search cblas_sgemm in ATLAS and OpenBLAS target
Browse files Browse the repository at this point in the history
  • Loading branch information
grafi-tt committed Jul 4, 2019
1 parent 2b13d09 commit 41903d4
Showing 1 changed file with 20 additions and 18 deletions.
38 changes: 20 additions & 18 deletions chainerx_cc/cmake/FindBLAS.cmake
Expand Up @@ -171,21 +171,6 @@ macro(Check_Fortran_Libraries LIBRARIES _prefix _name _flags _list _thread)
mark_as_advanced(${_prefix}${_combined_name}_WORKS)
set(_libraries_work ${${_prefix}${_combined_name}_WORKS})
endif()
if(_libraries_work)
# NOTE: ChainerX uses CBLAS API. Search `libcblas.so` if CBLAS functions are
# not provided in the blas library found.
set(CMAKE_REQUIRED_LIBRARIES ${_flags} ${${LIBRARIES}} ${_thread})
check_function_exists("cblas_sgemm" ${_prefix}${_combined_name}_HAS_CBLAS)
if(NOT ${_prefix}${_combined_name}_HAS_CBLAS)
find_library(${_prefix}${_combined_name}_CBLAS_LIBRARY cblas)
if(${_prefix}${_combined_name}_CBLAS_LIBRARY)
set(${LIBRARIES} ${${LIBRARIES}} ${${_prefix}${_combined_name}_CBLAS_LIBRARY})
else()
set(_libraries_work FALSE)
endif()
endif()
set(CMAKE_REQUIRED_LIBRARIES)
endif()
if(_libraries_work)
if("${_list}" STREQUAL "")
set(${LIBRARIES} "${LIBRARIES}-PLACEHOLDER-FOR-EMPTY-LIBRARIES")
Expand Down Expand Up @@ -424,17 +409,33 @@ endif ()
if (BLA_VENDOR STREQUAL "OpenBLAS" OR BLA_VENDOR STREQUAL "All")
if(NOT BLAS_LIBRARIES)
# OpenBLAS (http://www.openblas.net)
# ChainerX modification: check `cblas_sgemm`.
check_fortran_libraries(
BLAS_LIBRARIES
BLAS
sgemm
cblas_sgemm
""
"openblas"
""
)
endif()
endif ()

if (BLA_VENDOR STREQUAL "OpenBLAS" OR BLA_VENDOR STREQUAL "All")
if(NOT BLAS_LIBRARIES)
# ChainerX modification: search libcblas if `cblas_sgemm` not found.
# OpenBLAS might be built without cblas functions.
check_fortran_libraries(
BLAS_LIBRARIES
BLAS
cblas_sgemm
""
"openblas;cblas"
""
)
endif()
endif ()

if (BLA_VENDOR STREQUAL "FLAME" OR BLA_VENDOR STREQUAL "All")
if(NOT BLAS_LIBRARIES)
# FLAME's blis library (https://github.com/flame/blis)
Expand All @@ -452,12 +453,13 @@ endif ()
if (BLA_VENDOR STREQUAL "ATLAS" OR BLA_VENDOR STREQUAL "All")
if(NOT BLAS_LIBRARIES)
# BLAS in ATLAS library? (http://math-atlas.sourceforge.net/)
# ChainerX change: check `cblas_sgemm` and search libcblas.
check_fortran_libraries(
BLAS_LIBRARIES
BLAS
dgemm
cblas_sgemm
""
"f77blas;atlas"
"f77blas;atlas;cblas"
""
)
endif()
Expand Down

0 comments on commit 41903d4

Please sign in to comment.