Intel #5721

Open
wants to merge 1,467 commits into
from
Commits
The table of contents is too big for display.
+194,904 −29,868
Split
View
@@ -78,6 +78,7 @@ distribute/*
python/caffe/proto/
cmake_build
.cmake_build
+nbproject/*
# Generated documentation
docs/_site
@@ -93,3 +94,7 @@ LOCK
LOG*
CURRENT
MANIFEST-*
+
+# Ignore MKL files (except prepare_mkl.sh)
+/external/mkl/*
+!/external/mkl/prepare_mkl.sh
View
@@ -27,7 +27,10 @@ include(cmake/ConfigGen.cmake)
# ---[ Options
caffe_option(CPU_ONLY "Build Caffe without CUDA support" OFF) # TODO: rename to USE_CUDA
+caffe_option(USE_OPENMP "Build Caffe with OpenMP support" ON )
caffe_option(USE_CUDNN "Build Caffe with cuDNN library support" ON IF NOT CPU_ONLY)
+caffe_option(USE_MKL2017_AS_DEFAULT_ENGINE "Use MKL2017 primitives for supported layers" OFF)
+caffe_option(USE_MKLDNN_AS_DEFAULT_ENGINE "Use MKL-DNN primitives for supported layers" OFF)
caffe_option(BUILD_SHARED_LIBS "Build shared libraries" ON)
caffe_option(BUILD_python "Build Python wrapper" ON)
set(python_version "2" CACHE STRING "Specify which Python version to use")
@@ -38,13 +41,53 @@ caffe_option(USE_OPENCV "Build with OpenCV support" ON)
caffe_option(USE_LEVELDB "Build with levelDB" ON)
caffe_option(USE_LMDB "Build with lmdb" ON)
caffe_option(ALLOW_LMDB_NOLOCK "Allow MDB_NOLOCK when reading LMDB files (only if necessary)" OFF)
-
+caffe_option(USE_SYSTEMTAP "Build for SystemTap" OFF)
+caffe_option(PERFORMANCE_MONITORING "Build Caffe with PERFORMANCE_MONITORING " OFF)
+#caffe_option(USE_GITHUB_MKLDNN "Download and use MKL-DNN available on github" OFF)
+
# ---[ Dependencies
+include(cmake/MKLDNN.cmake)
include(cmake/Dependencies.cmake)
# ---[ Flags
if(UNIX OR APPLE)
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -Wall")
+
+ # Linker flags.
+ if( ${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU" OR ${CMAKE_CXX_COMPILER_ID} STREQUAL "Intel")
+ # GCC specific flags. ICC is compatible with them.
+ set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -z noexecstack -z relro -z now")
+ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -z noexecstack -z relro -z now")
+ elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
+ # In Clang, -z flags are not compatible, they need to be passed to linker via -Wl.
+ set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now")
+ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now")
+ endif()
+
+ # Compiler flags.
+ if( ${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
+ # GCC specific flags.
+ if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.9 OR CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL 4.9)
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIE -fstack-protector-strong")
+ else()
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIE -fstack-protector")
+ endif()
+ elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
+ # Clang is compatbile with some of the flags.
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIE -fstack-protector")
+ elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL "Intel" )
+ # Same as above, with exception that ICC compilation crashes with -fPIE option, even
+ # though it uses -pie linker option that require -fPIE during compilation. Checksec
+ # shows that it generates correct PIE anyway if only -pie is provided.
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fstack-protector")
+ endif()
+
+ # Generic flags.
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -fno-operator-names -Wformat -Wformat-security -Wall")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
+ # Dot not forward c++11 flag to GPU beucause it is not supported
+ set( CUDA_PROPAGATE_HOST_FLAGS OFF )
+ set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -D_FORTIFY_SOURCE=2")
+ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pie")
endif()
caffe_set_caffe_link()
@@ -65,16 +108,20 @@ configure_file(cmake/Templates/caffe_config.h.in "${PROJECT_BINARY_DIR}/caffe_co
# ---[ Includes
set(Caffe_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/include)
include_directories(${Caffe_INCLUDE_DIR} ${PROJECT_BINARY_DIR})
-include_directories(BEFORE src) # This is needed for gtest.
+include_directories(BEFORE src/gtest/include src/gmock/include) # This is needed for gtest.
# ---[ Subdirectories
-add_subdirectory(src/gtest)
+#add_subdirectory(src/gtest)
+set(BUILD_SHARED_LIBS off)
+add_subdirectory(src/gmock)
+set(BUILD_SHARED_LIBS on)
add_subdirectory(src/caffe)
add_subdirectory(tools)
add_subdirectory(examples)
add_subdirectory(python)
add_subdirectory(matlab)
add_subdirectory(docs)
+add_subdirectory(scripts/SystemTap)
# ---[ Linter target
add_custom_target(lint COMMAND ${CMAKE_COMMAND} -P ${PROJECT_SOURCE_DIR}/cmake/lint.cmake)
View
@@ -1,5 +1,14 @@
+
COPYRIGHT
+All modification made by Intel Corporation: © 2017 Intel Corporation.
+
+All new contributions compared to the original branch:
+Copyright (c) 2015, 2016 Wei Liu (UNC Chapel Hill), Dragomir Anguelov (Zoox),
+Dumitru Erhan (Google), Christian Szegedy (Google), Scott Reed (UMich Ann Arbor),
+Cheng-Yang Fu (UNC Chapel Hill), Alexander C. Berg (UNC Chapel Hill).
+All rights reserved.
+
All contributions by the University of California:
Copyright (c) 2014, 2015, The Regents of the University of California (Regents)
All rights reserved.
Oops, something went wrong.