Enable customization of architecture dependent compiler optimizations via configure, defaulting to -march=native.
Change: 144470919
This commit is contained in:
parent
1c5120141b
commit
c4e3d4a74e
15
configure
vendored
15
configure
vendored
@ -54,6 +54,15 @@ while true; do
|
||||
# Retry
|
||||
done
|
||||
|
||||
## Set up architecture-dependent optimization flags.
|
||||
if [ -z "$CC_OPT_FLAGS" ]; then
|
||||
default_cc_opt_flags="-march=native"
|
||||
read -p "Please specify optimization flags to use during compilation [Default is $default_cc_opt_flags]: " CC_OPT_FLAGS
|
||||
if [ -z "$CC_OPT_FLAGS" ]; then
|
||||
CC_OPT_FLAGS=$default_cc_opt_flags
|
||||
fi
|
||||
fi
|
||||
|
||||
if is_windows; then
|
||||
TF_NEED_GCP=0
|
||||
TF_NEED_HDFS=0
|
||||
@ -153,6 +162,12 @@ fi
|
||||
# Invoke python_config and set up symlinks to python includes
|
||||
./util/python/python_config.sh --setup "$PYTHON_BIN_PATH"
|
||||
|
||||
# Append CC optimization flags to bazel.rc
|
||||
echo >> tools/bazel.rc
|
||||
for opt in $CC_OPT_FLAGS; do
|
||||
echo "build --cxxopt=$opt --copt=$opt" >> tools/bazel.rc
|
||||
done
|
||||
|
||||
# Run the gen_git_source to create links where bazel can track dependencies for
|
||||
# git hash propagation
|
||||
GEN_GIT_SOURCE=tensorflow/tools/git/gen_git_source.py
|
||||
|
@ -27,6 +27,7 @@ option(tensorflow_BUILD_ALL_KERNELS "Build all OpKernels" ON)
|
||||
option(tensorflow_BUILD_CONTRIB_KERNELS "Build OpKernels from tensorflow/contrib/..." ON)
|
||||
option(tensorflow_BUILD_CC_TESTS "Build cc unit tests " OFF)
|
||||
option(tensorflow_BUILD_PYTHON_TESTS "Build python unit tests " OFF)
|
||||
option(tensorflow_OPTIMIZE_FOR_NATIVE_ARCH "Enable compiler optimizations for the native processor architecture (if available)" ON)
|
||||
|
||||
if (NOT WIN32)
|
||||
# Threads: defines CMAKE_THREAD_LIBS_INIT and adds -pthread compile option
|
||||
@ -67,7 +68,15 @@ if(WIN32)
|
||||
endif()
|
||||
|
||||
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
||||
set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "-fno-exceptions -std=c++11")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions -std=c++11")
|
||||
endif()
|
||||
|
||||
if (tensorflow_OPTIMIZE_FOR_NATIVE_ARCH)
|
||||
include(CheckCXXCompilerFlag)
|
||||
CHECK_CXX_COMPILER_FLAG("-march=native" COMPILER_OPT_ARCH_NATIVE_SUPPORTED)
|
||||
if (COMPILER_OPT_ARCH_NATIVE_SUPPORTED)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# External dependencies
|
||||
|
@ -137,7 +137,7 @@ $(shell mkdir -p $(DEPDIR) >/dev/null)
|
||||
|
||||
# Settings for the target compiler.
|
||||
CXX := $(CC_PREFIX) gcc
|
||||
OPTFLAGS := -O2
|
||||
OPTFLAGS := -O2 -march=native
|
||||
CXXFLAGS := --std=c++11 -DIS_SLIM_BUILD -fno-exceptions -DNDEBUG $(OPTFLAGS)
|
||||
LDFLAGS := \
|
||||
-L/usr/local/lib
|
||||
|
Loading…
Reference in New Issue
Block a user