未验证 提交 92568edb 编写于 作者: S Sing_chan 提交者: GitHub

【code format check upgrade】 step2:cmake-format (#43057)

上级 cb1a0ec1
# Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
#
# 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.
# -----------------------------
# Options affecting formatting.
# -----------------------------
with section("format"):
# How wide to allow formatted cmake files
line_width = 80
# ------------------------------------------------
# Options affecting comment reflow and formatting.
# ------------------------------------------------
with section("markup"):
# enable comment markup parsing and reflow
enable_markup = False
# If comment markup is enabled, don't reflow the first comment block in each
# listfile. Use this to preserve formatting of your copyright/license
# statements.
first_comment_is_literal = True
# ----------------------------------
# Options affecting listfile parsing
# ----------------------------------
with section("parse"):
# Additional FLAGS and KWARGS for custom commands
additional_commands = {
"cc_library": {
"kwargs": {
"SRCS": '*',
"DEPS": '*',
}
},
"nv_library": {
"kwargs": {
"SRCS": '*',
"DEPS": '*',
}
},
"hip_library": {
"kwargs": {
"SRCS": '*',
"DEPS": '*',
}
},
"xpu_library": {
"kwargs": {
"SRCS": '*',
"DEPS": '*',
}
},
"hip_library": {
"kwargs": {
"SRCS": '*',
"DEPS": '*',
}
},
"hip_library": {
"kwargs": {
"SRCS": '*',
"DEPS": '*',
}
},
"go_library": {
"kwargs": {
"SRCS": '*',
"DEPS": '*',
}
},
"copy": {
"kwargs": {
"SRCS": '*',
"DSTS": '*',
}
},
"cc_test": {
"kwargs": {
"SRCS": '*',
"DEPS": '*',
}
},
"nv_test": {
"kwargs": {
"SRCS": '*',
"DEPS": '*',
}
},
"hip_test": {
"kwargs": {
"SRCS": '*',
"DEPS": '*',
}
},
"xpu_test": {
"kwargs": {
"SRCS": '*',
"DEPS": '*',
}
},
"go_test": {
"kwargs": {
"SRCS": '*',
"DEPS": '*',
}
},
"py_test": {
"kwargs": {
"SRCS": '*',
"DEPS": '*',
}
}
}
...@@ -55,3 +55,13 @@ repos: ...@@ -55,3 +55,13 @@ repos:
(?x)^( (?x)^(
paddle/utils/.* paddle/utils/.*
)$ )$
- repo: https://github.com/cheshirekow/cmake-format-precommit
rev: v0.6.13
hooks:
- id: cmake-format
# exclude paddle/fluid/operators/CMakeLists.txt, see the comment
# https://github.com/PaddlePaddle/Paddle/pull/43057#pullrequestreview-993471860
exclude: |
(?x)^(
paddle/fluid/operators/CMakeLists.txt
)$
...@@ -17,47 +17,46 @@ ...@@ -17,47 +17,46 @@
# GPERFTOOLS_LIBRARIES The Gperftools libraries (tcmalloc & profiler) # GPERFTOOLS_LIBRARIES The Gperftools libraries (tcmalloc & profiler)
# GPERFTOOLS_INCLUDE_DIR The location of Gperftools headers # GPERFTOOLS_INCLUDE_DIR The location of Gperftools headers
find_library(GPERFTOOLS_TCMALLOC find_library(
GPERFTOOLS_TCMALLOC
NAMES tcmalloc NAMES tcmalloc
HINTS ${Gperftools_ROOT_DIR}/lib) HINTS ${Gperftools_ROOT_DIR}/lib)
find_library(GPERFTOOLS_PROFILER find_library(
GPERFTOOLS_PROFILER
NAMES profiler NAMES profiler
HINTS ${Gperftools_ROOT_DIR}/lib) HINTS ${Gperftools_ROOT_DIR}/lib)
find_library(GPERFTOOLS_TCMALLOC_AND_PROFILER find_library(
GPERFTOOLS_TCMALLOC_AND_PROFILER
NAMES tcmalloc_and_profiler NAMES tcmalloc_and_profiler
HINTS ${Gperftools_ROOT_DIR}/lib) HINTS ${Gperftools_ROOT_DIR}/lib)
find_path(GPERFTOOLS_INCLUDE_DIR find_path(
GPERFTOOLS_INCLUDE_DIR
NAMES gperftools/heap-profiler.h NAMES gperftools/heap-profiler.h
HINTS ${Gperftools_ROOT_DIR}/include) HINTS ${Gperftools_ROOT_DIR}/include)
set(GPERFTOOLS_LIBRARIES ${GPERFTOOLS_TCMALLOC_AND_PROFILER}) set(GPERFTOOLS_LIBRARIES ${GPERFTOOLS_TCMALLOC_AND_PROFILER})
include(FindPackageHandleStandardArgs) include(FindPackageHandleStandardArgs)
find_package_handle_standard_args( find_package_handle_standard_args(Gperftools DEFAULT_MSG GPERFTOOLS_LIBRARIES
Gperftools GPERFTOOLS_INCLUDE_DIR)
DEFAULT_MSG
GPERFTOOLS_LIBRARIES
GPERFTOOLS_INCLUDE_DIR)
mark_as_advanced( mark_as_advanced(
Gperftools_ROOT_DIR Gperftools_ROOT_DIR GPERFTOOLS_TCMALLOC GPERFTOOLS_PROFILER
GPERFTOOLS_TCMALLOC GPERFTOOLS_TCMALLOC_AND_PROFILER GPERFTOOLS_LIBRARIES GPERFTOOLS_INCLUDE_DIR)
GPERFTOOLS_PROFILER
GPERFTOOLS_TCMALLOC_AND_PROFILER
GPERFTOOLS_LIBRARIES
GPERFTOOLS_INCLUDE_DIR)
# create IMPORTED targets # create IMPORTED targets
if (Gperftools_FOUND AND NOT TARGET gperftools::tcmalloc) if(Gperftools_FOUND AND NOT TARGET gperftools::tcmalloc)
add_library(gperftools::tcmalloc UNKNOWN IMPORTED) add_library(gperftools::tcmalloc UNKNOWN IMPORTED)
set_target_properties(gperftools::tcmalloc PROPERTIES set_target_properties(
IMPORTED_LOCATION ${GPERFTOOLS_TCMALLOC} gperftools::tcmalloc
INTERFACE_INCLUDE_DIRECTORIES "${GPERFTOOLS_INCLUDE_DIR}") PROPERTIES IMPORTED_LOCATION ${GPERFTOOLS_TCMALLOC}
INTERFACE_INCLUDE_DIRECTORIES "${GPERFTOOLS_INCLUDE_DIR}")
add_library(gperftools::profiler UNKNOWN IMPORTED) add_library(gperftools::profiler UNKNOWN IMPORTED)
set_target_properties(gperftools::profiler PROPERTIES set_target_properties(
IMPORTED_LOCATION ${GPERFTOOLS_PROFILER} gperftools::profiler
INTERFACE_INCLUDE_DIRECTORIES "${GPERFTOOLS_INCLUDE_DIR}") PROPERTIES IMPORTED_LOCATION ${GPERFTOOLS_PROFILER}
INTERFACE_INCLUDE_DIRECTORIES "${GPERFTOOLS_INCLUDE_DIR}")
endif() endif()
...@@ -14,13 +14,14 @@ if(NOT PYTHON_EXECUTABLE) ...@@ -14,13 +14,14 @@ if(NOT PYTHON_EXECUTABLE)
endif() endif()
endif() endif()
if (PYTHON_EXECUTABLE) if(PYTHON_EXECUTABLE)
# write a python script that finds the numpy path # write a python script that finds the numpy path
file(WRITE ${PROJECT_BINARY_DIR}/FindNumpyPath.py file(WRITE ${PROJECT_BINARY_DIR}/FindNumpyPath.py
"try: import numpy; print(numpy.get_include())\nexcept:pass\n") "try: import numpy; print(numpy.get_include())\nexcept:pass\n")
# execute the find script # execute the find script
exec_program("${PYTHON_EXECUTABLE}" ${PROJECT_BINARY_DIR} exec_program(
"${PYTHON_EXECUTABLE}" ${PROJECT_BINARY_DIR}
ARGS "FindNumpyPath.py" ARGS "FindNumpyPath.py"
OUTPUT_VARIABLE NUMPY_PATH) OUTPUT_VARIABLE NUMPY_PATH)
elseif(_numpy_out) elseif(_numpy_out)
...@@ -28,10 +29,12 @@ elseif(_numpy_out) ...@@ -28,10 +29,12 @@ elseif(_numpy_out)
endif(PYTHON_EXECUTABLE) endif(PYTHON_EXECUTABLE)
find_path(PYTHON_NUMPY_INCLUDE_DIR numpy/arrayobject.h find_path(PYTHON_NUMPY_INCLUDE_DIR numpy/arrayobject.h
HINTS "${NUMPY_PATH}" "${PYTHON_INCLUDE_PATH}") HINTS "${NUMPY_PATH}" "${PYTHON_INCLUDE_PATH}")
if(PYTHON_NUMPY_INCLUDE_DIR) if(PYTHON_NUMPY_INCLUDE_DIR)
set(PYTHON_NUMPY_FOUND 1 CACHE INTERNAL "Python numpy found") set(PYTHON_NUMPY_FOUND
1
CACHE INTERNAL "Python numpy found")
endif(PYTHON_NUMPY_INCLUDE_DIR) endif(PYTHON_NUMPY_INCLUDE_DIR)
include(FindPackageHandleStandardArgs) include(FindPackageHandleStandardArgs)
......
...@@ -31,9 +31,9 @@ endif() ...@@ -31,9 +31,9 @@ endif()
## Find MKLML First. ## Find MKLML First.
if(WITH_MKLML) if(WITH_MKLML)
include(external/mklml) # download, install mklml package include(external/mklml) # download, install mklml package
set(CBLAS_PROVIDER MKLML) set(CBLAS_PROVIDER MKLML)
set(CBLAS_INC_DIR ${MKLML_INC_DIR}) set(CBLAS_INC_DIR ${MKLML_INC_DIR})
set(CBLAS_LIBRARIES ${MKLML_LIB}) set(CBLAS_LIBRARIES ${MKLML_LIB})
add_definitions(-DPADDLE_WITH_MKLML) add_definitions(-DPADDLE_WITH_MKLML)
...@@ -43,40 +43,48 @@ if(WITH_MKLML) ...@@ -43,40 +43,48 @@ if(WITH_MKLML)
target_link_libraries(cblas dynload_mklml) target_link_libraries(cblas dynload_mklml)
message(STATUS "Found cblas and lapack in MKLML " message(STATUS "Found cblas and lapack in MKLML "
"(include: ${CBLAS_INC_DIR}, library: ${CBLAS_LIBRARIES})") "(include: ${CBLAS_INC_DIR}, library: ${CBLAS_LIBRARIES})")
endif() endif()
## Then find openblas. ## Then find openblas.
if(NOT DEFINED CBLAS_PROVIDER) if(NOT DEFINED CBLAS_PROVIDER)
set(OPENBLAS_ROOT $ENV{OPENBLAS_ROOT} CACHE PATH "Folder contains Openblas") set(OPENBLAS_ROOT
$ENV{OPENBLAS_ROOT}
CACHE PATH "Folder contains Openblas")
set(OPENBLAS_INCLUDE_SEARCH_PATHS set(OPENBLAS_INCLUDE_SEARCH_PATHS
${OPENBLAS_ROOT}/include ${OPENBLAS_ROOT}/include /usr/include /usr/include/lapacke
/usr/include /usr/include/openblas /usr/local/opt/openblas/include)
/usr/include/lapacke
/usr/include/openblas
/usr/local/opt/openblas/include)
set(OPENBLAS_LIB_SEARCH_PATHS set(OPENBLAS_LIB_SEARCH_PATHS
${OPENBLAS_ROOT}/lib ${OPENBLAS_ROOT}/lib /usr/lib /usr/lib/blas/openblas /usr/lib/openblas
/usr/lib /usr/local/opt/openblas/lib)
/usr/lib/blas/openblas
/usr/lib/openblas find_path(
/usr/local/opt/openblas/lib) OPENBLAS_INC_DIR
NAMES cblas.h
find_path(OPENBLAS_INC_DIR NAMES cblas.h PATHS ${OPENBLAS_INCLUDE_SEARCH_PATHS}
PATHS ${OPENBLAS_INCLUDE_SEARCH_PATHS} NO_DEFAULT_PATH) NO_DEFAULT_PATH)
find_path(OPENBLAS_LAPACKE_INC_DIR NAMES lapacke.h find_path(
OPENBLAS_LAPACKE_INC_DIR
NAMES lapacke.h
PATHS ${OPENBLAS_INCLUDE_SEARCH_PATHS}) PATHS ${OPENBLAS_INCLUDE_SEARCH_PATHS})
find_path(OPENBLAS_CONFIG_INC_DIR NAMES openblas_config.h find_path(
OPENBLAS_CONFIG_INC_DIR
NAMES openblas_config.h
PATHS ${OPENBLAS_INCLUDE_SEARCH_PATHS}) PATHS ${OPENBLAS_INCLUDE_SEARCH_PATHS})
find_library(OPENBLAS_LIB NAMES openblas find_library(
OPENBLAS_LIB
NAMES openblas
PATHS ${OPENBLAS_LIB_SEARCH_PATHS}) PATHS ${OPENBLAS_LIB_SEARCH_PATHS})
if(OPENBLAS_LAPACKE_INC_DIR AND OPENBLAS_INC_DIR AND OPENBLAS_CONFIG_INC_DIR AND OPENBLAS_LIB) if(OPENBLAS_LAPACKE_INC_DIR
AND OPENBLAS_INC_DIR
AND OPENBLAS_CONFIG_INC_DIR
AND OPENBLAS_LIB)
file(READ "${OPENBLAS_CONFIG_INC_DIR}/openblas_config.h" config_file) file(READ "${OPENBLAS_CONFIG_INC_DIR}/openblas_config.h" config_file)
string(REGEX MATCH "OpenBLAS ([0-9]+\.[0-9]+\.[0-9]+)" tmp ${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}) string(REGEX MATCH "([0-9]+\.[0-9]+\.[0-9]+)" ver ${tmp})
if (${ver} VERSION_GREATER_EQUAL "0.3.5") if(${ver} VERSION_GREATER_EQUAL "0.3.5")
set(CBLAS_PROVIDER OPENBLAS) set(CBLAS_PROVIDER OPENBLAS)
set(CBLAS_INC_DIR ${OPENBLAS_INC_DIR} ${OPENBLAS_LAPACKE_INC_DIR}) set(CBLAS_INC_DIR ${OPENBLAS_INC_DIR} ${OPENBLAS_LAPACKE_INC_DIR})
set(CBLAS_LIBRARIES ${OPENBLAS_LIB}) set(CBLAS_LIBRARIES ${OPENBLAS_LIB})
...@@ -84,52 +92,61 @@ if(NOT DEFINED CBLAS_PROVIDER) ...@@ -84,52 +92,61 @@ if(NOT DEFINED CBLAS_PROVIDER)
add_definitions(-DPADDLE_USE_OPENBLAS) add_definitions(-DPADDLE_USE_OPENBLAS)
add_definitions(-DLAPACK_FOUND) add_definitions(-DLAPACK_FOUND)
message(STATUS "Found OpenBLAS (include: ${OPENBLAS_INC_DIR}, library: ${CBLAS_LIBRARIES})") message(
message(STATUS "Found lapack in OpenBLAS (include: ${OPENBLAS_LAPACKE_INC_DIR})") STATUS
"Found OpenBLAS (include: ${OPENBLAS_INC_DIR}, library: ${CBLAS_LIBRARIES})"
)
message(
STATUS "Found lapack in OpenBLAS (include: ${OPENBLAS_LAPACKE_INC_DIR})"
)
endif() endif()
endif() endif()
endif() endif()
## Then find the reference-cblas if WITH_SYSTEM_BLAS. www.netlib.org/blas/ ## Then find the reference-cblas if WITH_SYSTEM_BLAS. www.netlib.org/blas/
if(NOT DEFINED CBLAS_PROVIDER AND WITH_SYSTEM_BLAS) if(NOT DEFINED CBLAS_PROVIDER AND WITH_SYSTEM_BLAS)
set(REFERENCE_CBLAS_ROOT $ENV{REFERENCE_CBLAS_ROOT} CACHE PATH set(REFERENCE_CBLAS_ROOT
"Folder contains reference-cblas") $ENV{REFERENCE_CBLAS_ROOT}
set(REFERENCE_CBLAS_INCLUDE_SEARCH_PATHS CACHE PATH "Folder contains reference-cblas")
${REFERENCE_CBLAS_ROOT}/include set(REFERENCE_CBLAS_INCLUDE_SEARCH_PATHS ${REFERENCE_CBLAS_ROOT}/include
/usr/include /usr/include /usr/include/cblas)
/usr/include/cblas
)
set(REFERENCE_CBLAS_LIB_SEARCH_PATHS set(REFERENCE_CBLAS_LIB_SEARCH_PATHS
${REFERENCE_CBLAS_ROOT}/lib ${REFERENCE_CBLAS_ROOT}/lib /usr/lib /usr/lib/blas/reference/
/usr/lib /usr/lib/reference/)
/usr/lib/blas/reference/
/usr/lib/reference/ find_path(
) REFERENCE_CBLAS_INCLUDE_DIR
NAMES cblas.h
find_path(REFERENCE_CBLAS_INCLUDE_DIR NAMES cblas.h PATHS PATHS ${REFERENCE_CBLAS_INCLUDE_SEARCH_PATHS})
${REFERENCE_CBLAS_INCLUDE_SEARCH_PATHS}) find_library(
find_library(REFERENCE_CBLAS_LIBRARY NAMES cblas PATHS REFERENCE_CBLAS_LIBRARY
${REFERENCE_CBLAS_LIB_SEARCH_PATHS}) NAMES cblas
find_library(REFERENCE_BLAS_LIBRARY NAMES blas PATHS PATHS ${REFERENCE_CBLAS_LIB_SEARCH_PATHS})
${REFERENCE_CBLAS_LIB_SEARCH_PATHS}) find_library(
REFERENCE_BLAS_LIBRARY
NAMES blas
PATHS ${REFERENCE_CBLAS_LIB_SEARCH_PATHS})
if(REFERENCE_CBLAS_INCLUDE_DIR AND REFERENCE_CBLAS_LIBRARY) if(REFERENCE_CBLAS_INCLUDE_DIR AND REFERENCE_CBLAS_LIBRARY)
set(CBLAS_PROVIDER REFERENCE_CBLAS) set(CBLAS_PROVIDER REFERENCE_CBLAS)
set(CBLAS_INC_DIR ${REFERENCE_CBLAS_INCLUDE_DIR}) set(CBLAS_INC_DIR ${REFERENCE_CBLAS_INCLUDE_DIR})
set(CBLAS_LIBRARIES ${REFERENCE_CBLAS_LIBRARY}) set(CBLAS_LIBRARIES ${REFERENCE_CBLAS_LIBRARY})
add_definitions(-DPADDLE_USE_REFERENCE_CBLAS) add_definitions(-DPADDLE_USE_REFERENCE_CBLAS)
message(STATUS "Found reference-cblas (include: ${CBLAS_INC_DIR}, library: ${CBLAS_LIBRARIES})") message(
STATUS
"Found reference-cblas (include: ${CBLAS_INC_DIR}, library: ${CBLAS_LIBRARIES})"
)
endif() endif()
endif() endif()
## Then build openblas by external_project ## Then build openblas by external_project
if(NOT DEFINED CBLAS_PROVIDER) if(NOT DEFINED CBLAS_PROVIDER)
include(external/openblas) # download, build, install openblas include(external/openblas) # download, build, install openblas
set(CBLAS_PROVIDER EXTERN_OPENBLAS) set(CBLAS_PROVIDER EXTERN_OPENBLAS)
add_dependencies(cblas extern_openblas) add_dependencies(cblas extern_openblas)
add_definitions(-DPADDLE_USE_OPENBLAS) add_definitions(-DPADDLE_USE_OPENBLAS)
message(STATUS "Build OpenBLAS by External Project " message(STATUS "Build OpenBLAS by External Project "
"(include: ${CBLAS_INC_DIR}, library: ${CBLAS_LIBRARIES})") "(include: ${CBLAS_INC_DIR}, library: ${CBLAS_LIBRARIES})")
endif() endif()
# FIXME(gangliao): generate cblas target to track all high performance # FIXME(gangliao): generate cblas target to track all high performance
...@@ -137,7 +154,8 @@ endif() ...@@ -137,7 +154,8 @@ endif()
include_directories(${CBLAS_INC_DIR}) include_directories(${CBLAS_INC_DIR})
if(${CBLAS_PROVIDER} STREQUAL REFERENCE_CBLAS) if(${CBLAS_PROVIDER} STREQUAL REFERENCE_CBLAS)
target_link_libraries(cblas gfortran ${CBLAS_LIBRARIES} ${REFERENCE_BLAS_LIBRARY}) target_link_libraries(cblas gfortran ${CBLAS_LIBRARIES}
${REFERENCE_BLAS_LIBRARY})
elseif(NOT ${CBLAS_PROVIDER} STREQUAL MKLML) elseif(NOT ${CBLAS_PROVIDER} STREQUAL MKLML)
target_link_libraries(cblas ${CBLAS_LIBRARIES}) target_link_libraries(cblas ${CBLAS_LIBRARIES})
endif() endif()
# Use ccache if found ccache program # Use ccache if found ccache program
if(NOT WIN32) if(NOT WIN32)
find_program(CCACHE_PATH ccache) find_program(CCACHE_PATH ccache)
if(CCACHE_PATH) if(CCACHE_PATH)
execute_process(COMMAND ccache -V OUTPUT_VARIABLE ccache_output) execute_process(COMMAND ccache -V OUTPUT_VARIABLE ccache_output)
execute_process(COMMAND ccache -s cache directory OUTPUT_VARIABLE cache_directory) execute_process(COMMAND ccache -s cache directory
string(REGEX MATCH "[0-9]+.[0-9]+" ccache_version ${ccache_output}) OUTPUT_VARIABLE cache_directory)
message(STATUS "ccache is founded, use ccache to speed up compile on Unix.") string(REGEX MATCH "[0-9]+.[0-9]+" ccache_version ${ccache_output})
# show statistics summary of ccache message(STATUS "ccache is founded, use ccache to speed up compile on Unix.")
message("ccache version\t\t\t " ${ccache_version} "\n" ${cache_directory}) # show statistics summary of ccache
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ${CCACHE_PATH}) message("ccache version\t\t\t " ${ccache_version} "\n"
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ${CCACHE_PATH}) ${cache_directory})
endif(CCACHE_PATH) set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ${CCACHE_PATH})
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ${CCACHE_PATH})
endif(CCACHE_PATH)
elseif("${CMAKE_GENERATOR}" STREQUAL "Ninja") elseif("${CMAKE_GENERATOR}" STREQUAL "Ninja")
# (Note:zhouwei25) Only Ninja Generator can support sccache now # (Note:zhouwei25) Only Ninja Generator can support sccache now
find_program(SCCACHE_PATH sccache) find_program(SCCACHE_PATH sccache)
if(SCCACHE_PATH) if(SCCACHE_PATH)
execute_process(COMMAND sccache -V OUTPUT_VARIABLE sccache_version) execute_process(COMMAND sccache -V OUTPUT_VARIABLE sccache_version)
message(STATUS "sccache is founded, use [${SCCACHE_PATH}] to speed up compile on Windows.") message(
STATUS
"sccache is founded, use [${SCCACHE_PATH}] to speed up compile on Windows."
)
set(CMAKE_C_COMPILER_LAUNCHER ${SCCACHE_PATH}) set(CMAKE_C_COMPILER_LAUNCHER ${SCCACHE_PATH})
set(CMAKE_CXX_COMPILER_LAUNCHER ${SCCACHE_PATH}) set(CMAKE_CXX_COMPILER_LAUNCHER ${SCCACHE_PATH})
# (Note:zhouwei25) sccache for cuda compiler has bug so that it can't be hit # (Note:zhouwei25) sccache for cuda compiler has bug so that it can't be hit
# refer to https://github.com/mozilla/sccache/issues/1017, so we fix it # refer to https://github.com/mozilla/sccache/issues/1017, so we fix it
set(CMAKE_CUDA_COMPILER_LAUNCHER ${SCCACHE_PATH}) set(CMAKE_CUDA_COMPILER_LAUNCHER ${SCCACHE_PATH})
endif(SCCACHE_PATH) endif(SCCACHE_PATH)
endif() endif()
...@@ -13,192 +13,195 @@ ...@@ -13,192 +13,195 @@
# limitations under the License. # limitations under the License.
if(NOT WITH_PYTHON) if(NOT WITH_PYTHON)
add_definitions(-DPADDLE_NO_PYTHON) add_definitions(-DPADDLE_NO_PYTHON)
endif(NOT WITH_PYTHON) endif(NOT WITH_PYTHON)
if(WITH_TESTING) if(WITH_TESTING)
add_definitions(-DPADDLE_WITH_TESTING) add_definitions(-DPADDLE_WITH_TESTING)
endif(WITH_TESTING) endif(WITH_TESTING)
if(WITH_INFERENCE_API_TEST) if(WITH_INFERENCE_API_TEST)
add_definitions(-DPADDLE_WITH_INFERENCE_API_TEST) add_definitions(-DPADDLE_WITH_INFERENCE_API_TEST)
endif(WITH_INFERENCE_API_TEST) endif(WITH_INFERENCE_API_TEST)
if(NOT WITH_PROFILER) if(NOT WITH_PROFILER)
add_definitions(-DPADDLE_DISABLE_PROFILER) add_definitions(-DPADDLE_DISABLE_PROFILER)
endif(NOT WITH_PROFILER) endif(NOT WITH_PROFILER)
if(WITH_AVX AND AVX_FOUND) if(WITH_AVX AND AVX_FOUND)
set(SIMD_FLAG ${AVX_FLAG}) set(SIMD_FLAG ${AVX_FLAG})
add_definitions(-DPADDLE_WITH_AVX) add_definitions(-DPADDLE_WITH_AVX)
elseif(SSE3_FOUND AND NOT WIN32) elseif(SSE3_FOUND AND NOT WIN32)
set(SIMD_FLAG ${SSE3_FLAG}) set(SIMD_FLAG ${SSE3_FLAG})
endif() endif()
if (SSE3_FOUND) if(SSE3_FOUND)
# TODO: Runtime detection should be used here. # TODO: Runtime detection should be used here.
add_definitions(-DPADDLE_WITH_SSE3) add_definitions(-DPADDLE_WITH_SSE3)
endif() endif()
if(WIN32) if(WIN32)
# windows header option for all targets. # windows header option for all targets.
add_definitions(-D_XKEYCHECK_H) add_definitions(-D_XKEYCHECK_H)
# Use symbols instead of absolute path, reduce the cmake link command length. # Use symbols instead of absolute path, reduce the cmake link command length.
SET(CMAKE_C_USE_RESPONSE_FILE_FOR_LIBRARIES 1) set(CMAKE_C_USE_RESPONSE_FILE_FOR_LIBRARIES 1)
SET(CMAKE_CXX_USE_RESPONSE_FILE_FOR_LIBRARIES 1) set(CMAKE_CXX_USE_RESPONSE_FILE_FOR_LIBRARIES 1)
SET(CMAKE_C_USE_RESPONSE_FILE_FOR_OBJECTS 1) set(CMAKE_C_USE_RESPONSE_FILE_FOR_OBJECTS 1)
SET(CMAKE_CXX_USE_RESPONSE_FILE_FOR_OBJECTS 1) set(CMAKE_CXX_USE_RESPONSE_FILE_FOR_OBJECTS 1)
SET(CMAKE_C_USE_RESPONSE_FILE_FOR_INCLUDES 1) set(CMAKE_C_USE_RESPONSE_FILE_FOR_INCLUDES 1)
SET(CMAKE_CXX_USE_RESPONSE_FILE_FOR_INCLUDES 1) set(CMAKE_CXX_USE_RESPONSE_FILE_FOR_INCLUDES 1)
SET(CMAKE_C_RESPONSE_FILE_LINK_FLAG "@") set(CMAKE_C_RESPONSE_FILE_LINK_FLAG "@")
SET(CMAKE_CXX_RESPONSE_FILE_LINK_FLAG "@") set(CMAKE_CXX_RESPONSE_FILE_LINK_FLAG "@")
add_definitions(-DPADDLE_DLL_INFERENCE) add_definitions(-DPADDLE_DLL_INFERENCE)
# set definition for the dll export # set definition for the dll export
if (NOT MSVC) if(NOT MSVC)
message(FATAL "Windows build only support msvc. Which was binded by the nvcc compiler of NVIDIA.") message(
FATAL
"Windows build only support msvc. Which was binded by the nvcc compiler of NVIDIA."
)
endif(NOT MSVC) endif(NOT MSVC)
endif(WIN32) endif(WIN32)
if(WITH_MUSL) if(WITH_MUSL)
add_definitions(-DPADDLE_WITH_MUSL) add_definitions(-DPADDLE_WITH_MUSL)
message(STATUS, "Set compile option WITH_MKL=OFF when WITH_MUSL=ON") message(STATUS, "Set compile option WITH_MKL=OFF when WITH_MUSL=ON")
SET(WITH_MKL OFF) set(WITH_MKL OFF)
message(STATUS, "Set compile option WITH_GPU=OFF when WITH_MUSL=ON") message(STATUS, "Set compile option WITH_GPU=OFF when WITH_MUSL=ON")
SET(WITH_GPU OFF) set(WITH_GPU OFF)
endif() endif()
if(WITH_PSLIB) if(WITH_PSLIB)
add_definitions(-DPADDLE_WITH_PSLIB) add_definitions(-DPADDLE_WITH_PSLIB)
endif() endif()
if(WITH_ARM_BRPC) if(WITH_ARM_BRPC)
add_definitions(-DPADDLE_WITH_ARM_BRPC) add_definitions(-DPADDLE_WITH_ARM_BRPC)
endif() endif()
if(WITH_FLPS) if(WITH_FLPS)
add_definitions(-DPADDLE_WITH_FLPS) add_definitions(-DPADDLE_WITH_FLPS)
endif() endif()
if(WITH_GLOO) if(WITH_GLOO)
add_definitions(-DPADDLE_WITH_GLOO) add_definitions(-DPADDLE_WITH_GLOO)
endif() endif()
if(WITH_BOX_PS) if(WITH_BOX_PS)
add_definitions(-DPADDLE_WITH_BOX_PS) add_definitions(-DPADDLE_WITH_BOX_PS)
endif() endif()
if(WITH_ASCEND) if(WITH_ASCEND)
add_definitions(-DPADDLE_WITH_ASCEND) add_definitions(-DPADDLE_WITH_ASCEND)
endif() endif()
if(WITH_ASCEND_CL) if(WITH_ASCEND_CL)
add_definitions(-DPADDLE_WITH_ASCEND_CL) add_definitions(-DPADDLE_WITH_ASCEND_CL)
endif() endif()
if(WITH_ASCEND_INT64) if(WITH_ASCEND_INT64)
add_definitions(-DPADDLE_WITH_ASCEND_INT64) add_definitions(-DPADDLE_WITH_ASCEND_INT64)
endif() endif()
if(WITH_XPU) if(WITH_XPU)
message(STATUS "Compile with XPU!") message(STATUS "Compile with XPU!")
add_definitions(-DPADDLE_WITH_XPU) add_definitions(-DPADDLE_WITH_XPU)
endif() endif()
if(WITH_XPU_KP) if(WITH_XPU_KP)
message(STATUS "Compile with XPU_KP!") message(STATUS "Compile with XPU_KP!")
add_definitions(-DPADDLE_WITH_XPU_KP) add_definitions(-DPADDLE_WITH_XPU_KP)
endif() endif()
if(WITH_IPU) if(WITH_IPU)
message(STATUS "Compile with IPU!") message(STATUS "Compile with IPU!")
add_definitions(-DPADDLE_WITH_IPU) add_definitions(-DPADDLE_WITH_IPU)
endif() endif()
if(WITH_MLU) if(WITH_MLU)
message(STATUS "Compile with MLU!") message(STATUS "Compile with MLU!")
add_definitions(-DPADDLE_WITH_MLU) add_definitions(-DPADDLE_WITH_MLU)
endif() endif()
if(WITH_GPU) if(WITH_GPU)
add_definitions(-DPADDLE_WITH_CUDA) add_definitions(-DPADDLE_WITH_CUDA)
add_definitions(-DEIGEN_USE_GPU) add_definitions(-DEIGEN_USE_GPU)
FIND_PACKAGE(CUDA REQUIRED) find_package(CUDA REQUIRED)
if(${CMAKE_CUDA_COMPILER_VERSION} VERSION_LESS 10.1) if(${CMAKE_CUDA_COMPILER_VERSION} VERSION_LESS 10.1)
message(FATAL_ERROR "Paddle needs CUDA >= 10.1 to compile") message(FATAL_ERROR "Paddle needs CUDA >= 10.1 to compile")
endif() endif()
if(NOT CUDNN_FOUND) if(NOT CUDNN_FOUND)
message(FATAL_ERROR "Paddle needs cudnn to compile") message(FATAL_ERROR "Paddle needs cudnn to compile")
endif() endif()
if(${CUDNN_MAJOR_VERSION} VERSION_LESS 7) if(${CUDNN_MAJOR_VERSION} VERSION_LESS 7)
message(FATAL_ERROR "Paddle needs CUDNN >= 7.0 to compile") message(FATAL_ERROR "Paddle needs CUDNN >= 7.0 to compile")
endif() endif()
if(CUPTI_FOUND)
include_directories(${CUPTI_INCLUDE_DIR})
add_definitions(-DPADDLE_WITH_CUPTI)
else()
message(STATUS "Cannot find CUPTI, GPU Profiling is incorrect.")
endif()
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -Xcompiler=\"${SIMD_FLAG}\"")
# Include cuda and cudnn
include_directories(${CUDNN_INCLUDE_DIR})
include_directories(${CUDA_TOOLKIT_INCLUDE})
if(CUPTI_FOUND) if(TENSORRT_FOUND)
include_directories(${CUPTI_INCLUDE_DIR}) if(WIN32)
add_definitions(-DPADDLE_WITH_CUPTI) if(${CMAKE_CUDA_COMPILER_VERSION} VERSION_LESS 9)
message(FATAL_ERROR "TensorRT needs CUDA >= 9.0 to compile on Windows")
endif()
else() else()
message(STATUS "Cannot find CUPTI, GPU Profiling is incorrect.") if(${CMAKE_CUDA_COMPILER_VERSION} VERSION_LESS 8)
endif() message(FATAL_ERROR "TensorRT needs CUDA >= 8.0 to compile")
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -Xcompiler=\"${SIMD_FLAG}\"") endif()
if(${CUDNN_MAJOR_VERSION} VERSION_LESS 7)
# Include cuda and cudnn message(FATAL_ERROR "TensorRT needs CUDNN >= 7.0 to compile")
include_directories(${CUDNN_INCLUDE_DIR}) endif()
include_directories(${CUDA_TOOLKIT_INCLUDE}) if(${TENSORRT_MAJOR_VERSION} VERSION_LESS 4)
message(FATAL_ERROR "Paddle needs TensorRT >= 4.0 to compile")
if(TENSORRT_FOUND) endif()
if(WIN32)
if(${CMAKE_CUDA_COMPILER_VERSION} VERSION_LESS 9)
message(FATAL_ERROR "TensorRT needs CUDA >= 9.0 to compile on Windows")
endif()
else()
if(${CMAKE_CUDA_COMPILER_VERSION} VERSION_LESS 8)
message(FATAL_ERROR "TensorRT needs CUDA >= 8.0 to compile")
endif()
if(${CUDNN_MAJOR_VERSION} VERSION_LESS 7)
message(FATAL_ERROR "TensorRT needs CUDNN >= 7.0 to compile")
endif()
if(${TENSORRT_MAJOR_VERSION} VERSION_LESS 4)
message(FATAL_ERROR "Paddle needs TensorRT >= 4.0 to compile")
endif()
endif()
include_directories(${TENSORRT_INCLUDE_DIR})
endif() endif()
include_directories(${TENSORRT_INCLUDE_DIR})
endif()
elseif(WITH_ROCM) elseif(WITH_ROCM)
add_definitions(-DPADDLE_WITH_HIP) add_definitions(-DPADDLE_WITH_HIP)
add_definitions(-DEIGEN_USE_GPU) add_definitions(-DEIGEN_USE_GPU)
add_definitions(-DEIGEN_USE_HIP) add_definitions(-DEIGEN_USE_HIP)
if(NOT MIOPEN_FOUND) if(NOT MIOPEN_FOUND)
message(FATAL_ERROR "Paddle needs MIOpen to compile") message(FATAL_ERROR "Paddle needs MIOpen to compile")
endif() endif()
if(${MIOPEN_VERSION} VERSION_LESS 2090) if(${MIOPEN_VERSION} VERSION_LESS 2090)
message(FATAL_ERROR "Paddle needs MIOPEN >= 2.9 to compile") message(FATAL_ERROR "Paddle needs MIOPEN >= 2.9 to compile")
endif() endif()
else() else()
add_definitions(-DHPPL_STUB_FUNC) add_definitions(-DHPPL_STUB_FUNC)
list(APPEND CMAKE_CXX_SOURCE_FILE_EXTENSIONS cu) list(APPEND CMAKE_CXX_SOURCE_FILE_EXTENSIONS cu)
endif() endif()
if (WITH_MKLML AND MKLML_IOMP_LIB) if(WITH_MKLML AND MKLML_IOMP_LIB)
message(STATUS "Enable Intel OpenMP with ${MKLML_IOMP_LIB}") message(STATUS "Enable Intel OpenMP with ${MKLML_IOMP_LIB}")
if(WIN32) if(WIN32)
# openmp not support well for now on windows # openmp not support well for now on windows
set(OPENMP_FLAGS "") set(OPENMP_FLAGS "")
else(WIN32) else(WIN32)
set(OPENMP_FLAGS "-fopenmp") set(OPENMP_FLAGS "-fopenmp")
endif(WIN32) endif(WIN32)
set(CMAKE_C_CREATE_SHARED_LIBRARY_FORBIDDEN_FLAGS ${OPENMP_FLAGS}) set(CMAKE_C_CREATE_SHARED_LIBRARY_FORBIDDEN_FLAGS ${OPENMP_FLAGS})
set(CMAKE_CXX_CREATE_SHARED_LIBRARY_FORBIDDEN_FLAGS ${OPENMP_FLAGS}) set(CMAKE_CXX_CREATE_SHARED_LIBRARY_FORBIDDEN_FLAGS ${OPENMP_FLAGS})
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OPENMP_FLAGS}") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OPENMP_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OPENMP_FLAGS}") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OPENMP_FLAGS}")
endif() endif()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${SIMD_FLAG}") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${SIMD_FLAG}")
...@@ -209,25 +212,25 @@ if(WITH_DISTRIBUTE) ...@@ -209,25 +212,25 @@ if(WITH_DISTRIBUTE)
endif() endif()
if(WITH_PSCORE) if(WITH_PSCORE)
add_definitions(-DPADDLE_WITH_PSCORE) add_definitions(-DPADDLE_WITH_PSCORE)
endif() endif()
if(WITH_HETERPS) if(WITH_HETERPS)
add_definitions(-DPADDLE_WITH_HETERPS) add_definitions(-DPADDLE_WITH_HETERPS)
endif() endif()
if(WITH_BRPC_RDMA) if(WITH_BRPC_RDMA)
add_definitions(-DPADDLE_WITH_BRPC_RDMA) add_definitions(-DPADDLE_WITH_BRPC_RDMA)
endif(WITH_BRPC_RDMA) endif(WITH_BRPC_RDMA)
if(ON_INFER) if(ON_INFER)
add_definitions(-DPADDLE_ON_INFERENCE) add_definitions(-DPADDLE_ON_INFERENCE)
endif(ON_INFER) endif(ON_INFER)
if(WITH_CRYPTO) if(WITH_CRYPTO)
add_definitions(-DPADDLE_WITH_CRYPTO) add_definitions(-DPADDLE_WITH_CRYPTO)
endif(WITH_CRYPTO) endif(WITH_CRYPTO)
if(WITH_CUSTOM_DEVICE AND NOT WIN32) if(WITH_CUSTOM_DEVICE AND NOT WIN32)
add_definitions(-DPADDLE_WITH_CUSTOM_DEVICE) add_definitions(-DPADDLE_WITH_CUSTOM_DEVICE)
endif() endif()
...@@ -5,107 +5,106 @@ ...@@ -5,107 +5,106 @@
# Param _COVERALLS_UPLOAD Upload the result to coveralls. # Param _COVERALLS_UPLOAD Upload the result to coveralls.
# Param _CMAKE_SCRIPT_PATH CMake script path. # Param _CMAKE_SCRIPT_PATH CMake script path.
function(code_coverage _COVERAGE_SRCS _COVERALLS_UPLOAD _CMAKE_SCRIPT_PATH) function(code_coverage _COVERAGE_SRCS _COVERALLS_UPLOAD _CMAKE_SCRIPT_PATH)
# clean previous gcov data. # clean previous gcov data.
file(REMOVE_RECURSE ${PROJECT_BINARY_DIR}/*.gcda) file(REMOVE_RECURSE ${PROJECT_BINARY_DIR}/*.gcda)
# find curl for upload JSON soon. # find curl for upload JSON soon.
if (_COVERALLS_UPLOAD) if(_COVERALLS_UPLOAD)
find_program(CURL_EXECUTABLE curl) find_program(CURL_EXECUTABLE curl)
if (NOT CURL_EXECUTABLE) if(NOT CURL_EXECUTABLE)
message(FATAL_ERROR "Coveralls: curl not found!") message(FATAL_ERROR "Coveralls: curl not found!")
endif()
endif() endif()
endif()
# When passing a CMake list to an external process, the list # When passing a CMake list to an external process, the list
# will be converted from the format "1;2;3" to "1 2 3". # will be converted from the format "1;2;3" to "1 2 3".
set(COVERAGE_SRCS "") set(COVERAGE_SRCS "")
foreach (SINGLE_SRC ${_COVERAGE_SRCS}) foreach(SINGLE_SRC ${_COVERAGE_SRCS})
set(COVERAGE_SRCS "${COVERAGE_SRCS}*${SINGLE_SRC}") set(COVERAGE_SRCS "${COVERAGE_SRCS}*${SINGLE_SRC}")
endforeach() endforeach()
# query number of logical cores # query number of logical cores
cmake_host_system_information(RESULT core_size QUERY NUMBER_OF_LOGICAL_CORES) cmake_host_system_information(RESULT core_size QUERY NUMBER_OF_LOGICAL_CORES)
# coveralls json file. # coveralls json file.
set(COVERALLS_FILE ${PROJECT_BINARY_DIR}/coveralls.json) set(COVERALLS_FILE ${PROJECT_BINARY_DIR}/coveralls.json)
add_custom_target(coveralls_generate add_custom_target(
# Run regress tests. coveralls_generate
COMMAND ${CMAKE_CTEST_COMMAND} # Run regress tests.
-j ${core_size} COMMAND ${CMAKE_CTEST_COMMAND} -j ${core_size} --output-on-failure
--output-on-failure # Generate Gcov and translate it into coveralls JSON.
# Generate Gcov and translate it into coveralls JSON. COMMAND
COMMAND ${CMAKE_COMMAND} ${CMAKE_COMMAND} -DCOVERAGE_SRCS="${COVERAGE_SRCS}"
-DCOVERAGE_SRCS="${COVERAGE_SRCS}" -DCOVERALLS_OUTPUT_FILE="${COVERALLS_FILE}"
-DCOVERALLS_OUTPUT_FILE="${COVERALLS_FILE}" -DCOV_PATH="${PROJECT_BINARY_DIR}" -DPROJECT_ROOT="${PROJECT_SOURCE_DIR}"
-DCOV_PATH="${PROJECT_BINARY_DIR}" -P "${_CMAKE_SCRIPT_PATH}/coverallsGcovJsons.cmake"
-DPROJECT_ROOT="${PROJECT_SOURCE_DIR}" WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
-P "${_CMAKE_SCRIPT_PATH}/coverallsGcovJsons.cmake" COMMENT "Coveralls: generating coveralls output...")
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
COMMENT "Coveralls: generating coveralls output..."
)
if (_COVERALLS_UPLOAD) if(_COVERALLS_UPLOAD)
message("COVERALLS UPLOAD: ON") message("COVERALLS UPLOAD: ON")
# Upload the JSON to coveralls. # Upload the JSON to coveralls.
add_custom_target(coveralls_upload add_custom_target(
COMMAND ${CURL_EXECUTABLE} coveralls_upload
-S -F json_file=@${COVERALLS_FILE} COMMAND ${CURL_EXECUTABLE} -S -F json_file=@${COVERALLS_FILE}
https://coveralls.io/api/v1/jobs https://coveralls.io/api/v1/jobs
DEPENDS coveralls_generate DEPENDS coveralls_generate
WORKING_DIRECTORY ${PROJECT_BINARY_DIR} WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
COMMENT "Coveralls: uploading coveralls output...") COMMENT "Coveralls: uploading coveralls output...")
add_custom_target(coveralls DEPENDS coveralls_upload) add_custom_target(coveralls DEPENDS coveralls_upload)
else() else()
message("COVERALLS UPLOAD: OFF") message("COVERALLS UPLOAD: OFF")
add_custom_target(coveralls DEPENDS coveralls_generate) add_custom_target(coveralls DEPENDS coveralls_generate)
endif() endif()
endfunction() endfunction()
if(WITH_COVERAGE) if(WITH_COVERAGE)
if (WITH_INCREMENTAL_COVERAGE) if(WITH_INCREMENTAL_COVERAGE)
# if *.h changed, generate coverage report totaly. # if *.h changed, generate coverage report totaly.
# if pybind.cc changed, generate coverage report totaly. # if pybind.cc changed, generate coverage report totaly.
# Because if pybind.cc add '-g -O0 -fprofile-arcs -ftest-coverage' only, some testcase will fail. # Because if pybind.cc add '-g -O0 -fprofile-arcs -ftest-coverage' only, some testcase will fail.
if ( (NOT ("$ENV{PADDLE_GIT_DIFF_H_FILE}" STREQUAL "")) OR ("$ENV{PADDLE_GIT_DIFF_CC_FILE}" MATCHES "pybind.cc") ) if((NOT ("$ENV{PADDLE_GIT_DIFF_H_FILE}" STREQUAL ""))
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0 -fprofile-arcs -ftest-coverage") OR ("$ENV{PADDLE_GIT_DIFF_CC_FILE}" MATCHES "pybind.cc"))
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O0 -fprofile-arcs -ftest-coverage") set(CMAKE_CXX_FLAGS
endif() "${CMAKE_CXX_FLAGS} -g -O0 -fprofile-arcs -ftest-coverage")
else() set(CMAKE_C_FLAGS
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0 -fprofile-arcs -ftest-coverage") "${CMAKE_C_FLAGS} -g -O0 -fprofile-arcs -ftest-coverage")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O0 -fprofile-arcs -ftest-coverage")
endif() endif()
set(EXCLUDE_DIRS else()
"demo/" set(CMAKE_CXX_FLAGS
"build/" "${CMAKE_CXX_FLAGS} -g -O0 -fprofile-arcs -ftest-coverage")
"tests/" set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O0 -fprofile-arcs -ftest-coverage")
".test_env/" endif()
) set(EXCLUDE_DIRS "demo/" "build/" "tests/" ".test_env/")
if(WITH_GPU) if(WITH_GPU)
file(GLOB_RECURSE PADDLE_SOURCES RELATIVE "${PROJECT_SOURCE_DIR}" "*.cpp" "*.cc" ".c" "*.cu") file(
else() GLOB_RECURSE PADDLE_SOURCES
file(GLOB_RECURSE PADDLE_SOURCES RELATIVE "${PROJECT_SOURCE_DIR}" "*.cpp" "*.cc" "*.c") RELATIVE "${PROJECT_SOURCE_DIR}"
endif() "*.cpp" "*.cc" ".c" "*.cu")
else()
file(
GLOB_RECURSE PADDLE_SOURCES
RELATIVE "${PROJECT_SOURCE_DIR}"
"*.cpp" "*.cc" "*.c")
endif()
# exclude trivial files in PADDLE_SOURCES # exclude trivial files in PADDLE_SOURCES
foreach(EXCLUDE_DIR ${EXCLUDE_DIRS}) foreach(EXCLUDE_DIR ${EXCLUDE_DIRS})
foreach(TMP_PATH ${PADDLE_SOURCES}) foreach(TMP_PATH ${PADDLE_SOURCES})
string(FIND ${TMP_PATH} ${EXCLUDE_DIR} EXCLUDE_DIR_FOUND) string(FIND ${TMP_PATH} ${EXCLUDE_DIR} EXCLUDE_DIR_FOUND)
if(NOT ${EXCLUDE_DIR_FOUND} EQUAL -1) if(NOT ${EXCLUDE_DIR_FOUND} EQUAL -1)
list(REMOVE_ITEM PADDLE_SOURCES ${TMP_PATH}) list(REMOVE_ITEM PADDLE_SOURCES ${TMP_PATH})
endif() endif()
endforeach(TMP_PATH) endforeach(TMP_PATH)
endforeach() endforeach()
# convert to absolute path # convert to absolute path
set(PADDLE_SRCS "") set(PADDLE_SRCS "")
foreach(PADDLE_SRC ${PADDLE_SOURCES}) foreach(PADDLE_SRC ${PADDLE_SOURCES})
set(PADDLE_SRCS "${PADDLE_SRCS};${PROJECT_SOURCE_DIR}/${PADDLE_SRC}") set(PADDLE_SRCS "${PADDLE_SRCS};${PROJECT_SOURCE_DIR}/${PADDLE_SRC}")
endforeach() endforeach()
code_coverage( code_coverage("${PADDLE_SRCS}" ${COVERALLS_UPLOAD}
"${PADDLE_SRCS}" "${PROJECT_SOURCE_DIR}/cmake")
${COVERALLS_UPLOAD}
"${PROJECT_SOURCE_DIR}/cmake"
)
endif() endif()
此差异已折叠。
if(NOT WITH_GPU) if(NOT WITH_GPU)
return() return()
endif() endif()
if(WITH_NV_JETSON) if(WITH_NV_JETSON)
...@@ -38,7 +38,9 @@ function(detect_installed_gpus out_variable) ...@@ -38,7 +38,9 @@ function(detect_installed_gpus out_variable)
if(NOT CUDA_gpu_detect_output) if(NOT CUDA_gpu_detect_output)
set(cufile ${PROJECT_BINARY_DIR}/detect_cuda_archs.cu) set(cufile ${PROJECT_BINARY_DIR}/detect_cuda_archs.cu)
file(WRITE ${cufile} "" file(
WRITE ${cufile}
""
"#include \"stdio.h\"\n" "#include \"stdio.h\"\n"
"#include \"cuda.h\"\n" "#include \"cuda.h\"\n"
"#include \"cuda_runtime.h\"\n" "#include \"cuda_runtime.h\"\n"
...@@ -54,55 +56,86 @@ function(detect_installed_gpus out_variable) ...@@ -54,55 +56,86 @@ function(detect_installed_gpus out_variable)
" return 0;\n" " return 0;\n"
"}\n") "}\n")
execute_process(COMMAND "${CUDA_NVCC_EXECUTABLE}" execute_process(
"--run" "${cufile}" COMMAND "${CUDA_NVCC_EXECUTABLE}" "--run" "${cufile}"
WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/CMakeFiles/" WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/CMakeFiles/"
RESULT_VARIABLE nvcc_res OUTPUT_VARIABLE nvcc_out RESULT_VARIABLE nvcc_res
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) OUTPUT_VARIABLE nvcc_out
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
if(nvcc_res EQUAL 0) if(nvcc_res EQUAL 0)
# only keep the last line of nvcc_out # only keep the last line of nvcc_out
STRING(REGEX REPLACE ";" "\\\\;" nvcc_out "${nvcc_out}") string(REGEX REPLACE ";" "\\\\;" nvcc_out "${nvcc_out}")
STRING(REGEX REPLACE "\n" ";" nvcc_out "${nvcc_out}") string(REGEX REPLACE "\n" ";" nvcc_out "${nvcc_out}")
list(GET nvcc_out -1 nvcc_out) list(GET nvcc_out -1 nvcc_out)
string(REPLACE "2.1" "2.1(2.0)" nvcc_out "${nvcc_out}") string(REPLACE "2.1" "2.1(2.0)" nvcc_out "${nvcc_out}")
set(CUDA_gpu_detect_output ${nvcc_out} CACHE INTERNAL "Returned GPU architetures from detect_installed_gpus tool" FORCE) set(CUDA_gpu_detect_output
${nvcc_out}
CACHE INTERNAL
"Returned GPU architetures from detect_installed_gpus tool"
FORCE)
endif() endif()
endif() endif()
if(NOT CUDA_gpu_detect_output) if(NOT CUDA_gpu_detect_output)
message(STATUS "Automatic GPU detection failed. Building for all known architectures.") message(
set(${out_variable} ${paddle_known_gpu_archs} PARENT_SCOPE) STATUS
"Automatic GPU detection failed. Building for all known architectures.")
set(${out_variable}
${paddle_known_gpu_archs}
PARENT_SCOPE)
else() else()
set(${out_variable} ${CUDA_gpu_detect_output} PARENT_SCOPE) set(${out_variable}
${CUDA_gpu_detect_output}
PARENT_SCOPE)
endif() endif()
endfunction() endfunction()
######################################################################## ########################################################################
# Function for selecting GPU arch flags for nvcc based on CUDA_ARCH_NAME # Function for selecting GPU arch flags for nvcc based on CUDA_ARCH_NAME
# Usage: # Usage:
# select_nvcc_arch_flags(out_variable) # select_nvcc_arch_flags(out_variable)
function(select_nvcc_arch_flags out_variable) function(select_nvcc_arch_flags out_variable)
# List of arch names # List of arch names
set(archs_names "Kepler" "Maxwell" "Pascal" "Volta" "Turing" "Ampere" "All" "Manual") set(archs_names
"Kepler"
"Maxwell"
"Pascal"
"Volta"
"Turing"
"Ampere"
"All"
"Manual")
set(archs_name_default "Auto") set(archs_name_default "Auto")
list(APPEND archs_names "Auto") list(APPEND archs_names "Auto")
# set CUDA_ARCH_NAME strings (so it will be seen as dropbox in CMake-Gui) # set CUDA_ARCH_NAME strings (so it will be seen as dropbox in CMake-Gui)
set(CUDA_ARCH_NAME ${archs_name_default} CACHE STRING "Select target NVIDIA GPU achitecture.") set(CUDA_ARCH_NAME
set_property( CACHE CUDA_ARCH_NAME PROPERTY STRINGS "" ${archs_names} ) ${archs_name_default}
CACHE STRING "Select target NVIDIA GPU achitecture.")
set_property(CACHE CUDA_ARCH_NAME PROPERTY STRINGS "" ${archs_names})
mark_as_advanced(CUDA_ARCH_NAME) mark_as_advanced(CUDA_ARCH_NAME)
# verify CUDA_ARCH_NAME value # verify CUDA_ARCH_NAME value
if(NOT ";${archs_names};" MATCHES ";${CUDA_ARCH_NAME};") if(NOT ";${archs_names};" MATCHES ";${CUDA_ARCH_NAME};")
string(REPLACE ";" ", " archs_names "${archs_names}") string(REPLACE ";" ", " archs_names "${archs_names}")
message(FATAL_ERROR "Only ${archs_names} architectures names are supported.") message(
FATAL_ERROR "Only ${archs_names} architectures names are supported.")
endif() endif()
if(${CUDA_ARCH_NAME} STREQUAL "Manual") if(${CUDA_ARCH_NAME} STREQUAL "Manual")
set(CUDA_ARCH_BIN ${paddle_known_gpu_archs} CACHE STRING "Specify 'real' GPU architectures to build binaries for, BIN(PTX) format is supported") set(CUDA_ARCH_BIN
set(CUDA_ARCH_PTX "" CACHE STRING "Specify 'virtual' PTX architectures to build PTX intermediate code for") ${paddle_known_gpu_archs}
CACHE
STRING
"Specify 'real' GPU architectures to build binaries for, BIN(PTX) format is supported"
)
set(CUDA_ARCH_PTX
""
CACHE
STRING
"Specify 'virtual' PTX architectures to build PTX intermediate code for"
)
mark_as_advanced(CUDA_ARCH_BIN CUDA_ARCH_PTX) mark_as_advanced(CUDA_ARCH_BIN CUDA_ARCH_PTX)
else() else()
unset(CUDA_ARCH_BIN CACHE) unset(CUDA_ARCH_BIN CACHE)
...@@ -112,19 +145,19 @@ function(select_nvcc_arch_flags out_variable) ...@@ -112,19 +145,19 @@ function(select_nvcc_arch_flags out_variable)
if(${CUDA_ARCH_NAME} STREQUAL "Kepler") if(${CUDA_ARCH_NAME} STREQUAL "Kepler")
set(cuda_arch_bin "30 35") set(cuda_arch_bin "30 35")
elseif(${CUDA_ARCH_NAME} STREQUAL "Maxwell") elseif(${CUDA_ARCH_NAME} STREQUAL "Maxwell")
if (WITH_NV_JETSON) if(WITH_NV_JETSON)
set(cuda_arch_bin "53") set(cuda_arch_bin "53")
else() else()
set(cuda_arch_bin "50") set(cuda_arch_bin "50")
endif() endif()
elseif(${CUDA_ARCH_NAME} STREQUAL "Pascal") elseif(${CUDA_ARCH_NAME} STREQUAL "Pascal")
if (WITH_NV_JETSON) if(WITH_NV_JETSON)
set(cuda_arch_bin "62") set(cuda_arch_bin "62")
else() else()
set(cuda_arch_bin "60 61") set(cuda_arch_bin "60 61")
endif() endif()
elseif(${CUDA_ARCH_NAME} STREQUAL "Volta") elseif(${CUDA_ARCH_NAME} STREQUAL "Volta")
if (WITH_NV_JETSON) if(WITH_NV_JETSON)
set(cuda_arch_bin "72") set(cuda_arch_bin "72")
else() else()
set(cuda_arch_bin "70") set(cuda_arch_bin "70")
...@@ -132,35 +165,37 @@ function(select_nvcc_arch_flags out_variable) ...@@ -132,35 +165,37 @@ function(select_nvcc_arch_flags out_variable)
elseif(${CUDA_ARCH_NAME} STREQUAL "Turing") elseif(${CUDA_ARCH_NAME} STREQUAL "Turing")
set(cuda_arch_bin "75") set(cuda_arch_bin "75")
elseif(${CUDA_ARCH_NAME} STREQUAL "Ampere") elseif(${CUDA_ARCH_NAME} STREQUAL "Ampere")
if (${CMAKE_CUDA_COMPILER_VERSION} LESS 11.1) # CUDA 11.0 if(${CMAKE_CUDA_COMPILER_VERSION} LESS 11.1) # CUDA 11.0
set(cuda_arch_bin "80") set(cuda_arch_bin "80")
elseif (${CMAKE_CUDA_COMPILER_VERSION} LESS 12.0) # CUDA 11.1+ elseif(${CMAKE_CUDA_COMPILER_VERSION} LESS 12.0) # CUDA 11.1+
set(cuda_arch_bin "80 86") set(cuda_arch_bin "80 86")
endif() endif()
elseif(${CUDA_ARCH_NAME} STREQUAL "All") elseif(${CUDA_ARCH_NAME} STREQUAL "All")
set(cuda_arch_bin ${paddle_known_gpu_archs}) set(cuda_arch_bin ${paddle_known_gpu_archs})
elseif(${CUDA_ARCH_NAME} STREQUAL "Auto") elseif(${CUDA_ARCH_NAME} STREQUAL "Auto")
message(STATUS "WARNING: This is just a warning for publishing release. message(
STATUS
"WARNING: This is just a warning for publishing release.
You are building GPU version without supporting different architectures. You are building GPU version without supporting different architectures.
So the wheel package may fail on other GPU architectures. So the wheel package may fail on other GPU architectures.
You can add -DCUDA_ARCH_NAME=All in cmake command You can add -DCUDA_ARCH_NAME=All in cmake command
to get a full wheel package to resolve this warning. to get a full wheel package to resolve this warning.
While, this version will still work on local GPU architecture.") While, this version will still work on local GPU architecture.")
detect_installed_gpus(cuda_arch_bin) detect_installed_gpus(cuda_arch_bin)
else() # (${CUDA_ARCH_NAME} STREQUAL "Manual") else() # (${CUDA_ARCH_NAME} STREQUAL "Manual")
set(cuda_arch_bin ${CUDA_ARCH_BIN}) set(cuda_arch_bin ${CUDA_ARCH_BIN})
endif() endif()
if(NEW_RELEASE_JIT) if(NEW_RELEASE_JIT)
set(cuda_arch_ptx "${cuda_arch_ptx}${cuda_arch_bin}") set(cuda_arch_ptx "${cuda_arch_ptx}${cuda_arch_bin}")
set(cuda_arch_bin "") set(cuda_arch_bin "")
endif() endif()
# remove dots and convert to lists # remove dots and convert to lists
string(REGEX REPLACE "\\." "" cuda_arch_bin "${cuda_arch_bin}") string(REGEX REPLACE "\\." "" cuda_arch_bin "${cuda_arch_bin}")
string(REGEX REPLACE "\\." "" cuda_arch_ptx "${cuda_arch_ptx}") string(REGEX REPLACE "\\." "" cuda_arch_ptx "${cuda_arch_ptx}")
string(REGEX MATCHALL "[0-9()]+" cuda_arch_bin "${cuda_arch_bin}") string(REGEX MATCHALL "[0-9()]+" cuda_arch_bin "${cuda_arch_bin}")
string(REGEX MATCHALL "[0-9]+" cuda_arch_ptx "${cuda_arch_ptx}") string(REGEX MATCHALL "[0-9]+" cuda_arch_ptx "${cuda_arch_ptx}")
list(REMOVE_DUPLICATES cuda_arch_bin) list(REMOVE_DUPLICATES cuda_arch_bin)
list(REMOVE_DUPLICATES cuda_arch_ptx) list(REMOVE_DUPLICATES cuda_arch_ptx)
...@@ -172,7 +207,8 @@ function(select_nvcc_arch_flags out_variable) ...@@ -172,7 +207,8 @@ function(select_nvcc_arch_flags out_variable)
foreach(arch ${cuda_arch_bin}) foreach(arch ${cuda_arch_bin})
if(arch MATCHES "([0-9]+)\\(([0-9]+)\\)") if(arch MATCHES "([0-9]+)\\(([0-9]+)\\)")
# User explicitly specified PTX for the concrete BIN # User explicitly specified PTX for the concrete BIN
string(APPEND nvcc_flags " -gencode arch=compute_${CMAKE_MATCH_2},code=sm_${CMAKE_MATCH_1}") string(APPEND nvcc_flags
" -gencode arch=compute_${CMAKE_MATCH_2},code=sm_${CMAKE_MATCH_1}")
string(APPEND nvcc_archs_readable " sm_${CMAKE_MATCH_1}") string(APPEND nvcc_archs_readable " sm_${CMAKE_MATCH_1}")
else() else()
# User didn't explicitly specify PTX for the concrete BIN, we assume PTX=BIN # User didn't explicitly specify PTX for the concrete BIN, we assume PTX=BIN
...@@ -183,34 +219,39 @@ function(select_nvcc_arch_flags out_variable) ...@@ -183,34 +219,39 @@ function(select_nvcc_arch_flags out_variable)
# Tell NVCC to add PTX intermediate code for the specified architectures # Tell NVCC to add PTX intermediate code for the specified architectures
foreach(arch ${cuda_arch_ptx}) foreach(arch ${cuda_arch_ptx})
string(APPEND nvcc_flags " -gencode arch=compute_${arch},code=compute_${arch}") string(APPEND nvcc_flags
" -gencode arch=compute_${arch},code=compute_${arch}")
string(APPEND nvcc_archs_readable " compute_${arch}") string(APPEND nvcc_archs_readable " compute_${arch}")
endforeach() endforeach()
string(REPLACE ";" " " nvcc_archs_readable "${nvcc_archs_readable}") string(REPLACE ";" " " nvcc_archs_readable "${nvcc_archs_readable}")
set(${out_variable} ${nvcc_flags} PARENT_SCOPE) set(${out_variable}
set(${out_variable}_readable ${nvcc_archs_readable} PARENT_SCOPE) ${nvcc_flags}
PARENT_SCOPE)
set(${out_variable}_readable
${nvcc_archs_readable}
PARENT_SCOPE)
endfunction() endfunction()
message(STATUS "CUDA detected: " ${CMAKE_CUDA_COMPILER_VERSION}) message(STATUS "CUDA detected: " ${CMAKE_CUDA_COMPILER_VERSION})
if (${CMAKE_CUDA_COMPILER_VERSION} LESS 11.0) # CUDA 10.x if(${CMAKE_CUDA_COMPILER_VERSION} LESS 11.0) # CUDA 10.x
set(paddle_known_gpu_archs ${paddle_known_gpu_archs10}) set(paddle_known_gpu_archs ${paddle_known_gpu_archs10})
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -D_MWAITXINTRIN_H_INCLUDED") set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -D_MWAITXINTRIN_H_INCLUDED")
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -D__STRICT_ANSI__") set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -D__STRICT_ANSI__")
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -Wno-deprecated-gpu-targets") set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -Wno-deprecated-gpu-targets")
elseif (${CMAKE_CUDA_COMPILER_VERSION} LESS 11.2) # CUDA 11.0/11.1 elseif(${CMAKE_CUDA_COMPILER_VERSION} LESS 11.2) # CUDA 11.0/11.1
set(paddle_known_gpu_archs ${paddle_known_gpu_archs11}) set(paddle_known_gpu_archs ${paddle_known_gpu_archs11})
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -D_MWAITXINTRIN_H_INCLUDED") set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -D_MWAITXINTRIN_H_INCLUDED")
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -D__STRICT_ANSI__") set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -D__STRICT_ANSI__")
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -Wno-deprecated-gpu-targets") set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -Wno-deprecated-gpu-targets")
elseif (${CMAKE_CUDA_COMPILER_VERSION} LESS 12.0) # CUDA 11.2+ elseif(${CMAKE_CUDA_COMPILER_VERSION} LESS 12.0) # CUDA 11.2+
set(paddle_known_gpu_archs "${paddle_known_gpu_archs11} 86") set(paddle_known_gpu_archs "${paddle_known_gpu_archs11} 86")
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -D_MWAITXINTRIN_H_INCLUDED") set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -D_MWAITXINTRIN_H_INCLUDED")
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -D__STRICT_ANSI__") set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -D__STRICT_ANSI__")
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -Wno-deprecated-gpu-targets") set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -Wno-deprecated-gpu-targets")
endif() endif()
if (NOT ${CMAKE_CUDA_COMPILER_VERSION} LESS 10.0) if(NOT ${CMAKE_CUDA_COMPILER_VERSION} LESS 10.0)
add_definitions("-DTRT_PLUGIN_FP16_AVALIABLE") add_definitions("-DTRT_PLUGIN_FP16_AVALIABLE")
endif() endif()
...@@ -231,7 +272,7 @@ set(CMAKE_CUDA_STANDARD 14) ...@@ -231,7 +272,7 @@ set(CMAKE_CUDA_STANDARD 14)
# (Note) For windows, if delete /W[1-4], /W1 will be added defaultly and conflic with -w # (Note) For windows, if delete /W[1-4], /W1 will be added defaultly and conflic with -w
# So replace /W[1-4] with /W0 # So replace /W[1-4] with /W0
if (WIN32) if(WIN32)
string(REGEX REPLACE "/W[1-4]" " /W0 " CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS}") string(REGEX REPLACE "/W[1-4]" " /W0 " CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS}")
endif(WIN32) endif(WIN32)
# in cuda9, suppress cuda warning on eigen # in cuda9, suppress cuda warning on eigen
...@@ -242,15 +283,16 @@ set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} --expt-relaxed-constexpr") ...@@ -242,15 +283,16 @@ set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} --expt-relaxed-constexpr")
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} --expt-extended-lambda") set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} --expt-extended-lambda")
if(WIN32) if(WIN32)
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -Xcompiler \"/wd4244 /wd4267 /wd4819 \"") set(CMAKE_CUDA_FLAGS
"${CMAKE_CUDA_FLAGS} -Xcompiler \"/wd4244 /wd4267 /wd4819 \"")
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -Xcompiler /bigobj") set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -Xcompiler /bigobj")
if(MSVC_STATIC_CRT) if(MSVC_STATIC_CRT)
foreach(flag_var foreach(flag_var
CMAKE_CUDA_FLAGS CMAKE_CUDA_FLAGS_DEBUG CMAKE_CUDA_FLAGS_RELEASE CMAKE_CUDA_FLAGS CMAKE_CUDA_FLAGS_DEBUG CMAKE_CUDA_FLAGS_RELEASE
CMAKE_CUDA_FLAGS_MINSIZEREL CMAKE_CUDA_FLAGS_RELWITHDEBINFO) CMAKE_CUDA_FLAGS_MINSIZEREL CMAKE_CUDA_FLAGS_RELWITHDEBINFO)
if(${flag_var} MATCHES "-MD") if(${flag_var} MATCHES "-MD")
string(REGEX REPLACE "-MD" "-MT" ${flag_var} "${${flag_var}}") string(REGEX REPLACE "-MD" "-MT" ${flag_var} "${${flag_var}}")
endif() endif()
endforeach(flag_var) endforeach(flag_var)
endif() endif()
endif() endif()
......
if(NOT WITH_GPU) if(NOT WITH_GPU)
return() return()
endif() endif()
if(WIN32) if(WIN32)
set(CUDNN_ROOT ${CUDA_TOOLKIT_ROOT_DIR}) set(CUDNN_ROOT ${CUDA_TOOLKIT_ROOT_DIR})
else(WIN32) else(WIN32)
set(CUDNN_ROOT "/usr" CACHE PATH "CUDNN ROOT") set(CUDNN_ROOT
"/usr"
CACHE PATH "CUDNN ROOT")
endif(WIN32) endif(WIN32)
find_path(CUDNN_INCLUDE_DIR cudnn.h find_path(
PATHS ${CUDNN_ROOT} ${CUDNN_ROOT}/include CUDNN_INCLUDE_DIR cudnn.h
$ENV{CUDNN_ROOT} $ENV{CUDNN_ROOT}/include ${CUDA_TOOLKIT_INCLUDE} PATHS ${CUDNN_ROOT} ${CUDNN_ROOT}/include $ENV{CUDNN_ROOT}
NO_DEFAULT_PATH $ENV{CUDNN_ROOT}/include ${CUDA_TOOLKIT_INCLUDE}
) NO_DEFAULT_PATH)
get_filename_component(__libpath_hist ${CUDA_CUDART_LIBRARY} PATH) get_filename_component(__libpath_hist ${CUDA_CUDART_LIBRARY} PATH)
set(TARGET_ARCH "x86_64") set(TARGET_ARCH "x86_64")
if(NOT ${CMAKE_SYSTEM_PROCESSOR}) if(NOT ${CMAKE_SYSTEM_PROCESSOR})
set(TARGET_ARCH ${CMAKE_SYSTEM_PROCESSOR}) set(TARGET_ARCH ${CMAKE_SYSTEM_PROCESSOR})
endif() endif()
list(APPEND CUDNN_CHECK_LIBRARY_DIRS list(
${CUDNN_ROOT} APPEND
${CUDNN_ROOT}/lib64 CUDNN_CHECK_LIBRARY_DIRS
${CUDNN_ROOT}/lib ${CUDNN_ROOT}
${CUDNN_ROOT}/lib/${TARGET_ARCH}-linux-gnu ${CUDNN_ROOT}/lib64
${CUDNN_ROOT}/local/cuda-${CUDA_VERSION}/targets/${TARGET_ARCH}-linux/lib/ ${CUDNN_ROOT}/lib
$ENV{CUDNN_ROOT} ${CUDNN_ROOT}/lib/${TARGET_ARCH}-linux-gnu
$ENV{CUDNN_ROOT}/lib64 ${CUDNN_ROOT}/local/cuda-${CUDA_VERSION}/targets/${TARGET_ARCH}-linux/lib/
$ENV{CUDNN_ROOT}/lib $ENV{CUDNN_ROOT}
/usr/lib $ENV{CUDNN_ROOT}/lib64
${CUDA_TOOLKIT_ROOT_DIR} $ENV{CUDNN_ROOT}/lib
${CUDA_TOOLKIT_ROOT_DIR}/lib/x64 /usr/lib
) ${CUDA_TOOLKIT_ROOT_DIR}
${CUDA_TOOLKIT_ROOT_DIR}/lib/x64)
set(CUDNN_LIB_NAME "") set(CUDNN_LIB_NAME "")
if (LINUX) if(LINUX)
set(CUDNN_LIB_NAME "libcudnn.so") set(CUDNN_LIB_NAME "libcudnn.so")
endif(LINUX) endif(LINUX)
if(WIN32) if(WIN32)
# only support cudnn7 # only support cudnn7
set(CUDNN_LIB_NAME "cudnn.lib" "cudnn64_7.dll") set(CUDNN_LIB_NAME "cudnn.lib" "cudnn64_7.dll")
endif(WIN32) endif(WIN32)
if(APPLE) if(APPLE)
set(CUDNN_LIB_NAME "libcudnn.dylib" "libcudnn.so") set(CUDNN_LIB_NAME "libcudnn.dylib" "libcudnn.so")
endif(APPLE) endif(APPLE)
find_library(CUDNN_LIBRARY NAMES ${CUDNN_LIB_NAME} # libcudnn_static.a find_library(
PATHS ${CUDNN_CHECK_LIBRARY_DIRS} ${CUDNN_INCLUDE_DIR} ${__libpath_hist} CUDNN_LIBRARY
NO_DEFAULT_PATH NAMES ${CUDNN_LIB_NAME} # libcudnn_static.a
DOC "Path to cuDNN library.") PATHS ${CUDNN_CHECK_LIBRARY_DIRS} ${CUDNN_INCLUDE_DIR} ${__libpath_hist}
NO_DEFAULT_PATH
DOC "Path to cuDNN library.")
if(CUDNN_INCLUDE_DIR AND CUDNN_LIBRARY) if(CUDNN_INCLUDE_DIR AND CUDNN_LIBRARY)
set(CUDNN_FOUND ON) set(CUDNN_FOUND ON)
else() else()
set(CUDNN_FOUND OFF) set(CUDNN_FOUND OFF)
endif() endif()
macro(find_cudnn_version cudnn_header_file) macro(find_cudnn_version cudnn_header_file)
file(READ ${cudnn_header_file} CUDNN_VERSION_FILE_CONTENTS) file(READ ${cudnn_header_file} CUDNN_VERSION_FILE_CONTENTS)
get_filename_component(CUDNN_LIB_PATH ${CUDNN_LIBRARY} DIRECTORY) get_filename_component(CUDNN_LIB_PATH ${CUDNN_LIBRARY} DIRECTORY)
string(REGEX MATCH "define CUDNN_VERSION +([0-9]+)" string(REGEX MATCH "define CUDNN_VERSION +([0-9]+)" CUDNN_VERSION
CUDNN_VERSION "${CUDNN_VERSION_FILE_CONTENTS}") "${CUDNN_VERSION_FILE_CONTENTS}")
string(REGEX REPLACE "define CUDNN_VERSION +([0-9]+)" "\\1" string(REGEX REPLACE "define CUDNN_VERSION +([0-9]+)" "\\1" CUDNN_VERSION
CUDNN_VERSION "${CUDNN_VERSION}") "${CUDNN_VERSION}")
if("${CUDNN_VERSION}" STREQUAL "2000") if("${CUDNN_VERSION}" STREQUAL "2000")
message(STATUS "Current cuDNN version is v2. ") message(STATUS "Current cuDNN version is v2. ")
else()
string(REGEX MATCH "define CUDNN_MAJOR +([0-9]+)" CUDNN_MAJOR_VERSION
"${CUDNN_VERSION_FILE_CONTENTS}")
string(REGEX REPLACE "define CUDNN_MAJOR +([0-9]+)" "\\1"
CUDNN_MAJOR_VERSION "${CUDNN_MAJOR_VERSION}")
string(REGEX MATCH "define CUDNN_MINOR +([0-9]+)" CUDNN_MINOR_VERSION
"${CUDNN_VERSION_FILE_CONTENTS}")
string(REGEX REPLACE "define CUDNN_MINOR +([0-9]+)" "\\1"
CUDNN_MINOR_VERSION "${CUDNN_MINOR_VERSION}")
string(REGEX MATCH "define CUDNN_PATCHLEVEL +([0-9]+)"
CUDNN_PATCHLEVEL_VERSION "${CUDNN_VERSION_FILE_CONTENTS}")
string(REGEX REPLACE "define CUDNN_PATCHLEVEL +([0-9]+)" "\\1"
CUDNN_PATCHLEVEL_VERSION "${CUDNN_PATCHLEVEL_VERSION}")
if(NOT CUDNN_MAJOR_VERSION)
set(CUDNN_VERSION "???")
else() else()
string(REGEX MATCH "define CUDNN_MAJOR +([0-9]+)" CUDNN_MAJOR_VERSION add_definitions("-DCUDNN_MAJOR_VERSION=\"${CUDNN_MAJOR_VERSION}\"")
"${CUDNN_VERSION_FILE_CONTENTS}") math(EXPR CUDNN_VERSION "${CUDNN_MAJOR_VERSION} * 1000 +
string(REGEX REPLACE "define CUDNN_MAJOR +([0-9]+)" "\\1"
CUDNN_MAJOR_VERSION "${CUDNN_MAJOR_VERSION}")
string(REGEX MATCH "define CUDNN_MINOR +([0-9]+)" CUDNN_MINOR_VERSION
"${CUDNN_VERSION_FILE_CONTENTS}")
string(REGEX REPLACE "define CUDNN_MINOR +([0-9]+)" "\\1"
CUDNN_MINOR_VERSION "${CUDNN_MINOR_VERSION}")
string(REGEX MATCH "define CUDNN_PATCHLEVEL +([0-9]+)"
CUDNN_PATCHLEVEL_VERSION "${CUDNN_VERSION_FILE_CONTENTS}")
string(REGEX REPLACE "define CUDNN_PATCHLEVEL +([0-9]+)" "\\1"
CUDNN_PATCHLEVEL_VERSION "${CUDNN_PATCHLEVEL_VERSION}")
if(NOT CUDNN_MAJOR_VERSION)
set(CUDNN_VERSION "???")
else()
add_definitions("-DCUDNN_MAJOR_VERSION=\"${CUDNN_MAJOR_VERSION}\"")
math(EXPR CUDNN_VERSION
"${CUDNN_MAJOR_VERSION} * 1000 +
${CUDNN_MINOR_VERSION} * 100 + ${CUDNN_PATCHLEVEL_VERSION}") ${CUDNN_MINOR_VERSION} * 100 + ${CUDNN_PATCHLEVEL_VERSION}")
message(STATUS "Current cuDNN header is ${cudnn_header_file} " message(
"Current cuDNN version is v${CUDNN_MAJOR_VERSION}.${CUDNN_MINOR_VERSION}.${CUDNN_PATCHLEVEL_VERSION}. ") STATUS
endif() "Current cuDNN header is ${cudnn_header_file} "
"Current cuDNN version is v${CUDNN_MAJOR_VERSION}.${CUDNN_MINOR_VERSION}.${CUDNN_PATCHLEVEL_VERSION}. "
)
endif() endif()
endif()
endmacro() endmacro()
if(CUDNN_FOUND) if(CUDNN_FOUND)
find_cudnn_version(${CUDNN_INCLUDE_DIR}/cudnn.h) find_cudnn_version(${CUDNN_INCLUDE_DIR}/cudnn.h)
if (NOT CUDNN_MAJOR_VERSION) if(NOT CUDNN_MAJOR_VERSION)
find_cudnn_version(${CUDNN_INCLUDE_DIR}/cudnn_version.h) find_cudnn_version(${CUDNN_INCLUDE_DIR}/cudnn_version.h)
endif() endif()
endif() endif()
if(NOT WITH_GPU) if(NOT WITH_GPU)
return() return()
endif() endif()
set(CUPTI_ROOT
set(CUPTI_ROOT "/usr" CACHE PATH "CUPTI ROOT") "/usr"
find_path(CUPTI_INCLUDE_DIR cupti.h CACHE PATH "CUPTI ROOT")
PATHS ${CUPTI_ROOT} ${CUPTI_ROOT}/include find_path(
$ENV{CUPTI_ROOT} $ENV{CUPTI_ROOT}/include CUPTI_INCLUDE_DIR cupti.h
PATHS ${CUPTI_ROOT}
${CUPTI_ROOT}/include
$ENV{CUPTI_ROOT}
$ENV{CUPTI_ROOT}/include
${CUDA_TOOLKIT_ROOT_DIR}/extras/CUPTI/include ${CUDA_TOOLKIT_ROOT_DIR}/extras/CUPTI/include
${CUDA_TOOLKIT_ROOT_DIR}/targets/x86_64-linux/include ${CUDA_TOOLKIT_ROOT_DIR}/targets/x86_64-linux/include
${CUDA_TOOLKIT_ROOT_DIR}/targets/aarch64-linux/include ${CUDA_TOOLKIT_ROOT_DIR}/targets/aarch64-linux/include
NO_DEFAULT_PATH NO_DEFAULT_PATH)
)
get_filename_component(__libpath_hist ${CUDA_CUDART_LIBRARY} PATH) get_filename_component(__libpath_hist ${CUDA_CUDART_LIBRARY} PATH)
set(TARGET_ARCH "x86_64") set(TARGET_ARCH "x86_64")
if(NOT ${CMAKE_SYSTEM_PROCESSOR}) if(NOT ${CMAKE_SYSTEM_PROCESSOR})
set(TARGET_ARCH ${CMAKE_SYSTEM_PROCESSOR}) set(TARGET_ARCH ${CMAKE_SYSTEM_PROCESSOR})
endif() endif()
list(APPEND CUPTI_CHECK_LIBRARY_DIRS list(
${CUPTI_ROOT} APPEND
${CUPTI_ROOT}/lib64 CUPTI_CHECK_LIBRARY_DIRS
${CUPTI_ROOT}/lib ${CUPTI_ROOT}
${CUPTI_ROOT}/lib/${TARGET_ARCH}-linux-gnu ${CUPTI_ROOT}/lib64
$ENV{CUPTI_ROOT} ${CUPTI_ROOT}/lib
$ENV{CUPTI_ROOT}/lib64 ${CUPTI_ROOT}/lib/${TARGET_ARCH}-linux-gnu
$ENV{CUPTI_ROOT}/lib $ENV{CUPTI_ROOT}
/usr/lib $ENV{CUPTI_ROOT}/lib64
${CUDA_TOOLKIT_ROOT_DIR}/targets/x86_64-linux/lib64 $ENV{CUPTI_ROOT}/lib
${CUDA_TOOLKIT_ROOT_DIR}/extras/CUPTI/lib64) /usr/lib
find_library(CUPTI_LIBRARY NAMES libcupti.so libcupti.dylib # libcupti_static.a ${CUDA_TOOLKIT_ROOT_DIR}/targets/x86_64-linux/lib64
PATHS ${CUPTI_CHECK_LIBRARY_DIRS} ${CUPTI_INCLUDE_DIR} ${__libpath_hist} ${CUDA_TOOLKIT_ROOT_DIR}/extras/CUPTI/lib64)
NO_DEFAULT_PATH find_library(
DOC "Path to cuPTI library.") CUPTI_LIBRARY
NAMES libcupti.so libcupti.dylib # libcupti_static.a
PATHS ${CUPTI_CHECK_LIBRARY_DIRS} ${CUPTI_INCLUDE_DIR} ${__libpath_hist}
NO_DEFAULT_PATH
DOC "Path to cuPTI library.")
get_filename_component(CUPTI_LIBRARY_PATH ${CUPTI_LIBRARY} DIRECTORY) get_filename_component(CUPTI_LIBRARY_PATH ${CUPTI_LIBRARY} DIRECTORY)
if(CUPTI_INCLUDE_DIR AND CUPTI_LIBRARY) if(CUPTI_INCLUDE_DIR AND CUPTI_LIBRARY)
set(CUPTI_FOUND ON) set(CUPTI_FOUND ON)
else() else()
set(CUPTI_FOUND OFF) set(CUPTI_FOUND OFF)
endif() endif()
# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved. # Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved.
# #
# Licensed under the Apache License, Version 2.0 (the "License"); # Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License. # you may not use this file except in compliance with the License.
# You may obtain a copy of the License at # You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, software # Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, # distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
......
# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved. # Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved.
# #
# Licensed under the Apache License, Version 2.0 (the "License"); # Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License. # you may not use this file except in compliance with the License.
# You may obtain a copy of the License at # You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, software # Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, # distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
...@@ -16,25 +16,35 @@ ...@@ -16,25 +16,35 @@
# cuda moduel lazy loading is supported by CUDA 11.6+ # cuda moduel lazy loading is supported by CUDA 11.6+
# this experiment option makes Paddle supports lazy loading before CUDA 11.6. # this experiment option makes Paddle supports lazy loading before CUDA 11.6.
option(EXP_CUDA_MODULE_LOADING_LAZY "enable lazy cuda module loading" OFF) option(EXP_CUDA_MODULE_LOADING_LAZY "enable lazy cuda module loading" OFF)
if (${EXP_CUDA_MODULE_LOADING_LAZY}) if(${EXP_CUDA_MODULE_LOADING_LAZY})
if (NOT ${ON_INFER} OR NOT ${LINUX}) if(NOT ${ON_INFER} OR NOT ${LINUX})
message("EXP_CUDA_MODULE_LOADING_LAZY only works with ON_INFER=ON on Linux platforms") message(
"EXP_CUDA_MODULE_LOADING_LAZY only works with ON_INFER=ON on Linux platforms"
)
return() return()
endif () endif()
if (NOT ${CUDA_FOUND}) if(NOT ${CUDA_FOUND})
message("EXP_CUDA_MODULE_LOADING_LAZY only works with CUDA") message("EXP_CUDA_MODULE_LOADING_LAZY only works with CUDA")
return() return()
endif () endif()
if (${CUDA_VERSION} VERSION_GREATER_EQUAL "11.6") if(${CUDA_VERSION} VERSION_GREATER_EQUAL "11.6")
message("cuda 11.6+ already support lazy module loading") message("cuda 11.6+ already support lazy module loading")
return() return()
endif () endif()
message("for cuda before 11.6, libcudart.so must be used for the lazy module loading trick to work, instead of libcudart_static.a") message(
set(CUDA_USE_STATIC_CUDA_RUNTIME OFF CACHE BOOL "" FORCE) "for cuda before 11.6, libcudart.so must be used for the lazy module loading trick to work, instead of libcudart_static.a"
)
set(CUDA_USE_STATIC_CUDA_RUNTIME
OFF
CACHE BOOL "" FORCE)
set(CMAKE_CUDA_FLAGS "--cudart shared") set(CMAKE_CUDA_FLAGS "--cudart shared")
enable_language(CUDA) enable_language(CUDA)
set(CUDA_NVCC_EXECUTABLE "${CMAKE_SOURCE_DIR}/tools/nvcc_lazy" CACHE FILEPATH "" FORCE) set(CUDA_NVCC_EXECUTABLE
set(CMAKE_CUDA_COMPILER "${CMAKE_SOURCE_DIR}/tools/nvcc_lazy" CACHE FILEPATH "" FORCE) "${CMAKE_SOURCE_DIR}/tools/nvcc_lazy"
CACHE FILEPATH "" FORCE)
set(CMAKE_CUDA_COMPILER
"${CMAKE_SOURCE_DIR}/tools/nvcc_lazy"
CACHE FILEPATH "" FORCE)
endif() endif()
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
INCLUDE(ExternalProject) include(ExternalProject)
#find_package(OpenSSL REQUIRED) #find_package(OpenSSL REQUIRED)
...@@ -25,52 +25,56 @@ INCLUDE(ExternalProject) ...@@ -25,52 +25,56 @@ INCLUDE(ExternalProject)
#ADD_LIBRARY(crypto SHARED IMPORTED GLOBAL) #ADD_LIBRARY(crypto SHARED IMPORTED GLOBAL)
#SET_PROPERTY(TARGET crypto PROPERTY IMPORTED_LOCATION ${OPENSSL_CRYPTO_LIBRARY}) #SET_PROPERTY(TARGET crypto PROPERTY IMPORTED_LOCATION ${OPENSSL_CRYPTO_LIBRARY})
IF((NOT DEFINED ARM_BRPC_NAME) OR (NOT DEFINED ARM_BRPC_URL)) if((NOT DEFINED ARM_BRPC_NAME) OR (NOT DEFINED ARM_BRPC_URL))
SET(ARM_BRPC_VER "1.1.0" CACHE STRING "" FORCE) set(ARM_BRPC_VER
SET(ARM_BRPC_NAME "arm_brpc" CACHE STRING "" FORCE) "1.1.0"
ENDIF() CACHE STRING "" FORCE)
set(ARM_BRPC_NAME
"arm_brpc"
CACHE STRING "" FORCE)
endif()
MESSAGE(STATUS "ARM_BRPC_NAME: ${ARM_BRPC_NAME}, ARM_BRPC_URL: ${ARM_BRPC_URL}") message(STATUS "ARM_BRPC_NAME: ${ARM_BRPC_NAME}, ARM_BRPC_URL: ${ARM_BRPC_URL}")
SET(ARM_BRPC_PREFIX_DIR "${THIRD_PARTY_PATH}/arm_brpc") set(ARM_BRPC_PREFIX_DIR "${THIRD_PARTY_PATH}/arm_brpc")
SET(ARM_BRPC_PROJECT "extern_arm_brpc") set(ARM_BRPC_PROJECT "extern_arm_brpc")
SET(ARM_BRPC_DOWNLOAD_DIR "${ARM_BRPC_PREFIX_DIR}/src/${ARM_BRPC_PROJECT}") set(ARM_BRPC_DOWNLOAD_DIR "${ARM_BRPC_PREFIX_DIR}/src/${ARM_BRPC_PROJECT}")
SET(ARM_BRPC_DST_DIR "output") set(ARM_BRPC_DST_DIR "output")
SET(ARM_BRPC_INSTALL_ROOT "${THIRD_PARTY_PATH}/install") set(ARM_BRPC_INSTALL_ROOT "${THIRD_PARTY_PATH}/install")
SET(ARM_BRPC_INSTALL_DIR ${ARM_BRPC_INSTALL_ROOT}/arm_brpc/output) set(ARM_BRPC_INSTALL_DIR ${ARM_BRPC_INSTALL_ROOT}/arm_brpc/output)
SET(ARM_BRPC_ROOT ${ARM_BRPC_INSTALL_DIR}) set(ARM_BRPC_ROOT ${ARM_BRPC_INSTALL_DIR})
SET(ARM_BRPC_INC_DIR ${ARM_BRPC_ROOT}/include) set(ARM_BRPC_INC_DIR ${ARM_BRPC_ROOT}/include)
SET(ARM_BRPC_LIB_DIR ${ARM_BRPC_ROOT}/lib) set(ARM_BRPC_LIB_DIR ${ARM_BRPC_ROOT}/lib)
SET(ARM_BRPC_LIB ${ARM_BRPC_LIB_DIR}/libbrpc.a) set(ARM_BRPC_LIB ${ARM_BRPC_LIB_DIR}/libbrpc.a)
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_RPATH}" "${ARM_BRPC_ROOT}/lib") set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_RPATH}" "${ARM_BRPC_ROOT}/lib")
INCLUDE_DIRECTORIES(${ARM_BRPC_INSTALL_ROOT}/${ARM_BRPC_NAME}/output/include) include_directories(${ARM_BRPC_INSTALL_ROOT}/${ARM_BRPC_NAME}/output/include)
FILE(WRITE ${ARM_BRPC_DOWNLOAD_DIR}/CMakeLists.txt file(
"PROJECT(ARM_BRPC)\n" WRITE ${ARM_BRPC_DOWNLOAD_DIR}/CMakeLists.txt
"cmake_minimum_required(VERSION 3.0)\n" "PROJECT(ARM_BRPC)\n" "cmake_minimum_required(VERSION 3.0)\n"
"install(DIRECTORY ${ARM_BRPC_DST_DIR} ${ARM_BRPC_DST_DIR} \n" "install(DIRECTORY ${ARM_BRPC_DST_DIR} ${ARM_BRPC_DST_DIR} \n"
" DESTINATION ${ARM_BRPC_NAME})\n") " DESTINATION ${ARM_BRPC_NAME})\n")
SET(ARM_BRPC_URL "https://paddlerec.bj.bcebos.com/online_infer/arm_brpc_ubuntu18/output.tar.gz" CACHE STRING "" FORCE) set(ARM_BRPC_URL
"https://paddlerec.bj.bcebos.com/online_infer/arm_brpc_ubuntu18/output.tar.gz"
CACHE STRING "" FORCE)
ExternalProject_Add( ExternalProject_Add(
${ARM_BRPC_PROJECT} ${ARM_BRPC_PROJECT}
${EXTERNAL_PROJECT_LOG_ARGS} ${EXTERNAL_PROJECT_LOG_ARGS}
PREFIX ${ARM_BRPC_PREFIX_DIR} PREFIX ${ARM_BRPC_PREFIX_DIR}
DOWNLOAD_DIR ${ARM_BRPC_DOWNLOAD_DIR} DOWNLOAD_DIR ${ARM_BRPC_DOWNLOAD_DIR}
DOWNLOAD_COMMAND rm -rf output.tar.gz DOWNLOAD_COMMAND rm -rf output.tar.gz && wget --no-check-certificate
&& wget --no-check-certificate ${ARM_BRPC_URL} ${ARM_BRPC_URL} && tar zxvf output.tar.gz
&& tar zxvf output.tar.gz #DOWNLOAD_COMMAND cp /home/wangbin44/Paddle/build/output.tar.gz .
#DOWNLOAD_COMMAND cp /home/wangbin44/Paddle/build/output.tar.gz . # && tar zxvf output.tar.gz
# && tar zxvf output.tar.gz DOWNLOAD_NO_PROGRESS 1
DOWNLOAD_NO_PROGRESS 1 UPDATE_COMMAND ""
UPDATE_COMMAND "" CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${ARM_BRPC_INSTALL_ROOT}
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${ARM_BRPC_INSTALL_ROOT} -DCMAKE_BUILD_TYPE=${THIRD_PARTY_BUILD_TYPE}
-DCMAKE_BUILD_TYPE=${THIRD_PARTY_BUILD_TYPE} CMAKE_CACHE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${ARM_BRPC_INSTALL_ROOT}
CMAKE_CACHE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${ARM_BRPC_INSTALL_ROOT} -DCMAKE_BUILD_TYPE=${THIRD_PARTY_BUILD_TYPE}
-DCMAKE_BUILD_TYPE=${THIRD_PARTY_BUILD_TYPE} BUILD_BYPRODUCTS ${ARM_BRPC_LIB})
BUILD_BYPRODUCTS ${ARM_BRPC_LIB}
)
ADD_LIBRARY(arm_brpc STATIC IMPORTED GLOBAL) # 直接导入已经生成的库 add_library(arm_brpc STATIC IMPORTED GLOBAL) # 直接导入已经生成的库
SET_PROPERTY(TARGET arm_brpc PROPERTY IMPORTED_LOCATION ${ARM_BRPC_LIB}) set_property(TARGET arm_brpc PROPERTY IMPORTED_LOCATION ${ARM_BRPC_LIB})
ADD_DEPENDENCIES(arm_brpc ${ARM_BRPC_PROJECT}) add_dependencies(arm_brpc ${ARM_BRPC_PROJECT})
...@@ -12,21 +12,20 @@ ...@@ -12,21 +12,20 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
#NOTE: Logic is from #NOTE: Logic is from
# https://github.com/mindspore-ai/graphengine/blob/master/CMakeLists.txt # https://github.com/mindspore-ai/graphengine/blob/master/CMakeLists.txt
if(DEFINED ENV{ASCEND_CUSTOM_PATH}) if(DEFINED ENV{ASCEND_CUSTOM_PATH})
set(ASCEND_DIR $ENV{ASCEND_CUSTOM_PATH}) set(ASCEND_DIR $ENV{ASCEND_CUSTOM_PATH})
else() else()
set(ASCEND_DIR /usr/local/Ascend) set(ASCEND_DIR /usr/local/Ascend)
endif() endif()
if(EXISTS ${ASCEND_DIR}/ascend-toolkit/latest/fwkacllib/include/graph/ascend_string.h) if(EXISTS
${ASCEND_DIR}/ascend-toolkit/latest/fwkacllib/include/graph/ascend_string.h)
# It means CANN 20.2 + # It means CANN 20.2 +
add_definitions(-DPADDLE_WITH_ASCEND_STRING) add_definitions(-DPADDLE_WITH_ASCEND_STRING)
endif() endif()
if(WITH_ASCEND OR WITH_ASCEND_CL) if(WITH_ASCEND OR WITH_ASCEND_CL)
set(ASCEND_DRIVER_DIR ${ASCEND_DIR}/driver/lib64) set(ASCEND_DRIVER_DIR ${ASCEND_DIR}/driver/lib64)
set(ASCEND_DRIVER_COMMON_DIR ${ASCEND_DIR}/driver/lib64/common) set(ASCEND_DRIVER_COMMON_DIR ${ASCEND_DIR}/driver/lib64/common)
...@@ -36,28 +35,32 @@ if(WITH_ASCEND OR WITH_ASCEND_CL) ...@@ -36,28 +35,32 @@ if(WITH_ASCEND OR WITH_ASCEND_CL)
set(ASCEND_ACL_DIR ${ASCEND_DIR}/acllib/lib64) set(ASCEND_ACL_DIR ${ASCEND_DIR}/acllib/lib64)
set(STATIC_ACL_LIB ${ASCEND_ACL_DIR}) set(STATIC_ACL_LIB ${ASCEND_ACL_DIR})
set(ASCEND_MS_RUNTIME_PATH ${ASCEND_RUNTIME_DIR} ${ASCEND_ACL_DIR} ${ASCEND_ATC_DIR}) set(ASCEND_MS_RUNTIME_PATH ${ASCEND_RUNTIME_DIR} ${ASCEND_ACL_DIR}
${ASCEND_ATC_DIR})
set(ASCEND_MS_DRIVER_PATH ${ASCEND_DRIVER_DIR} ${ASCEND_DRIVER_COMMON_DIR}) set(ASCEND_MS_DRIVER_PATH ${ASCEND_DRIVER_DIR} ${ASCEND_DRIVER_COMMON_DIR})
set(ATLAS_RUNTIME_DIR ${ASCEND_DIR}/ascend-toolkit/latest/fwkacllib/lib64) set(ATLAS_RUNTIME_DIR ${ASCEND_DIR}/ascend-toolkit/latest/fwkacllib/lib64)
set(ATLAS_RUNTIME_INC_DIR ${ASCEND_DIR}/ascend-toolkit/latest/fwkacllib/include) set(ATLAS_RUNTIME_INC_DIR
${ASCEND_DIR}/ascend-toolkit/latest/fwkacllib/include)
set(ATLAS_ACL_DIR ${ASCEND_DIR}/ascend-toolkit/latest/acllib/lib64) set(ATLAS_ACL_DIR ${ASCEND_DIR}/ascend-toolkit/latest/acllib/lib64)
set(ATLAS_ATC_DIR ${ASCEND_DIR}/ascend-toolkit/latest/atc/lib64) set(ATLAS_ATC_DIR ${ASCEND_DIR}/ascend-toolkit/latest/atc/lib64)
set(ATLAS_MS_RUNTIME_PATH ${ATLAS_RUNTIME_DIR} ${ATLAS_ACL_DIR} ${ATLAS_ATC_DIR}) set(ATLAS_MS_RUNTIME_PATH ${ATLAS_RUNTIME_DIR} ${ATLAS_ACL_DIR}
${ATLAS_ATC_DIR})
set(atlas_graph_lib ${ATLAS_RUNTIME_DIR}/libgraph.so) set(atlas_graph_lib ${ATLAS_RUNTIME_DIR}/libgraph.so)
set(atlas_ge_runner_lib ${ATLAS_RUNTIME_DIR}/libge_runner.so) set(atlas_ge_runner_lib ${ATLAS_RUNTIME_DIR}/libge_runner.so)
set(atlas_acl_lib ${ATLAS_RUNTIME_DIR}/libascendcl.so) set(atlas_acl_lib ${ATLAS_RUNTIME_DIR}/libascendcl.so)
INCLUDE_DIRECTORIES(${ATLAS_RUNTIME_INC_DIR}) include_directories(${ATLAS_RUNTIME_INC_DIR})
ADD_LIBRARY(ascend_ge SHARED IMPORTED GLOBAL) add_library(ascend_ge SHARED IMPORTED GLOBAL)
SET_PROPERTY(TARGET ascend_ge PROPERTY IMPORTED_LOCATION ${atlas_ge_runner_lib}) set_property(TARGET ascend_ge PROPERTY IMPORTED_LOCATION
${atlas_ge_runner_lib})
ADD_LIBRARY(ascend_graph SHARED IMPORTED GLOBAL) add_library(ascend_graph SHARED IMPORTED GLOBAL)
SET_PROPERTY(TARGET ascend_graph PROPERTY IMPORTED_LOCATION ${atlas_graph_lib}) set_property(TARGET ascend_graph PROPERTY IMPORTED_LOCATION
${atlas_graph_lib})
ADD_LIBRARY(atlas_acl SHARED IMPORTED GLOBAL) add_library(atlas_acl SHARED IMPORTED GLOBAL)
SET_PROPERTY(TARGET atlas_acl PROPERTY IMPORTED_LOCATION ${atlas_acl_lib}) set_property(TARGET atlas_acl PROPERTY IMPORTED_LOCATION ${atlas_acl_lib})
add_custom_target(extern_ascend DEPENDS ascend_ge ascend_graph atlas_acl) add_custom_target(extern_ascend DEPENDS ascend_ge ascend_graph atlas_acl)
endif() endif()
...@@ -73,52 +76,60 @@ if(WITH_ASCEND_CL) ...@@ -73,52 +76,60 @@ if(WITH_ASCEND_CL)
message(STATUS "FWKACLLIB_INC_DIR ${FWKACLLIB_INC_DIR}") message(STATUS "FWKACLLIB_INC_DIR ${FWKACLLIB_INC_DIR}")
message(STATUS "ASCEND_CL_DIR ${ASCEND_CL_DIR}") message(STATUS "ASCEND_CL_DIR ${ASCEND_CL_DIR}")
INCLUDE_DIRECTORIES(${FWKACLLIB_INC_DIR}) include_directories(${FWKACLLIB_INC_DIR})
INCLUDE_DIRECTORIES(${ACLLIB_INC_DIR}) include_directories(${ACLLIB_INC_DIR})
ADD_LIBRARY(ascendcl SHARED IMPORTED GLOBAL) add_library(ascendcl SHARED IMPORTED GLOBAL)
SET_PROPERTY(TARGET ascendcl PROPERTY IMPORTED_LOCATION ${ascendcl_lib}) set_property(TARGET ascendcl PROPERTY IMPORTED_LOCATION ${ascendcl_lib})
ADD_LIBRARY(ascend_hccl SHARED IMPORTED GLOBAL) add_library(ascend_hccl SHARED IMPORTED GLOBAL)
SET_PROPERTY(TARGET ascend_hccl PROPERTY IMPORTED_LOCATION ${ascend_hccl_lib}) set_property(TARGET ascend_hccl PROPERTY IMPORTED_LOCATION ${ascend_hccl_lib})
ADD_LIBRARY(acl_op_compiler SHARED IMPORTED GLOBAL) add_library(acl_op_compiler SHARED IMPORTED GLOBAL)
SET_PROPERTY(TARGET acl_op_compiler PROPERTY IMPORTED_LOCATION ${acl_op_compiler_lib}) set_property(TARGET acl_op_compiler PROPERTY IMPORTED_LOCATION
${acl_op_compiler_lib})
add_custom_target(extern_ascend_cl DEPENDS ascendcl acl_op_compiler) add_custom_target(extern_ascend_cl DEPENDS ascendcl acl_op_compiler)
endif() endif()
if (WITH_ASCEND_CL) if(WITH_ASCEND_CL)
macro(find_ascend_toolkit_version ascend_toolkit_version_info) macro(find_ascend_toolkit_version ascend_toolkit_version_info)
file(READ ${ascend_toolkit_version_info} ASCEND_TOOLKIT_VERSION_CONTENTS) file(READ ${ascend_toolkit_version_info} ASCEND_TOOLKIT_VERSION_CONTENTS)
string(REGEX MATCH "version=([0-9]+\.[0-9]+\.(RC)?[0-9][.a-z0-9]*)" ASCEND_TOOLKIT_VERSION "${ASCEND_TOOLKIT_VERSION_CONTENTS}") string(REGEX MATCH "version=([0-9]+\.[0-9]+\.(RC)?[0-9][.a-z0-9]*)"
string(REGEX REPLACE "version=([0-9]+\.[0-9]+\.(RC)?[0-9][.a-z0-9]*)" "\\1" ASCEND_TOOLKIT_VERSION "${ASCEND_TOOLKIT_VERSION}") ASCEND_TOOLKIT_VERSION "${ASCEND_TOOLKIT_VERSION_CONTENTS}")
string(REGEX REPLACE "[A-Z]|[a-z|\.]" "" CANN_VERSION ${ASCEND_TOOLKIT_VERSION}) string(REGEX REPLACE "version=([0-9]+\.[0-9]+\.(RC)?[0-9][.a-z0-9]*)" "\\1"
STRING(SUBSTRING "${CANN_VERSION}000" 0 6 CANN_VERSION) ASCEND_TOOLKIT_VERSION "${ASCEND_TOOLKIT_VERSION}")
string(REGEX REPLACE "[A-Z]|[a-z|\.]" "" CANN_VERSION
${ASCEND_TOOLKIT_VERSION})
string(SUBSTRING "${CANN_VERSION}000" 0 6 CANN_VERSION)
add_definitions("-DCANN_VERSION_CODE=${CANN_VERSION}") add_definitions("-DCANN_VERSION_CODE=${CANN_VERSION}")
if(NOT ASCEND_TOOLKIT_VERSION) if(NOT ASCEND_TOOLKIT_VERSION)
set(ASCEND_TOOLKIT_VERSION "???") set(ASCEND_TOOLKIT_VERSION "???")
else() else()
message(STATUS "Current Ascend Toolkit version is ${ASCEND_TOOLKIT_VERSION}") message(
STATUS "Current Ascend Toolkit version is ${ASCEND_TOOLKIT_VERSION}")
endif() endif()
endmacro() endmacro()
macro(find_ascend_driver_version ascend_driver_version_info) macro(find_ascend_driver_version ascend_driver_version_info)
file(READ ${ascend_driver_version_info} ASCEND_DRIVER_VERSION_CONTENTS) file(READ ${ascend_driver_version_info} ASCEND_DRIVER_VERSION_CONTENTS)
string(REGEX MATCH "Version=([0-9]+\.[0-9]+\.[0-9]+)" ASCEND_DRIVER_VERSION "${ASCEND_DRIVER_VERSION_CONTENTS}") string(REGEX MATCH "Version=([0-9]+\.[0-9]+\.[0-9]+)" ASCEND_DRIVER_VERSION
string(REGEX REPLACE "Version=([0-9]+\.[0-9]+\.[0-9]+)" "\\1" ASCEND_DRIVER_VERSION "${ASCEND_DRIVER_VERSION}") "${ASCEND_DRIVER_VERSION_CONTENTS}")
string(REGEX REPLACE "Version=([0-9]+\.[0-9]+\.[0-9]+)" "\\1"
ASCEND_DRIVER_VERSION "${ASCEND_DRIVER_VERSION}")
if(NOT ASCEND_DRIVER_VERSION) if(NOT ASCEND_DRIVER_VERSION)
set(ASCEND_DRIVER_VERSION "???") set(ASCEND_DRIVER_VERSION "???")
else() else()
message(STATUS "Current Ascend Driver version is ${ASCEND_DRIVER_VERSION}") message(
STATUS "Current Ascend Driver version is ${ASCEND_DRIVER_VERSION}")
endif() endif()
endmacro() endmacro()
if (WITH_ARM) if(WITH_ARM)
set(ASCEND_TOOLKIT_DIR ${ASCEND_DIR}/ascend-toolkit/latest/arm64-linux) set(ASCEND_TOOLKIT_DIR ${ASCEND_DIR}/ascend-toolkit/latest/arm64-linux)
else() else()
set(ASCEND_TOOLKIT_DIR ${ASCEND_DIR}/ascend-toolkit/latest/x86_64-linux) set(ASCEND_TOOLKIT_DIR ${ASCEND_DIR}/ascend-toolkit/latest/x86_64-linux)
endif() endif()
find_ascend_toolkit_version(${ASCEND_TOOLKIT_DIR}/ascend_toolkit_install.info) find_ascend_toolkit_version(${ASCEND_TOOLKIT_DIR}/ascend_toolkit_install.info)
find_ascend_driver_version(${ASCEND_DIR}/driver/version.info) find_ascend_driver_version(${ASCEND_DIR}/driver/version.info)
endif() endif()
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
include(ExternalProject) include(ExternalProject)
set(BOOST_PROJECT "extern_boost") set(BOOST_PROJECT "extern_boost")
# To release PaddlePaddle as a pip package, we have to follow the # To release PaddlePaddle as a pip package, we have to follow the
# manylinux1 standard, which features as old Linux kernels and # manylinux1 standard, which features as old Linux kernels and
# compilers as possible and recommends CentOS 5. Indeed, the earliest # compilers as possible and recommends CentOS 5. Indeed, the earliest
...@@ -22,36 +22,41 @@ set(BOOST_PROJECT "extern_boost") ...@@ -22,36 +22,41 @@ set(BOOST_PROJECT "extern_boost")
# version of boost, say, 1.66.0, doesn't build on CentOS 6. We # version of boost, say, 1.66.0, doesn't build on CentOS 6. We
# checked that the devtools package of CentOS 6 installs boost 1.41.0. # checked that the devtools package of CentOS 6 installs boost 1.41.0.
# So we use 1.41.0 here. # So we use 1.41.0 here.
set(BOOST_VER "1.41.0") set(BOOST_VER "1.41.0")
# boost_1_41_0_2021_10.tar.gz is almost the same with boost_1_41_0.tar.gz, # boost_1_41_0_2021_10.tar.gz is almost the same with boost_1_41_0.tar.gz,
# except in visualc.hpp i comment a warning of "unknown compiler version", # except in visualc.hpp i comment a warning of "unknown compiler version",
# so if you need to change boost, you may need to block the warning similarly. # so if you need to change boost, you may need to block the warning similarly.
set(BOOST_TAR "boost_1_41_0_2021_10" CACHE STRING "" FORCE) set(BOOST_TAR
set(BOOST_URL "http://paddlepaddledeps.bj.bcebos.com/${BOOST_TAR}.tar.gz" CACHE STRING "" FORCE) "boost_1_41_0_2021_10"
CACHE STRING "" FORCE)
set(BOOST_URL
"http://paddlepaddledeps.bj.bcebos.com/${BOOST_TAR}.tar.gz"
CACHE STRING "" FORCE)
MESSAGE(STATUS "BOOST_VERSION: ${BOOST_VER}, BOOST_URL: ${BOOST_URL}") message(STATUS "BOOST_VERSION: ${BOOST_VER}, BOOST_URL: ${BOOST_URL}")
set(BOOST_PREFIX_DIR ${THIRD_PARTY_PATH}/boost) set(BOOST_PREFIX_DIR ${THIRD_PARTY_PATH}/boost)
set(BOOST_INCLUDE_DIR "${THIRD_PARTY_PATH}/boost/src/extern_boost" CACHE PATH "boost include directory." FORCE) set(BOOST_INCLUDE_DIR
"${THIRD_PARTY_PATH}/boost/src/extern_boost"
CACHE PATH "boost include directory." FORCE)
set_directory_properties(PROPERTIES CLEAN_NO_CUSTOM 1) set_directory_properties(PROPERTIES CLEAN_NO_CUSTOM 1)
include_directories(${BOOST_INCLUDE_DIR}) include_directories(${BOOST_INCLUDE_DIR})
if(WIN32 AND MSVC_VERSION GREATER_EQUAL 1600) if(WIN32 AND MSVC_VERSION GREATER_EQUAL 1600)
add_definitions(-DBOOST_HAS_STATIC_ASSERT) add_definitions(-DBOOST_HAS_STATIC_ASSERT)
endif() endif()
ExternalProject_Add( ExternalProject_Add(
${BOOST_PROJECT} ${BOOST_PROJECT}
${EXTERNAL_PROJECT_LOG_ARGS} ${EXTERNAL_PROJECT_LOG_ARGS}
URL ${BOOST_URL} URL ${BOOST_URL}
URL_MD5 51be7cc203628dc0848e97eee32d79e3 URL_MD5 51be7cc203628dc0848e97eee32d79e3
PREFIX ${BOOST_PREFIX_DIR} PREFIX ${BOOST_PREFIX_DIR}
DOWNLOAD_NO_PROGRESS 1 DOWNLOAD_NO_PROGRESS 1
CONFIGURE_COMMAND "" CONFIGURE_COMMAND ""
BUILD_COMMAND "" BUILD_COMMAND ""
INSTALL_COMMAND "" INSTALL_COMMAND ""
UPDATE_COMMAND "" UPDATE_COMMAND "")
)
add_library(boost INTERFACE) add_library(boost INTERFACE)
......
...@@ -12,48 +12,53 @@ ...@@ -12,48 +12,53 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
INCLUDE(ExternalProject) include(ExternalProject)
SET(BOX_PS_PROJECT "extern_box_ps") set(BOX_PS_PROJECT "extern_box_ps")
IF((NOT DEFINED BOX_PS_VER) OR (NOT DEFINED BOX_PS_URL)) if((NOT DEFINED BOX_PS_VER) OR (NOT DEFINED BOX_PS_URL))
MESSAGE(STATUS "use pre defined download url") message(STATUS "use pre defined download url")
SET(BOX_PS_VER "0.1.1" CACHE STRING "" FORCE) set(BOX_PS_VER
SET(BOX_PS_NAME "box_ps" CACHE STRING "" FORCE) "0.1.1"
SET(BOX_PS_URL "http://box-ps.gz.bcebos.com/box_ps.tar.gz" CACHE STRING "" FORCE) CACHE STRING "" FORCE)
ENDIF() set(BOX_PS_NAME
MESSAGE(STATUS "BOX_PS_NAME: ${BOX_PS_NAME}, BOX_PS_URL: ${BOX_PS_URL}") "box_ps"
SET(BOX_PS_SOURCE_DIR "${THIRD_PARTY_PATH}/box_ps") CACHE STRING "" FORCE)
SET(BOX_PS_DOWNLOAD_DIR "${BOX_PS_SOURCE_DIR}/src/${BOX_PS_PROJECT}") set(BOX_PS_URL
SET(BOX_PS_DST_DIR "box_ps") "http://box-ps.gz.bcebos.com/box_ps.tar.gz"
SET(BOX_PS_INSTALL_ROOT "${THIRD_PARTY_PATH}/install") CACHE STRING "" FORCE)
SET(BOX_PS_INSTALL_DIR ${BOX_PS_INSTALL_ROOT}/${BOX_PS_DST_DIR}) endif()
SET(BOX_PS_ROOT ${BOX_PS_INSTALL_DIR}) message(STATUS "BOX_PS_NAME: ${BOX_PS_NAME}, BOX_PS_URL: ${BOX_PS_URL}")
SET(BOX_PS_INC_DIR ${BOX_PS_ROOT}/include) set(BOX_PS_SOURCE_DIR "${THIRD_PARTY_PATH}/box_ps")
SET(BOX_PS_LIB_DIR ${BOX_PS_ROOT}/lib) set(BOX_PS_DOWNLOAD_DIR "${BOX_PS_SOURCE_DIR}/src/${BOX_PS_PROJECT}")
SET(BOX_PS_LIB ${BOX_PS_LIB_DIR}/libbox_ps.so) set(BOX_PS_DST_DIR "box_ps")
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_RPATH}" "${BOX_PS_ROOT}/lib") set(BOX_PS_INSTALL_ROOT "${THIRD_PARTY_PATH}/install")
set(BOX_PS_INSTALL_DIR ${BOX_PS_INSTALL_ROOT}/${BOX_PS_DST_DIR})
set(BOX_PS_ROOT ${BOX_PS_INSTALL_DIR})
set(BOX_PS_INC_DIR ${BOX_PS_ROOT}/include)
set(BOX_PS_LIB_DIR ${BOX_PS_ROOT}/lib)
set(BOX_PS_LIB ${BOX_PS_LIB_DIR}/libbox_ps.so)
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_RPATH}" "${BOX_PS_ROOT}/lib")
INCLUDE_DIRECTORIES(${BOX_PS_INC_DIR}) include_directories(${BOX_PS_INC_DIR})
FILE(WRITE ${BOX_PS_DOWNLOAD_DIR}/CMakeLists.txt file(
"PROJECT(BOX_PS)\n" WRITE ${BOX_PS_DOWNLOAD_DIR}/CMakeLists.txt
"cmake_minimum_required(VERSION 3.0)\n" "PROJECT(BOX_PS)\n" "cmake_minimum_required(VERSION 3.0)\n"
"install(DIRECTORY ${BOX_PS_NAME}/include ${BOX_PS_NAME}/lib \n" "install(DIRECTORY ${BOX_PS_NAME}/include ${BOX_PS_NAME}/lib \n"
" DESTINATION ${BOX_PS_DST_DIR})\n") " DESTINATION ${BOX_PS_DST_DIR})\n")
ExternalProject_Add( ExternalProject_Add(
${BOX_PS_PROJECT} ${BOX_PS_PROJECT}
${EXTERNAL_PROJECT_LOG_ARGS} ${EXTERNAL_PROJECT_LOG_ARGS}
PREFIX ${BOX_PS_SOURCE_DIR} PREFIX ${BOX_PS_SOURCE_DIR}
DOWNLOAD_DIR ${BOX_PS_DOWNLOAD_DIR} DOWNLOAD_DIR ${BOX_PS_DOWNLOAD_DIR}
DOWNLOAD_COMMAND wget --no-check-certificate ${BOX_PS_URL} -c -q -O ${BOX_PS_NAME}.tar.gz DOWNLOAD_COMMAND wget --no-check-certificate ${BOX_PS_URL} -c -q -O
&& tar zxvf ${BOX_PS_NAME}.tar.gz ${BOX_PS_NAME}.tar.gz && tar zxvf ${BOX_PS_NAME}.tar.gz
DOWNLOAD_NO_PROGRESS 1 DOWNLOAD_NO_PROGRESS 1
UPDATE_COMMAND "" UPDATE_COMMAND ""
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${BOX_PS_INSTALL_ROOT} CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${BOX_PS_INSTALL_ROOT}
-DCMAKE_BUILD_TYPE=${THIRD_PARTY_BUILD_TYPE} -DCMAKE_BUILD_TYPE=${THIRD_PARTY_BUILD_TYPE}
CMAKE_CACHE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${BOX_PS_INSTALL_ROOT} CMAKE_CACHE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${BOX_PS_INSTALL_ROOT}
-DCMAKE_BUILD_TYPE=${THIRD_PARTY_BUILD_TYPE} -DCMAKE_BUILD_TYPE=${THIRD_PARTY_BUILD_TYPE}
BUILD_BYPRODUCTS ${BOX_PS_LIB} BUILD_BYPRODUCTS ${BOX_PS_LIB})
) add_library(box_ps SHARED IMPORTED GLOBAL)
ADD_LIBRARY(box_ps SHARED IMPORTED GLOBAL) set_property(TARGET box_ps PROPERTY IMPORTED_LOCATION ${BOX_PS_LIB})
SET_PROPERTY(TARGET box_ps PROPERTY IMPORTED_LOCATION ${BOX_PS_LIB}) add_dependencies(box_ps ${BOX_PS_PROJECT})
ADD_DEPENDENCIES(box_ps ${BOX_PS_PROJECT})
...@@ -12,66 +12,80 @@ ...@@ -12,66 +12,80 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
INCLUDE(ExternalProject) include(ExternalProject)
find_package(OpenSSL REQUIRED) find_package(OpenSSL REQUIRED)
message(STATUS "ssl:" ${OPENSSL_SSL_LIBRARY}) message(STATUS "ssl:" ${OPENSSL_SSL_LIBRARY})
message(STATUS "crypto:" ${OPENSSL_CRYPTO_LIBRARY}) message(STATUS "crypto:" ${OPENSSL_CRYPTO_LIBRARY})
ADD_LIBRARY(ssl SHARED IMPORTED GLOBAL) add_library(ssl SHARED IMPORTED GLOBAL)
SET_PROPERTY(TARGET ssl PROPERTY IMPORTED_LOCATION ${OPENSSL_SSL_LIBRARY}) set_property(TARGET ssl PROPERTY IMPORTED_LOCATION ${OPENSSL_SSL_LIBRARY})
ADD_LIBRARY(crypto SHARED IMPORTED GLOBAL) add_library(crypto SHARED IMPORTED GLOBAL)
SET_PROPERTY(TARGET crypto PROPERTY IMPORTED_LOCATION ${OPENSSL_CRYPTO_LIBRARY}) set_property(TARGET crypto PROPERTY IMPORTED_LOCATION ${OPENSSL_CRYPTO_LIBRARY})
SET(BRPC_PREFIX_DIR ${THIRD_PARTY_PATH}/brpc) set(BRPC_PREFIX_DIR ${THIRD_PARTY_PATH}/brpc)
SET(BRPC_INSTALL_DIR ${THIRD_PARTY_PATH}/install/brpc) set(BRPC_INSTALL_DIR ${THIRD_PARTY_PATH}/install/brpc)
SET(BRPC_INCLUDE_DIR "${BRPC_INSTALL_DIR}/include" CACHE PATH "brpc include directory." FORCE) set(BRPC_INCLUDE_DIR
SET(BRPC_LIBRARIES "${BRPC_INSTALL_DIR}/lib/libbrpc.a" CACHE FILEPATH "brpc library." FORCE) "${BRPC_INSTALL_DIR}/include"
CACHE PATH "brpc include directory." FORCE)
set(BRPC_LIBRARIES
"${BRPC_INSTALL_DIR}/lib/libbrpc.a"
CACHE FILEPATH "brpc library." FORCE)
INCLUDE_DIRECTORIES(${BRPC_INCLUDE_DIR}) include_directories(${BRPC_INCLUDE_DIR})
# Reference https://stackoverflow.com/questions/45414507/pass-a-list-of-prefix-paths-to-externalproject-add-in-cmake-args # Reference https://stackoverflow.com/questions/45414507/pass-a-list-of-prefix-paths-to-externalproject-add-in-cmake-args
set(prefix_path "${THIRD_PARTY_PATH}/install/gflags|${THIRD_PARTY_PATH}/install/leveldb|${THIRD_PARTY_PATH}/install/snappy|${THIRD_PARTY_PATH}/install/gtest|${THIRD_PARTY_PATH}/install/protobuf|${THIRD_PARTY_PATH}/install/zlib|${THIRD_PARTY_PATH}/install/glog") set(prefix_path
"${THIRD_PARTY_PATH}/install/gflags|${THIRD_PARTY_PATH}/install/leveldb|${THIRD_PARTY_PATH}/install/snappy|${THIRD_PARTY_PATH}/install/gtest|${THIRD_PARTY_PATH}/install/protobuf|${THIRD_PARTY_PATH}/install/zlib|${THIRD_PARTY_PATH}/install/glog"
)
# If minimal .a is need, you can set WITH_DEBUG_SYMBOLS=OFF # If minimal .a is need, you can set WITH_DEBUG_SYMBOLS=OFF
ExternalProject_Add( ExternalProject_Add(
extern_brpc extern_brpc
${EXTERNAL_PROJECT_LOG_ARGS} ${EXTERNAL_PROJECT_LOG_ARGS}
# TODO(gongwb): change to de newst repo when they changed # TODO(gongwb): change to de newst repo when they changed
GIT_REPOSITORY "https://github.com/wangjiawei04/brpc" GIT_REPOSITORY "https://github.com/wangjiawei04/brpc"
#GIT_REPOSITORY "https://github.com/ziyoujiyi/brpc" # ssl error in the previous repo(can be mannual fixed) #GIT_REPOSITORY "https://github.com/ziyoujiyi/brpc" # ssl error in the previous repo(can be mannual fixed)
GIT_TAG "e203afb794caf027da0f1e0776443e7d20c0c28e" GIT_TAG "e203afb794caf027da0f1e0776443e7d20c0c28e"
PREFIX ${BRPC_PREFIX_DIR} PREFIX ${BRPC_PREFIX_DIR}
UPDATE_COMMAND "" UPDATE_COMMAND ""
CMAKE_ARGS -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} CMAKE_ARGS -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS} -DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS} -DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
-DCMAKE_INSTALL_PREFIX=${BRPC_INSTALL_DIR} -DCMAKE_INSTALL_PREFIX=${BRPC_INSTALL_DIR}
-DCMAKE_INSTALL_LIBDIR=${BRPC_INSTALL_DIR}/lib -DCMAKE_INSTALL_LIBDIR=${BRPC_INSTALL_DIR}/lib
-DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCMAKE_POSITION_INDEPENDENT_CODE=ON
-DCMAKE_BUILD_TYPE=${THIRD_PARTY_BUILD_TYPE} -DCMAKE_BUILD_TYPE=${THIRD_PARTY_BUILD_TYPE}
-DCMAKE_PREFIX_PATH=${prefix_path} -DCMAKE_PREFIX_PATH=${prefix_path}
-DWITH_GLOG=ON -DWITH_GLOG=ON
-DIOBUF_WITH_HUGE_BLOCK=ON -DIOBUF_WITH_HUGE_BLOCK=ON
-DBRPC_WITH_RDMA=${WITH_BRPC_RDMA} -DBRPC_WITH_RDMA=${WITH_BRPC_RDMA}
${EXTERNAL_OPTIONAL_ARGS} ${EXTERNAL_OPTIONAL_ARGS}
LIST_SEPARATOR | LIST_SEPARATOR |
CMAKE_CACHE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${BRPC_INSTALL_DIR} CMAKE_CACHE_ARGS
-DCMAKE_INSTALL_LIBDIR:PATH=${BRPC_INSTALL_DIR}/lib -DCMAKE_INSTALL_PREFIX:PATH=${BRPC_INSTALL_DIR}
-DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON -DCMAKE_INSTALL_LIBDIR:PATH=${BRPC_INSTALL_DIR}/lib
-DCMAKE_BUILD_TYPE:STRING=${THIRD_PARTY_BUILD_TYPE} -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON
BUILD_BYPRODUCTS ${BRPC_LIBRARIES} -DCMAKE_BUILD_TYPE:STRING=${THIRD_PARTY_BUILD_TYPE}
) BUILD_BYPRODUCTS ${BRPC_LIBRARIES})
# ADD_DEPENDENCIES(extern_brpc protobuf ssl crypto leveldb gflags glog gtest snappy) # ADD_DEPENDENCIES(extern_brpc protobuf ssl crypto leveldb gflags glog gtest snappy)
ADD_DEPENDENCIES(extern_brpc protobuf ssl crypto leveldb gflags glog snappy) add_dependencies(
ADD_LIBRARY(brpc STATIC IMPORTED GLOBAL) extern_brpc
SET_PROPERTY(TARGET brpc PROPERTY IMPORTED_LOCATION ${BRPC_LIBRARIES}) protobuf
ADD_DEPENDENCIES(brpc extern_brpc) ssl
crypto
leveldb
gflags
glog
snappy)
add_library(brpc STATIC IMPORTED GLOBAL)
set_property(TARGET brpc PROPERTY IMPORTED_LOCATION ${BRPC_LIBRARIES})
add_dependencies(brpc extern_brpc)
add_definitions(-DBRPC_WITH_GLOG) add_definitions(-DBRPC_WITH_GLOG)
LIST(APPEND external_project_dependencies brpc) list(APPEND external_project_dependencies brpc)
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
if (NOT WITH_CINN) if(NOT WITH_CINN)
return() return()
endif() endif()
...@@ -27,36 +27,33 @@ add_definitions(-w) ...@@ -27,36 +27,33 @@ add_definitions(-w)
include(ExternalProject) include(ExternalProject)
set(CINN_PREFIX_DIR ${THIRD_PARTY_PATH}/CINN) set(CINN_PREFIX_DIR ${THIRD_PARTY_PATH}/CINN)
set(CINN_GIT_TAG release/v0.2) set(CINN_GIT_TAG release/v0.2)
set(CINN_OPTIONAL_ARGS -DPY_VERSION=${PY_VERSION} set(CINN_OPTIONAL_ARGS
-DWITH_CUDA=${WITH_GPU} -DPY_VERSION=${PY_VERSION}
-DWITH_CUDNN=${WITH_GPU} -DWITH_CUDA=${WITH_GPU}
-DWITH_MKL_CBLAS=${WITH_MKL} -DWITH_CUDNN=${WITH_GPU}
-DWITH_MKLDNN=${WITH_MKL} -DWITH_MKL_CBLAS=${WITH_MKL}
-DPUBLISH_LIBS=ON -DWITH_MKLDNN=${WITH_MKL}
-DWITH_TESTING=ON -DPUBLISH_LIBS=ON
) -DWITH_TESTING=ON)
set(CINN_BUILD_COMMAND $(MAKE) cinnapi -j) set(CINN_BUILD_COMMAND $(MAKE) cinnapi -j)
ExternalProject_Add( ExternalProject_Add(
external_cinn external_cinn
${EXTERNAL_PROJECT_LOG_ARGS} ${EXTERNAL_PROJECT_LOG_ARGS}
GIT_REPOSITORY "${GIT_URL}/PaddlePaddle/CINN.git" GIT_REPOSITORY "${GIT_URL}/PaddlePaddle/CINN.git"
GIT_TAG ${CINN_GIT_TAG} GIT_TAG ${CINN_GIT_TAG}
PREFIX ${CINN_PREFIX_DIR} PREFIX ${CINN_PREFIX_DIR}
BUILD_COMMAND ${CINN_BUILD_COMMAND} BUILD_COMMAND ${CINN_BUILD_COMMAND}
INSTALL_COMMAND "" INSTALL_COMMAND ""
CMAKE_ARGS ${CINN_OPTIONAL_ARGS}) CMAKE_ARGS ${CINN_OPTIONAL_ARGS})
ExternalProject_Get_Property(external_cinn BINARY_DIR)
ExternalProject_Get_Property(external_cinn SOURCE_DIR)
ExternalProject_Get_property(external_cinn BINARY_DIR)
ExternalProject_Get_property(external_cinn SOURCE_DIR)
set(CINN_BINARY_DIR ${BINARY_DIR}) set(CINN_BINARY_DIR ${BINARY_DIR})
set(CINN_SOURCE_DIR ${SOURCE_DIR}) set(CINN_SOURCE_DIR ${SOURCE_DIR})
message(STATUS "CINN BINARY_DIR: ${CINN_BINARY_DIR}") message(STATUS "CINN BINARY_DIR: ${CINN_BINARY_DIR}")
message(STATUS "CINN SOURCE_DIR: ${CINN_SOURCE_DIR}") message(STATUS "CINN SOURCE_DIR: ${CINN_SOURCE_DIR}")
###################################### ######################################
# Add CINN's dependencies header files # Add CINN's dependencies header files
###################################### ######################################
...@@ -82,6 +79,7 @@ set(CINN_LIB_LOCATION "${CINN_BINARY_DIR}/dist/cinn/lib") ...@@ -82,6 +79,7 @@ set(CINN_LIB_LOCATION "${CINN_BINARY_DIR}/dist/cinn/lib")
set(CINN_INCLUDE_DIR "${CINN_BINARY_DIR}/dist/cinn/include") set(CINN_INCLUDE_DIR "${CINN_BINARY_DIR}/dist/cinn/include")
add_library(cinn SHARED IMPORTED GLOBAL) add_library(cinn SHARED IMPORTED GLOBAL)
set_target_properties(cinn PROPERTIES IMPORTED_LOCATION "${CINN_LIB_LOCATION}/${CINN_LIB_NAME}") set_target_properties(cinn PROPERTIES IMPORTED_LOCATION
"${CINN_LIB_LOCATION}/${CINN_LIB_NAME}")
include_directories(${CINN_INCLUDE_DIR}) include_directories(${CINN_INCLUDE_DIR})
add_dependencies(cinn external_cinn) add_dependencies(cinn external_cinn)
...@@ -16,27 +16,32 @@ include(ExternalProject) ...@@ -16,27 +16,32 @@ include(ExternalProject)
set(CONCURRENTQUEUE_PROJECT "extern_concurrentqueue") set(CONCURRENTQUEUE_PROJECT "extern_concurrentqueue")
set(CONCURRENTQUEUE_VER "v1.0.3") set(CONCURRENTQUEUE_VER "v1.0.3")
SET(CONCURRENTQUEUE_URL_MD5 118e5bb661b567634647312991e10222) set(CONCURRENTQUEUE_URL_MD5 118e5bb661b567634647312991e10222)
set(CONCURRENTQUEUE_PREFIX_URL "https://github.com/cameron314/concurrentqueue/archive/refs/tags") set(CONCURRENTQUEUE_PREFIX_URL
set(CONCURRENTQUEUE_URL "${CONCURRENTQUEUE_PREFIX_URL}/${CONCURRENTQUEUE_VER}.tar.gz") "https://github.com/cameron314/concurrentqueue/archive/refs/tags")
set(CONCURRENTQUEUE_URL
"${CONCURRENTQUEUE_PREFIX_URL}/${CONCURRENTQUEUE_VER}.tar.gz")
MESSAGE(STATUS "CONCURRENTQUEUE_VERSION: ${CONCURRENTQUEUE_VER}, CONCURRENTQUEUE_URL: ${CONCURRENTQUEUE_URL}") message(
STATUS
"CONCURRENTQUEUE_VERSION: ${CONCURRENTQUEUE_VER}, CONCURRENTQUEUE_URL: ${CONCURRENTQUEUE_URL}"
)
set(CONCURRENTQUEUE_PREFIX_DIR ${THIRD_PARTY_PATH}/concurrentqueue) set(CONCURRENTQUEUE_PREFIX_DIR ${THIRD_PARTY_PATH}/concurrentqueue)
set(CONCURRENTQUEUE_SOURCE_DIR ${THIRD_PARTY_PATH}/concurrentqueue/src/) set(CONCURRENTQUEUE_SOURCE_DIR ${THIRD_PARTY_PATH}/concurrentqueue/src/)
set(CONCURRENTQUEUE_INCLUDE_DIR "${CONCURRENTQUEUE_SOURCE_DIR}/extern_concurrentqueue") set(CONCURRENTQUEUE_INCLUDE_DIR
"${CONCURRENTQUEUE_SOURCE_DIR}/extern_concurrentqueue")
ExternalProject_Add( ExternalProject_Add(
${CONCURRENTQUEUE_PROJECT} ${CONCURRENTQUEUE_PROJECT}
${EXTERNAL_PROJECT_LOG_ARGS} ${EXTERNAL_PROJECT_LOG_ARGS}
URL ${CONCURRENTQUEUE_URL} URL ${CONCURRENTQUEUE_URL}
URL_MD5 ${CONCURRENTQUEUE_URL_MD5} URL_MD5 ${CONCURRENTQUEUE_URL_MD5}
PREFIX ${CONCURRENTQUEUE_PREFIX_DIR} PREFIX ${CONCURRENTQUEUE_PREFIX_DIR}
DOWNLOAD_NO_PROGRESS 1 DOWNLOAD_NO_PROGRESS 1
CONFIGURE_COMMAND "" CONFIGURE_COMMAND ""
BUILD_COMMAND "" BUILD_COMMAND ""
INSTALL_COMMAND "" INSTALL_COMMAND ""
UPDATE_COMMAND "" UPDATE_COMMAND "")
)
include_directories(${CONCURRENTQUEUE_INCLUDE_DIR}) include_directories(${CONCURRENTQUEUE_INCLUDE_DIR})
...@@ -12,68 +12,77 @@ ...@@ -12,68 +12,77 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
INCLUDE(ExternalProject) include(ExternalProject)
SET(CRYPTOPP_PREFIX_DIR ${THIRD_PARTY_PATH}/cryptopp) set(CRYPTOPP_PREFIX_DIR ${THIRD_PARTY_PATH}/cryptopp)
SET(CRYPTOPP_INSTALL_DIR ${THIRD_PARTY_PATH}/install/cryptopp) set(CRYPTOPP_INSTALL_DIR ${THIRD_PARTY_PATH}/install/cryptopp)
SET(CRYPTOPP_INCLUDE_DIR "${CRYPTOPP_INSTALL_DIR}/include" CACHE PATH "cryptopp include directory." FORCE) set(CRYPTOPP_INCLUDE_DIR
SET(CRYPTOPP_REPOSITORY ${GIT_URL}/weidai11/cryptopp.git) "${CRYPTOPP_INSTALL_DIR}/include"
SET(CRYPTOPP_TAG CRYPTOPP_8_2_0) CACHE PATH "cryptopp include directory." FORCE)
set(CRYPTOPP_REPOSITORY ${GIT_URL}/weidai11/cryptopp.git)
set(CRYPTOPP_TAG CRYPTOPP_8_2_0)
IF(WIN32) if(WIN32)
SET(CRYPTOPP_LIBRARIES "${CRYPTOPP_INSTALL_DIR}/lib/cryptopp-static.lib" CACHE FILEPATH "cryptopp library." FORCE) set(CRYPTOPP_LIBRARIES
"${CRYPTOPP_INSTALL_DIR}/lib/cryptopp-static.lib"
CACHE FILEPATH "cryptopp library." FORCE)
# There is a compilation parameter "/FI\"winapifamily.h\"" or "/FIwinapifamily.h" can't be used correctly # There is a compilation parameter "/FI\"winapifamily.h\"" or "/FIwinapifamily.h" can't be used correctly
# with Ninja on Windows. The only difference between the patch file and original # with Ninja on Windows. The only difference between the patch file and original
# file is that the compilation parameters are changed to '/nologo'. This # file is that the compilation parameters are changed to '/nologo'. This
# patch command can be removed when upgrading to a higher version. # patch command can be removed when upgrading to a higher version.
if("${CMAKE_GENERATOR}" STREQUAL "Ninja") if("${CMAKE_GENERATOR}" STREQUAL "Ninja")
set(CRYPTOPP_PATCH_COMMAND ${CMAKE_COMMAND} -E copy_if_different "${PADDLE_SOURCE_DIR}/patches/cryptopp/CMakeLists.txt" "<SOURCE_DIR>/") set(CRYPTOPP_PATCH_COMMAND
${CMAKE_COMMAND} -E copy_if_different
"${PADDLE_SOURCE_DIR}/patches/cryptopp/CMakeLists.txt" "<SOURCE_DIR>/")
endif() endif()
ELSE(WIN32) else(WIN32)
SET(CRYPTOPP_LIBRARIES "${CRYPTOPP_INSTALL_DIR}/lib/libcryptopp.a" CACHE FILEPATH "cryptopp library." FORCE) set(CRYPTOPP_LIBRARIES
ENDIF(WIN32) "${CRYPTOPP_INSTALL_DIR}/lib/libcryptopp.a"
CACHE FILEPATH "cryptopp library." FORCE)
endif(WIN32)
IF(APPLE AND WITH_ARM) if(APPLE AND WITH_ARM)
SET(CMAKE_CXX_FLAGS "-DCRYPTOPP_ARM_CRC32_AVAILABLE=0") set(CMAKE_CXX_FLAGS "-DCRYPTOPP_ARM_CRC32_AVAILABLE=0")
ENDIF() endif()
set(CRYPTOPP_CMAKE_ARGS ${COMMON_CMAKE_ARGS} set(CRYPTOPP_CMAKE_ARGS
-DBUILD_SHARED=ON ${COMMON_CMAKE_ARGS}
-DBUILD_STATIC=ON -DBUILD_SHARED=ON
-DBUILD_TESTING=OFF -DBUILD_STATIC=ON
-DCMAKE_INSTALL_LIBDIR=${CRYPTOPP_INSTALL_DIR}/lib -DBUILD_TESTING=OFF
-DCMAKE_INSTALL_PREFIX=${CRYPTOPP_INSTALL_DIR} -DCMAKE_INSTALL_LIBDIR=${CRYPTOPP_INSTALL_DIR}/lib
-DCMAKE_BUILD_TYPE=${THIRD_PARTY_BUILD_TYPE} -DCMAKE_INSTALL_PREFIX=${CRYPTOPP_INSTALL_DIR}
-DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS} -DCMAKE_BUILD_TYPE=${THIRD_PARTY_BUILD_TYPE}
-DCMAKE_CXX_FLAGS_RELEASE=${CMAKE_CXX_FLAGS_RELEASE} -DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} -DCMAKE_CXX_FLAGS_RELEASE=${CMAKE_CXX_FLAGS_RELEASE}
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
) -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER})
INCLUDE_DIRECTORIES(${CRYPTOPP_INCLUDE_DIR}) include_directories(${CRYPTOPP_INCLUDE_DIR})
ExternalProject_Add( ExternalProject_Add(
extern_cryptopp extern_cryptopp
${EXTERNAL_PROJECT_LOG_ARGS} ${EXTERNAL_PROJECT_LOG_ARGS} ${SHALLOW_CLONE}
${SHALLOW_CLONE} GIT_REPOSITORY ${CRYPTOPP_REPOSITORY}
GIT_REPOSITORY ${CRYPTOPP_REPOSITORY} GIT_TAG ${CRYPTOPP_TAG}
GIT_TAG ${CRYPTOPP_TAG} PREFIX ${CRYPTOPP_PREFIX_DIR}
PREFIX ${CRYPTOPP_PREFIX_DIR} UPDATE_COMMAND ""
UPDATE_COMMAND "" PATCH_COMMAND
PATCH_COMMAND COMMAND ${CMAKE_COMMAND} -E remove_directory "<SOURCE_DIR>/cmake/"
COMMAND ${CMAKE_COMMAND} -E remove_directory "<SOURCE_DIR>/cmake/" COMMAND git clone ${GIT_URL}/noloader/cryptopp-cmake "<SOURCE_DIR>/cmake"
COMMAND git clone ${GIT_URL}/noloader/cryptopp-cmake "<SOURCE_DIR>/cmake" COMMAND cd "<SOURCE_DIR>/cmake" && git checkout tags/${CRYPTOPP_TAG} -b
COMMAND cd "<SOURCE_DIR>/cmake" && git checkout tags/${CRYPTOPP_TAG} -b ${CRYPTOPP_TAG} ${CRYPTOPP_TAG}
COMMAND ${CMAKE_COMMAND} -E copy_directory "<SOURCE_DIR>/cmake/" "<SOURCE_DIR>/" COMMAND ${CMAKE_COMMAND} -E copy_directory "<SOURCE_DIR>/cmake/"
COMMAND ${CRYPTOPP_PATCH_COMMAND} "<SOURCE_DIR>/"
INSTALL_DIR ${CRYPTOPP_INSTALL_DIR} COMMAND ${CRYPTOPP_PATCH_COMMAND}
CMAKE_ARGS ${CRYPTOPP_CMAKE_ARGS} INSTALL_DIR ${CRYPTOPP_INSTALL_DIR}
CMAKE_CACHE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${CRYPTOPP_INSTALL_DIR} CMAKE_ARGS ${CRYPTOPP_CMAKE_ARGS}
-DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON CMAKE_CACHE_ARGS
-DCMAKE_BUILD_TYPE:STRING=${THIRD_PARTY_BUILD_TYPE} -DCMAKE_INSTALL_PREFIX:PATH=${CRYPTOPP_INSTALL_DIR}
BUILD_BYPRODUCTS ${CRYPTOPP_LIBRARIES} -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON
) -DCMAKE_BUILD_TYPE:STRING=${THIRD_PARTY_BUILD_TYPE}
BUILD_BYPRODUCTS ${CRYPTOPP_LIBRARIES})
ADD_LIBRARY(cryptopp STATIC IMPORTED GLOBAL) add_library(cryptopp STATIC IMPORTED GLOBAL)
SET_PROPERTY(TARGET cryptopp PROPERTY IMPORTED_LOCATION ${CRYPTOPP_LIBRARIES}) set_property(TARGET cryptopp PROPERTY IMPORTED_LOCATION ${CRYPTOPP_LIBRARIES})
ADD_DEPENDENCIES(cryptopp extern_cryptopp) add_dependencies(cryptopp extern_cryptopp)
...@@ -14,32 +14,32 @@ ...@@ -14,32 +14,32 @@
include(ExternalProject) include(ExternalProject)
# Note(zhouwei): extern_cub has code __FILE_, If the path of extern_cub is changed, # Note(zhouwei): extern_cub has code __FILE_, If the path of extern_cub is changed,
# it will effect about 30+ cu files sccache hit and slow compile speed on windows. # it will effect about 30+ cu files sccache hit and slow compile speed on windows.
# Therefore, a fixed CUB_PATH will be input to increase the sccache hit rate. # Therefore, a fixed CUB_PATH will be input to increase the sccache hit rate.
set(CUB_PATH "${THIRD_PARTY_PATH}/cub" CACHE STRING "A path setting for external_cub path.") set(CUB_PATH
set(CUB_PREFIX_DIR ${CUB_PATH}) "${THIRD_PARTY_PATH}/cub"
CACHE STRING "A path setting for external_cub path.")
set(CUB_PREFIX_DIR ${CUB_PATH})
set(CUB_REPOSITORY ${GIT_URL}/NVlabs/cub.git) set(CUB_REPOSITORY ${GIT_URL}/NVlabs/cub.git)
set(CUB_TAG 1.8.0) set(CUB_TAG 1.8.0)
SET(CUB_INCLUDE_DIR ${CUB_PREFIX_DIR}/src/extern_cub) set(CUB_INCLUDE_DIR ${CUB_PREFIX_DIR}/src/extern_cub)
message("CUB_INCLUDE_DIR is ${CUB_INCLUDE_DIR}") message("CUB_INCLUDE_DIR is ${CUB_INCLUDE_DIR}")
include_directories(${CUB_INCLUDE_DIR}) include_directories(${CUB_INCLUDE_DIR})
ExternalProject_Add( ExternalProject_Add(
extern_cub extern_cub
${EXTERNAL_PROJECT_LOG_ARGS} ${EXTERNAL_PROJECT_LOG_ARGS} ${SHALLOW_CLONE}
${SHALLOW_CLONE} GIT_REPOSITORY ${CUB_REPOSITORY}
GIT_REPOSITORY ${CUB_REPOSITORY} GIT_TAG ${CUB_TAG}
GIT_TAG ${CUB_TAG} PREFIX ${CUB_PREFIX_DIR}
PREFIX ${CUB_PREFIX_DIR} UPDATE_COMMAND ""
UPDATE_COMMAND ""
CONFIGURE_COMMAND "" CONFIGURE_COMMAND ""
BUILD_COMMAND "" BUILD_COMMAND ""
INSTALL_COMMAND "" INSTALL_COMMAND ""
TEST_COMMAND "" TEST_COMMAND "")
)
add_library(cub INTERFACE) add_library(cub INTERFACE)
......
...@@ -12,32 +12,35 @@ ...@@ -12,32 +12,35 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
INCLUDE(ExternalProject) include(ExternalProject)
SET(DGC_PREFIX_DIR "${THIRD_PARTY_PATH}/dgc") set(DGC_PREFIX_DIR "${THIRD_PARTY_PATH}/dgc")
SET(DGC_SOURCES_DIR "${THIRD_PARTY_PATH}/dgc/src/extern_dgc") set(DGC_SOURCES_DIR "${THIRD_PARTY_PATH}/dgc/src/extern_dgc")
SET(DGC_INSTALL_DIR "${THIRD_PARTY_PATH}/install/dgc") set(DGC_INSTALL_DIR "${THIRD_PARTY_PATH}/install/dgc")
SET(DGC_INCLUDE_DIR "${DGC_INSTALL_DIR}/include" CACHE PATH "dgc include directory." FORCE) set(DGC_INCLUDE_DIR
SET(DGC_LIBRARIES "${DGC_INSTALL_DIR}/lib/libdgc.a" CACHE FILEPATH "dgc library." FORCE) "${DGC_INSTALL_DIR}/include"
SET(DGC_URL "https://fleet.bj.bcebos.com/dgc/collective_f66ef73.tgz") CACHE PATH "dgc include directory." FORCE)
INCLUDE_DIRECTORIES(${DGC_INCLUDE_DIR}) set(DGC_LIBRARIES
"${DGC_INSTALL_DIR}/lib/libdgc.a"
CACHE FILEPATH "dgc library." FORCE)
set(DGC_URL "https://fleet.bj.bcebos.com/dgc/collective_f66ef73.tgz")
include_directories(${DGC_INCLUDE_DIR})
ExternalProject_Add( ExternalProject_Add(
extern_dgc extern_dgc
${EXTERNAL_PROJECT_LOG_ARGS} ${EXTERNAL_PROJECT_LOG_ARGS}
URL ${DGC_URL} URL ${DGC_URL}
URL_MD5 "94e6fa1bc97169d0e1aad44570fe3251" URL_MD5 "94e6fa1bc97169d0e1aad44570fe3251"
PREFIX "${DGC_PREFIX_DIR}" PREFIX "${DGC_PREFIX_DIR}"
CONFIGURE_COMMAND "" CONFIGURE_COMMAND ""
BUILD_COMMAND make -j $(nproc) BUILD_COMMAND make -j $(nproc)
INSTALL_COMMAND mkdir -p ${DGC_INSTALL_DIR}/lib/ ${DGC_INCLUDE_DIR}/dgc INSTALL_COMMAND
&& cp ${DGC_SOURCES_DIR}/build/lib/libdgc.a ${DGC_LIBRARIES} mkdir -p ${DGC_INSTALL_DIR}/lib/ ${DGC_INCLUDE_DIR}/dgc && cp
&& cp ${DGC_SOURCES_DIR}/build/include/dgc.h ${DGC_INCLUDE_DIR}/dgc/ ${DGC_SOURCES_DIR}/build/lib/libdgc.a ${DGC_LIBRARIES} && cp
BUILD_IN_SOURCE 1 ${DGC_SOURCES_DIR}/build/include/dgc.h ${DGC_INCLUDE_DIR}/dgc/
BUILD_BYPRODUCTS ${DGC_LIBRARIES} BUILD_IN_SOURCE 1
) BUILD_BYPRODUCTS ${DGC_LIBRARIES})
ADD_LIBRARY(dgc STATIC IMPORTED GLOBAL)
SET_PROPERTY(TARGET dgc PROPERTY IMPORTED_LOCATION ${DGC_LIBRARIES})
ADD_DEPENDENCIES(dgc extern_dgc)
add_library(dgc STATIC IMPORTED GLOBAL)
set_property(TARGET dgc PROPERTY IMPORTED_LOCATION ${DGC_LIBRARIES})
add_dependencies(dgc extern_dgc)
...@@ -15,30 +15,28 @@ ...@@ -15,30 +15,28 @@
# Note(chenxin33): dirent.h is only exist in Linux, so get it from github when build in windows. # Note(chenxin33): dirent.h is only exist in Linux, so get it from github when build in windows.
# use dirent tag v1.23.2 on 09/05//2018 https://github.com/tronkko/dirent.git # use dirent tag v1.23.2 on 09/05//2018 https://github.com/tronkko/dirent.git
INCLUDE (ExternalProject) include(ExternalProject)
SET(DIRENT_PREFIX_DIR ${THIRD_PARTY_PATH}/dirent) set(DIRENT_PREFIX_DIR ${THIRD_PARTY_PATH}/dirent)
SET(DIRENT_INCLUDE_DIR ${THIRD_PARTY_PATH}/dirent/src/extern_dirent/include) set(DIRENT_INCLUDE_DIR ${THIRD_PARTY_PATH}/dirent/src/extern_dirent/include)
include_directories(${DIRENT_INCLUDE_DIR}) include_directories(${DIRENT_INCLUDE_DIR})
set(DIRENT_REPOSITORY ${GIT_URL}/tronkko/dirent) set(DIRENT_REPOSITORY ${GIT_URL}/tronkko/dirent)
set(DIRENT_TAG 1.23.2) set(DIRENT_TAG 1.23.2)
ExternalProject_Add( ExternalProject_Add(
extern_dirent extern_dirent
${EXTERNAL_PROJECT_LOG_ARGS} ${EXTERNAL_PROJECT_LOG_ARGS} ${SHALLOW_CLONE}
${SHALLOW_CLONE} GIT_REPOSITORY ${DIRENT_REPOSITORY}
GIT_REPOSITORY ${DIRENT_REPOSITORY} GIT_TAG ${DIRENT_TAG}
GIT_TAG ${DIRENT_TAG} PREFIX ${DIRENT_PREFIX_DIR}
PREFIX ${DIRENT_PREFIX_DIR} UPDATE_COMMAND ""
UPDATE_COMMAND ""
CONFIGURE_COMMAND "" CONFIGURE_COMMAND ""
BUILD_COMMAND "" BUILD_COMMAND ""
INSTALL_COMMAND "" INSTALL_COMMAND ""
TEST_COMMAND "" TEST_COMMAND "")
)
add_library(dirent INTERFACE) add_library(dirent INTERFACE)
add_dependencies(dirent extern_dirent) add_dependencies(dirent extern_dirent)
\ No newline at end of file
...@@ -17,24 +17,22 @@ include(ExternalProject) ...@@ -17,24 +17,22 @@ include(ExternalProject)
set(DLPACK_PREFIX_DIR ${THIRD_PARTY_PATH}/dlpack) set(DLPACK_PREFIX_DIR ${THIRD_PARTY_PATH}/dlpack)
set(DLPACK_REPOSITORY ${GIT_URL}/dmlc/dlpack.git) set(DLPACK_REPOSITORY ${GIT_URL}/dmlc/dlpack.git)
set(DLPACK_TAG v0.4) set(DLPACK_TAG v0.4)
set(DLPACK_INCLUDE_DIR ${THIRD_PARTY_PATH}/dlpack/src/extern_dlpack/include) set(DLPACK_INCLUDE_DIR ${THIRD_PARTY_PATH}/dlpack/src/extern_dlpack/include)
include_directories(${DLPACK_INCLUDE_DIR}) include_directories(${DLPACK_INCLUDE_DIR})
ExternalProject_Add( ExternalProject_Add(
extern_dlpack extern_dlpack
${EXTERNAL_PROJECT_LOG_ARGS} ${EXTERNAL_PROJECT_LOG_ARGS} ${SHALLOW_CLONE}
${SHALLOW_CLONE} GIT_REPOSITORY ${DLPACK_REPOSITORY}
GIT_REPOSITORY ${DLPACK_REPOSITORY} GIT_TAG ${DLPACK_TAG}
GIT_TAG ${DLPACK_TAG} PREFIX ${DLPACK_PREFIX_DIR}
PREFIX ${DLPACK_PREFIX_DIR} UPDATE_COMMAND ""
UPDATE_COMMAND ""
CONFIGURE_COMMAND "" CONFIGURE_COMMAND ""
BUILD_COMMAND "" BUILD_COMMAND ""
INSTALL_COMMAND "" INSTALL_COMMAND ""
TEST_COMMAND "" TEST_COMMAND "")
)
add_library(dlpack INTERFACE) add_library(dlpack INTERFACE)
......
...@@ -18,39 +18,43 @@ include(ExternalProject) ...@@ -18,39 +18,43 @@ include(ExternalProject)
set(EIGEN_PREFIX_DIR ${THIRD_PARTY_PATH}/eigen3) set(EIGEN_PREFIX_DIR ${THIRD_PARTY_PATH}/eigen3)
set(EIGEN_SOURCE_DIR ${THIRD_PARTY_PATH}/eigen3/src/extern_eigen3) set(EIGEN_SOURCE_DIR ${THIRD_PARTY_PATH}/eigen3/src/extern_eigen3)
set(EIGEN_REPOSITORY https://gitlab.com/libeigen/eigen.git) set(EIGEN_REPOSITORY https://gitlab.com/libeigen/eigen.git)
set(EIGEN_TAG f612df273689a19d25b45ca4f8269463207c4fee) set(EIGEN_TAG f612df273689a19d25b45ca4f8269463207c4fee)
if(WIN32) if(WIN32)
add_definitions(-DEIGEN_STRONG_INLINE=inline) add_definitions(-DEIGEN_STRONG_INLINE=inline)
elseif(LINUX) elseif(LINUX)
if(WITH_ROCM) if(WITH_ROCM)
# For HIPCC Eigen::internal::device::numeric_limits is not EIGEN_DEVICE_FUNC # For HIPCC Eigen::internal::device::numeric_limits is not EIGEN_DEVICE_FUNC
# which will cause compiler error of using __host__ funciont in __host__ __device__ # which will cause compiler error of using __host__ funciont in __host__ __device__
file(TO_NATIVE_PATH ${PADDLE_SOURCE_DIR}/patches/eigen/Meta.h native_src) file(TO_NATIVE_PATH ${PADDLE_SOURCE_DIR}/patches/eigen/Meta.h native_src)
file(TO_NATIVE_PATH ${EIGEN_SOURCE_DIR}/Eigen/src/Core/util/Meta.h native_dst) file(TO_NATIVE_PATH ${EIGEN_SOURCE_DIR}/Eigen/src/Core/util/Meta.h
file(TO_NATIVE_PATH ${PADDLE_SOURCE_DIR}/patches/eigen/TensorReductionGpu.h native_src1) native_dst)
file(TO_NATIVE_PATH ${EIGEN_SOURCE_DIR}/unsupported/Eigen/CXX11/src/Tensor/TensorReductionGpu.h native_dst1) file(TO_NATIVE_PATH ${PADDLE_SOURCE_DIR}/patches/eigen/TensorReductionGpu.h
set(EIGEN_PATCH_COMMAND cp ${native_src} ${native_dst} && cp ${native_src1} ${native_dst1}) native_src1)
endif() file(
TO_NATIVE_PATH
${EIGEN_SOURCE_DIR}/unsupported/Eigen/CXX11/src/Tensor/TensorReductionGpu.h
native_dst1)
set(EIGEN_PATCH_COMMAND cp ${native_src} ${native_dst} && cp ${native_src1}
${native_dst1})
endif()
endif() endif()
set(EIGEN_INCLUDE_DIR ${EIGEN_SOURCE_DIR}) set(EIGEN_INCLUDE_DIR ${EIGEN_SOURCE_DIR})
INCLUDE_DIRECTORIES(${EIGEN_INCLUDE_DIR}) include_directories(${EIGEN_INCLUDE_DIR})
ExternalProject_Add( ExternalProject_Add(
extern_eigen3 extern_eigen3
${EXTERNAL_PROJECT_LOG_ARGS} ${EXTERNAL_PROJECT_LOG_ARGS} ${SHALLOW_CLONE}
${SHALLOW_CLONE} GIT_REPOSITORY ${EIGEN_REPOSITORY}
GIT_REPOSITORY ${EIGEN_REPOSITORY} GIT_TAG ${EIGEN_TAG}
GIT_TAG ${EIGEN_TAG} PREFIX ${EIGEN_PREFIX_DIR}
PREFIX ${EIGEN_PREFIX_DIR} UPDATE_COMMAND ""
UPDATE_COMMAND "" PATCH_COMMAND ${EIGEN_PATCH_COMMAND}
PATCH_COMMAND ${EIGEN_PATCH_COMMAND} CONFIGURE_COMMAND ""
CONFIGURE_COMMAND "" BUILD_COMMAND ""
BUILD_COMMAND "" INSTALL_COMMAND ""
INSTALL_COMMAND "" TEST_COMMAND "")
TEST_COMMAND ""
)
add_library(eigen3 INTERFACE) add_library(eigen3 INTERFACE)
......
...@@ -12,90 +12,94 @@ ...@@ -12,90 +12,94 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
INCLUDE(ExternalProject) include(ExternalProject)
SET(GFLAGS_PREFIX_DIR ${THIRD_PARTY_PATH}/gflags) set(GFLAGS_PREFIX_DIR ${THIRD_PARTY_PATH}/gflags)
SET(GFLAGS_INSTALL_DIR ${THIRD_PARTY_PATH}/install/gflags) set(GFLAGS_INSTALL_DIR ${THIRD_PARTY_PATH}/install/gflags)
SET(GFLAGS_INCLUDE_DIR "${GFLAGS_INSTALL_DIR}/include" CACHE PATH "gflags include directory." FORCE) set(GFLAGS_INCLUDE_DIR
"${GFLAGS_INSTALL_DIR}/include"
CACHE PATH "gflags include directory." FORCE)
set(GFLAGS_REPOSITORY ${GIT_URL}/gflags/gflags.git) set(GFLAGS_REPOSITORY ${GIT_URL}/gflags/gflags.git)
set(GFLAGS_TAG "v2.2.2") set(GFLAGS_TAG "v2.2.2")
IF(WIN32) if(WIN32)
set(GFLAGS_LIBRARIES "${GFLAGS_INSTALL_DIR}/lib/gflags_static.lib" CACHE FILEPATH "GFLAGS_LIBRARIES" FORCE) set(GFLAGS_LIBRARIES
ELSE(WIN32) "${GFLAGS_INSTALL_DIR}/lib/gflags_static.lib"
set(GFLAGS_LIBRARIES "${GFLAGS_INSTALL_DIR}/lib/libgflags.a" CACHE FILEPATH "GFLAGS_LIBRARIES" FORCE) CACHE FILEPATH "GFLAGS_LIBRARIES" FORCE)
else(WIN32)
set(GFLAGS_LIBRARIES
"${GFLAGS_INSTALL_DIR}/lib/libgflags.a"
CACHE FILEPATH "GFLAGS_LIBRARIES" FORCE)
set(BUILD_COMMAND $(MAKE) --silent) set(BUILD_COMMAND $(MAKE) --silent)
set(INSTALL_COMMAND $(MAKE) install) set(INSTALL_COMMAND $(MAKE) install)
ENDIF(WIN32) endif(WIN32)
INCLUDE_DIRECTORIES(${GFLAGS_INCLUDE_DIR}) include_directories(${GFLAGS_INCLUDE_DIR})
if(WITH_ARM_BRPC) if(WITH_ARM_BRPC)
SET(ARM_GFLAGS_URL "https://paddlerec.bj.bcebos.com/online_infer/arm_brpc_ubuntu18/arm_gflags.tar.gz" CACHE STRING "" FORCE) set(ARM_GFLAGS_URL
set(GFLAGS_SOURCE_DIR ${THIRD_PARTY_PATH}/gflags/src/extern_gflags) "https://paddlerec.bj.bcebos.com/online_infer/arm_brpc_ubuntu18/arm_gflags.tar.gz"
FILE(WRITE ${GFLAGS_SOURCE_DIR}/CMakeLists.txt CACHE STRING "" FORCE)
"PROJECT(ARM_GFLAGS)\n" set(GFLAGS_SOURCE_DIR ${THIRD_PARTY_PATH}/gflags/src/extern_gflags)
"cmake_minimum_required(VERSION 3.0)\n" file(
WRITE ${GFLAGS_SOURCE_DIR}/CMakeLists.txt
"PROJECT(ARM_GFLAGS)\n" "cmake_minimum_required(VERSION 3.0)\n"
"install(DIRECTORY arm_gflags/bin arm_gflags/include arm_gflags/lib \n" "install(DIRECTORY arm_gflags/bin arm_gflags/include arm_gflags/lib \n"
" DESTINATION . USE_SOURCE_PERMISSIONS)\n") " DESTINATION . USE_SOURCE_PERMISSIONS)\n")
ExternalProject_Add( ExternalProject_Add(
extern_gflags extern_gflags
${EXTERNAL_PROJECT_LOG_ARGS} ${EXTERNAL_PROJECT_LOG_ARGS} ${SHALLOW_CLONE}
${SHALLOW_CLONE} PREFIX ${GFLAGS_PREFIX_DIR}
PREFIX ${GFLAGS_PREFIX_DIR} DOWNLOAD_DIR ${GFLAGS_SOURCE_DIR}
DOWNLOAD_DIR ${GFLAGS_SOURCE_DIR} DOWNLOAD_COMMAND rm -rf arm_gflags.tar.gz && wget --no-check-certificate
DOWNLOAD_COMMAND rm -rf arm_gflags.tar.gz && ${ARM_GFLAGS_URL} && tar zxvf arm_gflags.tar.gz
wget --no-check-certificate ${ARM_GFLAGS_URL} #DOWNLOAD_COMMAND cp /home/wangbin44/Paddle/build/arm_gflags.tar.gz .
&& tar zxvf arm_gflags.tar.gz # && tar zxvf arm_gflags.tar.gz
#DOWNLOAD_COMMAND cp /home/wangbin44/Paddle/build/arm_gflags.tar.gz . UPDATE_COMMAND ""
# && tar zxvf arm_gflags.tar.gz CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${GFLAGS_INSTALL_DIR}
UPDATE_COMMAND "" -DCMAKE_BUILD_TYPE:STRING=${THIRD_PARTY_BUILD_TYPE}
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${GFLAGS_INSTALL_DIR} CMAKE_CACHE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${GFLAGS_INSTALL_DIR}
-DCMAKE_BUILD_TYPE:STRING=${THIRD_PARTY_BUILD_TYPE} -DCMAKE_BUILD_TYPE:STRING=${THIRD_PARTY_BUILD_TYPE}
CMAKE_CACHE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${GFLAGS_INSTALL_DIR} BUILD_BYPRODUCTS ${GFLAGS_LIBRARIES})
-DCMAKE_BUILD_TYPE:STRING=${THIRD_PARTY_BUILD_TYPE}
BUILD_BYPRODUCTS ${GFLAGS_LIBRARIES}
)
else() else()
ExternalProject_Add( ExternalProject_Add(
extern_gflags extern_gflags
${EXTERNAL_PROJECT_LOG_ARGS} ${EXTERNAL_PROJECT_LOG_ARGS} ${SHALLOW_CLONE}
${SHALLOW_CLONE} GIT_REPOSITORY ${GFLAGS_REPOSITORY}
GIT_REPOSITORY ${GFLAGS_REPOSITORY} GIT_TAG ${GFLAGS_TAG}
GIT_TAG ${GFLAGS_TAG} PREFIX ${GFLAGS_PREFIX_DIR}
PREFIX ${GFLAGS_PREFIX_DIR} UPDATE_COMMAND ""
UPDATE_COMMAND "" BUILD_COMMAND ${BUILD_COMMAND}
BUILD_COMMAND ${BUILD_COMMAND} INSTALL_COMMAND ${INSTALL_COMMAND}
INSTALL_COMMAND ${INSTALL_COMMAND} CMAKE_ARGS -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
CMAKE_ARGS -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} -DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
-DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS} -DCMAKE_CXX_FLAGS_RELEASE=${CMAKE_CXX_FLAGS_RELEASE}
-DCMAKE_CXX_FLAGS_RELEASE=${CMAKE_CXX_FLAGS_RELEASE} -DCMAKE_CXX_FLAGS_DEBUG=${CMAKE_CXX_FLAGS_DEBUG}
-DCMAKE_CXX_FLAGS_DEBUG=${CMAKE_CXX_FLAGS_DEBUG} -DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS} -DCMAKE_C_FLAGS_DEBUG=${CMAKE_C_FLAGS_DEBUG}
-DCMAKE_C_FLAGS_DEBUG=${CMAKE_C_FLAGS_DEBUG} -DCMAKE_C_FLAGS_RELEASE=${CMAKE_C_FLAGS_RELEASE}
-DCMAKE_C_FLAGS_RELEASE=${CMAKE_C_FLAGS_RELEASE} -DBUILD_STATIC_LIBS=ON
-DBUILD_STATIC_LIBS=ON -DCMAKE_INSTALL_PREFIX=${GFLAGS_INSTALL_DIR}
-DCMAKE_INSTALL_PREFIX=${GFLAGS_INSTALL_DIR} -DCMAKE_POSITION_INDEPENDENT_CODE=ON
-DCMAKE_POSITION_INDEPENDENT_CODE=ON -DBUILD_TESTING=OFF
-DBUILD_TESTING=OFF -DCMAKE_BUILD_TYPE=${THIRD_PARTY_BUILD_TYPE}
-DCMAKE_BUILD_TYPE=${THIRD_PARTY_BUILD_TYPE} ${EXTERNAL_OPTIONAL_ARGS}
${EXTERNAL_OPTIONAL_ARGS} CMAKE_CACHE_ARGS
CMAKE_CACHE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${GFLAGS_INSTALL_DIR} -DCMAKE_INSTALL_PREFIX:PATH=${GFLAGS_INSTALL_DIR}
-DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON
-DCMAKE_BUILD_TYPE:STRING=${THIRD_PARTY_BUILD_TYPE} -DCMAKE_BUILD_TYPE:STRING=${THIRD_PARTY_BUILD_TYPE}
BUILD_BYPRODUCTS ${GFLAGS_LIBRARIES} BUILD_BYPRODUCTS ${GFLAGS_LIBRARIES})
)
endif() endif()
ADD_LIBRARY(gflags STATIC IMPORTED GLOBAL) add_library(gflags STATIC IMPORTED GLOBAL)
SET_PROPERTY(TARGET gflags PROPERTY IMPORTED_LOCATION ${GFLAGS_LIBRARIES}) set_property(TARGET gflags PROPERTY IMPORTED_LOCATION ${GFLAGS_LIBRARIES})
ADD_DEPENDENCIES(gflags extern_gflags) add_dependencies(gflags extern_gflags)
# On Windows (including MinGW), the Shlwapi library is used by gflags if available. # On Windows (including MinGW), the Shlwapi library is used by gflags if available.
if (WIN32) if(WIN32)
include(CheckIncludeFileCXX) include(CheckIncludeFileCXX)
check_include_file_cxx("shlwapi.h" HAVE_SHLWAPI) check_include_file_cxx("shlwapi.h" HAVE_SHLWAPI)
if (HAVE_SHLWAPI) if(HAVE_SHLWAPI)
set_property(GLOBAL PROPERTY OS_DEPENDENCY_MODULES shlwapi.lib) set_property(GLOBAL PROPERTY OS_DEPENDENCY_MODULES shlwapi.lib)
endif(HAVE_SHLWAPI) endif(HAVE_SHLWAPI)
endif (WIN32) endif(WIN32)
...@@ -12,86 +12,90 @@ ...@@ -12,86 +12,90 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
INCLUDE(ExternalProject) include(ExternalProject)
SET(GLOG_PREFIX_DIR ${THIRD_PARTY_PATH}/glog) set(GLOG_PREFIX_DIR ${THIRD_PARTY_PATH}/glog)
SET(GLOG_INSTALL_DIR ${THIRD_PARTY_PATH}/install/glog) set(GLOG_INSTALL_DIR ${THIRD_PARTY_PATH}/install/glog)
SET(GLOG_INCLUDE_DIR "${GLOG_INSTALL_DIR}/include" CACHE PATH "glog include directory." FORCE) set(GLOG_INCLUDE_DIR
SET(GLOG_REPOSITORY ${GIT_URL}/google/glog.git) "${GLOG_INSTALL_DIR}/include"
SET(GLOG_TAG v0.4.0) CACHE PATH "glog include directory." FORCE)
set(GLOG_REPOSITORY ${GIT_URL}/google/glog.git)
set(GLOG_TAG v0.4.0)
IF(WIN32) if(WIN32)
SET(GLOG_LIBRARIES "${GLOG_INSTALL_DIR}/lib/glog.lib" CACHE FILEPATH "glog library." FORCE) set(GLOG_LIBRARIES
SET(GLOG_CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4267 /wd4530") "${GLOG_INSTALL_DIR}/lib/glog.lib"
CACHE FILEPATH "glog library." FORCE)
set(GLOG_CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4267 /wd4530")
add_definitions("/DGOOGLE_GLOG_DLL_DECL=") add_definitions("/DGOOGLE_GLOG_DLL_DECL=")
ELSE(WIN32) else(WIN32)
SET(GLOG_LIBRARIES "${GLOG_INSTALL_DIR}/lib/libglog.a" CACHE FILEPATH "glog library." FORCE) set(GLOG_LIBRARIES
SET(GLOG_CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) "${GLOG_INSTALL_DIR}/lib/libglog.a"
ENDIF(WIN32) CACHE FILEPATH "glog library." FORCE)
set(GLOG_CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
endif(WIN32)
INCLUDE_DIRECTORIES(${GLOG_INCLUDE_DIR}) include_directories(${GLOG_INCLUDE_DIR})
if(WITH_ARM_BRPC) if(WITH_ARM_BRPC)
SET(ARM_GLOG_URL "https://paddlerec.bj.bcebos.com/online_infer/arm_brpc_ubuntu18/arm_glog.tar.gz" CACHE STRING "" FORCE) set(ARM_GLOG_URL
set(GLOG_SOURCE_DIR ${THIRD_PARTY_PATH}/glog/src/extern_glog) "https://paddlerec.bj.bcebos.com/online_infer/arm_brpc_ubuntu18/arm_glog.tar.gz"
FILE(WRITE ${GLOG_SOURCE_DIR}/CMakeLists.txt CACHE STRING "" FORCE)
"PROJECT(ARM_GLOGS)\n" set(GLOG_SOURCE_DIR ${THIRD_PARTY_PATH}/glog/src/extern_glog)
"cmake_minimum_required(VERSION 3.0)\n" file(
WRITE ${GLOG_SOURCE_DIR}/CMakeLists.txt
"PROJECT(ARM_GLOGS)\n" "cmake_minimum_required(VERSION 3.0)\n"
"install(DIRECTORY arm_glog/include arm_glog/lib \n" "install(DIRECTORY arm_glog/include arm_glog/lib \n"
" DESTINATION . USE_SOURCE_PERMISSIONS)\n") " DESTINATION . USE_SOURCE_PERMISSIONS)\n")
ExternalProject_Add( ExternalProject_Add(
extern_glog extern_glog
${EXTERNAL_PROJECT_LOG_ARGS} ${EXTERNAL_PROJECT_LOG_ARGS} ${SHALLOW_CLONE}
${SHALLOW_CLONE} DEPENDS gflags
DEPENDS gflags PREFIX ${GLOG_PREFIX_DIR}
PREFIX ${GLOG_PREFIX_DIR} DOWNLOAD_DIR ${GLOG_SOURCE_DIR}
DOWNLOAD_DIR ${GLOG_SOURCE_DIR} DOWNLOAD_COMMAND rm -rf arm_glog.tar.gz && wget --no-check-certificate
DOWNLOAD_COMMAND rm -rf arm_glog.tar.gz && ${ARM_GLOG_URL} && tar zxvf arm_glog.tar.gz
wget --no-check-certificate ${ARM_GLOG_URL} #DOWNLOAD_COMMAND cp /home/wangbin44/Paddle/build/arm_glog.tar.gz .
&& tar zxvf arm_glog.tar.gz # && tar zxvf arm_glog.tar.gz
#DOWNLOAD_COMMAND cp /home/wangbin44/Paddle/build/arm_glog.tar.gz . UPDATE_COMMAND ""
# && tar zxvf arm_glog.tar.gz CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${GLOG_INSTALL_DIR}
UPDATE_COMMAND "" -DCMAKE_BUILD_TYPE:STRING=${THIRD_PARTY_BUILD_TYPE}
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${GLOG_INSTALL_DIR} CMAKE_CACHE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${GLOG_INSTALL_DIR}
-DCMAKE_BUILD_TYPE:STRING=${THIRD_PARTY_BUILD_TYPE} -DCMAKE_BUILD_TYPE:STRING=${THIRD_PARTY_BUILD_TYPE}
CMAKE_CACHE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${GLOG_INSTALL_DIR} BUILD_BYPRODUCTS ${GLOG_LIBRARIES})
-DCMAKE_BUILD_TYPE:STRING=${THIRD_PARTY_BUILD_TYPE}
BUILD_BYPRODUCTS ${GLOG_LIBRARIES}
)
else() else()
ExternalProject_Add( ExternalProject_Add(
extern_glog extern_glog
${EXTERNAL_PROJECT_LOG_ARGS} ${EXTERNAL_PROJECT_LOG_ARGS} ${SHALLOW_CLONE}
${SHALLOW_CLONE} GIT_REPOSITORY ${GLOG_REPOSITORY}
GIT_REPOSITORY ${GLOG_REPOSITORY} GIT_TAG ${GLOG_TAG}
GIT_TAG ${GLOG_TAG} DEPENDS gflags
DEPENDS gflags PREFIX ${GLOG_PREFIX_DIR}
PREFIX ${GLOG_PREFIX_DIR} UPDATE_COMMAND ""
UPDATE_COMMAND "" CMAKE_ARGS -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
CMAKE_ARGS -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} -DCMAKE_CXX_FLAGS=${GLOG_CMAKE_CXX_FLAGS}
-DCMAKE_CXX_FLAGS=${GLOG_CMAKE_CXX_FLAGS} -DCMAKE_CXX_FLAGS_RELEASE=${CMAKE_CXX_FLAGS_RELEASE}
-DCMAKE_CXX_FLAGS_RELEASE=${CMAKE_CXX_FLAGS_RELEASE} -DCMAKE_CXX_FLAGS_DEBUG=${CMAKE_CXX_FLAGS_DEBUG}
-DCMAKE_CXX_FLAGS_DEBUG=${CMAKE_CXX_FLAGS_DEBUG} -DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS} -DCMAKE_C_FLAGS_DEBUG=${CMAKE_C_FLAGS_DEBUG}
-DCMAKE_C_FLAGS_DEBUG=${CMAKE_C_FLAGS_DEBUG} -DCMAKE_C_FLAGS_RELEASE=${CMAKE_C_FLAGS_RELEASE}
-DCMAKE_C_FLAGS_RELEASE=${CMAKE_C_FLAGS_RELEASE} -DCMAKE_INSTALL_PREFIX=${GLOG_INSTALL_DIR}
-DCMAKE_INSTALL_PREFIX=${GLOG_INSTALL_DIR} -DCMAKE_INSTALL_LIBDIR=${GLOG_INSTALL_DIR}/lib
-DCMAKE_INSTALL_LIBDIR=${GLOG_INSTALL_DIR}/lib -DCMAKE_POSITION_INDEPENDENT_CODE=ON
-DCMAKE_POSITION_INDEPENDENT_CODE=ON -DWITH_GFLAGS=OFF
-DWITH_GFLAGS=OFF -DBUILD_TESTING=OFF
-DBUILD_TESTING=OFF -DCMAKE_BUILD_TYPE=${THIRD_PARTY_BUILD_TYPE}
-DCMAKE_BUILD_TYPE=${THIRD_PARTY_BUILD_TYPE} ${EXTERNAL_OPTIONAL_ARGS}
${EXTERNAL_OPTIONAL_ARGS} CMAKE_CACHE_ARGS
CMAKE_CACHE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${GLOG_INSTALL_DIR} -DCMAKE_INSTALL_PREFIX:PATH=${GLOG_INSTALL_DIR}
-DCMAKE_INSTALL_LIBDIR:PATH=${GLOG_INSTALL_DIR}/lib -DCMAKE_INSTALL_LIBDIR:PATH=${GLOG_INSTALL_DIR}/lib
-DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON
-DCMAKE_BUILD_TYPE:STRING=${THIRD_PARTY_BUILD_TYPE} -DCMAKE_BUILD_TYPE:STRING=${THIRD_PARTY_BUILD_TYPE}
BUILD_BYPRODUCTS ${GLOG_LIBRARIES} BUILD_BYPRODUCTS ${GLOG_LIBRARIES})
)
endif() endif()
ADD_LIBRARY(glog STATIC IMPORTED GLOBAL) add_library(glog STATIC IMPORTED GLOBAL)
SET_PROPERTY(TARGET glog PROPERTY IMPORTED_LOCATION ${GLOG_LIBRARIES}) set_property(TARGET glog PROPERTY IMPORTED_LOCATION ${GLOG_LIBRARIES})
ADD_DEPENDENCIES(glog extern_glog gflags) add_dependencies(glog extern_glog gflags)
LINK_LIBRARIES(glog) link_libraries(glog)
...@@ -12,58 +12,65 @@ ...@@ -12,58 +12,65 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
INCLUDE(ExternalProject) include(ExternalProject)
SET(GLOO_PROJECT "extern_gloo") set(GLOO_PROJECT "extern_gloo")
SET(GLOO_PREFIX_DIR ${THIRD_PARTY_PATH}/gloo) set(GLOO_PREFIX_DIR ${THIRD_PARTY_PATH}/gloo)
SET(GLOO_SOURCE_DIR ${THIRD_PARTY_PATH}/gloo/src/extern_gloo) set(GLOO_SOURCE_DIR ${THIRD_PARTY_PATH}/gloo/src/extern_gloo)
SET(GLOO_INSTALL_DIR ${THIRD_PARTY_PATH}/install/gloo) set(GLOO_INSTALL_DIR ${THIRD_PARTY_PATH}/install/gloo)
SET(GLOO_INCLUDE_DIR "${GLOO_INSTALL_DIR}/include" CACHE PATH "gloo include directory." FORCE) set(GLOO_INCLUDE_DIR
SET(GLOO_LIBRARY_DIR "${GLOO_INSTALL_DIR}/lib" CACHE PATH "gloo library directory." FORCE) "${GLOO_INSTALL_DIR}/include"
CACHE PATH "gloo include directory." FORCE)
set(GLOO_LIBRARY_DIR
"${GLOO_INSTALL_DIR}/lib"
CACHE PATH "gloo library directory." FORCE)
# As we add extra features for gloo, we use the non-official repo # As we add extra features for gloo, we use the non-official repo
SET(GLOO_REPOSITORY ${GIT_URL}/sandyhouse/gloo.git) set(GLOO_REPOSITORY ${GIT_URL}/sandyhouse/gloo.git)
SET(GLOO_TAG v0.0.2) set(GLOO_TAG v0.0.2)
SET(GLOO_LIBRARIES "${GLOO_INSTALL_DIR}/lib/libgloo.a" CACHE FILEPATH "gloo library." FORCE) set(GLOO_LIBRARIES
"${GLOO_INSTALL_DIR}/lib/libgloo.a"
CACHE FILEPATH "gloo library." FORCE)
INCLUDE_DIRECTORIES(${GLOO_INCLUDE_DIR}) include_directories(${GLOO_INCLUDE_DIR})
if(WITH_ASCEND OR WITH_ASCEND_CL) if(WITH_ASCEND OR WITH_ASCEND_CL)
ExternalProject_Add( ExternalProject_Add(
${GLOO_PROJECT} ${GLOO_PROJECT}
${EXTERNAL_PROJECT_LOG_ARGS} ${EXTERNAL_PROJECT_LOG_ARGS} ${SHALLOW_CLONE}
${SHALLOW_CLONE} GIT_REPOSITORY ${GLOO_REPOSITORY}
GIT_REPOSITORY ${GLOO_REPOSITORY} GIT_TAG ${GLOO_TAG}
GIT_TAG ${GLOO_TAG} PREFIX "${GLOO_PREFIX_DIR}"
PREFIX "${GLOO_PREFIX_DIR}" UPDATE_COMMAND ""
UPDATE_COMMAND "" CONFIGURE_COMMAND ""
CONFIGURE_COMMAND "" BUILD_COMMAND
BUILD_COMMAND mkdir -p ${GLOO_SOURCE_DIR}/build mkdir -p ${GLOO_SOURCE_DIR}/build && cd ${GLOO_SOURCE_DIR}/build && cmake
&& cd ${GLOO_SOURCE_DIR}/build && cmake .. -DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS} && make .. -DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS} && make && mkdir -p
&& mkdir -p ${GLOO_LIBRARY_DIR} ${GLOO_INCLUDE_DIR}/gloo ${GLOO_LIBRARY_DIR} ${GLOO_INCLUDE_DIR}/gloo
INSTALL_COMMAND ${CMAKE_COMMAND} -E copy ${GLOO_SOURCE_DIR}/build/gloo/libgloo.a ${GLOO_LIBRARY_DIR} INSTALL_COMMAND ${CMAKE_COMMAND} -E copy
COMMAND ${CMAKE_COMMAND} -E copy_directory "${GLOO_SOURCE_DIR}/gloo/" "${GLOO_INCLUDE_DIR}/gloo" ${GLOO_SOURCE_DIR}/build/gloo/libgloo.a ${GLOO_LIBRARY_DIR}
BUILD_BYPRODUCTS ${GLOO_LIBRARIES} COMMAND ${CMAKE_COMMAND} -E copy_directory "${GLOO_SOURCE_DIR}/gloo/"
) "${GLOO_INCLUDE_DIR}/gloo"
BUILD_BYPRODUCTS ${GLOO_LIBRARIES})
else() else()
ExternalProject_Add( ExternalProject_Add(
${GLOO_PROJECT} ${GLOO_PROJECT}
${EXTERNAL_PROJECT_LOG_ARGS} ${EXTERNAL_PROJECT_LOG_ARGS} ${SHALLOW_CLONE}
${SHALLOW_CLONE} GIT_REPOSITORY ${GLOO_REPOSITORY}
GIT_REPOSITORY ${GLOO_REPOSITORY} GIT_TAG ${GLOO_TAG}
GIT_TAG ${GLOO_TAG} PREFIX "${GLOO_PREFIX_DIR}"
PREFIX "${GLOO_PREFIX_DIR}" UPDATE_COMMAND ""
UPDATE_COMMAND "" CONFIGURE_COMMAND ""
CONFIGURE_COMMAND "" BUILD_COMMAND
BUILD_COMMAND mkdir -p ${GLOO_SOURCE_DIR}/build mkdir -p ${GLOO_SOURCE_DIR}/build && cd ${GLOO_SOURCE_DIR}/build && cmake
&& cd ${GLOO_SOURCE_DIR}/build && cmake .. -DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS} && make .. -DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS} && make && mkdir -p
&& mkdir -p ${GLOO_LIBRARY_DIR} ${GLOO_INCLUDE_DIR}/gloo ${GLOO_LIBRARY_DIR} ${GLOO_INCLUDE_DIR}/gloo
INSTALL_COMMAND ${CMAKE_COMMAND} -E copy ${GLOO_SOURCE_DIR}/build/gloo/libgloo.a ${GLOO_LIBRARY_DIR} INSTALL_COMMAND ${CMAKE_COMMAND} -E copy
COMMAND ${CMAKE_COMMAND} -E copy_directory "${GLOO_SOURCE_DIR}/gloo/" "${GLOO_INCLUDE_DIR}/gloo" ${GLOO_SOURCE_DIR}/build/gloo/libgloo.a ${GLOO_LIBRARY_DIR}
BUILD_BYPRODUCTS ${GLOO_LIBRARIES} COMMAND ${CMAKE_COMMAND} -E copy_directory "${GLOO_SOURCE_DIR}/gloo/"
) "${GLOO_INCLUDE_DIR}/gloo"
BUILD_BYPRODUCTS ${GLOO_LIBRARIES})
endif() endif()
add_library(gloo STATIC IMPORTED GLOBAL)
ADD_LIBRARY(gloo STATIC IMPORTED GLOBAL) set_property(TARGET gloo PROPERTY IMPORTED_LOCATION ${GLOO_LIBRARIES})
SET_PROPERTY(TARGET gloo PROPERTY IMPORTED_LOCATION ${GLOO_LIBRARIES}) add_dependencies(gloo ${GLOO_PROJECT})
ADD_DEPENDENCIES(gloo ${GLOO_PROJECT})
...@@ -14,79 +14,85 @@ ...@@ -14,79 +14,85 @@
#FIXME:(gongwb) Move brpc's gtest dependency. #FIXME:(gongwb) Move brpc's gtest dependency.
IF(WITH_TESTING) if(WITH_TESTING)
ENABLE_TESTING() enable_testing()
ENDIF() endif()
INCLUDE(GNUInstallDirs) include(GNUInstallDirs)
INCLUDE(ExternalProject) include(ExternalProject)
SET(GTEST_PREFIX_DIR ${THIRD_PARTY_PATH}/gtest) set(GTEST_PREFIX_DIR ${THIRD_PARTY_PATH}/gtest)
SET(GTEST_INSTALL_DIR ${THIRD_PARTY_PATH}/install/gtest) set(GTEST_INSTALL_DIR ${THIRD_PARTY_PATH}/install/gtest)
SET(GTEST_INCLUDE_DIR "${GTEST_INSTALL_DIR}/include" CACHE PATH "gtest include directory." FORCE) set(GTEST_INCLUDE_DIR
set(GTEST_REPOSITORY ${GIT_URL}/google/googletest.git) "${GTEST_INSTALL_DIR}/include"
set(GTEST_TAG release-1.8.1) CACHE PATH "gtest include directory." FORCE)
set(GTEST_REPOSITORY ${GIT_URL}/google/googletest.git)
set(GTEST_TAG release-1.8.1)
INCLUDE_DIRECTORIES(${GTEST_INCLUDE_DIR}) include_directories(${GTEST_INCLUDE_DIR})
IF(WIN32) if(WIN32)
set(GTEST_LIBRARIES set(GTEST_LIBRARIES
"${GTEST_INSTALL_DIR}/${CMAKE_INSTALL_LIBDIR}/gtest.lib" CACHE FILEPATH "gtest libraries." FORCE) "${GTEST_INSTALL_DIR}/${CMAKE_INSTALL_LIBDIR}/gtest.lib"
set(GTEST_MAIN_LIBRARIES CACHE FILEPATH "gtest libraries." FORCE)
"${GTEST_INSTALL_DIR}/${CMAKE_INSTALL_LIBDIR}/gtest_main.lib" CACHE FILEPATH "gtest main libraries." FORCE) set(GTEST_MAIN_LIBRARIES
string(REPLACE "/w " "" GTEST_CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") "${GTEST_INSTALL_DIR}/${CMAKE_INSTALL_LIBDIR}/gtest_main.lib"
string(REPLACE "/w " "" GTEST_CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") CACHE FILEPATH "gtest main libraries." FORCE)
string(REPLACE "/W0 " "" GTEST_CMAKE_C_FLAGS "${GTEST_CMAKE_C_FLAGS}") string(REPLACE "/w " "" GTEST_CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
string(REPLACE "/W0 " "" GTEST_CMAKE_CXX_FLAGS "${GTEST_CMAKE_CXX_FLAGS}") string(REPLACE "/w " "" GTEST_CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
ELSE(WIN32) string(REPLACE "/W0 " "" GTEST_CMAKE_C_FLAGS "${GTEST_CMAKE_C_FLAGS}")
set(GTEST_LIBRARIES string(REPLACE "/W0 " "" GTEST_CMAKE_CXX_FLAGS "${GTEST_CMAKE_CXX_FLAGS}")
"${GTEST_INSTALL_DIR}/${CMAKE_INSTALL_LIBDIR}/libgtest.a" CACHE FILEPATH "gtest libraries." FORCE) else(WIN32)
set(GTEST_MAIN_LIBRARIES set(GTEST_LIBRARIES
"${GTEST_INSTALL_DIR}/${CMAKE_INSTALL_LIBDIR}/libgtest_main.a" CACHE FILEPATH "gtest main libraries." FORCE) "${GTEST_INSTALL_DIR}/${CMAKE_INSTALL_LIBDIR}/libgtest.a"
set(GTEST_CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") CACHE FILEPATH "gtest libraries." FORCE)
set(GTEST_CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") set(GTEST_MAIN_LIBRARIES
ENDIF(WIN32) "${GTEST_INSTALL_DIR}/${CMAKE_INSTALL_LIBDIR}/libgtest_main.a"
CACHE FILEPATH "gtest main libraries." FORCE)
set(GTEST_CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
set(GTEST_CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
endif(WIN32)
IF(WITH_MKLML) if(WITH_MKLML)
# wait for mklml downloading completed # wait for mklml downloading completed
SET(GTEST_DEPENDS ${MKLML_PROJECT}) set(GTEST_DEPENDS ${MKLML_PROJECT})
ENDIF() endif()
ExternalProject_Add( ExternalProject_Add(
extern_gtest extern_gtest
${EXTERNAL_PROJECT_LOG_ARGS} ${EXTERNAL_PROJECT_LOG_ARGS} ${SHALLOW_CLONE}
${SHALLOW_CLONE} GIT_REPOSITORY ${GTEST_REPOSITORY}
GIT_REPOSITORY ${GTEST_REPOSITORY} GIT_TAG ${GTEST_TAG}
GIT_TAG ${GTEST_TAG} DEPENDS ${GTEST_DEPENDS}
DEPENDS ${GTEST_DEPENDS} PREFIX ${GTEST_PREFIX_DIR}
PREFIX ${GTEST_PREFIX_DIR} UPDATE_COMMAND ""
UPDATE_COMMAND "" CMAKE_ARGS -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
CMAKE_ARGS -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} -DCMAKE_CXX_FLAGS=${GTEST_CMAKE_CXX_FLAGS}
-DCMAKE_CXX_FLAGS=${GTEST_CMAKE_CXX_FLAGS} -DCMAKE_CXX_FLAGS_RELEASE=${CMAKE_CXX_FLAGS_RELEASE}
-DCMAKE_CXX_FLAGS_RELEASE=${CMAKE_CXX_FLAGS_RELEASE} -DCMAKE_CXX_FLAGS_DEBUG=${CMAKE_CXX_FLAGS_DEBUG}
-DCMAKE_CXX_FLAGS_DEBUG=${CMAKE_CXX_FLAGS_DEBUG} -DCMAKE_C_FLAGS=${GTEST_CMAKE_C_FLAGS}
-DCMAKE_C_FLAGS=${GTEST_CMAKE_C_FLAGS} -DCMAKE_C_FLAGS_DEBUG=${CMAKE_C_FLAGS_DEBUG}
-DCMAKE_C_FLAGS_DEBUG=${CMAKE_C_FLAGS_DEBUG} -DCMAKE_C_FLAGS_RELEASE=${CMAKE_C_FLAGS_RELEASE}
-DCMAKE_C_FLAGS_RELEASE=${CMAKE_C_FLAGS_RELEASE} -DCMAKE_INSTALL_PREFIX=${GTEST_INSTALL_DIR}
-DCMAKE_INSTALL_PREFIX=${GTEST_INSTALL_DIR} -DCMAKE_POSITION_INDEPENDENT_CODE=ON
-DCMAKE_POSITION_INDEPENDENT_CODE=ON -DBUILD_GMOCK=ON
-DBUILD_GMOCK=ON -Dgtest_disable_pthreads=ON
-Dgtest_disable_pthreads=ON -Dgtest_force_shared_crt=ON
-Dgtest_force_shared_crt=ON -DCMAKE_BUILD_TYPE=${THIRD_PARTY_BUILD_TYPE}
-DCMAKE_BUILD_TYPE=${THIRD_PARTY_BUILD_TYPE} ${EXTERNAL_OPTIONAL_ARGS}
${EXTERNAL_OPTIONAL_ARGS} CMAKE_CACHE_ARGS
CMAKE_CACHE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${GTEST_INSTALL_DIR} -DCMAKE_INSTALL_PREFIX:PATH=${GTEST_INSTALL_DIR}
-DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON
-DCMAKE_BUILD_TYPE:STRING=${THIRD_PARTY_BUILD_TYPE} -DCMAKE_BUILD_TYPE:STRING=${THIRD_PARTY_BUILD_TYPE}
BUILD_BYPRODUCTS ${GTEST_LIBRARIES} BUILD_BYPRODUCTS ${GTEST_LIBRARIES}
BUILD_BYPRODUCTS ${GTEST_MAIN_LIBRARIES} BUILD_BYPRODUCTS ${GTEST_MAIN_LIBRARIES})
)
ADD_LIBRARY(gtest STATIC IMPORTED GLOBAL) add_library(gtest STATIC IMPORTED GLOBAL)
SET_PROPERTY(TARGET gtest PROPERTY IMPORTED_LOCATION ${GTEST_LIBRARIES}) set_property(TARGET gtest PROPERTY IMPORTED_LOCATION ${GTEST_LIBRARIES})
ADD_DEPENDENCIES(gtest extern_gtest) add_dependencies(gtest extern_gtest)
ADD_LIBRARY(gtest_main STATIC IMPORTED GLOBAL) add_library(gtest_main STATIC IMPORTED GLOBAL)
SET_PROPERTY(TARGET gtest_main PROPERTY IMPORTED_LOCATION ${GTEST_MAIN_LIBRARIES}) set_property(TARGET gtest_main PROPERTY IMPORTED_LOCATION
ADD_DEPENDENCIES(gtest_main extern_gtest) ${GTEST_MAIN_LIBRARIES})
add_dependencies(gtest_main extern_gtest)
...@@ -12,56 +12,68 @@ ...@@ -12,56 +12,68 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
INCLUDE (ExternalProject) include(ExternalProject)
SET(LAPACK_PREFIX_DIR ${THIRD_PARTY_PATH}/lapack) set(LAPACK_PREFIX_DIR ${THIRD_PARTY_PATH}/lapack)
SET(LAPACK_SOURCE_DIR ${THIRD_PARTY_PATH}/lapack/src/extern_lapack) set(LAPACK_SOURCE_DIR ${THIRD_PARTY_PATH}/lapack/src/extern_lapack)
SET(LAPACK_INSTALL_DIR ${THIRD_PARTY_PATH}/install/lapack) set(LAPACK_INSTALL_DIR ${THIRD_PARTY_PATH}/install/lapack)
SET(LAPACK_LIB_DIR ${LAPACK_INSTALL_DIR}/lib) set(LAPACK_LIB_DIR ${LAPACK_INSTALL_DIR}/lib)
# Note(zhouwei): lapack need fortan compiler which many machines don't have, so use precompiled library. # Note(zhouwei): lapack need fortan compiler which many machines don't have, so use precompiled library.
# use lapack tag v3.10.0 on 06/28/2021 https://github.com/Reference-LAPACK/lapack # use lapack tag v3.10.0 on 06/28/2021 https://github.com/Reference-LAPACK/lapack
if(LINUX) if(LINUX)
SET(LAPACK_VER "lapack_lnx_v3.10.0.20210628" CACHE STRING "" FORCE) set(LAPACK_VER
SET(LAPACK_URL "https://paddlepaddledeps.bj.bcebos.com/${LAPACK_VER}.tar.gz" CACHE STRING "" FORCE) "lapack_lnx_v3.10.0.20210628"
SET(LAPACK_URL_MD5 71f8cc8237a8571692f3e07f9a4f25f6) CACHE STRING "" FORCE)
SET(GNU_RT_LIB_1 "${LAPACK_LIB_DIR}/libquadmath.so.0") set(LAPACK_URL
SET(GFORTRAN_LIB "${LAPACK_LIB_DIR}/libgfortran.so.3") "https://paddlepaddledeps.bj.bcebos.com/${LAPACK_VER}.tar.gz"
SET(BLAS_LIB "${LAPACK_LIB_DIR}/libblas.so.3") CACHE STRING "" FORCE)
SET(LAPACK_LIB "${LAPACK_LIB_DIR}/liblapack.so.3") set(LAPACK_URL_MD5 71f8cc8237a8571692f3e07f9a4f25f6)
set(GNU_RT_LIB_1 "${LAPACK_LIB_DIR}/libquadmath.so.0")
set(GFORTRAN_LIB "${LAPACK_LIB_DIR}/libgfortran.so.3")
set(BLAS_LIB "${LAPACK_LIB_DIR}/libblas.so.3")
set(LAPACK_LIB "${LAPACK_LIB_DIR}/liblapack.so.3")
elseif(WIN32) elseif(WIN32)
# Refer to [lapack-for-windows] http://icl.cs.utk.edu/lapack-for-windows/lapack/#lapacke # Refer to [lapack-for-windows] http://icl.cs.utk.edu/lapack-for-windows/lapack/#lapacke
SET(LAPACK_VER "lapack_win_v3.10.0.20210628" CACHE STRING "" FORCE) set(LAPACK_VER
SET(LAPACK_URL "https://paddlepaddledeps.bj.bcebos.com/${LAPACK_VER}.zip" CACHE STRING "" FORCE) "lapack_win_v3.10.0.20210628"
SET(LAPACK_URL_MD5 590d080392dcd5abbd5dca767a50b63a) CACHE STRING "" FORCE)
SET(GNU_RT_LIB_1 "${LAPACK_LIB_DIR}/libquadmath-0.dll") set(LAPACK_URL
SET(GNU_RT_LIB_2 "${LAPACK_LIB_DIR}/libgcc_s_seh-1.dll") "https://paddlepaddledeps.bj.bcebos.com/${LAPACK_VER}.zip"
SET(GFORTRAN_LIB "${LAPACK_LIB_DIR}/libgfortran-3.dll") CACHE STRING "" FORCE)
SET(BLAS_LIB "${LAPACK_LIB_DIR}/libblas.dll") set(LAPACK_URL_MD5 590d080392dcd5abbd5dca767a50b63a)
SET(LAPACK_LIB "${LAPACK_LIB_DIR}/liblapack.dll") set(GNU_RT_LIB_1 "${LAPACK_LIB_DIR}/libquadmath-0.dll")
set(GNU_RT_LIB_2 "${LAPACK_LIB_DIR}/libgcc_s_seh-1.dll")
set(GFORTRAN_LIB "${LAPACK_LIB_DIR}/libgfortran-3.dll")
set(BLAS_LIB "${LAPACK_LIB_DIR}/libblas.dll")
set(LAPACK_LIB "${LAPACK_LIB_DIR}/liblapack.dll")
else() else()
SET(LAPACK_VER "lapack_mac_v3.10.0.20210628" CACHE STRING "" FORCE) set(LAPACK_VER
SET(LAPACK_URL "https://paddlepaddledeps.bj.bcebos.com/${LAPACK_VER}.tar.gz" CACHE STRING "" FORCE) "lapack_mac_v3.10.0.20210628"
SET(LAPACK_URL_MD5 427aecf8dee8523de3566ca8e47944d7) CACHE STRING "" FORCE)
SET(GNU_RT_LIB_1 "${LAPACK_LIB_DIR}/libquadmath.0.dylib") set(LAPACK_URL
SET(GNU_RT_LIB_2 "${LAPACK_LIB_DIR}/libgcc_s.1.dylib") "https://paddlepaddledeps.bj.bcebos.com/${LAPACK_VER}.tar.gz"
SET(GFORTRAN_LIB "${LAPACK_LIB_DIR}/libgfortran.5.dylib") CACHE STRING "" FORCE)
SET(BLAS_LIB "${LAPACK_LIB_DIR}/libblas.3.dylib") set(LAPACK_URL_MD5 427aecf8dee8523de3566ca8e47944d7)
SET(LAPACK_LIB "${LAPACK_LIB_DIR}/liblapack.3.dylib") set(GNU_RT_LIB_1 "${LAPACK_LIB_DIR}/libquadmath.0.dylib")
set(GNU_RT_LIB_2 "${LAPACK_LIB_DIR}/libgcc_s.1.dylib")
set(GFORTRAN_LIB "${LAPACK_LIB_DIR}/libgfortran.5.dylib")
set(BLAS_LIB "${LAPACK_LIB_DIR}/libblas.3.dylib")
set(LAPACK_LIB "${LAPACK_LIB_DIR}/liblapack.3.dylib")
endif() endif()
ExternalProject_Add( ExternalProject_Add(
extern_lapack extern_lapack
${EXTERNAL_PROJECT_LOG_ARGS} ${EXTERNAL_PROJECT_LOG_ARGS}
URL ${LAPACK_URL} URL ${LAPACK_URL}
URL_MD5 ${LAPACK_URL_MD5} URL_MD5 ${LAPACK_URL_MD5}
PREFIX ${LAPACK_PREFIX_DIR} PREFIX ${LAPACK_PREFIX_DIR}
DOWNLOAD_NO_PROGRESS 1 DOWNLOAD_NO_PROGRESS 1
PATCH_COMMAND "" PATCH_COMMAND ""
UPDATE_COMMAND "" UPDATE_COMMAND ""
CONFIGURE_COMMAND "" CONFIGURE_COMMAND ""
BUILD_COMMAND "" BUILD_COMMAND ""
INSTALL_COMMAND ${CMAKE_COMMAND} -E copy_directory ${LAPACK_SOURCE_DIR} ${LAPACK_LIB_DIR} INSTALL_COMMAND ${CMAKE_COMMAND} -E copy_directory ${LAPACK_SOURCE_DIR}
BUILD_BYPRODUCTS ${BLAS_LIB} ${LAPACK_LIB_DIR}
BUILD_BYPRODUCTS ${LAPACK_LIB} BUILD_BYPRODUCTS ${BLAS_LIB}
) BUILD_BYPRODUCTS ${LAPACK_LIB})
...@@ -12,35 +12,39 @@ ...@@ -12,35 +12,39 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
INCLUDE(ExternalProject) include(ExternalProject)
SET(LEVELDB_PREFIX_DIR ${THIRD_PARTY_PATH}/leveldb) set(LEVELDB_PREFIX_DIR ${THIRD_PARTY_PATH}/leveldb)
SET(LEVELDB_INSTALL_DIR ${THIRD_PARTY_PATH}/install/leveldb) set(LEVELDB_INSTALL_DIR ${THIRD_PARTY_PATH}/install/leveldb)
SET(LEVELDB_INCLUDE_DIR "${LEVELDB_INSTALL_DIR}/include" CACHE PATH "leveldb include directory." FORCE) set(LEVELDB_INCLUDE_DIR
SET(LEVELDB_LIBRARIES "${LEVELDB_INSTALL_DIR}/lib/libleveldb.a" CACHE FILEPATH "leveldb library." FORCE) "${LEVELDB_INSTALL_DIR}/include"
INCLUDE_DIRECTORIES(${LEVELDB_INCLUDE_DIR}) CACHE PATH "leveldb include directory." FORCE)
set(LEVELDB_LIBRARIES
"${LEVELDB_INSTALL_DIR}/lib/libleveldb.a"
CACHE FILEPATH "leveldb library." FORCE)
include_directories(${LEVELDB_INCLUDE_DIR})
ExternalProject_Add( ExternalProject_Add(
extern_leveldb extern_leveldb
${EXTERNAL_PROJECT_LOG_ARGS} ${EXTERNAL_PROJECT_LOG_ARGS}
PREFIX ${LEVELDB_PREFIX_DIR} PREFIX ${LEVELDB_PREFIX_DIR}
GIT_REPOSITORY "https://github.com/google/leveldb" GIT_REPOSITORY "https://github.com/google/leveldb"
GIT_TAG v1.18 GIT_TAG v1.18
UPDATE_COMMAND "" UPDATE_COMMAND ""
CONFIGURE_COMMAND "" CONFIGURE_COMMAND ""
BUILD_COMMAND CXXFLAGS=-fPIC make -j ${NUM_OF_PROCESSOR} libleveldb.a BUILD_COMMAND CXXFLAGS=-fPIC make -j ${NUM_OF_PROCESSOR} libleveldb.a
INSTALL_COMMAND mkdir -p ${LEVELDB_INSTALL_DIR}/lib/ INSTALL_COMMAND
&& cp ${LEVELDB_PREFIX_DIR}/src/extern_leveldb/libleveldb.a ${LEVELDB_LIBRARIES} mkdir -p ${LEVELDB_INSTALL_DIR}/lib/ && cp
&& cp -r ${LEVELDB_PREFIX_DIR}/src/extern_leveldb/include ${LEVELDB_INSTALL_DIR}/ ${LEVELDB_PREFIX_DIR}/src/extern_leveldb/libleveldb.a ${LEVELDB_LIBRARIES}
BUILD_IN_SOURCE 1 && cp -r ${LEVELDB_PREFIX_DIR}/src/extern_leveldb/include
BUILD_BYPRODUCTS ${LEVELDB_LIBRARIES} ${LEVELDB_INSTALL_DIR}/
) BUILD_IN_SOURCE 1
BUILD_BYPRODUCTS ${LEVELDB_LIBRARIES})
ADD_DEPENDENCIES(extern_leveldb snappy) add_dependencies(extern_leveldb snappy)
ADD_LIBRARY(leveldb STATIC IMPORTED GLOBAL) add_library(leveldb STATIC IMPORTED GLOBAL)
SET_PROPERTY(TARGET leveldb PROPERTY IMPORTED_LOCATION ${LEVELDB_LIBRARIES}) set_property(TARGET leveldb PROPERTY IMPORTED_LOCATION ${LEVELDB_LIBRARIES})
ADD_DEPENDENCIES(leveldb extern_leveldb) add_dependencies(leveldb extern_leveldb)
LIST(APPEND external_project_dependencies leveldb)
list(APPEND external_project_dependencies leveldb)
...@@ -12,48 +12,54 @@ ...@@ -12,48 +12,54 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
INCLUDE(ExternalProject) include(ExternalProject)
SET(LIBMCT_PROJECT "extern_libmct") set(LIBMCT_PROJECT "extern_libmct")
IF((NOT DEFINED LIBMCT_VER) OR (NOT DEFINED LIBMCT_URL)) if((NOT DEFINED LIBMCT_VER) OR (NOT DEFINED LIBMCT_URL))
MESSAGE(STATUS "use pre defined download url") message(STATUS "use pre defined download url")
SET(LIBMCT_VER "0.1.0" CACHE STRING "" FORCE) set(LIBMCT_VER
SET(LIBMCT_NAME "libmct" CACHE STRING "" FORCE) "0.1.0"
SET(LIBMCT_URL "https://pslib.bj.bcebos.com/libmct/libmct.tar.gz" CACHE STRING "" FORCE) CACHE STRING "" FORCE)
ENDIF() set(LIBMCT_NAME
MESSAGE(STATUS "LIBMCT_NAME: ${LIBMCT_NAME}, LIBMCT_URL: ${LIBMCT_URL}") "libmct"
SET(LIBMCT_PREFIX_DIR "${THIRD_PARTY_PATH}/libmct") CACHE STRING "" FORCE)
SET(LIBMCT_DOWNLOAD_DIR "${LIBMCT_PREFIX_DIR}/src/${LIBMCT_PROJECT}") set(LIBMCT_URL
SET(LIBMCT_DST_DIR "libmct") "https://pslib.bj.bcebos.com/libmct/libmct.tar.gz"
SET(LIBMCT_INSTALL_ROOT "${THIRD_PARTY_PATH}/install") CACHE STRING "" FORCE)
SET(LIBMCT_INSTALL_DIR ${LIBMCT_INSTALL_ROOT}/${LIBMCT_DST_DIR}) endif()
SET(LIBMCT_ROOT ${LIBMCT_INSTALL_DIR}) message(STATUS "LIBMCT_NAME: ${LIBMCT_NAME}, LIBMCT_URL: ${LIBMCT_URL}")
SET(LIBMCT_INC_DIR ${LIBMCT_ROOT}/include) set(LIBMCT_PREFIX_DIR "${THIRD_PARTY_PATH}/libmct")
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_RPATH}" "${LIBMCT_ROOT}/lib") set(LIBMCT_DOWNLOAD_DIR "${LIBMCT_PREFIX_DIR}/src/${LIBMCT_PROJECT}")
set(LIBMCT_DST_DIR "libmct")
set(LIBMCT_INSTALL_ROOT "${THIRD_PARTY_PATH}/install")
set(LIBMCT_INSTALL_DIR ${LIBMCT_INSTALL_ROOT}/${LIBMCT_DST_DIR})
set(LIBMCT_ROOT ${LIBMCT_INSTALL_DIR})
set(LIBMCT_INC_DIR ${LIBMCT_ROOT}/include)
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_RPATH}" "${LIBMCT_ROOT}/lib")
INCLUDE_DIRECTORIES(${LIBMCT_INC_DIR}) include_directories(${LIBMCT_INC_DIR})
FILE(WRITE ${LIBMCT_DOWNLOAD_DIR}/CMakeLists.txt file(
"PROJECT(LIBMCT)\n" WRITE ${LIBMCT_DOWNLOAD_DIR}/CMakeLists.txt
"cmake_minimum_required(VERSION 3.0)\n" "PROJECT(LIBMCT)\n" "cmake_minimum_required(VERSION 3.0)\n"
"install(DIRECTORY ${LIBMCT_NAME}/include ${LIBMCT_NAME}/lib \n" "install(DIRECTORY ${LIBMCT_NAME}/include ${LIBMCT_NAME}/lib \n"
" DESTINATION ${LIBMCT_DST_DIR})\n") " DESTINATION ${LIBMCT_DST_DIR})\n")
ExternalProject_Add( ExternalProject_Add(
${LIBMCT_PROJECT} ${LIBMCT_PROJECT}
${EXTERNAL_PROJECT_LOG_ARGS} ${EXTERNAL_PROJECT_LOG_ARGS}
PREFIX ${LIBMCT_PREFIX_DIR} PREFIX ${LIBMCT_PREFIX_DIR}
DOWNLOAD_DIR ${LIBMCT_DOWNLOAD_DIR} DOWNLOAD_DIR ${LIBMCT_DOWNLOAD_DIR}
DOWNLOAD_COMMAND wget --no-check-certificate ${LIBMCT_URL} -c -q -O ${LIBMCT_NAME}.tar.gz DOWNLOAD_COMMAND
&& tar --no-same-owner -zxvf ${LIBMCT_NAME}.tar.gz wget --no-check-certificate ${LIBMCT_URL} -c -q -O ${LIBMCT_NAME}.tar.gz &&
DOWNLOAD_NO_PROGRESS 1 tar --no-same-owner -zxvf ${LIBMCT_NAME}.tar.gz
UPDATE_COMMAND "" DOWNLOAD_NO_PROGRESS 1
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBMCT_INSTALL_ROOT} UPDATE_COMMAND ""
-DCMAKE_BUILD_TYPE=${THIRD_PARTY_BUILD_TYPE} CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBMCT_INSTALL_ROOT}
CMAKE_CACHE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${LIBMCT_INSTALL_ROOT} -DCMAKE_BUILD_TYPE=${THIRD_PARTY_BUILD_TYPE}
-DCMAKE_BUILD_TYPE=${THIRD_PARTY_BUILD_TYPE} CMAKE_CACHE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${LIBMCT_INSTALL_ROOT}
) -DCMAKE_BUILD_TYPE=${THIRD_PARTY_BUILD_TYPE})
add_library(libmct INTERFACE) add_library(libmct INTERFACE)
ADD_DEPENDENCIES(libmct ${LIBMCT_PROJECT}) add_dependencies(libmct ${LIBMCT_PROJECT})
...@@ -12,34 +12,38 @@ ...@@ -12,34 +12,38 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
INCLUDE (ExternalProject) include(ExternalProject)
SET(LIBXSMM_PREFIX_DIR ${THIRD_PARTY_PATH}/libxsmm) set(LIBXSMM_PREFIX_DIR ${THIRD_PARTY_PATH}/libxsmm)
SET(LIBXSMM_INSTALL_DIR ${THIRD_PARTY_PATH}/install/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_INCLUDE_DIR
SET(LIBXSMM_LIBRARY_DIR "${LIBXSMM_INSTALL_DIR}/lib" CACHE PATH "LIBXSMM library directory." FORCE) "${LIBXSMM_INSTALL_DIR}/include"
SET(LIBXSMM_LIB "${LIBXSMM_LIBRARY_DIR}/libxsmm.a") CACHE PATH "LIBXSMM include directory." FORCE)
SET(LIBXSMMNOBLAS_LIB "${LIBXSMM_LIBRARY_DIR}/libxsmmnoblas.a") set(LIBXSMM_LIBRARY_DIR
"${LIBXSMM_INSTALL_DIR}/lib"
CACHE PATH "LIBXSMM library directory." FORCE)
set(LIBXSMM_LIB "${LIBXSMM_LIBRARY_DIR}/libxsmm.a")
set(LIBXSMMNOBLAS_LIB "${LIBXSMM_LIBRARY_DIR}/libxsmmnoblas.a")
ExternalProject_Add( ExternalProject_Add(
extern_libxsmm extern_libxsmm
${SHALLOW_CLONE} ${SHALLOW_CLONE}
GIT_REPOSITORY "${GIT_URL}/hfp/libxsmm.git" GIT_REPOSITORY "${GIT_URL}/hfp/libxsmm.git"
GIT_TAG "7cc03b5b342fdbc6b6d990b190671c5dbb8489a2" GIT_TAG "7cc03b5b342fdbc6b6d990b190671c5dbb8489a2"
PREFIX ${LIBXSMM_PREFIX_DIR} PREFIX ${LIBXSMM_PREFIX_DIR}
UPDATE_COMMAND "" UPDATE_COMMAND ""
CONFIGURE_COMMAND "" CONFIGURE_COMMAND ""
BUILD_IN_SOURCE 1 BUILD_IN_SOURCE 1
BUILD_COMMAND $(MAKE) --silent PREFIX=${LIBXSMM_INSTALL_DIR} CXX=g++ CC=gcc WARP=0 install BUILD_COMMAND $(MAKE) --silent PREFIX=${LIBXSMM_INSTALL_DIR} CXX=g++ CC=gcc
INSTALL_COMMAND "" WARP=0 install
BUILD_BYPRODUCTS ${LIBXSMM_LIB} INSTALL_COMMAND ""
BUILD_BYPRODUCTS ${LIBXSMMNOBLAS_LIB} BUILD_BYPRODUCTS ${LIBXSMM_LIB}
) BUILD_BYPRODUCTS ${LIBXSMMNOBLAS_LIB})
ADD_LIBRARY(libxsmm STATIC IMPORTED GLOBAL) add_library(libxsmm STATIC IMPORTED GLOBAL)
SET_PROPERTY(TARGET libxsmm PROPERTY IMPORTED_LOCATION "${LIBXSMM_LIB}") set_property(TARGET libxsmm PROPERTY IMPORTED_LOCATION "${LIBXSMM_LIB}")
SET_PROPERTY(TARGET libxsmm PROPERTY IMPORTED_LOCATION "${LIBXSMMNOBLAS_LIB}") set_property(TARGET libxsmm PROPERTY IMPORTED_LOCATION "${LIBXSMMNOBLAS_LIB}")
MESSAGE(STATUS "Libxsmm library: ${LIBXSMM_LIBS}") message(STATUS "Libxsmm library: ${LIBXSMM_LIBS}")
include_directories(${LIBXSMM_INCLUDE_DIR}) include_directories(${LIBXSMM_INCLUDE_DIR})
ADD_DEFINITIONS(-DPADDLE_WITH_LIBXSMM) add_definitions(-DPADDLE_WITH_LIBXSMM)
ADD_DEPENDENCIES(libxsmm extern_libxsmm) add_dependencies(libxsmm extern_libxsmm)
...@@ -18,32 +18,34 @@ if(NOT LINUX) ...@@ -18,32 +18,34 @@ if(NOT LINUX)
return() return()
endif() endif()
if (LITE_WITH_XPU) if(LITE_WITH_XPU)
add_definitions(-DLITE_SUBGRAPH_WITH_XPU) add_definitions(-DLITE_SUBGRAPH_WITH_XPU)
IF(WITH_AARCH64) if(WITH_AARCH64)
SET(XPU_SDK_ENV "kylin_aarch64") set(XPU_SDK_ENV "kylin_aarch64")
ELSEIF(WITH_SUNWAY) elseif(WITH_SUNWAY)
SET(XPU_SDK_ENV "deepin_sw6_64") set(XPU_SDK_ENV "deepin_sw6_64")
ELSEIF(WITH_BDCENTOS) elseif(WITH_BDCENTOS)
SET(XPU_SDK_ENV "bdcentos_x86_64") set(XPU_SDK_ENV "bdcentos_x86_64")
ELSEIF(WITH_UBUNTU) elseif(WITH_UBUNTU)
SET(XPU_SDK_ENV "ubuntu_x86_64") set(XPU_SDK_ENV "ubuntu_x86_64")
ELSEIF(WITH_CENTOS) elseif(WITH_CENTOS)
SET(XPU_SDK_ENV "centos7_x86_64") set(XPU_SDK_ENV "centos7_x86_64")
ELSE () else()
SET(XPU_SDK_ENV "ubuntu_x86_64") set(XPU_SDK_ENV "ubuntu_x86_64")
ENDIF() endif()
endif() endif()
if (LITE_WITH_NNADAPTER) if(LITE_WITH_NNADAPTER)
add_definitions(-DLITE_SUBGRAPH_WITH_NNADAPTER) add_definitions(-DLITE_SUBGRAPH_WITH_NNADAPTER)
if (NNADAPTER_WITH_HUAWEI_ASCEND_NPU) if(NNADAPTER_WITH_HUAWEI_ASCEND_NPU)
add_definitions(-DLITE_SUBGRAPH_WITH_NPU) add_definitions(-DLITE_SUBGRAPH_WITH_NPU)
set(NPU_SDK_ROOT "/usr/local/Ascend/ascend-toolkit/latest" CACHE STRING "default NPU SDK ROOT") set(NPU_SDK_ROOT
"/usr/local/Ascend/ascend-toolkit/latest"
CACHE STRING "default NPU SDK ROOT")
endif() endif()
endif() endif()
if (NOT LITE_SOURCE_DIR OR NOT LITE_BINARY_DIR) if(NOT LITE_SOURCE_DIR OR NOT LITE_BINARY_DIR)
include(ExternalProject) include(ExternalProject)
set(LITE_PROJECT extern_lite) set(LITE_PROJECT extern_lite)
set(LITE_PREFIX_DIR ${THIRD_PARTY_PATH}/lite) set(LITE_PREFIX_DIR ${THIRD_PARTY_PATH}/lite)
...@@ -61,109 +63,118 @@ if (NOT LITE_SOURCE_DIR OR NOT LITE_BINARY_DIR) ...@@ -61,109 +63,118 @@ if (NOT LITE_SOURCE_DIR OR NOT LITE_BINARY_DIR)
if(WITH_ARM) if(WITH_ARM)
set(LITE_BUILD_COMMAND $(MAKE) publish_inference -j) set(LITE_BUILD_COMMAND $(MAKE) publish_inference -j)
message(WARNING "BUILD_COMMAND: ${LITE_BUILD_COMMAND}") message(WARNING "BUILD_COMMAND: ${LITE_BUILD_COMMAND}")
set(LITE_OPTIONAL_ARGS -DWITH_MKL=OFF set(LITE_OPTIONAL_ARGS
-DLITE_WITH_CUDA=OFF -DWITH_MKL=OFF
-DWITH_MKLDNN=OFF -DLITE_WITH_CUDA=OFF
-DLITE_WITH_X86=OFF -DWITH_MKLDNN=OFF
-DLITE_WITH_LIGHT_WEIGHT_FRAMEWORK=ON -DLITE_WITH_X86=OFF
-DLITE_WITH_PROFILE=OFF -DLITE_WITH_LIGHT_WEIGHT_FRAMEWORK=ON
-DARM_TARGET_OS=armlinux -DLITE_WITH_PROFILE=OFF
-DWITH_LITE=ON -DARM_TARGET_OS=armlinux
-DWITH_PYTHON=OFF -DWITH_LITE=ON
-DWITH_TESTING=OFF -DWITH_PYTHON=OFF
-DLITE_BUILD_EXTRA=ON -DWITH_TESTING=OFF
-DLITE_WITH_XPU=${LITE_WITH_XPU} -DLITE_BUILD_EXTRA=ON
-DXPU_SDK_URL=${XPU_BASE_URL} -DLITE_WITH_XPU=${LITE_WITH_XPU}
-DXPU_SDK_ENV=${XPU_SDK_ENV} -DXPU_SDK_URL=${XPU_BASE_URL}
-DLITE_WITH_NNADAPTER=${LITE_WITH_NNADAPTER} -DXPU_SDK_ENV=${XPU_SDK_ENV}
-DNNADAPTER_WITH_HUAWEI_ASCEND_NPU=${NNADAPTER_WITH_HUAWEI_ASCEND_NPU} -DLITE_WITH_NNADAPTER=${LITE_WITH_NNADAPTER}
-DNNADAPTER_HUAWEI_ASCEND_NPU_SDK_ROOT=${NPU_SDK_ROOT} -DNNADAPTER_WITH_HUAWEI_ASCEND_NPU=${NNADAPTER_WITH_HUAWEI_ASCEND_NPU}
-DLITE_WITH_CODE_META_INFO=OFF -DNNADAPTER_HUAWEI_ASCEND_NPU_SDK_ROOT=${NPU_SDK_ROOT}
-DLITE_WITH_ARM=ON) -DLITE_WITH_CODE_META_INFO=OFF
-DLITE_WITH_ARM=ON)
ExternalProject_Add( ExternalProject_Add(
${LITE_PROJECT} ${LITE_PROJECT}
${EXTERNAL_PROJECT_LOG_ARGS} ${EXTERNAL_PROJECT_LOG_ARGS}
GIT_REPOSITORY "${GIT_URL}/PaddlePaddle/Paddle-Lite.git" GIT_REPOSITORY "${GIT_URL}/PaddlePaddle/Paddle-Lite.git"
GIT_TAG ${LITE_GIT_TAG} GIT_TAG ${LITE_GIT_TAG}
PREFIX ${LITE_PREFIX_DIR} PREFIX ${LITE_PREFIX_DIR}
PATCH_COMMAND mkdir -p ${LITE_PREFIX_DIR}/src/extern_lite-build/lite/gen_code && touch ${LITE_PREFIX_DIR}/src/extern_lite-build/lite/gen_code/__generated_code__.cc && sed -i "/aarch64-linux-gnu-gcc/d" ${LITE_PREFIX_DIR}/src/extern_lite/cmake/os/armlinux.cmake && sed -i "/aarch64-linux-gnu-g++/d" ${LITE_PREFIX_DIR}/src/extern_lite/cmake/os/armlinux.cmake PATCH_COMMAND
UPDATE_COMMAND "" mkdir -p ${LITE_PREFIX_DIR}/src/extern_lite-build/lite/gen_code && touch
BUILD_COMMAND ${LITE_BUILD_COMMAND} ${LITE_PREFIX_DIR}/src/extern_lite-build/lite/gen_code/__generated_code__.cc
INSTALL_COMMAND "" && sed -i "/aarch64-linux-gnu-gcc/d"
CMAKE_ARGS -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} ${LITE_PREFIX_DIR}/src/extern_lite/cmake/os/armlinux.cmake && sed -i
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} "/aarch64-linux-gnu-g++/d"
-DCMAKE_CXX_FLAGS=${LITE_CMAKE_CXX_FLAGS} ${LITE_PREFIX_DIR}/src/extern_lite/cmake/os/armlinux.cmake
-DCMAKE_CXX_FLAGS_RELEASE=${CMAKE_CXX_FLAGS_RELEASE} UPDATE_COMMAND ""
-DCMAKE_CXX_FLAGS_DEBUG=${CMAKE_CXX_FLAGS_DEBUG} BUILD_COMMAND ${LITE_BUILD_COMMAND}
-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS} INSTALL_COMMAND ""
-DCMAKE_C_FLAGS_DEBUG=${CMAKE_C_FLAGS_DEBUG} CMAKE_ARGS -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
-DCMAKE_C_FLAGS_RELEASE=${CMAKE_C_FLAGS_RELEASE} -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCMAKE_CXX_FLAGS=${LITE_CMAKE_CXX_FLAGS}
-DCMAKE_BUILD_TYPE=${THIRD_PARTY_BUILD_TYPE} -DCMAKE_CXX_FLAGS_RELEASE=${CMAKE_CXX_FLAGS_RELEASE}
${EXTERNAL_OPTIONAL_ARGS} -DCMAKE_CXX_FLAGS_DEBUG=${CMAKE_CXX_FLAGS_DEBUG}
${LITE_OPTIONAL_ARGS} -DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
) -DCMAKE_C_FLAGS_DEBUG=${CMAKE_C_FLAGS_DEBUG}
-DCMAKE_C_FLAGS_RELEASE=${CMAKE_C_FLAGS_RELEASE}
-DCMAKE_POSITION_INDEPENDENT_CODE=ON
-DCMAKE_BUILD_TYPE=${THIRD_PARTY_BUILD_TYPE}
${EXTERNAL_OPTIONAL_ARGS}
${LITE_OPTIONAL_ARGS})
else() else()
set(LITE_BUILD_COMMAND $(MAKE) publish_inference -j) set(LITE_BUILD_COMMAND $(MAKE) publish_inference -j)
set(LITE_OPTIONAL_ARGS -DWITH_MKL=ON set(LITE_OPTIONAL_ARGS
-DLITE_WITH_CUDA=${WITH_GPU} -DWITH_MKL=ON
-DWITH_MKLDNN=OFF -DLITE_WITH_CUDA=${WITH_GPU}
-DLITE_WITH_X86=ON -DWITH_MKLDNN=OFF
-DLITE_WITH_PROFILE=OFF -DLITE_WITH_X86=ON
-DWITH_LITE=OFF -DLITE_WITH_PROFILE=OFF
-DLITE_WITH_LIGHT_WEIGHT_FRAMEWORK=OFF -DWITH_LITE=OFF
-DWITH_PYTHON=OFF -DLITE_WITH_LIGHT_WEIGHT_FRAMEWORK=OFF
-DWITH_TESTING=OFF -DWITH_PYTHON=OFF
-DLITE_BUILD_EXTRA=ON -DWITH_TESTING=OFF
-DCUDNN_ROOT=${CUDNN_ROOT} -DLITE_BUILD_EXTRA=ON
-DLITE_WITH_STATIC_CUDA=OFF -DCUDNN_ROOT=${CUDNN_ROOT}
-DCUDA_ARCH_NAME=${CUDA_ARCH_NAME} -DLITE_WITH_STATIC_CUDA=OFF
-DLITE_WITH_XPU=${LITE_WITH_XPU} -DCUDA_ARCH_NAME=${CUDA_ARCH_NAME}
-DXPU_SDK_URL=${XPU_BASE_URL} -DLITE_WITH_XPU=${LITE_WITH_XPU}
-DXPU_SDK_ENV=${XPU_SDK_ENV} -DXPU_SDK_URL=${XPU_BASE_URL}
-DLITE_WITH_NNADAPTER=${LITE_WITH_NNADAPTER} -DXPU_SDK_ENV=${XPU_SDK_ENV}
-DNNADAPTER_WITH_HUAWEI_ASCEND_NPU=${NNADAPTER_WITH_HUAWEI_ASCEND_NPU} -DLITE_WITH_NNADAPTER=${LITE_WITH_NNADAPTER}
-DNNADAPTER_HUAWEI_ASCEND_NPU_SDK_ROOT=${NPU_SDK_ROOT} -DNNADAPTER_WITH_HUAWEI_ASCEND_NPU=${NNADAPTER_WITH_HUAWEI_ASCEND_NPU}
-DLITE_WITH_CODE_META_INFO=OFF -DNNADAPTER_HUAWEI_ASCEND_NPU_SDK_ROOT=${NPU_SDK_ROOT}
-DLITE_WITH_ARM=OFF) -DLITE_WITH_CODE_META_INFO=OFF
-DLITE_WITH_ARM=OFF)
ExternalProject_Add( ExternalProject_Add(
${LITE_PROJECT} ${LITE_PROJECT}
${EXTERNAL_PROJECT_LOG_ARGS} ${EXTERNAL_PROJECT_LOG_ARGS}
GIT_REPOSITORY "${GIT_URL}/PaddlePaddle/Paddle-Lite.git" GIT_REPOSITORY "${GIT_URL}/PaddlePaddle/Paddle-Lite.git"
GIT_TAG ${LITE_GIT_TAG} GIT_TAG ${LITE_GIT_TAG}
PREFIX ${LITE_PREFIX_DIR} PREFIX ${LITE_PREFIX_DIR}
UPDATE_COMMAND "" UPDATE_COMMAND ""
PATCH_COMMAND sed -i "s?NNadapter_bridges_path = os.path.abspath('..')+\"\/lite\/kernels\/nnadapter\/bridges\/paddle_use_bridges.h\"?NNadapter_bridges_path = os.path.abspath(\'..\')+\"\/extern_lite\/lite\/kernels\/nnadapter\/bridges\/paddle_use_bridges.h\"?" ${LITE_PREFIX_DIR}/src/extern_lite//lite/tools/cmake_tools/record_supported_kernel_op.py PATCH_COMMAND
BUILD_COMMAND ${LITE_BUILD_COMMAND} sed -i
INSTALL_COMMAND "" "s?NNadapter_bridges_path = os.path.abspath('..')+\"\/lite\/kernels\/nnadapter\/bridges\/paddle_use_bridges.h\"?NNadapter_bridges_path = os.path.abspath(\'..\')+\"\/extern_lite\/lite\/kernels\/nnadapter\/bridges\/paddle_use_bridges.h\"?"
CMAKE_ARGS -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} ${LITE_PREFIX_DIR}/src/extern_lite//lite/tools/cmake_tools/record_supported_kernel_op.py
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} BUILD_COMMAND ${LITE_BUILD_COMMAND}
-DCMAKE_CXX_FLAGS=${LITE_CMAKE_CXX_FLAGS} INSTALL_COMMAND ""
-DCMAKE_CXX_FLAGS_RELEASE=${CMAKE_CXX_FLAGS_RELEASE} CMAKE_ARGS -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
-DCMAKE_CXX_FLAGS_DEBUG=${CMAKE_CXX_FLAGS_DEBUG} -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS} -DCMAKE_CXX_FLAGS=${LITE_CMAKE_CXX_FLAGS}
-DCMAKE_C_FLAGS_DEBUG=${CMAKE_C_FLAGS_DEBUG} -DCMAKE_CXX_FLAGS_RELEASE=${CMAKE_CXX_FLAGS_RELEASE}
-DCMAKE_C_FLAGS_RELEASE=${CMAKE_C_FLAGS_RELEASE} -DCMAKE_CXX_FLAGS_DEBUG=${CMAKE_CXX_FLAGS_DEBUG}
-DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
-DCMAKE_BUILD_TYPE=${THIRD_PARTY_BUILD_TYPE} -DCMAKE_C_FLAGS_DEBUG=${CMAKE_C_FLAGS_DEBUG}
${EXTERNAL_OPTIONAL_ARGS} -DCMAKE_C_FLAGS_RELEASE=${CMAKE_C_FLAGS_RELEASE}
${LITE_OPTIONAL_ARGS} -DCMAKE_POSITION_INDEPENDENT_CODE=ON
) -DCMAKE_BUILD_TYPE=${THIRD_PARTY_BUILD_TYPE}
${EXTERNAL_OPTIONAL_ARGS}
${LITE_OPTIONAL_ARGS})
endif() endif()
ExternalProject_Get_property(${LITE_PROJECT} BINARY_DIR) ExternalProject_Get_Property(${LITE_PROJECT} BINARY_DIR)
ExternalProject_Get_property(${LITE_PROJECT} SOURCE_DIR) ExternalProject_Get_Property(${LITE_PROJECT} SOURCE_DIR)
set(LITE_BINARY_DIR ${BINARY_DIR}) set(LITE_BINARY_DIR ${BINARY_DIR})
set(LITE_SOURCE_DIR ${SOURCE_DIR}) set(LITE_SOURCE_DIR ${SOURCE_DIR})
endif() endif()
if (WITH_ARM) if(WITH_ARM)
if(LITE_WITH_XPU) if(LITE_WITH_XPU)
set(LITE_OUTPUT_BIN_DIR inference_lite_lib.armlinux.armv8.xpu) set(LITE_OUTPUT_BIN_DIR inference_lite_lib.armlinux.armv8.xpu)
elseif(LITE_WITH_NNADAPTER) elseif(LITE_WITH_NNADAPTER)
message("Enable LITE_WITH_NNADAPTER") message("Enable LITE_WITH_NNADAPTER")
if (NNADAPTER_WITH_HUAWEI_ASCEND_NPU) if(NNADAPTER_WITH_HUAWEI_ASCEND_NPU)
set(LITE_OUTPUT_BIN_DIR inference_lite_lib.armlinux.armv8.nnadapter) set(LITE_OUTPUT_BIN_DIR inference_lite_lib.armlinux.armv8.nnadapter)
endif() endif()
else() else()
...@@ -184,22 +195,32 @@ endif() ...@@ -184,22 +195,32 @@ endif()
function(external_lite_libs alias path) function(external_lite_libs alias path)
add_library(${alias} SHARED IMPORTED GLOBAL) add_library(${alias} SHARED IMPORTED GLOBAL)
SET_PROPERTY(TARGET ${alias} PROPERTY IMPORTED_LOCATION set_property(TARGET ${alias} PROPERTY IMPORTED_LOCATION ${path})
${path}) if(LITE_PROJECT)
if (LITE_PROJECT)
add_dependencies(${alias} ${LITE_PROJECT}) add_dependencies(${alias} ${LITE_PROJECT})
endif() endif()
endfunction() endfunction()
external_lite_libs(lite_full_static ${LITE_BINARY_DIR}/${LITE_OUTPUT_BIN_DIR}/cxx/lib/libpaddle_full_api_shared.so) external_lite_libs(
set(LITE_SHARED_LIB ${LITE_BINARY_DIR}/${LITE_OUTPUT_BIN_DIR}/cxx/lib/libpaddle_full_api_shared.so) lite_full_static
${LITE_BINARY_DIR}/${LITE_OUTPUT_BIN_DIR}/cxx/lib/libpaddle_full_api_shared.so
)
set(LITE_SHARED_LIB
${LITE_BINARY_DIR}/${LITE_OUTPUT_BIN_DIR}/cxx/lib/libpaddle_full_api_shared.so
)
if (LITE_WITH_NNADAPTER) if(LITE_WITH_NNADAPTER)
set(LITE_NNADAPTER_LIB ${LITE_BINARY_DIR}/${LITE_OUTPUT_BIN_DIR}/cxx/lib/libnnadapter.so) set(LITE_NNADAPTER_LIB
if (NNADAPTER_WITH_HUAWEI_ASCEND_NPU) ${LITE_BINARY_DIR}/${LITE_OUTPUT_BIN_DIR}/cxx/lib/libnnadapter.so)
external_lite_libs(lite_nnadapter ${LITE_BINARY_DIR}/${LITE_OUTPUT_BIN_DIR}/cxx/lib/libnnadapter.so ${LITE_BINARY_DIR}/${LITE_OUTPUT_BIN_DIR}/cxx/lib/libhuawei_ascend_npu.so) if(NNADAPTER_WITH_HUAWEI_ASCEND_NPU)
external_lite_libs(
lite_nnadapter
${LITE_BINARY_DIR}/${LITE_OUTPUT_BIN_DIR}/cxx/lib/libnnadapter.so
${LITE_BINARY_DIR}/${LITE_OUTPUT_BIN_DIR}/cxx/lib/libhuawei_ascend_npu.so)
set(LITE_DEPS lite_full_static lite_nnadapter) set(LITE_DEPS lite_full_static lite_nnadapter)
set(LITE_NNADAPTER_NPU_LIB ${LITE_BINARY_DIR}/${LITE_OUTPUT_BIN_DIR}/cxx/lib/libhuawei_ascend_npu.so) set(LITE_NNADAPTER_NPU_LIB
${LITE_BINARY_DIR}/${LITE_OUTPUT_BIN_DIR}/cxx/lib/libhuawei_ascend_npu.so
)
endif() endif()
else() else()
set(LITE_DEPS lite_full_static) set(LITE_DEPS lite_full_static)
......
include(FetchContent) include(FetchContent)
set(LLVM_DOWNLOAD_URL https://paddle-inference-dist.bj.bcebos.com/infrt/llvm_b5149f4e66a49a98b67e8e2de4e24a4af8e2781b.tar.gz) set(LLVM_DOWNLOAD_URL
https://paddle-inference-dist.bj.bcebos.com/infrt/llvm_b5149f4e66a49a98b67e8e2de4e24a4af8e2781b.tar.gz
)
set(LLVM_MD5 022819bb5760817013cf4b8a37e97d5e) set(LLVM_MD5 022819bb5760817013cf4b8a37e97d5e)
set(FETCHCONTENT_BASE_DIR ${THIRD_PARTY_PATH}/llvm) set(FETCHCONTENT_BASE_DIR ${THIRD_PARTY_PATH}/llvm)
set(FETCHCONTENT_QUIET OFF) set(FETCHCONTENT_QUIET OFF)
FetchContent_Declare(external_llvm FetchContent_Declare(
external_llvm
URL ${LLVM_DOWNLOAD_URL} URL ${LLVM_DOWNLOAD_URL}
URL_MD5 ${LLVM_MD5} URL_MD5 ${LLVM_MD5}
PREFIX ${THIRD_PARTY_PATH}/llvm PREFIX ${THIRD_PARTY_PATH}/llvm SOURCE_DIR ${THIRD_PARTY_PATH}/install/llvm)
SOURCE_DIR ${THIRD_PARTY_PATH}/install/llvm if(NOT LLVM_PATH)
)
if (NOT LLVM_PATH)
FetchContent_GetProperties(external_llvm) FetchContent_GetProperties(external_llvm)
if (NOT external_llvm_POPULATED) if(NOT external_llvm_POPULATED)
FetchContent_Populate(external_llvm) FetchContent_Populate(external_llvm)
endif() endif()
set(LLVM_PATH ${THIRD_PARTY_PATH}/install/llvm) set(LLVM_PATH ${THIRD_PARTY_PATH}/install/llvm)
set(LLVM_DIR ${THIRD_PARTY_PATH}/install/llvm/lib/cmake/llvm) set(LLVM_DIR ${THIRD_PARTY_PATH}/install/llvm/lib/cmake/llvm)
set(MLIR_DIR ${THIRD_PARTY_PATH}/install/llvm/lib/cmake/mlir) set(MLIR_DIR ${THIRD_PARTY_PATH}/install/llvm/lib/cmake/mlir)
else () else()
set(LLVM_DIR ${LLVM_PATH}/lib/cmake/llvm) set(LLVM_DIR ${LLVM_PATH}/lib/cmake/llvm)
set(MLIR_DIR ${LLVM_PATH}/lib/cmake/mlir) set(MLIR_DIR ${LLVM_PATH}/lib/cmake/mlir)
endif() endif()
if (${CMAKE_CXX_COMPILER} STREQUAL "clang++") if(${CMAKE_CXX_COMPILER} STREQUAL "clang++")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -stdlib=libc++ -lc++abi") set(CMAKE_EXE_LINKER_FLAGS
"${CMAKE_EXE_LINKER_FLAGS} -stdlib=libc++ -lc++abi")
endif() endif()
message(STATUS "set LLVM_DIR: ${LLVM_DIR}") message(STATUS "set LLVM_DIR: ${LLVM_DIR}")
...@@ -66,8 +68,17 @@ cmake ../llvm -G "Unix Makefiles" \ ...@@ -66,8 +68,17 @@ cmake ../llvm -G "Unix Makefiles" \
add_definitions(${LLVM_DEFINITIONS}) add_definitions(${LLVM_DEFINITIONS})
llvm_map_components_to_libnames(llvm_libs Support Core irreader llvm_map_components_to_libnames(
X86 executionengine orcjit mcjit all codegen) llvm_libs
Support
Core
irreader
X86
executionengine
orcjit
mcjit
all
codegen)
message(STATUS "LLVM libs: ${llvm_libs}") message(STATUS "LLVM libs: ${llvm_libs}")
...@@ -75,23 +86,24 @@ get_property(mlir_libs GLOBAL PROPERTY MLIR_ALL_LIBS) ...@@ -75,23 +86,24 @@ get_property(mlir_libs GLOBAL PROPERTY MLIR_ALL_LIBS)
message(STATUS "MLIR libs: ${mlir_libs}") message(STATUS "MLIR libs: ${mlir_libs}")
add_definitions(${LLVM_DEFINITIONS}) add_definitions(${LLVM_DEFINITIONS})
# The minimum needed libraries for MLIR IR parse and transform. # The minimum needed libraries for MLIR IR parse and transform.
set(MLIR_IR_LIBS MLIRAnalysis MLIRPass MLIRParser MLIRDialect MLIRIR MLIROptLib) set(MLIR_IR_LIBS MLIRAnalysis MLIRPass MLIRParser MLIRDialect MLIRIR MLIROptLib)
# tb_base is the name of a xxx.td file (without the .td suffix) # tb_base is the name of a xxx.td file (without the .td suffix)
function(mlir_tablegen_on td_base) function(mlir_tablegen_on td_base)
set(options) set(options)
set(oneValueArgs DIALECT) set(oneValueArgs DIALECT)
cmake_parse_arguments(mlir_tablegen_on "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) cmake_parse_arguments(mlir_tablegen_on "${options}" "${oneValueArgs}"
"${multiValueArgs}" ${ARGN})
set(LLVM_TARGET_DEFINITIONS ${td_base}.td) set(LLVM_TARGET_DEFINITIONS ${td_base}.td)
mlir_tablegen(${td_base}.hpp.inc -gen-op-decls) mlir_tablegen(${td_base}.hpp.inc -gen-op-decls)
mlir_tablegen(${td_base}.cpp.inc -gen-op-defs) mlir_tablegen(${td_base}.cpp.inc -gen-op-defs)
if (mlir_tablegen_on_DIALECT) if(mlir_tablegen_on_DIALECT)
mlir_tablegen(${td_base}_dialect.hpp.inc --gen-dialect-decls -dialect=${mlir_tablegen_on_DIALECT}) mlir_tablegen(${td_base}_dialect.hpp.inc --gen-dialect-decls
mlir_tablegen(${td_base}_dialect.cpp.inc --gen-dialect-defs -dialect=${mlir_tablegen_on_DIALECT}) -dialect=${mlir_tablegen_on_DIALECT})
mlir_tablegen(${td_base}_dialect.cpp.inc --gen-dialect-defs
-dialect=${mlir_tablegen_on_DIALECT})
endif() endif()
add_public_tablegen_target(${td_base}_IncGen) add_public_tablegen_target(${td_base}_IncGen)
add_custom_target(${td_base}_inc DEPENDS ${td_base}_IncGen) add_custom_target(${td_base}_inc DEPENDS ${td_base}_IncGen)
...@@ -99,7 +111,9 @@ endfunction() ...@@ -99,7 +111,9 @@ endfunction()
function(mlir_add_rewriter td_base) function(mlir_add_rewriter td_base)
set(LLVM_TARGET_DEFINITIONS ${td_base}.td) set(LLVM_TARGET_DEFINITIONS ${td_base}.td)
set(LLVM_TARGET_DEPENDS ${LLVM_TARGET_DEPENDS} ${CMAKE_SOURCE_DIR}/paddle/infrt/dialect/infrt/ir/infrt_base.td) set(LLVM_TARGET_DEPENDS
${LLVM_TARGET_DEPENDS}
${CMAKE_SOURCE_DIR}/paddle/infrt/dialect/infrt/ir/infrt_base.td)
mlir_tablegen(${td_base}.cpp.inc -gen-rewriters) mlir_tablegen(${td_base}.cpp.inc -gen-rewriters)
add_public_tablegen_target(MLIR${td_base}IncGen) add_public_tablegen_target(MLIR${td_base}IncGen)
add_dependencies(mlir-headers MLIR${td_base}IncGen) add_dependencies(mlir-headers MLIR${td_base}IncGen)
...@@ -108,7 +122,11 @@ endfunction() ...@@ -108,7 +122,11 @@ endfunction()
# Execute the mlir script with infrt-exec program. # Execute the mlir script with infrt-exec program.
# @name: name of the test # @name: name of the test
# @script: path to the mlir script file # @script: path to the mlir script file
function (infrt_exec_check name script) function(infrt_exec_check name script)
add_test(NAME ${name} add_test(
COMMAND sh -c "${CMAKE_BINARY_DIR}/paddle/infrt/host_context/infrt-exec -i ${CMAKE_CURRENT_SOURCE_DIR}/${script}| ${LLVM_PATH}/bin/FileCheck ${CMAKE_CURRENT_SOURCE_DIR}/${script}") NAME ${name}
COMMAND
sh -c
"${CMAKE_BINARY_DIR}/paddle/infrt/host_context/infrt-exec -i ${CMAKE_CURRENT_SOURCE_DIR}/${script}| ${LLVM_PATH}/bin/FileCheck ${CMAKE_CURRENT_SOURCE_DIR}/${script}"
)
endfunction() endfunction()
...@@ -12,108 +12,131 @@ ...@@ -12,108 +12,131 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
INCLUDE(ExternalProject) include(ExternalProject)
SET(MKLDNN_PROJECT "extern_mkldnn")
SET(MKLDNN_PREFIX_DIR ${THIRD_PARTY_PATH}/mkldnn)
SET(MKLDNN_INSTALL_DIR ${THIRD_PARTY_PATH}/install/mkldnn)
SET(MKLDNN_INC_DIR "${MKLDNN_INSTALL_DIR}/include" CACHE PATH "mkldnn include directory." FORCE)
SET(MKLDNN_REPOSITORY ${GIT_URL}/oneapi-src/oneDNN.git)
SET(MKLDNN_TAG 9b186765dded79066e0cd9c17eb70b680b76fb8e)
set(MKLDNN_PROJECT "extern_mkldnn")
set(MKLDNN_PREFIX_DIR ${THIRD_PARTY_PATH}/mkldnn)
set(MKLDNN_INSTALL_DIR ${THIRD_PARTY_PATH}/install/mkldnn)
set(MKLDNN_INC_DIR
"${MKLDNN_INSTALL_DIR}/include"
CACHE PATH "mkldnn include directory." FORCE)
set(MKLDNN_REPOSITORY ${GIT_URL}/oneapi-src/oneDNN.git)
set(MKLDNN_TAG 9b186765dded79066e0cd9c17eb70b680b76fb8e)
# Introduce variables: # Introduce variables:
# * CMAKE_INSTALL_LIBDIR # * CMAKE_INSTALL_LIBDIR
INCLUDE(GNUInstallDirs) include(GNUInstallDirs)
SET(LIBDIR "lib") set(LIBDIR "lib")
if(CMAKE_INSTALL_LIBDIR MATCHES ".*lib64$") if(CMAKE_INSTALL_LIBDIR MATCHES ".*lib64$")
SET(LIBDIR "lib64") set(LIBDIR "lib64")
endif() endif()
MESSAGE(STATUS "Set ${MKLDNN_INSTALL_DIR}/${LIBDIR} to runtime path") message(STATUS "Set ${MKLDNN_INSTALL_DIR}/${LIBDIR} to runtime path")
SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_RPATH}" "${MKLDNN_INSTALL_DIR}/${LIBDIR}") set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_RPATH}"
"${MKLDNN_INSTALL_DIR}/${LIBDIR}")
INCLUDE_DIRECTORIES(${MKLDNN_INC_DIR}) # For MKLDNN code to include internal headers.
include_directories(${MKLDNN_INC_DIR}
)# For MKLDNN code to include internal headers.
IF(NOT WIN32) if(NOT WIN32)
SET(MKLDNN_FLAG "-Wno-error=strict-overflow -Wno-error=unused-result -Wno-error=array-bounds") set(MKLDNN_FLAG
SET(MKLDNN_FLAG "${MKLDNN_FLAG} -Wno-unused-result -Wno-unused-value") "-Wno-error=strict-overflow -Wno-error=unused-result -Wno-error=array-bounds"
SET(MKLDNN_CFLAG "${CMAKE_C_FLAGS} ${MKLDNN_FLAG}") )
SET(MKLDNN_CXXFLAG "${CMAKE_CXX_FLAGS} ${MKLDNN_FLAG}") set(MKLDNN_FLAG "${MKLDNN_FLAG} -Wno-unused-result -Wno-unused-value")
SET(MKLDNN_CXXFLAG_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}") set(MKLDNN_CFLAG "${CMAKE_C_FLAGS} ${MKLDNN_FLAG}")
SET(MKLDNN_CFLAG_RELEASE "${CMAKE_C_FLAGS_RELEASE}") set(MKLDNN_CXXFLAG "${CMAKE_CXX_FLAGS} ${MKLDNN_FLAG}")
SET(MKLDNN_LIB "${MKLDNN_INSTALL_DIR}/${LIBDIR}/libdnnl.so" CACHE FILEPATH "mkldnn library." FORCE) set(MKLDNN_CXXFLAG_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
ELSE() set(MKLDNN_CFLAG_RELEASE "${CMAKE_C_FLAGS_RELEASE}")
SET(MKLDNN_CXXFLAG "${CMAKE_CXX_FLAGS} /EHsc") set(MKLDNN_LIB
SET(MKLDNN_CFLAG "${CMAKE_C_FLAGS}") "${MKLDNN_INSTALL_DIR}/${LIBDIR}/libdnnl.so"
string(REPLACE "/O2 " "" MKLDNN_CFLAG_RELEASE "${CMAKE_C_FLAGS_RELEASE}") CACHE FILEPATH "mkldnn library." FORCE)
string(REPLACE "/O2 " "" MKLDNN_CXXFLAG_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}") else()
SET(MKLDNN_LIB "${MKLDNN_INSTALL_DIR}/bin/mkldnn.lib" CACHE FILEPATH "mkldnn library." FORCE) set(MKLDNN_CXXFLAG "${CMAKE_CXX_FLAGS} /EHsc")
ENDIF(NOT WIN32) set(MKLDNN_CFLAG "${CMAKE_C_FLAGS}")
string(REPLACE "/O2 " "" MKLDNN_CFLAG_RELEASE "${CMAKE_C_FLAGS_RELEASE}")
string(REPLACE "/O2 " "" MKLDNN_CXXFLAG_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
set(MKLDNN_LIB
"${MKLDNN_INSTALL_DIR}/bin/mkldnn.lib"
CACHE FILEPATH "mkldnn library." FORCE)
endif(NOT WIN32)
ExternalProject_Add( ExternalProject_Add(
${MKLDNN_PROJECT} ${MKLDNN_PROJECT}
${EXTERNAL_PROJECT_LOG_ARGS} ${EXTERNAL_PROJECT_LOG_ARGS} ${SHALLOW_CLONE}
${SHALLOW_CLONE} GIT_REPOSITORY ${MKLDNN_REPOSITORY}
GIT_REPOSITORY ${MKLDNN_REPOSITORY} GIT_TAG ${MKLDNN_TAG}
GIT_TAG ${MKLDNN_TAG} DEPENDS ${MKLDNN_DEPENDS}
DEPENDS ${MKLDNN_DEPENDS} PREFIX ${MKLDNN_PREFIX_DIR}
PREFIX ${MKLDNN_PREFIX_DIR} UPDATE_COMMAND ""
UPDATE_COMMAND "" #BUILD_ALWAYS 1
#BUILD_ALWAYS 1 CMAKE_ARGS -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
CMAKE_ARGS -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} -DCMAKE_CXX_FLAGS=${MKLDNN_CXXFLAG}
-DCMAKE_CXX_FLAGS=${MKLDNN_CXXFLAG} -DCMAKE_CXX_FLAGS_RELEASE=${MKLDNN_CXXFLAG_RELEASE}
-DCMAKE_CXX_FLAGS_RELEASE=${MKLDNN_CXXFLAG_RELEASE} -DCMAKE_CXX_FLAGS_DEBUG=${CMAKE_CXX_FLAGS_DEBUG}
-DCMAKE_CXX_FLAGS_DEBUG=${CMAKE_CXX_FLAGS_DEBUG} -DCMAKE_C_FLAGS=${MKLDNN_CFLAG}
-DCMAKE_C_FLAGS=${MKLDNN_CFLAG} -DCMAKE_C_FLAGS_DEBUG=${CMAKE_C_FLAGS_DEBUG}
-DCMAKE_C_FLAGS_DEBUG=${CMAKE_C_FLAGS_DEBUG} -DCMAKE_C_FLAGS_RELEASE=${MKLDNN_CFLAG_RELEASE}
-DCMAKE_C_FLAGS_RELEASE=${MKLDNN_CFLAG_RELEASE} -DCMAKE_INSTALL_PREFIX=${MKLDNN_INSTALL_DIR}
-DCMAKE_INSTALL_PREFIX=${MKLDNN_INSTALL_DIR} -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DCMAKE_POSITION_INDEPENDENT_CODE=ON
-DCMAKE_POSITION_INDEPENDENT_CODE=ON -DDNNL_BUILD_TESTS=OFF
-DDNNL_BUILD_TESTS=OFF -DDNNL_BUILD_EXAMPLES=OFF -DDNNL_BUILD_EXAMPLES=OFF
CMAKE_CACHE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${MKLDNN_INSTALL_DIR} CMAKE_CACHE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${MKLDNN_INSTALL_DIR})
)
MESSAGE(STATUS "MKLDNN library: ${MKLDNN_LIB}") message(STATUS "MKLDNN library: ${MKLDNN_LIB}")
add_definitions(-DPADDLE_WITH_MKLDNN) add_definitions(-DPADDLE_WITH_MKLDNN)
# copy the real so.0 lib to install dir # copy the real so.0 lib to install dir
# it can be directly contained in wheel or capi # it can be directly contained in wheel or capi
if(WIN32) if(WIN32)
SET(MKLDNN_SHARED_LIB ${MKLDNN_INSTALL_DIR}/bin/mkldnn.dll) set(MKLDNN_SHARED_LIB ${MKLDNN_INSTALL_DIR}/bin/mkldnn.dll)
file(TO_NATIVE_PATH ${MKLDNN_INSTALL_DIR} NATIVE_MKLDNN_INSTALL_DIR) file(TO_NATIVE_PATH ${MKLDNN_INSTALL_DIR} NATIVE_MKLDNN_INSTALL_DIR)
file(TO_NATIVE_PATH ${MKLDNN_SHARED_LIB} NATIVE_MKLDNN_SHARED_LIB) file(TO_NATIVE_PATH ${MKLDNN_SHARED_LIB} NATIVE_MKLDNN_SHARED_LIB)
ADD_CUSTOM_COMMAND(OUTPUT ${MKLDNN_LIB} add_custom_command(
COMMAND (copy ${NATIVE_MKLDNN_INSTALL_DIR}\\bin\\dnnl.dll ${NATIVE_MKLDNN_SHARED_LIB} /Y) OUTPUT ${MKLDNN_LIB}
COMMAND dumpbin /exports ${MKLDNN_INSTALL_DIR}/bin/mkldnn.dll > ${MKLDNN_INSTALL_DIR}/bin/exports.txt COMMAND (copy ${NATIVE_MKLDNN_INSTALL_DIR}\\bin\\dnnl.dll
COMMAND echo LIBRARY mkldnn > ${MKLDNN_INSTALL_DIR}/bin/mkldnn.def ${NATIVE_MKLDNN_SHARED_LIB} /Y)
COMMAND echo EXPORTS >> ${MKLDNN_INSTALL_DIR}/bin/mkldnn.def COMMAND dumpbin /exports ${MKLDNN_INSTALL_DIR}/bin/mkldnn.dll >
COMMAND echo off && (for /f "skip=19 tokens=4" %A in (${MKLDNN_INSTALL_DIR}/bin/exports.txt) do echo %A >> ${MKLDNN_INSTALL_DIR}/bin/mkldnn.def) && echo on ${MKLDNN_INSTALL_DIR}/bin/exports.txt
COMMAND lib /def:${MKLDNN_INSTALL_DIR}/bin/mkldnn.def /out:${MKLDNN_LIB} /machine:x64 COMMAND echo LIBRARY mkldnn > ${MKLDNN_INSTALL_DIR}/bin/mkldnn.def
COMMENT "Generate mkldnn.lib manually--->" COMMAND echo EXPORTS >> ${MKLDNN_INSTALL_DIR}/bin/mkldnn.def
DEPENDS ${MKLDNN_PROJECT} COMMAND
VERBATIM) echo off && (for
ADD_CUSTOM_TARGET(mkldnn_cmd ALL DEPENDS ${MKLDNN_LIB}) /f
"skip=19 tokens=4"
%A
in
(${MKLDNN_INSTALL_DIR}/bin/exports.txt)
do
echo
%A
>>
${MKLDNN_INSTALL_DIR}/bin/mkldnn.def) && echo on
COMMAND lib /def:${MKLDNN_INSTALL_DIR}/bin/mkldnn.def /out:${MKLDNN_LIB}
/machine:x64
COMMENT "Generate mkldnn.lib manually--->"
DEPENDS ${MKLDNN_PROJECT}
VERBATIM)
add_custom_target(mkldnn_cmd ALL DEPENDS ${MKLDNN_LIB})
else(WIN32) else(WIN32)
SET(MKLDNN_SHARED_LIB ${MKLDNN_INSTALL_DIR}/libmkldnn.so.0) set(MKLDNN_SHARED_LIB ${MKLDNN_INSTALL_DIR}/libmkldnn.so.0)
SET(MKLDNN_SHARED_LIB_1 ${MKLDNN_INSTALL_DIR}/libdnnl.so.1) set(MKLDNN_SHARED_LIB_1 ${MKLDNN_INSTALL_DIR}/libdnnl.so.1)
SET(MKLDNN_SHARED_LIB_2 ${MKLDNN_INSTALL_DIR}/libdnnl.so.2) set(MKLDNN_SHARED_LIB_2 ${MKLDNN_INSTALL_DIR}/libdnnl.so.2)
ADD_CUSTOM_COMMAND(OUTPUT ${MKLDNN_SHARED_LIB_2} add_custom_command(
COMMAND ${CMAKE_COMMAND} -E copy ${MKLDNN_LIB} ${MKLDNN_SHARED_LIB} OUTPUT ${MKLDNN_SHARED_LIB_2}
COMMAND ${CMAKE_COMMAND} -E copy ${MKLDNN_LIB} ${MKLDNN_SHARED_LIB_1} COMMAND ${CMAKE_COMMAND} -E copy ${MKLDNN_LIB} ${MKLDNN_SHARED_LIB}
COMMAND ${CMAKE_COMMAND} -E copy ${MKLDNN_LIB} ${MKLDNN_SHARED_LIB_2} COMMAND ${CMAKE_COMMAND} -E copy ${MKLDNN_LIB} ${MKLDNN_SHARED_LIB_1}
DEPENDS ${MKLDNN_PROJECT}) COMMAND ${CMAKE_COMMAND} -E copy ${MKLDNN_LIB} ${MKLDNN_SHARED_LIB_2}
ADD_CUSTOM_TARGET(mkldnn_cmd ALL DEPENDS ${MKLDNN_SHARED_LIB_2}) DEPENDS ${MKLDNN_PROJECT})
add_custom_target(mkldnn_cmd ALL DEPENDS ${MKLDNN_SHARED_LIB_2})
endif(WIN32) endif(WIN32)
# generate a static dummy target to track mkldnn dependencies # generate a static dummy target to track mkldnn dependencies
# for cc_library(xxx SRCS xxx.c DEPS mkldnn) # for cc_library(xxx SRCS xxx.c DEPS mkldnn)
generate_dummy_static_lib(LIB_NAME "mkldnn" GENERATOR "mkldnn.cmake") generate_dummy_static_lib(LIB_NAME "mkldnn" GENERATOR "mkldnn.cmake")
TARGET_LINK_LIBRARIES(mkldnn ${MKLDNN_LIB} ${MKLML_IOMP_LIB}) target_link_libraries(mkldnn ${MKLDNN_LIB} ${MKLML_IOMP_LIB})
ADD_DEPENDENCIES(mkldnn ${MKLDNN_PROJECT} mkldnn_cmd) add_dependencies(mkldnn ${MKLDNN_PROJECT} mkldnn_cmd)
...@@ -12,59 +12,68 @@ ...@@ -12,59 +12,68 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
INCLUDE(ExternalProject) include(ExternalProject)
SET(MKLML_INSTALL_DIR ${THIRD_PARTY_PATH}/install/mklml) set(MKLML_INSTALL_DIR ${THIRD_PARTY_PATH}/install/mklml)
SET(MKLML_INC_DIR ${MKLML_INSTALL_DIR}/include) set(MKLML_INC_DIR ${MKLML_INSTALL_DIR}/include)
SET(MKLML_LIB_DIR ${MKLML_INSTALL_DIR}/lib) set(MKLML_LIB_DIR ${MKLML_INSTALL_DIR}/lib)
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_RPATH}" "${MKLML_LIB_DIR}") set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_RPATH}" "${MKLML_LIB_DIR}")
IF(WIN32) if(WIN32)
SET(MKLML_VER "mklml_win_2019.0.5.20190502" CACHE STRING "" FORCE) set(MKLML_VER
SET(MKLML_URL "https://paddlepaddledeps.bj.bcebos.com/${MKLML_VER}.zip" CACHE STRING "" FORCE) "mklml_win_2019.0.5.20190502"
SET(MKLML_URL_MD5 ff8c5237570f03eea37377ccfc95a08a) CACHE STRING "" FORCE)
SET(MKLML_LIB ${MKLML_LIB_DIR}/mklml.lib) set(MKLML_URL
SET(MKLML_IOMP_LIB ${MKLML_LIB_DIR}/libiomp5md.lib) "https://paddlepaddledeps.bj.bcebos.com/${MKLML_VER}.zip"
SET(MKLML_SHARED_LIB ${MKLML_LIB_DIR}/mklml.dll) CACHE STRING "" FORCE)
SET(MKLML_SHARED_IOMP_LIB ${MKLML_LIB_DIR}/libiomp5md.dll) set(MKLML_URL_MD5 ff8c5237570f03eea37377ccfc95a08a)
ELSE() set(MKLML_LIB ${MKLML_LIB_DIR}/mklml.lib)
#TODO(intel-huying): set(MKLML_IOMP_LIB ${MKLML_LIB_DIR}/libiomp5md.lib)
# Now enable csrmm function in mklml library temporarily, it will be updated as offical version later. set(MKLML_SHARED_LIB ${MKLML_LIB_DIR}/mklml.dll)
SET(MKLML_VER "csrmm_mklml_lnx_2019.0.5" CACHE STRING "" FORCE) set(MKLML_SHARED_IOMP_LIB ${MKLML_LIB_DIR}/libiomp5md.dll)
SET(MKLML_URL "http://paddlepaddledeps.bj.bcebos.com/${MKLML_VER}.tgz" CACHE STRING "" FORCE) else()
SET(MKLML_URL_MD5 bc6a7faea6a2a9ad31752386f3ae87da) #TODO(intel-huying):
SET(MKLML_LIB ${MKLML_LIB_DIR}/libmklml_intel.so) # Now enable csrmm function in mklml library temporarily, it will be updated as offical version later.
SET(MKLML_IOMP_LIB ${MKLML_LIB_DIR}/libiomp5.so) set(MKLML_VER
SET(MKLML_SHARED_LIB ${MKLML_LIB_DIR}/libmklml_intel.so) "csrmm_mklml_lnx_2019.0.5"
SET(MKLML_SHARED_IOMP_LIB ${MKLML_LIB_DIR}/libiomp5.so) CACHE STRING "" FORCE)
ENDIF() set(MKLML_URL
"http://paddlepaddledeps.bj.bcebos.com/${MKLML_VER}.tgz"
CACHE STRING "" FORCE)
set(MKLML_URL_MD5 bc6a7faea6a2a9ad31752386f3ae87da)
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)
endif()
SET(MKLML_PROJECT "extern_mklml") set(MKLML_PROJECT "extern_mklml")
MESSAGE(STATUS "MKLML_VER: ${MKLML_VER}, MKLML_URL: ${MKLML_URL}") message(STATUS "MKLML_VER: ${MKLML_VER}, MKLML_URL: ${MKLML_URL}")
SET(MKLML_PREFIX_DIR ${THIRD_PARTY_PATH}/mklml) set(MKLML_PREFIX_DIR ${THIRD_PARTY_PATH}/mklml)
SET(MKLML_SOURCE_DIR ${THIRD_PARTY_PATH}/mklml/src/extern_mklml) set(MKLML_SOURCE_DIR ${THIRD_PARTY_PATH}/mklml/src/extern_mklml)
# Ninja Generator can not establish the correct dependency relationship between the imported library with target, # 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 # 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 # https://stackoverflow.com/questions/54866067/cmake-and-ninja-missing-and-no-known-rule-to-make-it
# It is the same to all other ExternalProject. # It is the same to all other ExternalProject.
ExternalProject_Add( ExternalProject_Add(
${MKLML_PROJECT} ${MKLML_PROJECT}
${EXTERNAL_PROJECT_LOG_ARGS} ${EXTERNAL_PROJECT_LOG_ARGS}
URL ${MKLML_URL} URL ${MKLML_URL}
URL_MD5 ${MKLML_URL_MD5} URL_MD5 ${MKLML_URL_MD5}
PREFIX ${MKLML_PREFIX_DIR} PREFIX ${MKLML_PREFIX_DIR}
DOWNLOAD_NO_PROGRESS 1 DOWNLOAD_NO_PROGRESS 1
CONFIGURE_COMMAND "" CONFIGURE_COMMAND ""
BUILD_COMMAND "" BUILD_COMMAND ""
UPDATE_COMMAND "" UPDATE_COMMAND ""
INSTALL_COMMAND ${CMAKE_COMMAND} -E copy_directory ${MKLML_SOURCE_DIR}/include ${MKLML_INC_DIR} && INSTALL_COMMAND
${CMAKE_COMMAND} -E copy_directory ${MKLML_SOURCE_DIR}/lib ${MKLML_LIB_DIR} ${CMAKE_COMMAND} -E copy_directory ${MKLML_SOURCE_DIR}/include
BUILD_BYPRODUCTS ${MKLML_LIB} ${MKLML_INC_DIR} && ${CMAKE_COMMAND} -E copy_directory
BUILD_BYPRODUCTS ${MKLML_IOMP_LIB} ${MKLML_SOURCE_DIR}/lib ${MKLML_LIB_DIR}
) BUILD_BYPRODUCTS ${MKLML_LIB}
BUILD_BYPRODUCTS ${MKLML_IOMP_LIB})
INCLUDE_DIRECTORIES(${MKLML_INC_DIR}) include_directories(${MKLML_INC_DIR})
ADD_LIBRARY(mklml SHARED IMPORTED GLOBAL) add_library(mklml SHARED IMPORTED GLOBAL)
SET_PROPERTY(TARGET mklml PROPERTY IMPORTED_LOCATION ${MKLML_LIB}) set_property(TARGET mklml PROPERTY IMPORTED_LOCATION ${MKLML_LIB})
ADD_DEPENDENCIES(mklml ${MKLML_PROJECT}) add_dependencies(mklml ${MKLML_PROJECT})
此差异已折叠。
此差异已折叠。
此差异已折叠。
...@@ -14,30 +14,29 @@ ...@@ -14,30 +14,29 @@
include(ExternalProject) include(ExternalProject)
set(POCKETFFT_PATH
"${THIRD_PARTY_PATH}/pocketfft"
CACHE STRING "A path setting for external_pocketfft path.")
set(POCKETFFT_PREFIX_DIR ${POCKETFFT_PATH})
set(POCKETFFT_PATH "${THIRD_PARTY_PATH}/pocketfft" CACHE STRING "A path setting for external_pocketfft path.") set(POCKETFFT_REPOSITORY https://gitlab.mpcdf.mpg.de/mtr/pocketfft.git)
set(POCKETFFT_PREFIX_DIR ${POCKETFFT_PATH}) set(POCKETFFT_TAG release_for_eigen)
set(POCKETFFT_REPOSITORY https://gitlab.mpcdf.mpg.de/mtr/pocketfft.git) set(POCKETFFT_INCLUDE_DIR ${POCKETFFT_PREFIX_DIR}/src)
set(POCKETFFT_TAG release_for_eigen)
SET(POCKETFFT_INCLUDE_DIR ${POCKETFFT_PREFIX_DIR}/src)
message("POCKETFFT_INCLUDE_DIR is ${POCKETFFT_INCLUDE_DIR}") message("POCKETFFT_INCLUDE_DIR is ${POCKETFFT_INCLUDE_DIR}")
include_directories(${POCKETFFT_INCLUDE_DIR}) include_directories(${POCKETFFT_INCLUDE_DIR})
ExternalProject_Add( ExternalProject_Add(
extern_pocketfft extern_pocketfft
${EXTERNAL_PROJECT_LOG_ARGS} ${EXTERNAL_PROJECT_LOG_ARGS} ${SHALLOW_CLONE}
${SHALLOW_CLONE} GIT_REPOSITORY ${POCKETFFT_REPOSITORY}
GIT_REPOSITORY ${POCKETFFT_REPOSITORY} GIT_TAG ${POCKETFFT_TAG}
GIT_TAG ${POCKETFFT_TAG} PREFIX ${POCKETFFT_PREFIX_DIR}
PREFIX ${POCKETFFT_PREFIX_DIR} UPDATE_COMMAND ""
UPDATE_COMMAND ""
CONFIGURE_COMMAND "" CONFIGURE_COMMAND ""
BUILD_COMMAND "" BUILD_COMMAND ""
INSTALL_COMMAND "" INSTALL_COMMAND ""
TEST_COMMAND "" TEST_COMMAND "")
)
add_library(pocketfft INTERFACE) add_library(pocketfft INTERFACE)
......
...@@ -14,7 +14,12 @@ ...@@ -14,7 +14,12 @@
macro(find_popart_version popart_version_file) macro(find_popart_version popart_version_file)
file(READ ${popart_version_file} popart_version_file_content) file(READ ${popart_version_file} popart_version_file_content)
string(REGEX MATCH "(POPART_VERSION_STRING)[ \t\r\n](\")([0-9]+\.[0-9]+\.[0-9]+)(\\+)([A-Za-z0-9_]*)(\")" POPART_VERSION ${popart_version_file_content}) string(
REGEX
MATCH
"(POPART_VERSION_STRING)[ \t\r\n](\")([0-9]+\.[0-9]+\.[0-9]+)(\\+)([A-Za-z0-9_]*)(\")"
POPART_VERSION
${popart_version_file_content})
string(REPLACE "POPART_VERSION_STRING" "" POPART_VERSION "${POPART_VERSION}") string(REPLACE "POPART_VERSION_STRING" "" POPART_VERSION "${POPART_VERSION}")
string(REPLACE "\"" "" POPART_VERSION "${POPART_VERSION}") string(REPLACE "\"" "" POPART_VERSION "${POPART_VERSION}")
string(REPLACE " " "" POPART_VERSION "${POPART_VERSION}") string(REPLACE " " "" POPART_VERSION "${POPART_VERSION}")
...@@ -28,7 +33,11 @@ endmacro() ...@@ -28,7 +33,11 @@ endmacro()
if(WITH_IPU) if(WITH_IPU)
set(POPLAR_DIR CACHE PATH "Path to a Poplar install") set(POPLAR_DIR CACHE PATH "Path to a Poplar install")
set(POPART_DIR CACHE PATH "Path to a Popart install") set(POPART_DIR CACHE PATH "Path to a Popart install")
set(POPLAR_SDK_DIR CACHE PATH "Path to an extracted SDK archive or to a Poplar & Popart install directory (Will populate POPLAR_DIR and POPART_DIR)") set(POPLAR_SDK_DIR
CACHE
PATH
"Path to an extracted SDK archive or to a Poplar & Popart install directory (Will populate POPLAR_DIR and POPART_DIR)"
)
# support setting SDK both from environment variable or command line arguments # support setting SDK both from environment variable or command line arguments
...@@ -36,10 +45,15 @@ if(WITH_IPU) ...@@ -36,10 +45,15 @@ if(WITH_IPU)
set(POPLAR_SDK_DIR $ENV{POPLAR_SDK_DIR}) set(POPLAR_SDK_DIR $ENV{POPLAR_SDK_DIR})
endif() endif()
if(EXISTS ${POPLAR_SDK_DIR}) if(EXISTS ${POPLAR_SDK_DIR})
execute_process(COMMAND find ${POPLAR_SDK_DIR}/ -maxdepth 1 -type d -name "popart*" execute_process(
OUTPUT_VARIABLE POPART_DIR OUTPUT_STRIP_TRAILING_WHITESPACE) COMMAND find ${POPLAR_SDK_DIR}/ -maxdepth 1 -type d -name "popart*"
execute_process(COMMAND find ${POPLAR_SDK_DIR}/ -maxdepth 1 -type d -name "poplar-*" -o -name "poplar" OUTPUT_VARIABLE POPART_DIR
OUTPUT_VARIABLE POPLAR_DIR OUTPUT_STRIP_TRAILING_WHITESPACE) OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(
COMMAND find ${POPLAR_SDK_DIR}/ -maxdepth 1 -type d -name "poplar-*" -o
-name "poplar"
OUTPUT_VARIABLE POPLAR_DIR
OUTPUT_STRIP_TRAILING_WHITESPACE)
endif() endif()
if(DEFINED ENV{POPLAR_DIR}) if(DEFINED ENV{POPLAR_DIR})
set(POPLAR_DIR $ENV{POPLAR_DIR}) set(POPLAR_DIR $ENV{POPLAR_DIR})
...@@ -51,7 +65,10 @@ if(WITH_IPU) ...@@ -51,7 +65,10 @@ if(WITH_IPU)
if(EXISTS ${POPLAR_DIR}) if(EXISTS ${POPLAR_DIR})
message("POPLAR_DIR is ${POPLAR_DIR}") message("POPLAR_DIR is ${POPLAR_DIR}")
if(NOT IS_DIRECTORY "${POPLAR_DIR}") if(NOT IS_DIRECTORY "${POPLAR_DIR}")
message(FATAL_ERROR "Couldn't find a \"poplar\" or \"poplar-*\" folder in '${POPLAR_SDK_DIR}'") message(
FATAL_ERROR
"Couldn't find a \"poplar\" or \"poplar-*\" folder in '${POPLAR_SDK_DIR}'"
)
endif() endif()
list(APPEND CMAKE_PREFIX_PATH ${POPLAR_DIR}) list(APPEND CMAKE_PREFIX_PATH ${POPLAR_DIR})
set(ENABLE_POPLAR_CMD "source ${POPLAR_DIR}/enable.sh") set(ENABLE_POPLAR_CMD "source ${POPLAR_DIR}/enable.sh")
...@@ -60,12 +77,16 @@ if(WITH_IPU) ...@@ -60,12 +77,16 @@ if(WITH_IPU)
link_directories("${POPLAR_DIR}/lib") link_directories("${POPLAR_DIR}/lib")
endif() endif()
if(NOT poplar_FOUND) if(NOT poplar_FOUND)
message(FATAL_ERROR "You must provide a path to a Poplar install using -DPOPLAR_DIR=/path/to/popart/build/install") message(
FATAL_ERROR
"You must provide a path to a Poplar install using -DPOPLAR_DIR=/path/to/popart/build/install"
)
endif() endif()
if(EXISTS ${POPART_DIR}) if(EXISTS ${POPART_DIR})
message("POPART_DIR is ${POPART_DIR}") message("POPART_DIR is ${POPART_DIR}")
if(NOT IS_DIRECTORY "${POPART_DIR}") if(NOT IS_DIRECTORY "${POPART_DIR}")
message(FATAL_ERROR "Couldn't find a \"popart*\" folder in '${POPLAR_SDK_DIR}'") message(
FATAL_ERROR "Couldn't find a \"popart*\" folder in '${POPLAR_SDK_DIR}'")
endif() endif()
list(APPEND CMAKE_PREFIX_PATH ${POPART_DIR}) list(APPEND CMAKE_PREFIX_PATH ${POPART_DIR})
set(ENABLE_POPART_CMD "source ${POPART_DIR}/enable.sh") set(ENABLE_POPART_CMD "source ${POPART_DIR}/enable.sh")
...@@ -74,7 +95,10 @@ if(WITH_IPU) ...@@ -74,7 +95,10 @@ if(WITH_IPU)
link_directories("${POPART_DIR}/lib") link_directories("${POPART_DIR}/lib")
endif() endif()
if(NOT popart_FOUND) if(NOT popart_FOUND)
message(FATAL_ERROR "You must provide a path to a Popart build using -DPOPART_DIR=/path/to/popart/build") message(
FATAL_ERROR
"You must provide a path to a Popart build using -DPOPART_DIR=/path/to/popart/build"
)
endif() endif()
find_popart_version("${POPART_DIR}/include/popart/version.hpp") find_popart_version("${POPART_DIR}/include/popart/version.hpp")
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
cc_library(
cc_library(afs_wrapper SRCS afs_warpper.cc DEPS fs ps_framework_proto) afs_wrapper
SRCS afs_warpper.cc
DEPS fs ps_framework_proto)
#set_property(GLOBAL PROPERTY COMMON_DEPS afs_warpper) #set_property(GLOBAL PROPERTY COMMON_DEPS afs_warpper)
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册