Skip to content

Commit

Permalink
Use own benchmark and not any system pre-built ones:
Browse files Browse the repository at this point in the history
(1) use the cmake files of the corresponding libs
(2) allow static linkage of gtest and gbenchmark.
(3) Helps removing the temp solution in facebookarchive#1112
  • Loading branch information
Yangqing committed Oct 20, 2017
1 parent 40210af commit b3a4b1e
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 16 deletions.
6 changes: 0 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,6 @@ set(CAFFE2_VERSION_PATCH 1)
set(CAFFE2_VERSION
"${CAFFE2_VERSION_MAJOR}.${CAFFE2_VERSION_MINOR}.${CAFFE2_VERSION_PATCH}")

# ---[ Do not search cmake install prefix. See the following link for details:
# https://github.com/caffe2/caffe2/commit/251d2d0c521c781276eea3748d92fc92e5dbceab
message(STATUS "Setting CMAKE_FIND_NO_INSTALL_PREFIX")
set(CMAKE_FIND_NO_INSTALL_PREFIX TRUE)


# ---[ Options.
# Note to developers: if you add an option below, make sure you also add it to
# cmake/Summary.cmake so that the summary prints out the option values.
Expand Down
4 changes: 4 additions & 0 deletions caffe2/binaries/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ if (USE_CUDA)
caffe2_binary_target("inspect_gpus.cc")
target_link_libraries(inspect_gpus ${CUDA_LIBRARIES})
caffe2_binary_target("print_core_object_sizes.cc")

# Core overhead benchmark
caffe2_binary_target("core_overhead_benchmark.cc")
target_link_libraries(core_overhead_benchmark benchmark)
endif()

if (USE_ZMQ)
Expand Down
27 changes: 19 additions & 8 deletions cmake/Dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -114,17 +114,28 @@ endif()

# ---[ Googletest and benchmark
if(BUILD_TEST)
set(TEMP_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS})
# We will build gtest as static libs and embed it directly into the binary.
set(BUILD_SHARED_LIBS OFF)
# For gtest, we will simply embed it into our test binaries, so we won't
# need to install it.
set(BUILD_GTEST ON)
set(INSTALL_GTEST OFF)
# We currently don't need gmock right now.
set(BUILD_GMOCK OFF)
add_subdirectory(${PROJECT_SOURCE_DIR}/third_party/googletest)
caffe2_include_directories(${PROJECT_SOURCE_DIR}/third_party/googletest/googletest/include)

find_package(Benchmark)
if(Benchmark_FOUND)
list(APPEND Caffe2_DEPENDENCY_LIBS ${Benchmark_LIBRARIES})
caffe2_include_directories(${Benchmark_INCLUDE_DIRS})
else()
add_subdirectory(${PROJECT_SOURCE_DIR}/third_party/benchmark)
caffe2_include_directories(${PROJECT_SOURCE_DIR}/third_party/benchmark/include)
endif()
# We will not need to test benchmark lib itself.
set(BENCHMARK_ENABLE_TESTING OFF)
# We will not need to install benchmark. This is pending
# https://github.com/google/benchmark/pull/463
set(INSTALL_BENCHMARK OFF)
add_subdirectory(${PROJECT_SOURCE_DIR}/third_party/benchmark)
caffe2_include_directories(${PROJECT_SOURCE_DIR}/third_party/benchmark/include)

# Recover the build shared libs option.
set(BUILD_SHARED_LIBS ${TEMP_BUILD_SHARED_LIBS})
endif()

# ---[ LMDB
Expand Down
2 changes: 1 addition & 1 deletion third_party/benchmark
Submodule benchmark updated 60 files
+6 −0 .travis-libcxx-setup.sh
+132 −77 .travis.yml
+5 −0 AUTHORS
+23 −14 CMakeLists.txt
+6 −0 CONTRIBUTORS
+168 −15 README.md
+13 −11 appveyor.yml
+32 −5 cmake/AddCXXCompilerFlag.cmake
+24 −6 cmake/CXXFeatureCheck.cmake
+1 −0 cmake/Config.cmake.in
+1,212 −3 include/benchmark/benchmark.h
+19 −856 include/benchmark/benchmark_api.h
+0 −66 include/benchmark/macros.h
+8 −200 include/benchmark/reporter.h
+41 −7 src/CMakeLists.txt
+75 −22 src/benchmark.cc
+6 −6 src/benchmark_api_internal.h
+53 −14 src/benchmark_register.cc
+8 −0 src/check.h
+2 −2 src/colorprint.cc
+3 −3 src/commandlineflags.cc
+11 −75 src/complexity.cc
+2 −8 src/complexity.h
+58 −10 src/console_reporter.cc
+68 −0 src/counter.cc
+26 −0 src/counter.h
+52 −11 src/csv_reporter.cc
+30 −3 src/cycleclock.h
+14 −4 src/internal_macros.h
+23 −9 src/json_reporter.cc
+2 −2 src/log.h
+4 −5 src/reporter.cc
+2 −1 src/sleep.cc
+5 −7 src/sleep.h
+0 −306 src/stat.h
+175 −0 src/statistics.cc
+37 −0 src/statistics.h
+18 −14 src/string_util.cc
+1 −1 src/string_util.h
+8 −1 src/sysinfo.cc
+33 −16 src/timers.cc
+44 −6 test/CMakeLists.txt
+1 −1 test/basic_test.cc
+5 −6 test/benchmark_test.cc
+3 −3 test/complexity_test.cc
+10 −0 test/cxx03_test.cc
+2 −2 test/diagnostics_test.cc
+20 −1 test/donotoptimize_test.cc
+24 −2 test/options_test.cc
+130 −0 test/output_test.h
+196 −7 test/output_test_helper.cc
+41 −7 test/register_benchmark_test.cc
+104 −15 test/reporter_output_test.cc
+250 −0 test/user_counters_tabular_test.cc
+217 −0 test/user_counters_test.cc
+6 −7 tools/compare_bench.py
+43 −1 tools/gbench/Inputs/test1_run1.json
+45 −3 tools/gbench/Inputs/test1_run2.json
+25 −14 tools/gbench/report.py
+11 −11 tools/gbench/util.py
2 changes: 1 addition & 1 deletion third_party/googletest
Submodule googletest updated 172 files

0 comments on commit b3a4b1e

Please sign in to comment.