From 17987eb3fc2a4370261c1585e0766be1db673668 Mon Sep 17 00:00:00 2001 From: tensor-tang Date: Thu, 5 Jul 2018 17:48:46 +0800 Subject: [PATCH] link libxsmm --- CMakeLists.txt | 4 ++++ cmake/external/libxsmm.cmake | 17 +++++++++++------ paddle/fluid/operators/math/CMakeLists.txt | 2 +- paddle/fluid/operators/math/blas.h | 4 ++++ 4 files changed, 20 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e24e71b69..22ba9b243 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -228,6 +228,10 @@ if(WITH_MKLML) list(APPEND EXTERNAL_LIBS ${MKLML_IOMP_LIB}) endif() +if(WITH_LIBXSMM) + list(APPEND EXTERNAL_LIBS ${LIBXSMM_LIBS}) +endif() + if(WITH_MKLDNN) list(APPEND EXTERNAL_LIBS ${MKLDNN_LIB}) endif() diff --git a/cmake/external/libxsmm.cmake b/cmake/external/libxsmm.cmake index d02472808..f9f1e7131 100644 --- a/cmake/external/libxsmm.cmake +++ b/cmake/external/libxsmm.cmake @@ -25,11 +25,13 @@ ENDIF() INCLUDE (ExternalProject) -SET(WITH_SMM ON) +SET(WITH_LIBXSMM ON) SET(LIBXSMM_SOURCES_DIR ${THIRD_PARTY_PATH}/libxsmm) SET(LIBXSMM_INSTALL_DIR ${THIRD_PARTY_PATH}/install/libxsmm) SET(LIBXSMM_INCLUDE_DIR "${LIBXSMM_INSTALL_DIR}/include" CACHE PATH "LIBXSMM include directory." FORCE) SET(LIBXSMM_LIBRARY_DIR "${LIBXSMM_INSTALL_DIR}/lib" CACHE PATH "LIBXSMM library directory." FORCE) +SET(LIBXSMM_LIBS "${LIBXSMM_LIBRARY_DIR}/libxsmm.a" + "${LIBXSMM_LIBRARY_DIR}/libxsmmnoblas.a") ExternalProject_Add( extern_libxsmm @@ -37,14 +39,17 @@ ExternalProject_Add( GIT_TAG "7cc03b5b342fdbc6b6d990b190671c5dbb8489a2" PREFIX ${LIBXSMM_SOURCES_DIR} UPDATE_COMMAND "" - BUILD_COMMAND make PREFIX=${LIBXSMM_INSTALL_DIR} CC=gcc WARP=0 install + CONFIGURE_COMMAND "" + BUILD_IN_SOURCE 1 + BUILD_COMMAND $(MAKE) --silent PREFIX=${LIBXSMM_INSTALL_DIR} CC=gcc WARP=0 install + INSTALL_COMMAND "" ) -ADD_DEFINITIONS(-DPADDLE_WITH_LIBXSMM) ADD_LIBRARY(libxsmm STATIC IMPORTED GLOBAL) -SET_PROPERTY(TARGET libxsmm PROPERTY IMPORTED_LOCATION - "${LIBXSMM_LIBRARY_DIR}/libxsmm.a" - "${LIBXSMM_LIBRARY_DIR}/libxsmmnoblas.a") +SET_PROPERTY(TARGET libxsmm PROPERTY IMPORTED_LOCATION "${LIBXSMM_LIBRARY_DIR}/libxsmm.a") +SET_PROPERTY(TARGET libxsmm PROPERTY IMPORTED_LOCATION "${LIBXSMM_LIBRARY_DIR}/libxsmmnoblas.a") +MESSAGE(STATUS "Libxsmm library: ${LIBXSMM_LIBS}") include_directories(${LIBXSMM_INCLUDE_DIR}) +ADD_DEFINITIONS(-DPADDLE_WITH_LIBXSMM) ADD_DEPENDENCIES(libxsmm extern_libxsmm) diff --git a/paddle/fluid/operators/math/CMakeLists.txt b/paddle/fluid/operators/math/CMakeLists.txt index 5571ff9a7..5ae4a00d3 100644 --- a/paddle/fluid/operators/math/CMakeLists.txt +++ b/paddle/fluid/operators/math/CMakeLists.txt @@ -41,7 +41,7 @@ math_library(depthwise_conv) math_library(gru_compute DEPS activation_functions math_function) math_library(im2col) math_library(lstm_compute DEPS activation_functions) -cc_library(blas SRCS blas.cc DEPS cblas framework_proto device_context) +cc_library(blas SRCS blas.cc DEPS cblas libxsmm framework_proto device_context) math_library(math_function DEPS blas) math_library(maxouting) math_library(pooling) diff --git a/paddle/fluid/operators/math/blas.h b/paddle/fluid/operators/math/blas.h index 9f6c1e5c3..70f88f24f 100644 --- a/paddle/fluid/operators/math/blas.h +++ b/paddle/fluid/operators/math/blas.h @@ -21,6 +21,10 @@ #include "paddle/fluid/platform/dynload/mklml.h" #endif +#ifdef PADDLE_WITH_LIBXSMM +#include +#endif + #ifdef PADDLE_USE_OPENBLAS #include #endif -- GitLab