Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Benchmarking overhaul #248

Merged
merged 11 commits into from
Jun 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
60 changes: 47 additions & 13 deletions benchmark/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,26 +1,60 @@
# NOTE: Boost is always required by the benchmarking code.
find_package(Boost 1.55.0 REQUIRED)
find_package(Boost 1.55.0 REQUIRED filesystem)
if(NOT TARGET Boost::boost)
# Depending on the CMake version, Boost::boost might not have been created.
# Depending on the CMake version, the Boost targets might not have been created.
message(STATUS "The 'Boost::boost' target is missing, creating it.")
add_library(Boost::boost INTERFACE IMPORTED)
set_target_properties(Boost::boost PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${Boost_INCLUDE_DIRS}")

message(STATUS "The 'Boost::filesystem' target is missing, creating it.")
add_library(Boost::filesystem UNKNOWN IMPORTED)
set_target_properties(Boost::filesystem PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${Boost_INCLUDE_DIRS}")
set_target_properties(Boost::filesystem PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES "CXX"
IMPORTED_LOCATION "${Boost_FILESYSTEM_LIBRARY}")
endif()

# fmt is always required.
# NOTE: need at least version 6.2
# to print 128-bit integers.
find_package(fmt 6.2 REQUIRED)

if(MPPP_BENCHMARK_FLINT)
find_package(mp++_FLINT REQUIRED)
endif()

# The benchmarking helper library.
add_library(mp++_benchmark STATIC utils.cpp)
target_compile_options(mp++_benchmark PRIVATE
"$<$<CONFIG:Debug>:${MPPP_CXX_FLAGS_DEBUG}>"
"$<$<CONFIG:Release>:${MPPP_CXX_FLAGS_RELEASE}>"
"$<$<CONFIG:RelWithDebInfo>:${MPPP_CXX_FLAGS_RELEASE}>"
"$<$<CONFIG:MinSizeRel>:${MPPP_CXX_FLAGS_RELEASE}>"
)
target_link_libraries(mp++_benchmark PRIVATE Boost::boost Boost::filesystem)
# Let's setup the target C++ standard, but only if the user did not provide it manually.
if(NOT CMAKE_CXX_STANDARD)
if(MPPP_COMPILER_SUPPORTS_CONCEPTS)
# NOTE: the idea here is that we want to use C++14 if the compilers supports
# concepts (as variable concepts are essentially template variables).
set_property(TARGET mp++_benchmark PROPERTY CXX_STANDARD 14)
else()
set_property(TARGET mp++_benchmark PROPERTY CXX_STANDARD 11)
endif()
endif()
set_property(TARGET mp++_benchmark PROPERTY CXX_STANDARD_REQUIRED YES)
set_property(TARGET mp++_benchmark PROPERTY CXX_EXTENSIONS NO)

# Custom target to run all benchmarks.
add_custom_target(benchmark)

# Helper to add a benchmark.
function(ADD_MPPP_BENCHMARK arg1)
add_executable(${arg1} ${arg1}.cpp)
# NOTE: always link to Boost, as we need its headers
# in the benchmarking code.
target_link_libraries(${arg1} PRIVATE mp++ Boost::boost)
target_link_libraries(${arg1} PRIVATE mp++_benchmark mp++ fmt::fmt)
if(MPPP_BENCHMARK_BOOST)
# NOTE: when benchmarking the Boost classes,
# we make direct use of functions from the GMP API.
target_link_libraries(${arg1} PRIVATE Boost::boost mp++::GMP)
target_compile_options(${arg1} PRIVATE "-DMPPP_BENCHMARK_BOOST")
endif()
if(MPPP_BENCHMARK_FLINT)
Expand Down Expand Up @@ -77,30 +111,30 @@ if(NOT WIN32 AND UNIX AND NOT APPLE)
endif()

ADD_MPPP_BENCHMARK(integer1_dot_product_unsigned)
ADD_MPPP_BENCHMARK(integer2_dot_product_unsigned)
ADD_MPPP_BENCHMARK(integer1_dot_product_signed)
ADD_MPPP_BENCHMARK(integer2_dot_product_unsigned)
ADD_MPPP_BENCHMARK(integer2_dot_product_signed)
ADD_MPPP_BENCHMARK(integer1_vec_lshift_unsigned)
ADD_MPPP_BENCHMARK(integer2_vec_lshift_unsigned)
ADD_MPPP_BENCHMARK(integer1_vec_lshift_signed)
ADD_MPPP_BENCHMARK(integer2_vec_lshift_unsigned)
ADD_MPPP_BENCHMARK(integer2_vec_lshift_signed)
ADD_MPPP_BENCHMARK(integer1_vec_mul_unsigned)
ADD_MPPP_BENCHMARK(integer2_vec_mul_unsigned)
ADD_MPPP_BENCHMARK(integer1_vec_mul_signed)
ADD_MPPP_BENCHMARK(integer2_vec_mul_unsigned)
ADD_MPPP_BENCHMARK(integer2_vec_mul_signed)
ADD_MPPP_BENCHMARK(integer1_vec_div_unsigned)
ADD_MPPP_BENCHMARK(integer2_vec_div_unsigned)
ADD_MPPP_BENCHMARK(integer1_vec_div_signed)
ADD_MPPP_BENCHMARK(integer2_vec_div_unsigned)
ADD_MPPP_BENCHMARK(integer2_vec_div_signed)
ADD_MPPP_BENCHMARK(integer1_vec_gcd_signed)
ADD_MPPP_BENCHMARK(integer1_sort_signed)
ADD_MPPP_BENCHMARK(integer2_sort_signed)
ADD_MPPP_BENCHMARK(integer1_sort_unsigned)
ADD_MPPP_BENCHMARK(integer1_sort_signed)
ADD_MPPP_BENCHMARK(integer2_sort_unsigned)
ADD_MPPP_BENCHMARK(integer1_int_conversion)
ADD_MPPP_BENCHMARK(integer2_int_conversion)
ADD_MPPP_BENCHMARK(integer2_sort_signed)
ADD_MPPP_BENCHMARK(integer1_uint_conversion)
ADD_MPPP_BENCHMARK(integer1_int_conversion)
ADD_MPPP_BENCHMARK(integer2_uint_conversion)
ADD_MPPP_BENCHMARK(integer2_int_conversion)

if(MPPP_WITH_MPFR)
ADD_MPPP_BENCHMARK(real_alloc)
Expand Down
39 changes: 0 additions & 39 deletions benchmark/constStrings.hpp

This file was deleted.