Unverified Commit 233d5cd2 authored by Robert Kimball's avatar Robert Kimball Committed by GitHub

Enable building without CPU without triggering mkldnn or eigen builds (#1670)

* fix CPU dependency
parent abf1a2fb
...@@ -25,19 +25,20 @@ set(SRC ...@@ -25,19 +25,20 @@ set(SRC
# This must be kept in sync with the LLVM + Clang version in use # This must be kept in sync with the LLVM + Clang version in use
set_source_files_properties(compiler.cpp PROPERTIES COMPILE_FLAGS "-fno-rtti") set_source_files_properties(compiler.cpp PROPERTIES COMPILE_FLAGS "-fno-rtti")
get_target_property(MKLDNN_INCLUDE_DIR libmkldnn INTERFACE_INCLUDE_DIRECTORIES)
get_target_property(EIGEN_INCLUDE_DIR libeigen INTERFACE_INCLUDE_DIRECTORIES)
get_target_property(LLVM_LIB_DIR libllvm INTERFACE_INCLUDE_DIRECTORIES) get_target_property(LLVM_LIB_DIR libllvm INTERFACE_INCLUDE_DIRECTORIES)
# find_file(HEADER_1 cmath HINTS /usr/include/c++/7) # find_file(HEADER_1 cmath HINTS /usr/include/c++/7)
get_filename_component(LLVM_LIB_DIR ${LLVM_LIB_DIR}/../lib/clang/5.0.2/include ABSOLUTE) get_filename_component(LLVM_LIB_DIR ${LLVM_LIB_DIR}/../lib/clang/5.0.2/include ABSOLUTE)
set(HEADER_SEARCH_DEFINES if(NGRAPH_CPU_ENABLE)
"EIGEN_HEADERS_PATH=\"${EIGEN_INCLUDE_DIR}\"" get_target_property(MKLDNN_INCLUDE_DIR libmkldnn INTERFACE_INCLUDE_DIRECTORIES)
"MKLDNN_HEADERS_PATH=\"${MKLDNN_INCLUDE_DIR}\"" get_target_property(EIGEN_INCLUDE_DIR libeigen INTERFACE_INCLUDE_DIRECTORIES)
"CLANG_BUILTIN_HEADERS_PATH=\"${LLVM_LIB_DIR}\"" list(APPEND HEADER_SEARCH_DEFINES EIGEN_HEADERS_PATH="${EIGEN_INCLUDE_DIR}")
"NGRAPH_HEADERS_PATH=\"${NGRAPH_INCLUDE_PATH}\"" list(APPEND HEADER_SEARCH_DEFINES MKLDNN_HEADERS_PATH="${MKLDNN_INCLUDE_DIR}")
) endif()
list(APPEND HEADER_SEARCH_DEFINES CLANG_BUILTIN_HEADERS_PATH="${LLVM_LIB_DIR}")
list(APPEND HEADER_SEARCH_DEFINES NGRAPH_HEADERS_PATH="${NGRAPH_INCLUDE_PATH}")
if(NGRAPH_DISTRIBUTED_ENABLE) if(NGRAPH_DISTRIBUTED_ENABLE)
find_package(MPI REQUIRED) find_package(MPI REQUIRED)
...@@ -45,19 +46,19 @@ if(NGRAPH_DISTRIBUTED_ENABLE) ...@@ -45,19 +46,19 @@ if(NGRAPH_DISTRIBUTED_ENABLE)
link_directories(${MPI_C_LIBRARIES} ${MPI_CXX_LIBRARIES}) link_directories(${MPI_C_LIBRARIES} ${MPI_CXX_LIBRARIES})
string(REPLACE ";" "\\;" MPI_C_INCLUDE_PATH "${MPI_C_INCLUDE_PATH}") string(REPLACE ";" "\\;" MPI_C_INCLUDE_PATH "${MPI_C_INCLUDE_PATH}")
add_definitions("-DMPI_HEADER_PATH=\"${MPI_C_INCLUDE_PATH}\"") add_definitions(-DMPI_HEADER_PATH="${MPI_C_INCLUDE_PATH}")
add_definitions(-DNGRAPH_DISTRIBUTED) add_definitions(-DNGRAPH_DISTRIBUTED)
endif() endif()
if(NGRAPH_GPU_ENABLE) if(NGRAPH_GPU_ENABLE)
find_package(CUDA 8 REQUIRED) find_package(CUDA 8 REQUIRED)
find_package(CUDNN 7 REQUIRED) find_package(CUDNN 7 REQUIRED)
list(APPEND HEADER_SEARCH_DEFINES "CUDA_HEADER_PATHS=\"${CUDA_INCLUDE_DIRS}\"") list(APPEND HEADER_SEARCH_DEFINES CUDA_HEADER_PATHS="${CUDA_INCLUDE_DIRS}")
list(APPEND HEADER_SEARCH_DEFINES "CUDNN_HEADER_PATHS=\"${CUDNN_INCLUDE_DIRS}\"") list(APPEND HEADER_SEARCH_DEFINES CUDNN_HEADER_PATHS="${CUDNN_INCLUDE_DIRS}")
endif() endif()
if(NGRAPH_TBB_ENABLE) if(NGRAPH_TBB_ENABLE)
list(APPEND HEADER_SEARCH_DEFINES "TBB_HEADERS_PATH=\"${TBB_ROOT}/include\"") list(APPEND HEADER_SEARCH_DEFINES TBB_HEADERS_PATH="${TBB_ROOT}/include")
endif() endif()
set_source_files_properties(compiler.cpp PROPERTIES COMPILE_DEFINITIONS "${HEADER_SEARCH_DEFINES}") set_source_files_properties(compiler.cpp PROPERTIES COMPILE_DEFINITIONS "${HEADER_SEARCH_DEFINES}")
...@@ -65,14 +66,20 @@ set_source_files_properties(compiler.cpp PROPERTIES COMPILE_DEFINITIONS "${HEADE ...@@ -65,14 +66,20 @@ set_source_files_properties(compiler.cpp PROPERTIES COMPILE_DEFINITIONS "${HEADE
# Generate the resource file containing all headers used by the codegen compiler # Generate the resource file containing all headers used by the codegen compiler
add_custom_target(header_resource add_custom_target(header_resource
resource_generator --output ${CMAKE_BINARY_DIR}/header_resource.hpp --base codegen resource_generator --output ${CMAKE_BINARY_DIR}/header_resource.hpp --base codegen
DEPENDS resource_generator ext_eigen ext_llvm ext_mkldnn DEPENDS resource_generator ext_llvm
BYPRODUCTS BYPRODUCTS
) )
if (NGRAPH_CPU_ENABLE)
add_dependencies(header_resource ext_eigen ext_mkldnn)
endif()
if (NGRAPH_GPU_ENABLE OR (NGRAPH_CPU_ENABLE AND NOT NGRAPH_DEX_ONLY)) if (NGRAPH_GPU_ENABLE OR (NGRAPH_CPU_ENABLE AND NOT NGRAPH_DEX_ONLY))
add_library(codegen SHARED ${SRC}) add_library(codegen SHARED ${SRC})
set_target_properties(codegen PROPERTIES VERSION ${NGRAPH_VERSION} SOVERSION ${NGRAPH_API_VERSION}) set_target_properties(codegen PROPERTIES VERSION ${NGRAPH_VERSION} SOVERSION ${NGRAPH_API_VERSION})
add_dependencies(codegen header_resource libmkldnn libeigen) add_dependencies(codegen header_resource)
if (NGRAPH_CPU_ENABLE)
add_dependencies(codegen libmkldnn libeigen)
endif()
target_include_directories(codegen SYSTEM PUBLIC ${CMAKE_BINARY_DIR}) target_include_directories(codegen SYSTEM PUBLIC ${CMAKE_BINARY_DIR})
target_link_libraries(codegen PRIVATE libllvm ngraph) target_link_libraries(codegen PRIVATE libllvm ngraph)
install(TARGETS codegen DESTINATION ${NGRAPH_INSTALL_LIB}) install(TARGETS codegen DESTINATION ${NGRAPH_INSTALL_LIB})
......
...@@ -21,35 +21,28 @@ set (SRC ...@@ -21,35 +21,28 @@ set (SRC
header_rewrite.cpp header_rewrite.cpp
) )
get_target_property(MKLDNN_INCLUDE_DIR libmkldnn INTERFACE_INCLUDE_DIRECTORIES) set(LLVM_LIB_DIR ${LLVM_INCLUDE_DIR}/../lib/clang/5.0.2/include)
get_target_property(EIGEN_INCLUDE_DIR libeigen INTERFACE_INCLUDE_DIRECTORIES) get_filename_component(LLVM_LIB_DIR ${LLVM_LIB_DIR} ABSOLUTE)
get_target_property(LLVM_INCLUDE_DIR libllvm INTERFACE_INCLUDE_DIRECTORIES)
set(CLANG_INCLUDE_DIR ${LLVM_INCLUDE_DIR}/../lib/clang/5.0.2/include)
get_filename_component(CLANG_INCLUDE_DIR ${CLANG_INCLUDE_DIR} ABSOLUTE)
set(HEADER_SEARCH_DEFINES
"EIGEN_HEADERS_PATH=\"${EIGEN_INCLUDE_DIR}\""
"MKLDNN_HEADERS_PATH=\"${MKLDNN_INCLUDE_DIR}\""
"CLANG_BUILTIN_HEADERS_PATH=\"${CLANG_INCLUDE_DIR}\""
"NGRAPH_HEADERS_PATH=\"${NGRAPH_INCLUDE_PATH}\""
)
if(NGRAPH_TBB_ENABLE) list(APPEND HEADER_SEARCH_DEFINES CLANG_BUILTIN_HEADERS_PATH="${LLVM_LIB_DIR}")
list(APPEND HEADER_SEARCH_DEFINES "TBB_HEADERS_PATH=\"${TBB_ROOT}/include\"") list(APPEND HEADER_SEARCH_DEFINES NGRAPH_HEADERS_PATH="${NGRAPH_INCLUDE_PATH}")
list(APPEND HEADER_SEARCH_DEFINES "NGRAPH_TBB_ENABLE")
if(NGRAPH_CPU_ENABLE)
get_target_property(MKLDNN_INCLUDE_DIR libmkldnn INTERFACE_INCLUDE_DIRECTORIES)
get_target_property(EIGEN_INCLUDE_DIR libeigen INTERFACE_INCLUDE_DIRECTORIES)
list(APPEND HEADER_SEARCH_DEFINES EIGEN_HEADERS_PATH="${EIGEN_INCLUDE_DIR}")
list(APPEND HEADER_SEARCH_DEFINES MKLDNN_HEADERS_PATH="${MKLDNN_INCLUDE_DIR}")
endif() endif()
if (NGRAPH_GPU_ENABLE) if(NGRAPH_TBB_ENABLE)
find_package(CUDA 8 REQUIRED) list(APPEND HEADER_SEARCH_DEFINES TBB_HEADERS_PATH="${TBB_ROOT}/include")
find_package(CUDNN 7 REQUIRED)
set_property(SOURCE codegen/compiler.cpp APPEND_STRING PROPERTY COMPILE_DEFINITIONS
"CUDA_HEADER_PATHS=\"${CUDA_INCLUDE_DIRS}\";")
set_property(SOURCE codegen/compiler.cpp APPEND_STRING PROPERTY COMPILE_DEFINITIONS
"CUDNN_HEADER_PATHS=\"${CUDNN_INCLUDE_DIRS}\";")
endif() endif()
add_executable(resource_generator EXCLUDE_FROM_ALL ${SRC}) add_executable(resource_generator EXCLUDE_FROM_ALL ${SRC})
add_dependencies(resource_generator ext_llvm ext_eigen ext_mkldnn) add_dependencies(resource_generator ext_llvm)
if(NGRAPH_CPU_ENABLE)
add_dependencies(resource_generator ext_eigen ext_mkldnn)
endif()
set_source_files_properties(main.cpp PROPERTIES COMPILE_DEFINITIONS "${HEADER_SEARCH_DEFINES}") set_source_files_properties(main.cpp PROPERTIES COMPILE_DEFINITIONS "${HEADER_SEARCH_DEFINES}")
...@@ -87,29 +87,27 @@ int main(int argc, char** argv) ...@@ -87,29 +87,27 @@ int main(int argc, char** argv)
vector<ResourceInfo> include_paths; vector<ResourceInfo> include_paths;
#ifdef __APPLE__ #ifdef __APPLE__
#ifdef EIGEN_HEADERS_PATH
include_paths.push_back({EIGEN_HEADERS_PATH, {}, true}); include_paths.push_back({EIGEN_HEADERS_PATH, {}, true});
#endif
#ifdef MKLDNN_HEADERS_PATH
include_paths.push_back({MKLDNN_HEADERS_PATH, {}, true}); include_paths.push_back({MKLDNN_HEADERS_PATH, {}, true});
#ifdef NGRAPH_TBB_ENABLE #endif
#ifdef TBB_HEADERS_PATH
include_paths.push_back({TBB_HEADERS_PATH, {}, true}); include_paths.push_back({TBB_HEADERS_PATH, {}, true});
#endif #endif
include_paths.push_back({NGRAPH_HEADERS_PATH, {}, true}); include_paths.push_back({NGRAPH_HEADERS_PATH, {}, true});
include_paths.push_back({CLANG_BUILTIN_HEADERS_PATH, {}, true}); include_paths.push_back({CLANG_BUILTIN_HEADERS_PATH, {}, true});
// include_paths.push_back({"/Library/Developer/CommandLineTools/usr/include/c++/v1", {}});
#else // __APPLE__ #else // __APPLE__
include_paths.push_back({CLANG_BUILTIN_HEADERS_PATH, {}, true}); include_paths.push_back({CLANG_BUILTIN_HEADERS_PATH, {}, true});
// string cpp0 = find_path("/usr/include/x86_64-linux-gnu/c++/"); #ifdef EIGEN_HEADERS_PATH
// string cpp1 = find_path("/usr/include/c++/");
// include_paths.push_back({"/usr/include/x86_64-linux-gnu", {"asm", "sys", "bits", "gnu"}});
// include_paths.push_back(
// {"/usr/include", {"asm", "sys", "bits", "gnu", "linux", "asm-generic"}});
// include_paths.push_back({cpp0, {"bits"}});
// include_paths.push_back({"/usr/include/c++/4.8.2/x86_64-redhat-linux", {"bits"}});
// include_paths.push_back({cpp1, {"bits", "ext", "debug", "backward"}});
include_paths.push_back({EIGEN_HEADERS_PATH, {}, true}); include_paths.push_back({EIGEN_HEADERS_PATH, {}, true});
#endif
#ifdef MKLDNN_HEADERS_PATH
include_paths.push_back({MKLDNN_HEADERS_PATH, {}, true}); include_paths.push_back({MKLDNN_HEADERS_PATH, {}, true});
#endif
include_paths.push_back({NGRAPH_HEADERS_PATH, {}, true}); include_paths.push_back({NGRAPH_HEADERS_PATH, {}, true});
#ifdef NGRAPH_TBB_ENABLE #ifdef TBB_HEADERS_PATH
include_paths.push_back({TBB_HEADERS_PATH, {}, true}); include_paths.push_back({TBB_HEADERS_PATH, {}, true});
#endif #endif
#endif #endif
......
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