Skip to content

Commit

Permalink
Revert "Disable optimizations"
Browse files Browse the repository at this point in the history
This reverts commit 8c8d6dc.
  • Loading branch information
root committed Sep 25, 2018
1 parent ab50390 commit f37c145
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 25 deletions.
31 changes: 14 additions & 17 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,20 @@ if(USE_TENSORRT)
${ONNX_PROTO_LIBRARY} ${ONNX_LIBRARY} ${PROTOBUF_LIBRARY})
endif()

if(ENABLE_TESTCOVERAGE)
message(STATUS "Compiling with test coverage support enabled. This will result in additional files being written to your source directory!")
find_program( GCOV_PATH gcov )
if(NOT GCOV_PATH)
message(FATAL_ERROR "gcov not found! Aborting...")
endif() # NOT GCOV_PATH

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --coverage")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage")
set(CMAKE_LINKER_FLAGS "${CMAKE_LINKER_FLAGS} --coverage")
set(GTEST_LIBRARIES "${GTEST_LIBRARIES} --coverage")
link_libraries(gcov)
endif()

if(USE_MKLDNN)
include(cmake/MklDnn.cmake)
# CPU architecture (e.g., C5) can't run on another architecture (e.g., g3).
Expand Down Expand Up @@ -295,23 +309,6 @@ if(USE_ASAN)
list(APPEND mxnet_LINKER_LIBS asan)
endif()

if(ENABLE_TESTCOVERAGE)
message(STATUS "Compiling with test coverage support enabled. This will result in additional files being written to your source directory!")
find_program( GCOV_PATH gcov )
if(NOT GCOV_PATH)
message(FATAL_ERROR "gcov not found! Aborting...")
endif() # NOT GCOV_PATH

# According to https://stackoverflow.com/questions/15909788/how-does-gcc-behave-if-passed-conflicting-compiler-flags,
# compilers will ignore earlier set flags (like -O) if they are re-set at a later point.
# Thus, this code should be at the very end of the logic
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --coverage -O0")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage -O0")
set(CMAKE_LINKER_FLAGS "${CMAKE_LINKER_FLAGS} --coverage")
set(GTEST_LIBRARIES "${GTEST_LIBRARIES} --coverage")
link_libraries(gcov)
endif()

list(APPEND mxnet_LINKER_LIBS ${mshadow_LINKER_LIBS})

foreach(var ${C_CXX_INCLUDE_DIRECTORIES})
Expand Down
13 changes: 5 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ endif
CFLAGS += -I$(TPARTYDIR)/mshadow/ -I$(TPARTYDIR)/dmlc-core/include -fPIC -I$(NNVM_PATH)/include -I$(DLPACK_PATH)/include -I$(TPARTYDIR)/tvm/include -Iinclude $(MSHADOW_CFLAGS)
LDFLAGS = -pthread $(MSHADOW_LDFLAGS) $(DMLC_LDFLAGS)

ifeq ($(ENABLE_TESTCOVERAGE), 1)
CFLAGS += --coverage
LDFLAGS += --coverage
endif

ifeq ($(USE_TENSORRT), 1)
CFLAGS += -I$(ROOTDIR) -I$(TPARTYDIR) -DONNX_NAMESPACE=$(ONNX_NAMESPACE) -DMXNET_USE_TENSORRT=1
LDFLAGS += -lprotobuf -pthread -lonnx -lonnx_proto -lnvonnxparser -lnvonnxparser_runtime -lnvinfer -lnvinfer_plugin
Expand Down Expand Up @@ -476,14 +481,6 @@ else
CFLAGS += -DMXNET_USE_LIBJPEG_TURBO=0
endif

ifeq ($(ENABLE_TESTCOVERAGE), 1)
# According to https://stackoverflow.com/questions/15909788/how-does-gcc-behave-if-passed-conflicting-compiler-flags,
# compilers will ignore earlier set flags (like -O) if they are re-set at a later point.
# Thus, this code should be at the very end of the Makefile init logic
CFLAGS += --coverage -O0
LDFLAGS += --coverage
endif

# For quick compile test, used smaller subset
ALLX_DEP= $(ALL_DEP)

Expand Down

0 comments on commit f37c145

Please sign in to comment.