Unverified Commit 8bccef1a authored by Adam Procter's avatar Adam Procter Committed by GitHub

Compatibility fixes for gcc-4.8.5 and CentOS-7.4 (#444)

(Squashing this commit but going to leave the full log here, unlike the way I usually do things)

* Incremental work on compatibility with system requirements

* Lower cmake version requirement so we can work with CentOS 7.4

* Disambiguate isnan call (CentOS's compiler doesn't like it)

* Make external_tbb conditional on NGRAPH_CPU_ENABLE

* Make MKLDNN inclusion conditional on NGRAPH_CPU_ENABLE

* Roll back desperation change to Ubuntu 14.04 binaries

* De-revert copyright date change (arrgh)

* Revert change of TBB's hard-coded compiler choice to gcc

* Cleanup of modified CMake stuff

* Add broken support for building LLVM from source

* Explain modification to json.hpp required compiler version

* Make TBB optional, and on by default. To disable, cmake -DNGRAPH_TBB_ENABLE=FALSE

* Add reasonable default for LLVM's CMAKE_ASM_COMPILER so users don't have to specify it

* Force TBB disabled if CMake is too old to build it (for CentOS)

* Build LLVM OpenMP as external project

* Tweak LLVM build options

* Minor comment edit in cmake scripts

* Workaround (fix?) for codegen crashes on CentOS

* Add some header paths for CentOS to resource_generator; temporary(?) tweak to ignore nonexistent paths

* Remove CMake compatibility figleaf since LLVM will require 3.1+ anyway

* Fix the TBB-enable flag to default to on

* Remove hard-coded choice of clang as tbb compiler

* ln -s -> ln -sf in command to create link for OpenMP source dir

* Make OpenMP build so it doesn't require symlink

* Allow use of prebuilt LLVM if requested at cmake time

* Some INSTALL instructions

* Allow NGRAPH_USE_PREBUILT_LLVM to be set in environment variable

* Tweak CI cmake options to use prebuilt LLVM

* Remove debug messages

* Rework defaulting behavior for LLVM_TARBALL_URL and LLVM_SHA1_HASH

* Remove warning message for unavailable header file directories
parent 4c9dd2b7
......@@ -23,7 +23,7 @@ endif()
project (ngraph)
SET( GCC_MIN_VERSION 4.9)
SET( GCC_MIN_VERSION 4.8)
SET( CLANG_MIN_VERSION 3.8)
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
......@@ -39,6 +39,10 @@ else()
message(WARNING "You are using an unsupported compiler! Compilation has only been tested with Clang ( ${CLANG_MIN_VERSION} and up) and GCC ( ${GCC_MIN_VERSION} and up). ")
endif()
if($ENV{NGRAPH_USE_PREBUILT_LLVM})
set(NGRAPH_USE_PREBUILT_LLVM TRUE)
endif()
# These variables are undocumented but useful.
set(CMAKE_DISABLE_SOURCE_CHANGES ON)
set(CMAKE_DISABLE_IN_SOURCE_BUILD ON)
......@@ -97,7 +101,11 @@ endif()
# Set true if CPU backend is built by default
if (NOT DEFINED NGRAPH_CPU_ENABLE)
SET(NGRAPH_CPU_ENABLE TRUE)
set(NGRAPH_CPU_ENABLE TRUE)
endif()
if (NOT DEFINED NGRAPH_TBB_ENABLE)
set(NGRAPH_TBB_ENABLE ${NGRAPH_CPU_ENABLE})
endif()
#-----------------------------------------------------------------------------------------------
......
Currently two platforms are known to work:
- Ubuntu 16.04
- CentOS 7.4
Ubuntu 16.04 Prerequisites
==========================
Compilers currently known to work are gcc-5.4.0, clang-3.9, and gcc-4.8.5.
If you are using gcc-5.4.0 or clang-3.9, it is recommended to add the
option `-DNGRAPH_USE_PREBUILT_LLVM=TRUE` to the `cmake` command. This causes
the build system to fetch a pre-built tarball of LLVM+Clang from `llvm.org`,
which substantially cuts down on build times.
If you are using gcc-4.8, it may be necessary to add symlinksfrom `gcc` to
`gcc-4.8`, and from `g++` to `g++-4.8`, in your PATH, even if you have
specify CMAKE_C_COMPILER and CMAKE_CXX_COMPILER when building. (You should
NOT supply the `-DNGRAPH_USE_PREBUILT_LLVM` flag in this case, because the
prebuilt tarball supplied on llvm.org is not compatible with a gcc-4.8
based build.)
CentOS 7.4 Prerequisites
========================
CentOS supplies an older version of CMake that is not compatible with
LLVM-5.0.1, which we build as an external dependency. There are two options:
1. (requires root privileges) install the the `cmake3` package from EPEL, or
2. (does not require root privileges) build CMake (3.1 or newer) from source,
and run it from its build directory.
General Instructions
====================
These instructions assume that your system has been prepared in accordance
with the above prerequisites.
$ cd private-ngraph-cpp
$ mkdir build
$ cd build
$ cmake .. \
-DCMAKE_C_COMPILER=<path to C compiler> \
-DCMAKE_CXX_COMPILER=<path to C++ compiler>
$ make -j install
......@@ -30,7 +30,7 @@ if (${CMAKE_VERSION} VERSION_LESS 3.2)
GIT_REPOSITORY ${EIGEN_GIT_URL}
GIT_TAG ${EIGEN_GIT_TAG}
UPDATE_COMMAND ""
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${EIGEN_INSTALL_DIR}
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${EIGEN_INSTALL_DIR} -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
)
else()
ExternalProject_Add(
......@@ -38,7 +38,7 @@ else()
GIT_REPOSITORY ${EIGEN_GIT_URL}
GIT_TAG ${EIGEN_GIT_TAG}
UPDATE_COMMAND ""
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${EIGEN_INSTALL_DIR}
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${EIGEN_INSTALL_DIR} -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
BUILD_BYPRODUCTS "${EIGEN_INSTALL_DIR}/include/eigen3"
)
endif()
......
......@@ -31,6 +31,7 @@ if (${CMAKE_VERSION} VERSION_LESS 3.2)
# Disable install step
INSTALL_COMMAND ""
UPDATE_COMMAND ""
CMAKE_ARGS -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
)
else()
ExternalProject_Add(
......@@ -41,6 +42,7 @@ else()
# Disable install step
INSTALL_COMMAND ""
UPDATE_COMMAND ""
CMAKE_ARGS -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
BUILD_BYPRODUCTS "${CMAKE_CURRENT_BINARY_DIR}/gtest/src/gtest-build/googlemock/gtest/libgtest.a"
)
endif()
......
......@@ -15,47 +15,69 @@ include(ExternalProject)
if((NGRAPH_CPU_ENABLE OR NGRAPH_GPU_ENABLE) AND (NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin") AND
(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Windows"))
message(STATUS "Fetching LLVM from llvm.org")
set(LLVM_RELEASE_URL http://releases.llvm.org/5.0.0/clang+llvm-5.0.0-linux-x86_64-ubuntu16.04.tar.xz)
set(LLVM_SHA1_HASH 9cb81c92aa4d3f9707a9b8413c4d24b8dee90c59)
set(CMAKE_DISABLE_SOURCE_CHANGES ON)
set(CMAKE_DISABLE_IN_SOURCE_BUILD ON)
# Override default LLVM binaries
if(PREBUILT_LLVM)
if(NOT DEFINED PREBUILT_LLVM_HASH)
message(FATAL_ERROR "SHA1 hash of prebuilt llvm tarball not provided in PREBUILT_LLVM_HASH.")
endif()
set(LLVM_RELEASE_URL ${PREBUILT_LLVM})
set(LLVM_SHA1_HASH ${PREBUILT_LLVM_HASH})
endif()
set(RELEASE_TAG release_50)
set(EXTERNAL_INSTALL_LOCATION ${CMAKE_CURRENT_BINARY_DIR}/ext_llvm-prefix)
ExternalProject_Add(clang
GIT_REPOSITORY https://github.com/llvm-mirror/clang.git
GIT_TAG ${RELEASE_TAG}
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
UPDATE_COMMAND ""
)
ExternalProject_Get_Property(clang SOURCE_DIR)
set(CLANG_SOURCE_DIR ${SOURCE_DIR})
ExternalProject_Add(openmp
GIT_REPOSITORY https://github.com/llvm-mirror/openmp.git
GIT_TAG ${RELEASE_TAG}
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
UPDATE_COMMAND ""
)
# The 'BUILD_BYPRODUCTS' argument was introduced in CMake 3.2.
if(${CMAKE_VERSION} VERSION_LESS 3.2)
ExternalProject_Add(
ext_llvm
URL ${LLVM_RELEASE_URL}
URL_HASH SHA1=${LLVM_SHA1_HASH}
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
UPDATE_COMMAND ""
)
ExternalProject_Get_Property(openmp SOURCE_DIR)
set(OPENMP_SOURCE_DIR ${SOURCE_DIR})
if(DEFINED CMAKE_ASM_COMPILER)
set(LLVM_CMAKE_ASM_COMPILER ${CMAKE_ASM_COMPILER})
else()
ExternalProject_Add(
ext_llvm
URL ${LLVM_RELEASE_URL}
URL_HASH SHA1=${LLVM_SHA1_HASH}
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
UPDATE_COMMAND ""
BUILD_BYPRODUCTS "${CMAKE_CURRENT_BINARY_DIR}/ext_llvm-prefix/src/ext_llvm/lib/libLLVMCore.a"
)
set(LLVM_CMAKE_ASM_COMPILER ${CMAKE_C_COMPILER})
endif()
ExternalProject_Get_Property(ext_llvm source_dir)
set(LLVM_INCLUDE_DIR "${source_dir}/include" PARENT_SCOPE)
set(LLVM_INCLUDE_DIR "${source_dir}/include") # used by other external projects in current scope
set(LLVM_LIB_DIR "${source_dir}/lib" PARENT_SCOPE)
ExternalProject_Add(ext_llvm
DEPENDS clang openmp
GIT_REPOSITORY https://github.com/llvm-mirror/llvm.git
GIT_TAG ${RELEASE_TAG}
CMAKE_ARGS -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_ASM_COMPILER=${LLVM_CMAKE_ASM_COMPILER}
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
-DCMAKE_INSTALL_PREFIX=${EXTERNAL_INSTALL_LOCATION}
-DCMAKE_BUILD_TYPE=Release
-DLLVM_ENABLE_ASSERTIONS=OFF
-DLLVM_INCLUDE_TESTS=OFF
-DLLVM_INCLUDE_EXAMPLES=OFF
-DLLVM_BUILD_TOOLS=ON
-DLLVM_TARGETS_TO_BUILD=X86
-DLLVM_EXTERNAL_CLANG_SOURCE_DIR=${CLANG_SOURCE_DIR}
-DLLVM_EXTERNAL_OPENMP_SOURCE_DIR=${OPENMP_SOURCE_DIR}
UPDATE_COMMAND ""
)
ExternalProject_Get_Property(ext_llvm SOURCE_DIR)
ExternalProject_Get_Property(ext_llvm BINARY_DIR)
ExternalProject_Get_Property(ext_llvm INSTALL_DIR)
set(LLVM_INCLUDE_DIR "${INSTALL_DIR}/include" PARENT_SCOPE)
set(LLVM_INCLUDE_DIR "${SOURCE_DIR}/include") # used by other external projects in current scope
set(LLVM_LIB_DIR "${INSTALL_DIR}/lib" PARENT_SCOPE)
set(LLVM_LINK_LIBS
clangTooling
......@@ -135,5 +157,4 @@ if((NGRAPH_CPU_ENABLE OR NGRAPH_GPU_ENABLE) AND (NOT ${CMAKE_SYSTEM_NAME} MATCHE
z
m
PARENT_SCOPE)
endif()
# Copyright 2017 Nervana Systems Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
include(ExternalProject)
if((NGRAPH_CPU_ENABLE OR NGRAPH_GPU_ENABLE) AND (NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin") AND
(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Windows"))
message(STATUS "Fetching LLVM from llvm.org")
# Override default LLVM binaries
if(NOT DEFINED LLVM_TARBALL_URL)
set(LLVM_TARBALL_URL http://releases.llvm.org/5.0.1/clang+llvm-5.0.1-x86_64-linux-gnu-ubuntu-16.04.tar.xz)
endif()
if(NOT DEFINED LLVM_SHA1_HASH)
set(LLVM_SHA1_HASH 2fddf9a90b182fa594786be6923e58f5ead71e9c)
endif()
# The 'BUILD_BYPRODUCTS' argument was introduced in CMake 3.2.
if(${CMAKE_VERSION} VERSION_LESS 3.2)
ExternalProject_Add(
ext_llvm
URL ${LLVM_TARBALL_URL}
URL_HASH SHA1=${LLVM_SHA1_HASH}
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
UPDATE_COMMAND ""
)
else()
ExternalProject_Add(
ext_llvm
URL ${LLVM_TARBALL_URL}
URL_HASH SHA1=${LLVM_SHA1_HASH}
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
UPDATE_COMMAND ""
BUILD_BYPRODUCTS "${CMAKE_CURRENT_BINARY_DIR}/ext_llvm-prefix/src/ext_llvm/lib/libLLVMCore.a"
)
endif()
ExternalProject_Get_Property(ext_llvm source_dir)
set(LLVM_INCLUDE_DIR "${source_dir}/include" PARENT_SCOPE)
set(LLVM_INCLUDE_DIR "${source_dir}/include") # used by other external projects in current scope
set(LLVM_LIB_DIR "${source_dir}/lib" PARENT_SCOPE)
set(LLVM_LINK_LIBS
clangTooling
clangFrontendTool
clangFrontend
clangDriver
clangSerialization
clangCodeGen
clangParse
clangSema
clangStaticAnalyzerFrontend
clangStaticAnalyzerCheckers
clangStaticAnalyzerCore
clangAnalysis
clangARCMigrate
clangRewriteFrontend
clangEdit
clangAST
clangLex
clangBasic
LLVMLTO
LLVMPasses
LLVMObjCARCOpts
LLVMSymbolize
LLVMDebugInfoPDB
LLVMDebugInfoDWARF
LLVMMIRParser
LLVMCoverage
LLVMTableGen
LLVMDlltoolDriver
LLVMOrcJIT
LLVMObjectYAML
LLVMLibDriver
LLVMOption
LLVMX86Disassembler
LLVMX86AsmParser
LLVMX86CodeGen
LLVMGlobalISel
LLVMSelectionDAG
LLVMAsmPrinter
LLVMDebugInfoCodeView
LLVMDebugInfoMSF
LLVMX86Desc
LLVMMCDisassembler
LLVMX86Info
LLVMX86AsmPrinter
LLVMX86Utils
LLVMMCJIT
LLVMLineEditor
LLVMInterpreter
LLVMExecutionEngine
LLVMRuntimeDyld
LLVMCodeGen
LLVMTarget
LLVMCoroutines
LLVMipo
LLVMInstrumentation
LLVMVectorize
LLVMScalarOpts
LLVMLinker
LLVMIRReader
LLVMAsmParser
LLVMInstCombine
LLVMTransformUtils
LLVMBitWriter
LLVMAnalysis
LLVMProfileData
LLVMObject
LLVMMCParser
LLVMMC
LLVMBitReader
LLVMCore
LLVMBinaryFormat
LLVMSupport
LLVMDemangle
tinfo
z
m
PARENT_SCOPE)
endif()
......@@ -17,7 +17,7 @@ include(ExternalProject)
# Fetch and install MKL-DNN
#----------------------------------------------------------------------------------------------------------
if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
if(NGRAPH_CPU_ENABLE AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(MKLDNN_GIT_REPO_URL https://github.com/intel/mkl-dnn)
set(MKLDNN_GIT_TAG "3e1f8f5")
......
......@@ -15,15 +15,17 @@
# Fetch and configure TBB
#----------------------------------------------------------------------------------------------------------
set(TBB_GIT_REPO_URL https://github.com/01org/tbb)
set(TBB_GIT_TAG "tbb_2018")
if(NGRAPH_TBB_ENABLE)
set(TBB_GIT_REPO_URL https://github.com/01org/tbb)
set(TBB_GIT_TAG "tbb_2018")
if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
configure_file(${CMAKE_SOURCE_DIR}/cmake/tbb_fetch.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/tbb/CMakeLists.txt)
execute_process(COMMAND "${CMAKE_COMMAND}" -G "${CMAKE_GENERATOR}" .
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/tbb")
execute_process(COMMAND "${CMAKE_COMMAND}" --build .
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/tbb")
if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
configure_file(${CMAKE_SOURCE_DIR}/cmake/tbb_fetch.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/tbb/CMakeLists.txt)
execute_process(COMMAND "${CMAKE_COMMAND}" -G "${CMAKE_GENERATOR}" .
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/tbb")
execute_process(COMMAND "${CMAKE_COMMAND}" --build .
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/tbb")
set(TBB_ROOT ${CMAKE_CURRENT_BINARY_DIR}/tbb/tbb-src PARENT_SCOPE)
set(TBB_ROOT ${CMAKE_CURRENT_BINARY_DIR}/tbb/tbb-src PARENT_SCOPE)
endif()
endif()
......@@ -29,8 +29,8 @@ DBUILD_DIR = ${DIR}/contrib/docker/.build-${DBUILD_VERSION}
# For gcc builds, we do NOT regard warnings as errors
# For clang builds, we DO make warnings into errors
CMAKE_OPTIONS_COMMON=-DNGRAPH_BUILD_DOXYGEN_DOCS=ON -DNGRAPH_BUILD_SPHINX_DOCS=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo
CMAKE_OPTIONS_GCC=$CMAKE_OPTIONS_COMMON -DNGRAPH_INSTALL_PREFIX=${DOCKUSER_HOME}/ngraph-cpp-test/BUILD-GCC/ngraph_dist
CMAKE_OPTIONS_CLANG=$CMAKE_OPTIONS_COMMON -DNGRAPH_INSTALL_PREFIX=${DOCKUSER_HOME}/ngraph-cpp-test/BUILD-CLANG/ngraph_dist -DCMAKE_CXX_COMPILER=clang++-3.9 -DCMAKE_C_COMPILER=clang-3.9 -DNGRAPH_WARNINGS_AS_ERRORS=ON
CMAKE_OPTIONS_GCC=$CMAKE_OPTIONS_COMMON -DNGRAPH_INSTALL_PREFIX=${DOCKUSER_HOME}/ngraph-cpp-test/BUILD-GCC/ngraph_dist -DNGRAPH_USE_PREBUILT_LLVM=TRUE
CMAKE_OPTIONS_CLANG=$CMAKE_OPTIONS_COMMON -DNGRAPH_INSTALL_PREFIX=${DOCKUSER_HOME}/ngraph-cpp-test/BUILD-CLANG/ngraph_dist -DCMAKE_CXX_COMPILER=clang++-3.9 -DCMAKE_C_COMPILER=clang-3.9 -DNGRAPH_WARNINGS_AS_ERRORS=ON -DNGRAPH_USE_PREBUILT_LLVM=TRUE
CALLER_UID := $(shell id -u)
CALLER_GID := $(shell id -g)
......
......@@ -137,14 +137,16 @@ if (NGRAPH_CPU_ENABLE AND LLVM_INCLUDE_DIR AND
MKLDNN_INCLUDE_DIR)
find_package(ZLIB REQUIRED)
include(${TBB_ROOT}/cmake/TBBBuild.cmake)
tbb_build(TBB_ROOT ${TBB_ROOT} MAKE_ARGS compiler=clang tbb_build_dir=${CMAKE_CURRENT_BINARY_DIR}/tbb_build
tbb_build_prefix=tbb CONFIG_DIR TBB_DIR)
find_package(TBB REQUIRED tbb)
if (NOT TBB_FOUND)
message(FATAL_ERROR "TBB is needed by the CPU backend and was not found")
else()
message(STATUS "Found TBB and imported target ${TBB_IMPORTED_TARGETS}")
if (NGRAPH_TBB_ENABLE)
include(${TBB_ROOT}/cmake/TBBBuild.cmake)
tbb_build(TBB_ROOT ${TBB_ROOT} MAKE_ARGS tbb_build_dir=${CMAKE_CURRENT_BINARY_DIR}/tbb_build
tbb_build_prefix=tbb CONFIG_DIR TBB_DIR)
find_package(TBB REQUIRED tbb)
if (NOT TBB_FOUND)
message(FATAL_ERROR "TBB is needed by the CPU backend and was not found")
else()
message(STATUS "Found TBB and imported target ${TBB_IMPORTED_TARGETS}")
endif()
endif()
include_directories(SYSTEM ${LLVM_INCLUDE_DIR} ${MKLDNN_INCLUDE_DIR})
......@@ -172,8 +174,14 @@ if (NGRAPH_CPU_ENABLE AND LLVM_INCLUDE_DIR AND
# The built-in headers are in a version-specific directory
# This must be kept in sync with the LLVM + Clang version in use
set_source_files_properties(codegen/compiler.cpp PROPERTIES COMPILE_FLAGS "-fno-rtti")
set_source_files_properties(codegen/compiler.cpp PROPERTIES COMPILE_DEFINITIONS
"EIGEN_HEADERS_PATH=\"${EIGEN_INCLUDE_DIR}\";MKLDNN_HEADERS_PATH=\"${MKLDNN_INCLUDE_DIR}\";CLANG_BUILTIN_HEADERS_PATH=\"${LLVM_LIB_DIR}/clang/5.0.0/include\";TBB_HEADERS_PATH=\"${TBB_ROOT}/include\";NGRAPH_HEADERS_PATH=\"${NGRAPH_INCLUDE_PATH}\";INSTALLED_HEADERS_PATH=\"${CMAKE_INSTALL_PREFIX}/include\";")
if (NGRAPH_TBB_ENABLE)
set_source_files_properties(codegen/compiler.cpp PROPERTIES COMPILE_DEFINITIONS
"EIGEN_HEADERS_PATH=\"${EIGEN_INCLUDE_DIR}\";MKLDNN_HEADERS_PATH=\"${MKLDNN_INCLUDE_DIR}\";CLANG_BUILTIN_HEADERS_PATH=\"${LLVM_LIB_DIR}/clang/5.0.1/include\";TBB_HEADERS_PATH=\"${TBB_ROOT}/include\";NGRAPH_HEADERS_PATH=\"${NGRAPH_INCLUDE_PATH}\";INSTALLED_HEADERS_PATH=\"${CMAKE_INSTALL_PREFIX}/include\";NGRAPH_TBB_ENABLE;")
set_source_files_properties(runtime/cpu/cpu_external_function.cpp PROPERTIES COMPILE_DEFINITIONS "NGRAPH_TBB_ENABLE")
else()
set_source_files_properties(codegen/compiler.cpp PROPERTIES COMPILE_DEFINITIONS
"EIGEN_HEADERS_PATH=\"${EIGEN_INCLUDE_DIR}\";MKLDNN_HEADERS_PATH=\"${MKLDNN_INCLUDE_DIR}\";CLANG_BUILTIN_HEADERS_PATH=\"${LLVM_LIB_DIR}/clang/5.0.1/include\";NGRAPH_HEADERS_PATH=\"${NGRAPH_INCLUDE_PATH}\";INSTALLED_HEADERS_PATH=\"${CMAKE_INSTALL_PREFIX}/include\";")
endif()
set(NGRAPH_CPU_DEBUGINFO_ENABLE 0 CACHE STRING "Enable debuginfo in the CPU backend")
set_property(SOURCE codegen/compiler.cpp APPEND_STRING PROPERTY COMPILE_DEFINITIONS
"NGCPU_DEBUGINFO=${NGRAPH_CPU_DEBUGINFO_ENABLE};")
......@@ -292,7 +300,7 @@ if (NOT APPLE)
DESTINATION "${NGRAPH_INSTALL_LIB}"
)
if (NGRAPH_CPU_ENABLE)
if (NGRAPH_TBB_ENABLE)
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/tbb_build/tbb_release/
DESTINATION ${NGRAPH_INSTALL_LIB}
FILES_MATCHING PATTERN "libtbb.so.*"
......
......@@ -270,6 +270,9 @@ std::unique_ptr<codegen::Module>
const string& source)
{
PreprocessorOptions& preprocessor_options = m_compiler->getInvocation().getPreprocessorOpts();
preprocessor_options.RetainRemappedFileBuffers = true;
if (!m_precompiled_header_valid && m_precomiled_header_source.empty() == false)
{
generate_pch(m_precomiled_header_source);
......
......@@ -66,7 +66,12 @@ SOFTWARE.
#error "unsupported Clang version - see https://github.com/nlohmann/json#supported-compilers"
#endif
#elif defined(__GNUC__) && !(defined(__ICC) || defined(__INTEL_COMPILER))
#if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) < 40900
// [Modified by Intel] The minimum GCC version below has been changed to
// gcc-4.8.5, from gcc-4.9.0. This library is not warranted to work with
// 4.8.5 due to certain compiler/runtime bugs, but testing seems to
// indicate that our usage of it is not actually triggering those bugs,
// since the relevant templates do not happen to be instantiated.
#if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) < 40805
#error "unsupported GCC version - see https://github.com/nlohmann/json#supported-compilers"
#endif
#endif
......
......@@ -236,9 +236,14 @@ void runtime::cpu::CPU_ExternalFunction::compile()
R"(// Generated by the NGraph CPU backend
#include <cmath>
#include <tbb/flow_graph.h>
)";
#ifdef NGRAPH_TBB_ENABLE
writer += "#include <tbb/flow_graph.h>\n\n";
#endif
#include <Eigen/Dense>
writer +=
R"(#include <Eigen/Dense>
#include <mkldnn.hpp>
#include "ngraph/runtime/aligned_buffer.hpp"
......
......@@ -313,7 +313,7 @@ void runtime::interpreter::INT_CallFrame::perform_nan_check(
const float* data = reinterpret_cast<float*>(tv->get_data_ptr());
for (size_t i = 0; i < tv->get_element_count(); i++)
{
if (isnan(data[i]))
if (std::isnan(data[i]))
{
if (op)
{
......@@ -332,7 +332,7 @@ void runtime::interpreter::INT_CallFrame::perform_nan_check(
const double* data = reinterpret_cast<double*>(tv->get_data_ptr());
for (size_t i = 0; i < tv->get_element_count(); i++)
{
if (isnan(data[i]))
if (std::isnan(data[i]))
{
if (op)
{
......
......@@ -25,12 +25,21 @@ if (NGRAPH_CPU_ENABLE AND NOT APPLE)
set(HEADER_PATHS
"EIGEN_HEADERS_PATH=\"${EIGEN_INCLUDE_DIR}\""
"MKLDNN_HEADERS_PATH=\"${MKLDNN_INCLUDE_DIR}\""
"CLANG_BUILTIN_HEADERS_PATH=\"${LLVM_LIB_DIR}/clang/5.0.0/include\""
"TBB_HEADERS_PATH=\"${TBB_ROOT}/include\""
"CLANG_BUILTIN_HEADERS_PATH=\"${LLVM_LIB_DIR}/clang/5.0.1/include\""
"NGRAPH_HEADERS_PATH=\"${NGRAPH_INCLUDE_PATH}\""
)
if(NGRAPH_TBB_ENABLE)
list(APPEND HEADER_PATHS "TBB_HEADERS_PATH=\"${TBB_ROOT}/include\"")
endif()
if(NGRAPH_TBB_ENABLE)
set(NGRAPH_TBB_OPTION "NGRAPH_TBB_ENABLE")
else()
set(NGRAPH_TBB_OPTION "")
endif()
message("HEADER_PATHS ${HEADER_PATHS}")
set_source_files_properties(main.cpp PROPERTIES COMPILE_DEFINITIONS "${HEADER_PATHS}")
set_source_files_properties(main.cpp PROPERTIES COMPILE_DEFINITIONS "${HEADER_PATHS};${NGRAPH_TBB_OPTION}")
endif()
......@@ -87,13 +87,17 @@ int main(int argc, char** argv)
vector<ResourceInfo> include_paths;
include_paths.push_back({CLANG_BUILTIN_HEADERS_PATH, {}, true});
include_paths.push_back({"/usr/include/x86_64-linux-gnu", {"asm", "sys", "bits", "gnu"}});
include_paths.push_back({"/usr/include", {"asm", "sys", "bits", "gnu"}});
include_paths.push_back({"/usr/include", {"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({MKLDNN_HEADERS_PATH, {}, true});
include_paths.push_back({NGRAPH_HEADERS_PATH, {}, true});
#ifdef NGRAPH_TBB_ENABLE
include_paths.push_back({TBB_HEADERS_PATH, {}, true});
#endif
if (output_path.empty())
{
......
......@@ -130,6 +130,8 @@ void iterate_files_worker(const string& path,
{
DIR* dir;
struct dirent* ent;
// If we cannot open the directory, we silently ignore it.
if ((dir = opendir(path.c_str())) != nullptr)
{
while ((ent = readdir(dir)) != nullptr)
......@@ -160,10 +162,6 @@ void iterate_files_worker(const string& path,
}
closedir(dir);
}
else
{
throw std::runtime_error("error enumerating file " + path);
}
}
void iterate_files(const string& path,
......
......@@ -14,6 +14,10 @@
include( ../cmake/external_gtest.cmake )
include( ../cmake/external_eigen.cmake )
include( ../cmake/external_mkldnn.cmake )
include( ../cmake/external_llvm.cmake )
if (NGRAPH_USE_PREBUILT_LLVM OR DEFINED LLVM_TARBALL_URL)
include( ../cmake/external_llvm_prebuilt.cmake )
else()
include( ../cmake/external_llvm.cmake )
endif()
include( ../cmake/external_tbb.cmake )
include( ../cmake/external_argon_transformer.cmake )
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