Unverified Commit c4018000 authored by Robert Kimball's avatar Robert Kimball Committed by GitHub

CMake cleanup (#1838)

* remove unused setting

* cleanup

* cleanup

* cleanup

* more cleanup
parent a5bb4361
...@@ -161,21 +161,24 @@ set (SRC ...@@ -161,21 +161,24 @@ set (SRC
placement.cpp placement.cpp
cpio.cpp cpio.cpp
) )
if(NGRAPH_DISTRIBUTED_ENABLE)
list(APPEND SRC distributed.cpp)
endif()
add_library(ngraph SHARED ${SRC})
if(NGRAPH_DISTRIBUTED_ENABLE) if(NGRAPH_DISTRIBUTED_ENABLE)
find_package(MPI REQUIRED) find_package(MPI REQUIRED)
add_definitions(-DNGRAPH_DISTRIBUTED) target_compile_definitions(ngraph PRIVATE NGRAPH_DISTRIBUTED)
include_directories(SYSTEM ${MPI_C_INCLUDE_PATH} ${MPI_CXX_INCLUDE_PATH}) target_include_directories(ngraph SYSTEM PRIVATE ${MPI_C_INCLUDE_PATH} ${MPI_CXX_INCLUDE_PATH})
link_directories(${MPI_C_LIBRARIES} ${MPI_CXX_LIBRARIES}) target_link_libraries(ngraph PRIVATE ${MPI_C_LIBRARIES} ${MPI_CXX_LIBRARIES})
link_libraries(${MPI_CXX_LIBRARIES})
set (SRC distributed.cpp ${SRC})
endif() endif()
add_subdirectory(frontend) add_subdirectory(frontend)
find_package(Graphviz QUIET) find_package(Graphviz QUIET)
if (GRAPHVIZ_FOUND) if (GRAPHVIZ_FOUND)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DGRAPHVIZ_FOUND") set_property(SOURCE pass/visualize_tree.cpp APPEND PROPERTY COMPILE_DEFINITIONS GRAPHVIZ_FOUND)
endif() endif()
if(NGRAPH_ADDRESS_SANITIZER) if(NGRAPH_ADDRESS_SANITIZER)
...@@ -183,21 +186,14 @@ if(NGRAPH_ADDRESS_SANITIZER) ...@@ -183,21 +186,14 @@ if(NGRAPH_ADDRESS_SANITIZER)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -fsanitize=address -fno-omit-frame-pointer") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -fsanitize=address -fno-omit-frame-pointer")
endif() endif()
include_directories("${NGRAPH_INCLUDE_PATH}")
add_subdirectory(codegen) add_subdirectory(codegen)
add_subdirectory(runtime) add_subdirectory(runtime)
add_library(ngraph SHARED ${SRC})
target_compile_definitions(ngraph PRIVATE SHARED_LIB_EXT="${CMAKE_SHARED_LIBRARY_SUFFIX}") target_compile_definitions(ngraph PRIVATE SHARED_LIB_EXT="${CMAKE_SHARED_LIBRARY_SUFFIX}")
set_target_properties(ngraph PROPERTIES VERSION ${NGRAPH_VERSION} SOVERSION ${NGRAPH_API_VERSION}) set_target_properties(ngraph PROPERTIES VERSION ${NGRAPH_VERSION} SOVERSION ${NGRAPH_API_VERSION})
target_link_libraries(ngraph PUBLIC libjson) target_link_libraries(ngraph PRIVATE libjson)
target_compile_definitions(ngraph PUBLIC NGRAPH_VERSION="${NGRAPH_VERSION}") target_compile_definitions(ngraph PUBLIC NGRAPH_VERSION="${NGRAPH_VERSION}")
if (NGRAPH_ONNX_IMPORT_ENABLE)
add_dependencies(ngraph onnx_import)
endif()
if (NOT APPLE) if (NOT APPLE)
set_property(TARGET ngraph APPEND_STRING PROPERTY LINK_FLAGS " -Wl,--rpath,$ORIGIN") set_property(TARGET ngraph APPEND_STRING PROPERTY LINK_FLAGS " -Wl,--rpath,$ORIGIN")
......
...@@ -14,73 +14,70 @@ ...@@ -14,73 +14,70 @@
# limitations under the License. # limitations under the License.
# ****************************************************************************** # ******************************************************************************
set(SRC
if (NGRAPH_GPU_ENABLE OR (NGRAPH_CPU_ENABLE AND NOT NGRAPH_DEX_ONLY))
set(SRC
code_writer.cpp code_writer.cpp
compiler.cpp compiler.cpp
execution_engine.cpp execution_engine.cpp
) )
add_library(codegen SHARED ${SRC})
# LLVM binary builds are typically built without RTTI # LLVM binary builds are typically built without RTTI
# The built-in headers are in a version-specific directory # The built-in headers are in a version-specific directory
# 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(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)
if(NGRAPH_CPU_ENABLE) if(NGRAPH_CPU_ENABLE)
get_target_property(MKLDNN_INCLUDE_DIR libmkldnn INTERFACE_INCLUDE_DIRECTORIES) get_target_property(MKLDNN_INCLUDE_DIR libmkldnn INTERFACE_INCLUDE_DIRECTORIES)
get_target_property(EIGEN_INCLUDE_DIR libeigen 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 EIGEN_HEADERS_PATH="${EIGEN_INCLUDE_DIR}")
list(APPEND HEADER_SEARCH_DEFINES MKLDNN_HEADERS_PATH="${MKLDNN_INCLUDE_DIR}") list(APPEND HEADER_SEARCH_DEFINES MKLDNN_HEADERS_PATH="${MKLDNN_INCLUDE_DIR}")
endif() endif()
list(APPEND HEADER_SEARCH_DEFINES CLANG_BUILTIN_HEADERS_PATH="${LLVM_LIB_DIR}") list(APPEND HEADER_SEARCH_DEFINES CLANG_BUILTIN_HEADERS_PATH="${LLVM_LIB_DIR}")
list(APPEND HEADER_SEARCH_DEFINES NGRAPH_HEADERS_PATH="${NGRAPH_INCLUDE_PATH}") 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)
include_directories(SYSTEM ${MPI_C_INCLUDE_PATH} ${MPI_CXX_INCLUDE_PATH}) target_compile_definitions(codegen PRIVATE NGRAPH_DISTRIBUTED)
link_directories(${MPI_C_LIBRARIES} ${MPI_CXX_LIBRARIES}) add_definitions(-DMPI_HEADER_PATH="${MPI_PATH}")
endif()
string(REPLACE ";" "\\;" MPI_C_INCLUDE_PATH "${MPI_C_INCLUDE_PATH}")
add_definitions(-DMPI_HEADER_PATH="${MPI_C_INCLUDE_PATH}")
add_definitions(-DNGRAPH_DISTRIBUTED)
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}")
# 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_llvm DEPENDS resource_generator ext_llvm
BYPRODUCTS BYPRODUCTS
) )
if (NGRAPH_CPU_ENABLE) if (NGRAPH_CPU_ENABLE)
add_dependencies(header_resource ext_eigen ext_mkldnn) add_dependencies(header_resource ext_eigen ext_mkldnn)
endif() endif()
if (NGRAPH_GPU_ENABLE OR (NGRAPH_CPU_ENABLE AND NOT NGRAPH_DEX_ONLY))
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) add_dependencies(codegen header_resource)
if (NGRAPH_CPU_ENABLE) if (NGRAPH_CPU_ENABLE)
add_dependencies(codegen libmkldnn libeigen) add_dependencies(codegen libmkldnn libeigen)
endif() endif()
target_include_directories(codegen SYSTEM PUBLIC ${CMAKE_BINARY_DIR}) target_include_directories(codegen SYSTEM PRIVATE ${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})
endif() endif()
...@@ -161,10 +161,12 @@ if (NGRAPH_CPU_ENABLE) ...@@ -161,10 +161,12 @@ if (NGRAPH_CPU_ENABLE)
if(NGRAPH_DISTRIBUTED_ENABLE) if(NGRAPH_DISTRIBUTED_ENABLE)
find_package(MPI REQUIRED) find_package(MPI REQUIRED)
add_definitions(-DNGRAPH_DISTRIBUTED) target_compile_definitions(cpu_backend
include_directories(SYSTEM ${MPI_C_INCLUDE_PATH} ${MPI_CXX_INCLUDE_PATH}) PRIVATE NGRAPH_DISTRIBUTED)
link_directories(${MPI_C_LIBRARIES} ${MPI_CXX_LIBRARIES}) target_include_directories(cpu_backend
target_link_libraries(cpu_backend PRIVATE ${MPI_CXX_LIBRARIES}) SYSTEM PRIVATE ${MPI_C_INCLUDE_PATH} ${MPI_CXX_INCLUDE_PATH})
target_link_libraries(cpu_backend
PRIVATE ${MPI_C_LIBRARIES} ${MPI_CXX_LIBRARIES})
endif() endif()
add_dependencies(cpu_backend ext_mkldnn ext_eigen) add_dependencies(cpu_backend ext_mkldnn ext_eigen)
......
...@@ -14,14 +14,6 @@ ...@@ -14,14 +14,6 @@
# limitations under the License. # limitations under the License.
# ****************************************************************************** # ******************************************************************************
if(NGRAPH_DISTRIBUTED_ENABLE)
find_package(MPI REQUIRED)
add_definitions(-DNGRAPH_DISTRIBUTED)
include_directories(SYSTEM ${MPI_C_INCLUDE_PATH} ${MPI_CXX_INCLUDE_PATH})
link_directories(${MPI_C_LIBRARIES} ${MPI_CXX_LIBRARIES})
link_libraries(${MPI_CXX_LIBRARIES})
endif()
if (NGRAPH_INTERPRETER_ENABLE) if (NGRAPH_INTERPRETER_ENABLE)
add_library(interpreter_backend SHARED int_backend.cpp node_wrapper.cpp) add_library(interpreter_backend SHARED int_backend.cpp node_wrapper.cpp)
set_target_properties(interpreter_backend PROPERTIES VERSION ${NGRAPH_VERSION}) set_target_properties(interpreter_backend PROPERTIES VERSION ${NGRAPH_VERSION})
...@@ -32,4 +24,14 @@ if (NGRAPH_INTERPRETER_ENABLE) ...@@ -32,4 +24,14 @@ if (NGRAPH_INTERPRETER_ENABLE)
LIBRARY DESTINATION "${NGRAPH_INSTALL_LIB}" LIBRARY DESTINATION "${NGRAPH_INSTALL_LIB}"
ARCHIVE DESTINATION "${NGRAPH_INSTALL_LIB}" ARCHIVE DESTINATION "${NGRAPH_INSTALL_LIB}"
) )
if(NGRAPH_DISTRIBUTED_ENABLE)
find_package(MPI REQUIRED)
target_compile_definitions(interpreter_backend
PRIVATE NGRAPH_DISTRIBUTED)
target_include_directories(interpreter_backend
SYSTEM PRIVATE ${MPI_C_INCLUDE_PATH} ${MPI_CXX_INCLUDE_PATH})
target_link_libraries(interpreter_backend
PRIVATE ${MPI_C_LIBRARIES} ${MPI_CXX_LIBRARIES})
endif()
endif() endif()
...@@ -61,18 +61,18 @@ if (NGRAPH_ONNX_IMPORT_ENABLE) ...@@ -61,18 +61,18 @@ if (NGRAPH_ONNX_IMPORT_ENABLE)
endif() endif()
if (NGRAPH_INTERPRETER_ENABLE) if (NGRAPH_INTERPRETER_ENABLE)
set(SRC ${SRC} backend_debug_api.cpp builder.cpp backend_api.cpp) list(APPEND SRC backend_debug_api.cpp builder.cpp backend_api.cpp)
set(ACTIVE_BACKEND_LIST ${ACTIVE_BACKEND_LIST} INTERPRETER) set(ACTIVE_BACKEND_LIST ${ACTIVE_BACKEND_LIST} INTERPRETER)
endif() endif()
if (NGRAPH_CPU_ENABLE) if (NGRAPH_CPU_ENABLE)
set(SRC ${SRC} core_fusion.cpp quantize_cpu.cpp) list(APPEND SRC core_fusion.cpp quantize_cpu.cpp)
set(SRC ${SRC} backend_performance.cpp cpu_fusion.cpp cpu_test.cpp cpu_reshape_sinking.cpp) list(APPEND SRC backend_performance.cpp cpu_fusion.cpp cpu_test.cpp cpu_reshape_sinking.cpp)
set(ACTIVE_BACKEND_LIST ${ACTIVE_BACKEND_LIST} CPU) set(ACTIVE_BACKEND_LIST ${ACTIVE_BACKEND_LIST} CPU)
endif() endif()
if(NGRAPH_GPU_ENABLE) if(NGRAPH_GPU_ENABLE)
set(SRC ${SRC} cudnn.cpp gpu_test.cpp gpu_fusion.cpp) list(APPEND SRC cudnn.cpp gpu_test.cpp gpu_fusion.cpp)
set(ACTIVE_BACKEND_LIST ${ACTIVE_BACKEND_LIST} GPU) set(ACTIVE_BACKEND_LIST ${ACTIVE_BACKEND_LIST} GPU)
endif() endif()
...@@ -96,7 +96,7 @@ set(MULTI_TEST_SRC ...@@ -96,7 +96,7 @@ set(MULTI_TEST_SRC
convolution_test.in.cpp convolution_test.in.cpp
) )
if(NGRAPH_DISTRIBUTED_ENABLE) if(NGRAPH_DISTRIBUTED_ENABLE)
set(MULTI_TEST_SRC ${MULTI_TEST_SRC} distributed.in.cpp) list(APPEND MULTI_TEST_SRC distributed.in.cpp)
endif() endif()
foreach(BACKEND_NAME ${ACTIVE_BACKEND_LIST}) foreach(BACKEND_NAME ${ACTIVE_BACKEND_LIST})
...@@ -123,7 +123,9 @@ foreach(BACKEND_NAME ${ACTIVE_BACKEND_LIST}) ...@@ -123,7 +123,9 @@ foreach(BACKEND_NAME ${ACTIVE_BACKEND_LIST})
message(STATUS "Adding unit test for backend ${BACKEND_NAME}") message(STATUS "Adding unit test for backend ${BACKEND_NAME}")
endforeach() endforeach()
include_directories(".") add_executable(unit-test ${SRC})
target_include_directories(unit-test PRIVATE ".")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DCURDIR=\\\"${CMAKE_CURRENT_SOURCE_DIR}\\\"") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DCURDIR=\\\"${CMAKE_CURRENT_SOURCE_DIR}\\\"")
...@@ -135,16 +137,15 @@ endif() ...@@ -135,16 +137,15 @@ endif()
if(NGRAPH_DISTRIBUTED_ENABLE) if(NGRAPH_DISTRIBUTED_ENABLE)
find_package(MPI REQUIRED) find_package(MPI REQUIRED)
add_definitions(-DNGRAPH_DISTRIBUTED) target_compile_definitions(unit-test PRIVATE NGRAPH_DISTRIBUTED)
include_directories(SYSTEM ${MPI_C_INCLUDE_PATH} ${MPI_CXX_INCLUDE_PATH}) target_include_directories(unit-test
link_directories(${MPI_C_LIBRARIES} ${MPI_CXX_LIBRARIES}) SYSTEM PRIVATE ${MPI_C_INCLUDE_PATH} ${MPI_CXX_INCLUDE_PATH})
link_libraries(${MPI_CXX_LIBRARIES}) target_link_libraries(unit-test PRIVATE ${MPI_C_LIBRARIES} ${MPI_CXX_LIBRARIES})
endif() endif()
add_executable(unit-test ${SRC}) target_link_libraries(unit-test PRIVATE ngraph_test_util)
target_link_libraries(unit-test ngraph_test_util) target_link_libraries(unit-test PRIVATE ngraph libgtest libjson pthread)
target_link_libraries(unit-test ngraph libgtest libjson pthread) target_link_libraries(unit-test PRIVATE ${CMAKE_DL_LIBS})
target_link_libraries(unit-test ${CMAKE_DL_LIBS})
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "^(Apple)?Clang$") if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "^(Apple)?Clang$")
target_compile_options(unit-test PRIVATE -Wno-undef -Wno-reserved-id-macro) target_compile_options(unit-test PRIVATE -Wno-undef -Wno-reserved-id-macro)
...@@ -152,26 +153,26 @@ endif() ...@@ -152,26 +153,26 @@ endif()
if (NGRAPH_CPU_ENABLE) if (NGRAPH_CPU_ENABLE)
# The INTERPRETER backend is required for graph_partition, convolution, and backwards unit tests # The INTERPRETER backend is required for graph_partition, convolution, and backwards unit tests
target_link_libraries(unit-test cpu_backend interpreter_backend) target_link_libraries(unit-test PRIVATE cpu_backend interpreter_backend)
target_link_libraries(unit-test libmkldnn) target_link_libraries(unit-test PRIVATE libmkldnn)
endif() endif()
if (NGRAPH_TBB_ENABLE) if (NGRAPH_TBB_ENABLE)
add_definitions(-DNGRAPH_TBB_ENABLE) target_compile_definitions(unit-test PRIVATE NGRAPH_TBB_ENABLE)
endif() endif()
if (NGRAPH_INTERPRETER_ENABLE) if (NGRAPH_INTERPRETER_ENABLE)
add_definitions(-DNGRAPH_INTERPRETER_ENABLE) target_compile_definitions(unit-test PRIVATE NGRAPH_INTERPRETER_ENABLE)
target_link_libraries(unit-test interpreter_backend) target_link_libraries(unit-test PRIVATE interpreter_backend)
endif() endif()
if (NGRAPH_GPU_ENABLE) if (NGRAPH_GPU_ENABLE)
target_link_libraries(unit-test gpu_backend) target_link_libraries(unit-test PRIVATE gpu_backend)
endif() endif()
if (NGRAPH_ONNXIFI_ENABLE) if (NGRAPH_ONNXIFI_ENABLE)
target_include_directories(unit-test SYSTEM PUBLIC ${ONNX_INCLUDE_DIR}) target_include_directories(unit-test SYSTEM PUBLIC ${ONNX_INCLUDE_DIR})
target_link_libraries(unit-test onnxifi-ngraph) target_link_libraries(unit-test PRIVATE onnxifi-ngraph)
endif() endif()
add_custom_target(unit-test-check add_custom_target(unit-test-check
......
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