diff --git a/cmake/cblas.cmake b/cmake/cblas.cmake index 6056b53bc2218fb24d2e97b281b9a0d68bc9a306..8e762be646acb814272f522cc229df307d88679e 100644 --- a/cmake/cblas.cmake +++ b/cmake/cblas.cmake @@ -69,15 +69,21 @@ if(NOT DEFINED CBLAS_PROVIDER) PATHS ${OPENBLAS_LIB_SEARCH_PATHS}) if(OPENBLAS_LAPACKE_INC_DIR AND OPENBLAS_INC_DIR AND OPENBLAS_LIB) - set(CBLAS_PROVIDER OPENBLAS) - set(CBLAS_INC_DIR ${OPENBLAS_INC_DIR} ${OPENBLAS_LAPACKE_INC_DIR}) - set(CBLAS_LIBRARIES ${OPENBLAS_LIB}) - - add_definitions(-DPADDLE_USE_OPENBLAS) - add_definitions(-DLAPACK_FOUND) - - message(STATUS "Found OpenBLAS (include: ${OPENBLAS_INC_DIR}, library: ${CBLAS_LIBRARIES})") - message(STATUS "Found lapack in OpenBLAS (include: ${OPENBLAS_LAPACKE_INC_DIR})") + file(READ "${OPENBLAS_INC_DIR}/openblas_config.h" config_file) + string(REGEX MATCH "OpenBLAS ([0-9]+\.[0-9]+\.[0-9]+)" tmp ${config_file}) + string(REGEX MATCH "([0-9]+\.[0-9]+\.[0-9]+)" ver ${tmp}) + + if (${ver} VERSION_EQUAL "0.3.7") + set(CBLAS_PROVIDER OPENBLAS) + set(CBLAS_INC_DIR ${OPENBLAS_INC_DIR} ${OPENBLAS_LAPACKE_INC_DIR}) + set(CBLAS_LIBRARIES ${OPENBLAS_LIB}) + + add_definitions(-DPADDLE_USE_OPENBLAS) + add_definitions(-DLAPACK_FOUND) + + message(STATUS "Found OpenBLAS (include: ${OPENBLAS_INC_DIR}, library: ${CBLAS_LIBRARIES})") + message(STATUS "Found lapack in OpenBLAS (include: ${OPENBLAS_LAPACKE_INC_DIR})") + endif() endif() endif() diff --git a/cmake/third_party.cmake b/cmake/third_party.cmake index d33edef38ca7b36ce0b0474407ae7363884bfdaa..e3a78d3cf3bfe0c12d42ab7039fd3377fda6cdef 100644 --- a/cmake/third_party.cmake +++ b/cmake/third_party.cmake @@ -215,6 +215,8 @@ list(APPEND third_party_deps extern_eigen3 extern_gflags extern_glog extern_boos list(APPEND third_party_deps extern_zlib extern_dlpack extern_warpctc extern_threadpool) include(cblas) # find first, then download, build, install openblas + +message(STATUS "CBLAS_PROVIDER: ${CBLAS_PROVIDER}") if(${CBLAS_PROVIDER} STREQUAL MKLML) list(APPEND third_party_deps extern_mklml) elseif(${CBLAS_PROVIDER} STREQUAL EXTERN_OPENBLAS)