From 2be3d32711c150d9d6cdb94124a6ecaa3c7ac0fe Mon Sep 17 00:00:00 2001 From: tensor-tang Date: Mon, 14 Aug 2017 23:33:27 +0800 Subject: [PATCH] use shared lib when mkl --- cmake/external/openblas.cmake | 11 +++++++++-- paddle/operators/math/CMakeLists.txt | 9 ++------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/cmake/external/openblas.cmake b/cmake/external/openblas.cmake index db09232c0e..d47eabba44 100644 --- a/cmake/external/openblas.cmake +++ b/cmake/external/openblas.cmake @@ -73,8 +73,15 @@ INCLUDE_DIRECTORIES(${CBLAS_INC_DIR}) # linear algebra libraries for cc_library(xxx SRCS xxx.c DEPS cblas) SET(dummyfile ${CMAKE_CURRENT_BINARY_DIR}/cblas_dummy.c) FILE(WRITE ${dummyfile} "const char * dummy = \"${dummyfile}\";") -ADD_LIBRARY(cblas STATIC ${dummyfile}) -TARGET_LINK_LIBRARIES(cblas ${CBLAS_LIBRARIES}) + +IF(${CBLAS_PROVIDER} MATCHES MKL) + ADD_LIBRARY(cblas SHARED ${dummyfile}) + TARGET_LINK_LIBRARIES(cblas ${CBLAS_LIBRARIES}) + ADD_DEPENDENCIES(cblas mklml) +ELSE() + ADD_LIBRARY(cblas STATIC ${dummyfile}) + TARGET_LINK_LIBRARIES(cblas ${CBLAS_LIBRARIES}) +ENDIF() IF(NOT ${CBLAS_FOUND}) ADD_DEPENDENCIES(cblas extern_openblas) diff --git a/paddle/operators/math/CMakeLists.txt b/paddle/operators/math/CMakeLists.txt index abcaf940ab..ed51d416ed 100644 --- a/paddle/operators/math/CMakeLists.txt +++ b/paddle/operators/math/CMakeLists.txt @@ -1,13 +1,8 @@ -if(WITH_MKLML) - set(BLAS_LIB mklml) -else() - set(BLAS_LIB cblas) -endif() if(WITH_GPU) - nv_library(math_function SRCS math_function.cc math_function.cu DEPS ${BLAS_LIB} device_context) + nv_library(math_function SRCS math_function.cc math_function.cu DEPS cblas device_context) else() - cc_library(math_function SRCS math_function.cc DEPS ${BLAS_LIB} device_context) + cc_library(math_function SRCS math_function.cc DEPS cblas device_context) endif() nv_test(math_function_test SRCS math_function_test.cc DEPS math_function tensor) -- GitLab