Commit 1eea5fe6 authored by Sang Ik Lee's avatar Sang Ik Lee Committed by Scott Cyphers

Silee2/external project rpath (#2525)

* Set rpath for mkl-dnn.

* Set library rpath to  on Linux.

* Use patchelf to set rpath of prebuilt mklml library.

* Add patchelf to Linux Dockerfiles.

* Revert "Add patchelf to Linux Dockerfiles."

This reverts commit 1769505a866061552942e19467ddcc0dad0922e8.

* Revert "Use patchelf to set rpath of prebuilt mklml library."

This reverts commit 726f6553a0450520328607177d64baf48fa93dd2.

* Copy cldnn runtime.

* Copy mlsl libraries.
parent 1a6f8487
......@@ -58,12 +58,8 @@ set(NGRAPH_INCLUDE_PATH
)
if (APPLE)
# Suppress an OS X-specific warning.
if (POLICY CMP0042)
cmake_policy(SET CMP0042 NEW)
else()
set(MACOS_RPATH ON)
endif()
# Enable MACOS_RPATH by default.
cmake_policy(SET CMP0042 NEW)
# Enable CMAKE_<LANG>_COMPILER_ID AppleClang
cmake_policy(SET CMP0025 NEW)
endif()
......@@ -256,6 +252,7 @@ if (LINUX)
else()
set(CMAKE_INSTALL_RPATH "$ORIGIN")
endif()
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
endif()
#-----------------------------------------------------------------------------------------------
......
......@@ -64,7 +64,22 @@ if (CLDNN_ROOT_DIR)
target_link_libraries(libcldnn INTERFACE ${CLDNN_LIBRARIES})
else()
ExternalProject_Get_Property(ext_cldnn SOURCE_DIR BINARY_DIR)
set(CLDNN_LIB ${CMAKE_SHARED_LIBRARY_PREFIX}clDNN64${CMAKE_SHARED_LIBRARY_SUFFIX})
ExternalProject_Add_Step(
ext_cldnn
CopyCLDNN
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${SOURCE_DIR}/build/out/Linux64/${CMAKE_BUILD_TYPE}/${CLDNN_LIB} ${NGRAPH_LIBRARY_OUTPUT_DIRECTORY}/${CLDNN_LIB}
COMMENT "Copy cldnn runtime libraries to ngraph build directory."
DEPENDEES install
)
add_dependencies(libcldnn ext_cldnn)
target_include_directories(libcldnn SYSTEM INTERFACE ${SOURCE_DIR}/api)
target_link_libraries(libcldnn INTERFACE ${SOURCE_DIR}/build/out/Linux64/${CMAKE_BUILD_TYPE}/${CMAKE_SHARED_LIBRARY_PREFIX}clDNN64${CMAKE_SHARED_LIBRARY_SUFFIX})
target_link_libraries(libcldnn INTERFACE ${NGRAPH_LIBRARY_OUTPUT_DIRECTORY}/${CLDNN_LIB})
install(
FILES
${NGRAPH_LIBRARY_OUTPUT_DIRECTORY}/${CLDNN_LIB}
DESTINATION
${NGRAPH_INSTALL_LIB}
OPTIONAL
)
endif()
......@@ -208,6 +208,9 @@ if (WIN32)
EXCLUDE_FROM_ALL TRUE
)
else()
if(LINUX)
set(MKLDNN_RPATH "-DCMAKE_INSTALL_RPATH=${CMAKE_INSTALL_RPATH}")
endif()
ExternalProject_Add(
ext_mkldnn
PREFIX mkldnn
......@@ -226,6 +229,7 @@ else()
-DWITH_TEST=FALSE
-DWITH_EXAMPLE=FALSE
-DCMAKE_INSTALL_PREFIX=${EXTERNAL_PROJECTS_ROOT}/mkldnn
${MKLDNN_RPATH}
-DMKLDNN_ENABLE_CONCURRENT_EXEC=ON
-DMKLROOT=${MKL_ROOT}
-DMKLDNN_LIB_VERSIONING_ENABLE=${NGRAPH_LIB_VERSIONING_ENABLE}
......
......@@ -46,12 +46,23 @@ ExternalProject_Add(
add_library(libmlsl INTERFACE)
ExternalProject_Get_Property(MLSL SOURCE_DIR)
ExternalProject_Get_Property(MLSL INSTALL_DIR)
set(MLSL_LIB_DIR ${INSTALL_DIR}/intel64/lib/thread)
set(MLSL_LIB ${CMAKE_SHARED_LIBRARY_PREFIX}mlsl${CMAKE_SHARED_LIBRARY_SUFFIX})
set(MPI_LIB ${CMAKE_SHARED_LIBRARY_PREFIX}mpi${CMAKE_SHARED_LIBRARY_SUFFIX})
set(FABRIC_LIB ${CMAKE_SHARED_LIBRARY_PREFIX}fabric${CMAKE_SHARED_LIBRARY_SUFFIX})
ExternalProject_Add_Step(
MLSL
CopyMLSL
COMMAND ${CMAKE_COMMAND} -E copy_directory ${MLSL_LIB_DIR} ${NGRAPH_LIBRARY_OUTPUT_DIRECTORY}
COMMENT "Copy mlsl runtime libraries to ngraph build directory."
DEPENDEES install
)
target_include_directories(libmlsl SYSTEM INTERFACE ${SOURCE_DIR}/include)
set(MLSL_LINK_LIBRARIES
${INSTALL_DIR}/intel64/lib/thread/${CMAKE_SHARED_LIBRARY_PREFIX}mlsl${CMAKE_SHARED_LIBRARY_SUFFIX}
${INSTALL_DIR}/intel64/lib/thread/${CMAKE_SHARED_LIBRARY_PREFIX}mpi${CMAKE_SHARED_LIBRARY_SUFFIX}
${INSTALL_DIR}/intel64/lib/thread/${CMAKE_SHARED_LIBRARY_PREFIX}fabric${CMAKE_SHARED_LIBRARY_SUFFIX})
${NGRAPH_LIBRARY_OUTPUT_DIRECTORY}/${MLSL_LIB}
${NGRAPH_LIBRARY_OUTPUT_DIRECTORY}/${MPI_LIB}
${NGRAPH_LIBRARY_OUTPUT_DIRECTORY}/${FABRIC_LIB})
target_link_libraries(libmlsl PRIVATE INTERFACE ${MLSL_LINK_LIBRARIES})
add_dependencies(libmlsl MLSL)
......
......@@ -423,8 +423,6 @@ target_link_libraries(ngraph PRIVATE libjson)
target_compile_definitions(ngraph PUBLIC NGRAPH_VERSION="${NGRAPH_VERSION}")
if (LINUX)
set_property(TARGET ngraph APPEND_STRING PROPERTY LINK_FLAGS " -Wl,--rpath,$ORIGIN")
# nGraph links against one or more libraries (ex. LLVM) but we don't want to
# export these symbols as part of the DSO. This is a GNU ld (and derivatives) specific
# option so making this portable is still an open issue. As a note for the future,
......
......@@ -18,6 +18,10 @@ if(NOT NGRAPH_CODEGEN_ENABLE)
return()
endif()
if(LINUX)
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
endif()
set (SRC
main.cpp
util.cpp
......
......@@ -14,6 +14,10 @@
# limitations under the License.
# ******************************************************************************
if(LINUX)
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
endif()
add_subdirectory(nbench)
add_subdirectory(ngraph-to-plaidml)
add_subdirectory(reserialize)
......
......@@ -14,6 +14,10 @@
# limitations under the License.
# ******************************************************************************
if(LINUX)
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
endif()
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER "4.0.0")
# gtest has issues with this with v1.8.x
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment