From 577bb4e3467aebf07118c69b85c6a246db235be8 Mon Sep 17 00:00:00 2001 From: tensor-tang Date: Thu, 20 Jul 2017 11:22:38 +0800 Subject: [PATCH] rename mkllite to mklml --- CMakeLists.txt | 10 +++--- cmake/cblas.cmake | 28 ++++------------ cmake/configure.cmake | 2 +- cmake/external/gtest.cmake | 6 ++-- cmake/external/mkldnn.cmake | 8 ++--- cmake/external/mkllite.cmake | 61 ----------------------------------- cmake/external/mklml.cmake | 61 +++++++++++++++++++++++++++++++++++ paddle/math/MathFunctions.cpp | 2 +- paddle/math/MathFunctions.h | 2 +- 9 files changed, 83 insertions(+), 97 deletions(-) delete mode 100644 cmake/external/mkllite.cmake create mode 100644 cmake/external/mklml.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index fedf5db0b..62ab4669c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -38,7 +38,7 @@ include(simd) option(WITH_GPU "Compile PaddlePaddle with NVIDIA GPU" ${CUDA_FOUND}) option(WITH_AVX "Compile PaddlePaddle with AVX intrinsics" ${AVX_FOUND}) option(WITH_MKLDNN "Compile PaddlePaddle with mkl-dnn support." ${AVX_FOUND}) -option(WITH_MKL_LITE "Compile PaddlePaddle with mkl lite package." ${AVX_FOUND}) +option(WITH_MKLML "Compile PaddlePaddle with mklml package." ${AVX_FOUND}) option(WITH_DSO "Compile PaddlePaddle with dynamic linked CUDA" ON) option(WITH_TESTING "Compile PaddlePaddle with unit testing" ON) option(WITH_SWIG_PY "Compile PaddlePaddle with inference api" ON) @@ -79,8 +79,8 @@ if(ANDROID) "Disable RDMA when cross-compiling for Android" FORCE) set(WITH_MKLDNN OFF CACHE STRING "Disable MKLDNN when cross-compiling for Android" FORCE) - set(WITH_MKL_LITE OFF CACHE STRING - "Disable MKL lite package when cross-compiling for Android" FORCE) + set(WITH_MKLML OFF CACHE STRING + "Disable MKLML package when cross-compiling for Android" FORCE) endif(ANDROID) set(THIRD_PARTY_PATH "${CMAKE_BINARY_DIR}/third_party" CACHE STRING @@ -94,7 +94,7 @@ endif() ######################################################################################## -include(external/mkllite) # download mkl minimal lite package +include(external/mklml) # download mklml package include(external/zlib) # download, build, install zlib include(external/gflags) # download, build, install gflags include(external/glog) # download, build, install glog @@ -145,7 +145,7 @@ if(WITH_GPU) endif(WITH_GPU) if(WITH_MKLDNN) - list(APPEND EXTERNAL_LIBS ${MKLDNN_LIBRARY} ${MKL_LITE_LIB_IOMP}) + list(APPEND EXTERNAL_LIBS ${MKLDNN_LIBRARY} ${MKLML_LIB_IOMP}) endif() if(USE_NNPACK) diff --git a/cmake/cblas.cmake b/cmake/cblas.cmake index 52556b1b4..854066fd1 100644 --- a/cmake/cblas.cmake +++ b/cmake/cblas.cmake @@ -15,17 +15,17 @@ set(CBLAS_FOUND OFF) -## Find MKL Lite First. -if(WITH_MKL_LITE AND MKL_LITE_INC_DIR AND MKL_LITE_LIB) +## Find MKLML First. +if(WITH_MKLML AND MKLML_INC_DIR AND MKLML_LIB) set(CBLAS_FOUND ON) - set(CBLAS_PROVIDER MKL_LITE) - set(CBLAS_INC_DIR ${MKL_LITE_INC_DIR}) - set(CBLAS_LIBRARIES ${MKL_LITE_LIB}) + set(CBLAS_PROVIDER MKLML) + set(CBLAS_INC_DIR ${MKLML_INC_DIR}) + set(CBLAS_LIBRARIES ${MKLML_LIB}) - add_definitions(-DPADDLE_USE_MKL_LITE) + add_definitions(-DPADDLE_USE_MKLML) add_definitions(-DLAPACK_FOUND) - message(STATUS "Found cblas and lapack in MKL Lite " + message(STATUS "Found cblas and lapack in MKLML " "(include: ${CBLAS_INC_DIR}, library: ${CBLAS_LIBRARIES})") return() endif() @@ -43,20 +43,6 @@ set(MKL_LIB_SEARCH_PATHS ${INTEL_MKL_ROOT}/lib ${INTEL_MKL_ROOT}/lib/intel64) -if(MKL_LITE_INC_DIR AND MKL_LITE_LIB) - set(CBLAS_FOUND ON) - set(CBLAS_PROVIDER MKL_LITE) - set(CBLAS_INC_DIR ${MKL_LITE_INC_DIR}) - set(CBLAS_LIBRARIES ${MKL_LITE_LIB}) - - add_definitions(-DPADDLE_USE_MKL_LITE) - add_definitions(-DLAPACK_FOUND) - - message(STATUS "Found cblas and lapack in MKL Lite " - "(include: ${MKL_LITE_INC_DIR}, library: ${CBLAS_LIBRARIES})") - return() -endif() - find_path(MKL_INC_DIR mkl.h PATHS ${MKL_INCLUDE_SEARCH_PATHS}) find_path(MKL_LAPACK_INC_DIR mkl_lapacke.h PATHS diff --git a/cmake/configure.cmake b/cmake/configure.cmake index 37eececfd..69220e03f 100644 --- a/cmake/configure.cmake +++ b/cmake/configure.cmake @@ -69,7 +69,7 @@ endif(NOT WITH_GPU) if(WITH_MKLDNN) add_definitions(-DPADDLE_USE_MKLDNN) - if (WITH_MKL_LITE AND MKLDNN_IOMP_DIR) + if (WITH_MKLML AND MKLDNN_IOMP_DIR) message(STATUS "Enable Intel OpenMP at ${MKLDNN_IOMP_DIR}") set(OPENMP_FLAGS "-fopenmp") set(CMAKE_C_CREATE_SHARED_LIBRARY_FORBIDDEN_FLAGS ${OPENMP_FLAGS}) diff --git a/cmake/external/gtest.cmake b/cmake/external/gtest.cmake index 8ac68aa32..e3970073a 100644 --- a/cmake/external/gtest.cmake +++ b/cmake/external/gtest.cmake @@ -34,9 +34,9 @@ IF(WITH_TESTING) "${GTEST_INSTALL_DIR}/lib/libgtest_main.a" CACHE FILEPATH "gtest main libraries." FORCE) ENDIF(WIN32) - IF(WITH_MKL_LITE) - # wait for mkl downloading completed - SET(GTEST_DEPENDS ${MKL_LITE_PROJECT}) + IF(WITH_MKLML) + # wait for mklml downloading completed + SET(GTEST_DEPENDS ${MKLML_PROJECT}) ENDIF() ExternalProject_Add( diff --git a/cmake/external/mkldnn.cmake b/cmake/external/mkldnn.cmake index 28a753e19..9066b5abd 100644 --- a/cmake/external/mkldnn.cmake +++ b/cmake/external/mkldnn.cmake @@ -38,10 +38,10 @@ ENDIF(WIN32) INCLUDE_DIRECTORIES(${MKLDNN_INCLUDE_DIR}) -IF(${CBLAS_PROVIDER} STREQUAL "MKL_LITE") - SET(MKLDNN_DEPENDS ${MKL_LITE_PROJECT}) - SET(MKLDNN_MKLROOT ${MKL_LITE_ROOT}) - SET(MKLDNN_IOMP_DIR ${MKL_LITE_LIB_DIR}) +IF(${CBLAS_PROVIDER} STREQUAL "MKLML") + SET(MKLDNN_DEPENDS ${MKLML_PROJECT}) + SET(MKLDNN_MKLROOT ${MKLML_ROOT}) + SET(MKLDNN_IOMP_DIR ${MKLML_LIB_DIR}) ENDIF() ExternalProject_Add( diff --git a/cmake/external/mkllite.cmake b/cmake/external/mkllite.cmake deleted file mode 100644 index e889290e3..000000000 --- a/cmake/external/mkllite.cmake +++ /dev/null @@ -1,61 +0,0 @@ -# Copyright (c) 2017 PaddlePaddle Authors. All Rights Reserve. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -IF(NOT ${WITH_MKL_LITE}) - return() -ENDIF(NOT ${WITH_MKL_LITE}) - -INCLUDE(ExternalProject) - -SET(MKL_LITE_PROJECT "extern_mkllite") -SET(MKL_LITE_VER "mklml_lnx_2018.0.20170425") -SET(MKL_LITE_URL "https://github.com/01org/mkl-dnn/releases/download/v0.9/${MKL_LITE_VER}.tgz") -SET(MKL_LITE_DOWNLOAD_DIR ${THIRD_PARTY_PATH}/mkllite) - -SET(MKL_LITE_ROOT ${MKL_LITE_DOWNLOAD_DIR}/${MKL_LITE_VER}) -SET(MKL_LITE_INC_DIR ${MKL_LITE_ROOT}/include) -SET(MKL_LITE_LIB_DIR ${MKL_LITE_ROOT}/lib) -SET(MKL_LITE_LIB ${MKL_LITE_LIB_DIR}/libmklml_intel.so) -SET(MKL_LITE_IOMP_LIB ${MKL_LITE_LIB_DIR}/libiomp5.so) -SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_RPATH}" "${MKL_LITE_ROOT}/lib") - -INCLUDE_DIRECTORIES(${MKL_LITE_INC_DIR}) - -ExternalProject_Add( - ${MKL_LITE_PROJECT} - ${EXTERNAL_PROJECT_LOG_ARGS} - PREFIX ${MKL_LITE_DOWNLOAD_DIR} - DOWNLOAD_DIR ${MKL_LITE_DOWNLOAD_DIR} - DOWNLOAD_COMMAND wget --no-check-certificate ${MKL_LITE_URL} - && tar -xzf ${MKL_LITE_DOWNLOAD_DIR}/${MKL_LITE_VER}.tgz - DOWNLOAD_NO_PROGRESS 1 - UPDATE_COMMAND "" - PATCH_COMMAND "" - CONFIGURE_COMMAND "" - BUILD_COMMAND "" - INSTALL_COMMAND "" - TEST_COMMAND "" -) - -IF (${CMAKE_VERSION} VERSION_LESS "3.3.0") - SET(dummyfile ${CMAKE_CURRENT_BINARY_DIR}/mkllite_dummy.c) - FILE(WRITE ${dummyfile} "const char * dummy_mkllite = \"${dummyfile}\";") - ADD_LIBRARY(mkllite STATIC ${dummyfile}) -ELSE() - ADD_LIBRARY(mkllite INTERFACE) -ENDIF() - -ADD_DEPENDENCIES(mkllite ${MKL_LITE_PROJECT}) - -LIST(APPEND external_project_dependencies mkllite) diff --git a/cmake/external/mklml.cmake b/cmake/external/mklml.cmake new file mode 100644 index 000000000..45b3f9d85 --- /dev/null +++ b/cmake/external/mklml.cmake @@ -0,0 +1,61 @@ +# Copyright (c) 2017 PaddlePaddle Authors. All Rights Reserve. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +IF(NOT ${WITH_MKLML}) + return() +ENDIF(NOT ${WITH_MKLML}) + +INCLUDE(ExternalProject) + +SET(MKLML_PROJECT "extern_mklml") +SET(MKLML_VER "mklml_lnx_2018.0.20170425") +SET(MKLML_URL "https://github.com/01org/mkl-dnn/releases/download/v0.9/${MKLML_VER}.tgz") +SET(MKLML_DOWNLOAD_DIR ${THIRD_PARTY_PATH}/mklml) + +SET(MKLML_ROOT ${MKLML_DOWNLOAD_DIR}/${MKLML_VER}) +SET(MKLML_INC_DIR ${MKLML_ROOT}/include) +SET(MKLML_LIB_DIR ${MKLML_ROOT}/lib) +SET(MKLML_LIB ${MKLML_LIB_DIR}/libmklml_intel.so) +SET(MKLML_IOMP_LIB ${MKLML_LIB_DIR}/libiomp5.so) +SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_RPATH}" "${MKLML_ROOT}/lib") + +INCLUDE_DIRECTORIES(${MKLML_INC_DIR}) + +ExternalProject_Add( + ${MKLML_PROJECT} + ${EXTERNAL_PROJECT_LOG_ARGS} + PREFIX ${MKLML_DOWNLOAD_DIR} + DOWNLOAD_DIR ${MKLML_DOWNLOAD_DIR} + DOWNLOAD_COMMAND wget --no-check-certificate -O ${MKLML_DOWNLOAD_DIR}/${MKLML_VER}.tgz ${MKLML_URL} + && tar -xzf ${MKLML_DOWNLOAD_DIR}/${MKLML_VER}.tgz + DOWNLOAD_NO_PROGRESS 1 + UPDATE_COMMAND "" + PATCH_COMMAND "" + CONFIGURE_COMMAND "" + BUILD_COMMAND "" + INSTALL_COMMAND "" + TEST_COMMAND "" +) + +IF (${CMAKE_VERSION} VERSION_LESS "3.3.0") + SET(dummyfile ${CMAKE_CURRENT_BINARY_DIR}/mklml_dummy.c) + FILE(WRITE ${dummyfile} "const char * dummy_mklml = \"${dummyfile}\";") + ADD_LIBRARY(mklml STATIC ${dummyfile}) +ELSE() + ADD_LIBRARY(mklml INTERFACE) +ENDIF() + +ADD_DEPENDENCIES(mklml ${MKLML_PROJECT}) + +LIST(APPEND external_project_dependencies mklml) diff --git a/paddle/math/MathFunctions.cpp b/paddle/math/MathFunctions.cpp index 999b72cc1..c8ba1074a 100644 --- a/paddle/math/MathFunctions.cpp +++ b/paddle/math/MathFunctions.cpp @@ -202,7 +202,7 @@ double dotProduct(const int n, const double* x, const double* y) { return cblas_ddot(n, x, 1, y, 1); } -#if defined(PADDLE_USE_MKL) || defined(PADDLE_USE_MKL_LITE) +#if defined(PADDLE_USE_MKL) || defined(PADDLE_USE_MKLML) template <> void vExp(const int n, const float* a, float* r) { diff --git a/paddle/math/MathFunctions.h b/paddle/math/MathFunctions.h index 799948cf0..637643838 100644 --- a/paddle/math/MathFunctions.h +++ b/paddle/math/MathFunctions.h @@ -15,7 +15,7 @@ limitations under the License. */ #ifndef MATHFUNCTIONS_H_ #define MATHFUNCTIONS_H_ -#ifdef PADDLE_USE_MKL_LITE +#ifdef PADDLE_USE_MKLML #include #include #include -- GitLab