mklml.cmake 3.3 KB
Newer Older
1
# Copyright (c) 2017 PaddlePaddle Authors. All Rights Reserved.
T
tensor-tang 已提交
2 3 4 5 6 7 8 9 10 11 12 13 14 15
#
# 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.

INCLUDE(ExternalProject)
16 17 18
SET(MKLML_INSTALL_DIR   ${THIRD_PARTY_PATH}/install/mklml)
SET(MKLML_INC_DIR       ${MKLML_INSTALL_DIR}/include)
SET(MKLML_LIB_DIR       ${MKLML_INSTALL_DIR}/lib)
T
Tao Luo 已提交
19 20 21
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_RPATH}" "${MKLML_ROOT}/lib")

IF(WIN32)
22
    SET(MKLML_VER "mklml_win_2019.0.5.20190502" CACHE STRING "" FORCE)
23
    SET(MKLML_URL "https://paddlepaddledeps.bj.bcebos.com/${MKLML_VER}.zip" CACHE STRING "" FORCE)
24
    SET(MKLML_URL_MD5             ff8c5237570f03eea37377ccfc95a08a)
P
peizhilin 已提交
25 26 27 28
    SET(MKLML_LIB                 ${MKLML_LIB_DIR}/mklml.lib)
    SET(MKLML_IOMP_LIB            ${MKLML_LIB_DIR}/libiomp5md.lib)
    SET(MKLML_SHARED_LIB          ${MKLML_LIB_DIR}/mklml.dll)
    SET(MKLML_SHARED_IOMP_LIB     ${MKLML_LIB_DIR}/libiomp5md.dll)
Y
Yihua Xu 已提交
29 30
ELSE()
    #TODO(intel-huying):
31 32
    #  Now enable csrmm function in mklml library temporarily, it will be updated as offical version later.
    SET(MKLML_VER "csrmm_mklml_lnx_2019.0.5" CACHE STRING "" FORCE)
33
    SET(MKLML_URL "http://paddlepaddledeps.bj.bcebos.com/${MKLML_VER}.tgz" CACHE STRING "" FORCE)
34
    SET(MKLML_URL_MD5             bc6a7faea6a2a9ad31752386f3ae87da)
P
peizhilin 已提交
35 36 37 38
    SET(MKLML_LIB                 ${MKLML_LIB_DIR}/libmklml_intel.so)
    SET(MKLML_IOMP_LIB            ${MKLML_LIB_DIR}/libiomp5.so)
    SET(MKLML_SHARED_LIB          ${MKLML_LIB_DIR}/libmklml_intel.so)
    SET(MKLML_SHARED_IOMP_LIB     ${MKLML_LIB_DIR}/libiomp5.so)
T
Tao Luo 已提交
39
ENDIF()
P
peizhilin 已提交
40

41 42 43 44
SET(MKLML_PROJECT           "extern_mklml")
MESSAGE(STATUS      "MKLML_VER: ${MKLML_VER}, MKLML_URL: ${MKLML_URL}")
SET(MKLML_PREFIX_DIR        ${THIRD_PARTY_PATH}/mklml)
SET(MKLML_SOURCE_DIR        ${THIRD_PARTY_PATH}/mklml/src/extern_mklml)
45

46 47 48 49
# Ninja Generator can not establish the correct dependency relationship between the imported library with target, 
# the product file in the ExternalProject need to be specified manually, please refer to
# https://stackoverflow.com/questions/54866067/cmake-and-ninja-missing-and-no-known-rule-to-make-it
# It is the same to all other ExternalProject.
P
peizhilin 已提交
50 51 52
ExternalProject_Add(
    ${MKLML_PROJECT}
    ${EXTERNAL_PROJECT_LOG_ARGS}
53
    URL                   ${MKLML_URL}
54
    URL_MD5               ${MKLML_URL_MD5}
55
    PREFIX                ${MKLML_PREFIX_DIR}
P
peizhilin 已提交
56 57 58
    DOWNLOAD_NO_PROGRESS  1
    CONFIGURE_COMMAND     ""
    BUILD_COMMAND         ""
59
    UPDATE_COMMAND        ""
60
    INSTALL_COMMAND       ${CMAKE_COMMAND} -E copy_directory ${MKLML_SOURCE_DIR}/include ${MKLML_INC_DIR} &&
61 62 63
                          ${CMAKE_COMMAND} -E copy_directory ${MKLML_SOURCE_DIR}/lib ${MKLML_LIB_DIR}
    BUILD_BYPRODUCTS      ${MKLML_LIB}
    BUILD_BYPRODUCTS      ${MKLML_IOMP_LIB}
P
peizhilin 已提交
64
)
P
peizhilin 已提交
65 66

INCLUDE_DIRECTORIES(${MKLML_INC_DIR})
T
tensor-tang 已提交
67

T
tensor-tang 已提交
68 69
ADD_LIBRARY(mklml SHARED IMPORTED GLOBAL)
SET_PROPERTY(TARGET mklml PROPERTY IMPORTED_LOCATION ${MKLML_LIB})
P
peizhilin 已提交
70
ADD_DEPENDENCIES(mklml ${MKLML_PROJECT})