2020-12-30 12:35:06 +00:00
|
|
|
# GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
|
2020-06-21 19:10:22 +00:00
|
|
|
# This file is part of GNSS-SDR.
|
|
|
|
#
|
2020-12-30 12:35:06 +00:00
|
|
|
# SPDX-FileCopyrightText: 2010-2020 C. Fernandez-Prades cfernandez(at)cttc.es
|
|
|
|
# SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
|
2020-06-21 19:10:22 +00:00
|
|
|
|
|
|
|
find_package(benchmark QUIET)
|
|
|
|
|
|
|
|
if(NOT benchmark_FOUND)
|
|
|
|
set(BENCHMARK_COMPILER -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER})
|
|
|
|
set(BENCHMARK_TOOLCHAIN_ARG "")
|
|
|
|
if(DEFINED ENV{OECORE_TARGET_SYSROOT})
|
|
|
|
set(BENCHMARK_COMPILER "")
|
2022-07-28 08:37:36 +00:00
|
|
|
set(BENCHMARK_TOOLCHAIN_ARG "-DCMAKE_TOOLCHAIN_FILE=${GNSSSDR_SOURCE_DIR}/cmake/Toolchains/oe-sdk_cross.cmake")
|
2020-06-21 19:10:22 +00:00
|
|
|
else()
|
|
|
|
if(CMAKE_TOOLCHAIN_FILE)
|
|
|
|
set(BENCHMARK_TOOLCHAIN_ARG "-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}")
|
|
|
|
endif()
|
|
|
|
if(ENABLE_PACKAGING)
|
|
|
|
set(BENCHMARK_TOOLCHAIN_ARG "-DCMAKE_VERBOSE_MAKEFILE=ON")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
set(BENCHMARK_BUILD_COMMAND "${CMAKE_COMMAND}"
|
2022-07-28 08:37:36 +00:00
|
|
|
"--build" "${GNSSSDR_BINARY_DIR}/benchmark-${GNSSSDR_BENCHMARK_LOCAL_VERSION}"
|
2020-06-21 19:10:22 +00:00
|
|
|
"--config" $<$<CONFIG:Debug>:Debug>$<$<CONFIG:Release>:Release>$<$<CONFIG:RelWithDebInfo>:RelWithDebInfo>$<$<CONFIG:MinSizeRel>:MinSizeRel>$<$<CONFIG:NoOptWithASM>:Debug>$<$<CONFIG:Coverage>:Debug>$<$<CONFIG:O2WithASM>:RelWithDebInfo>$<$<CONFIG:O3WithASM>:RelWithDebInfo>$<$<CONFIG:ASAN>:Debug>
|
|
|
|
)
|
2024-01-14 07:41:03 +00:00
|
|
|
if(CMAKE_GENERATOR STREQUAL Xcode)
|
|
|
|
set(VOLK_GNSSSDR_BUILD_COMMAND "xcodebuild"
|
|
|
|
"-configuration" $<$<CONFIG:Debug>:Debug>$<$<CONFIG:Release>:Release>$<$<CONFIG:RelWithDebInfo>:RelWithDebInfo>$<$<CONFIG:MinSizeRel>:MinSizeRel>$<$<CONFIG:NoOptWithASM>:Debug>$<$<CONFIG:Coverage>:Debug>$<$<CONFIG:O2WithASM>:RelWithDebInfo>$<$<CONFIG:O3WithASM>:RelWithDebInfo>$<$<CONFIG:ASAN>:Debug>
|
|
|
|
)
|
|
|
|
endif()
|
2020-06-21 19:10:22 +00:00
|
|
|
|
|
|
|
if((CMAKE_VERSION VERSION_GREATER 3.12.0) AND NOT (CMAKE_GENERATOR STREQUAL Xcode))
|
|
|
|
set(BENCHMARK_PARALLEL_BUILD "--parallel 2")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
ExternalProject_Add(google-benchmark-${GNSSSDR_BENCHMARK_LOCAL_VERSION}
|
|
|
|
GIT_REPOSITORY https://github.com/google/benchmark
|
|
|
|
GIT_TAG v${GNSSSDR_BENCHMARK_LOCAL_VERSION}
|
2022-07-28 08:37:36 +00:00
|
|
|
SOURCE_DIR ${GNSSSDR_BINARY_DIR}/thirdparty/benchmark
|
|
|
|
BINARY_DIR ${GNSSSDR_BINARY_DIR}/benchmark-${GNSSSDR_BENCHMARK_LOCAL_VERSION}
|
2020-06-21 19:10:22 +00:00
|
|
|
CMAKE_ARGS ${BENCHMARK_COMPILER}
|
2021-06-04 23:28:01 +00:00
|
|
|
-DBENCHMARK_ENABLE_TESTING=OFF
|
2022-07-19 05:36:45 +00:00
|
|
|
-DBENCHMARK_USE_BUNDLED_GTEST=OFF
|
2020-06-21 19:10:22 +00:00
|
|
|
${BENCHMARK_TOOLCHAIN_ARG}
|
|
|
|
-DCMAKE_BUILD_TYPE=$<$<CONFIG:Debug>:Debug>$<$<CONFIG:Release>:Release>$<$<CONFIG:RelWithDebInfo>:RelWithDebInfo>$<$<CONFIG:MinSizeRel>:MinSizeRel>$<$<CONFIG:NoOptWithASM>:Debug>$<$<CONFIG:Coverage>:Debug>$<$<CONFIG:O2WithASM>:RelWithDebInfo>$<$<CONFIG:O3WithASM>:RelWithDebInfo>$<$<CONFIG:ASAN>:Debug>
|
2020-06-21 19:59:05 +00:00
|
|
|
BUILD_COMMAND "${BENCHMARK_BUILD_COMMAND} ${BENCHMARK_PARALLEL_BUILD}"
|
2020-06-21 19:10:22 +00:00
|
|
|
UPDATE_COMMAND ""
|
|
|
|
PATCH_COMMAND ""
|
2022-07-28 08:37:36 +00:00
|
|
|
BUILD_BYPRODUCTS ${GNSSSDR_BINARY_DIR}/benchmark-${GNSSSDR_BENCHMARK_LOCAL_VERSION}/src/${CMAKE_FIND_LIBRARY_PREFIXES}benchmark${CMAKE_STATIC_LIBRARY_SUFFIX}
|
2020-06-21 19:10:22 +00:00
|
|
|
INSTALL_COMMAND ""
|
|
|
|
)
|
|
|
|
|
|
|
|
add_library(benchmark::benchmark STATIC IMPORTED)
|
|
|
|
add_dependencies(benchmark::benchmark google-benchmark-${GNSSSDR_BENCHMARK_LOCAL_VERSION})
|
2022-07-28 08:37:36 +00:00
|
|
|
file(MAKE_DIRECTORY ${GNSSSDR_BINARY_DIR}/thirdparty/benchmark/include)
|
|
|
|
file(MAKE_DIRECTORY ${GNSSSDR_BINARY_DIR}/benchmark-${GNSSSDR_BENCHMARK_LOCAL_VERSION}/include)
|
2020-06-21 19:10:22 +00:00
|
|
|
set_target_properties(benchmark::benchmark PROPERTIES
|
|
|
|
IMPORTED_LINK_INTERFACE_LANGUAGES "CXX"
|
|
|
|
IMPORTED_CONFIGURATIONS "None;Debug;Release;RelWithDebInfo;MinSizeRel"
|
|
|
|
MAP_IMPORTED_CONFIG_NOOPTWITHASM Debug
|
|
|
|
MAP_IMPORTED_CONFIG_COVERAGE Debug
|
|
|
|
MAP_IMPORTED_CONFIG_O2WITHASM RelWithDebInfo
|
|
|
|
MAP_IMPORTED_CONFIG_O3WITHASM RelWithDebInfo
|
|
|
|
MAP_IMPORTED_CONFIG_ASAN Debug
|
2022-07-28 08:37:36 +00:00
|
|
|
IMPORTED_LOCATION_NONE ${GNSSSDR_BINARY_DIR}/benchmark-${GNSSSDR_BENCHMARK_LOCAL_VERSION}/src/${CMAKE_FIND_LIBRARY_PREFIXES}benchmark${CMAKE_STATIC_LIBRARY_SUFFIX}
|
|
|
|
IMPORTED_LOCATION_DEBUG ${GNSSSDR_BINARY_DIR}/benchmark-${GNSSSDR_BENCHMARK_LOCAL_VERSION}/src/${CMAKE_FIND_LIBRARY_PREFIXES}benchmark${CMAKE_STATIC_LIBRARY_SUFFIX}
|
|
|
|
IMPORTED_LOCATION_RELEASE ${GNSSSDR_BINARY_DIR}/benchmark-${GNSSSDR_BENCHMARK_LOCAL_VERSION}/src/${CMAKE_FIND_LIBRARY_PREFIXES}benchmark${CMAKE_STATIC_LIBRARY_SUFFIX}
|
|
|
|
IMPORTED_LOCATION_RELWITHDEBINFO ${GNSSSDR_BINARY_DIR}/benchmark-${GNSSSDR_BENCHMARK_LOCAL_VERSION}/src/${CMAKE_FIND_LIBRARY_PREFIXES}benchmark${CMAKE_STATIC_LIBRARY_SUFFIX}
|
|
|
|
IMPORTED_LOCATION_MINSIZEREL ${GNSSSDR_BINARY_DIR}/benchmark-${GNSSSDR_BENCHMARK_LOCAL_VERSION}/src/${CMAKE_FIND_LIBRARY_PREFIXES}benchmark${CMAKE_STATIC_LIBRARY_SUFFIX}
|
|
|
|
INTERFACE_INCLUDE_DIRECTORIES "${GNSSSDR_BINARY_DIR}/thirdparty/benchmark/include"
|
|
|
|
INTERFACE_LINK_LIBRARIES "${GNSSSDR_BINARY_DIR}/benchmark-${GNSSSDR_BENCHMARK_LOCAL_VERSION}/src/${CMAKE_FIND_LIBRARY_PREFIXES}benchmark${CMAKE_STATIC_LIBRARY_SUFFIX};${GNSSSDR_BINARY_DIR}/benchmark-${GNSSSDR_BENCHMARK_LOCAL_VERSION}/src/${CMAKE_FIND_LIBRARY_PREFIXES}benchmark_main${CMAKE_STATIC_LIBRARY_SUFFIX}"
|
2020-06-21 19:10:22 +00:00
|
|
|
)
|
|
|
|
if((CMAKE_GENERATOR STREQUAL Xcode) OR MSVC)
|
|
|
|
set_target_properties(benchmark::benchmark PROPERTIES
|
2022-07-28 08:37:36 +00:00
|
|
|
IMPORTED_LOCATION_DEBUG ${GNSSSDR_BINARY_DIR}/benchmark-${GNSSSDR_BENCHMARK_LOCAL_VERSION}/src/Debug/${CMAKE_FIND_LIBRARY_PREFIXES}benchmark${CMAKE_STATIC_LIBRARY_SUFFIX}
|
|
|
|
IMPORTED_LOCATION_RELEASE ${GNSSSDR_BINARY_DIR}/benchmark-${GNSSSDR_BENCHMARK_LOCAL_VERSION}/src/Release/${CMAKE_FIND_LIBRARY_PREFIXES}benchmark${CMAKE_STATIC_LIBRARY_SUFFIX}
|
|
|
|
IMPORTED_LOCATION_RELWITHDEBINFO ${GNSSSDR_BINARY_DIR}/benchmark-${GNSSSDR_BENCHMARK_LOCAL_VERSION}/src/RelWithDebInfo/${CMAKE_FIND_LIBRARY_PREFIXES}benchmark${CMAKE_STATIC_LIBRARY_SUFFIX}
|
|
|
|
IMPORTED_LOCATION_MINSIZEREL ${GNSSSDR_BINARY_DIR}/benchmark-${GNSSSDR_BENCHMARK_LOCAL_VERSION}/src/MinSizeRel/${CMAKE_FIND_LIBRARY_PREFIXES}benchmark${CMAKE_STATIC_LIBRARY_SUFFIX}
|
|
|
|
INTERFACE_LINK_LIBRARIES "${GNSSSDR_BINARY_DIR}/benchmark-${GNSSSDR_BENCHMARK_LOCAL_VERSION}/src/$<$<CONFIG:Debug>:Debug/>$<$<CONFIG:Release>:Release/>$<$<CONFIG:RelWithDebInfo>:RelWithDebInfo/>$<$<CONFIG:MinSizeRel>:MinSizeRel/>benchmark${CMAKE_STATIC_LIBRARY_SUFFIX};
|
|
|
|
${GNSSSDR_BINARY_DIR}/benchmark-${GNSSSDR_BENCHMARK_LOCAL_VERSION}/src/$<$<CONFIG:Debug>:Debug/>$<$<CONFIG:Release>:Release/>$<$<CONFIG:RelWithDebInfo>:RelWithDebInfo/>$<$<CONFIG:MinSizeRel>:MinSizeRel/>benchmark_main${CMAKE_STATIC_LIBRARY_SUFFIX}"
|
2020-06-21 19:10:22 +00:00
|
|
|
)
|
|
|
|
endif()
|
|
|
|
set_target_properties(benchmark::benchmark PROPERTIES
|
|
|
|
INTERFACE_LINK_LIBRARIES Threads::Threads
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
2020-06-24 12:05:05 +00:00
|
|
|
macro(add_benchmark)
|
|
|
|
# First argument is the benchmark name, the rest are dependencies
|
|
|
|
add_executable(${ARGV0} ${ARGV0}.cc)
|
|
|
|
target_link_libraries(${ARGV0} PRIVATE benchmark::benchmark)
|
|
|
|
if(${ARGC} GREATER 1)
|
|
|
|
set(list_dependencies "${ARGN}")
|
2021-07-24 11:59:05 +00:00
|
|
|
list(REMOVE_AT list_dependencies 0)
|
2020-06-24 12:05:05 +00:00
|
|
|
foreach(dependency IN LISTS list_dependencies)
|
|
|
|
target_link_libraries(${ARGV0} PRIVATE ${dependency})
|
|
|
|
endforeach()
|
|
|
|
endif()
|
|
|
|
add_custom_command(TARGET ${ARGV0} POST_BUILD
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:${ARGV0}>
|
|
|
|
${LOCAL_INSTALL_BASE_DIR}/install/$<TARGET_FILE_NAME:${ARGV0}>
|
|
|
|
)
|
|
|
|
endmacro()
|
2020-06-21 19:10:22 +00:00
|
|
|
|
2024-06-30 07:45:51 +00:00
|
|
|
set(EXTRA_BENCHMARK_DEPENDENCIES "")
|
|
|
|
if(ENABLE_GLOG_AND_GFLAGS)
|
|
|
|
set(EXTRA_BENCHMARK_DEPENDENCIES "Gflags::gflags;Glog::glog")
|
|
|
|
endif()
|
|
|
|
|
2024-07-24 19:02:39 +00:00
|
|
|
add_benchmark(benchmark_atan2 Gnuradio::runtime)
|
2020-06-24 12:05:05 +00:00
|
|
|
add_benchmark(benchmark_copy)
|
2024-08-10 09:31:15 +00:00
|
|
|
add_benchmark(benchmark_crypto core_libs Boost::headers ${EXTRA_BENCHMARK_DEPENDENCIES})
|
2024-10-06 06:14:46 +00:00
|
|
|
# add_benchmark(benchmark_osnma core_libs Boost::headers ${EXTRA_BENCHMARK_DEPENDENCIES})
|
2024-06-30 07:45:51 +00:00
|
|
|
add_benchmark(benchmark_detector core_system_parameters ${EXTRA_BENCHMARK_DEPENDENCIES})
|
2024-07-24 19:02:39 +00:00
|
|
|
add_benchmark(benchmark_preamble core_system_parameters ${EXTRA_BENCHMARK_DEPENDENCIES})
|
2024-06-30 07:45:51 +00:00
|
|
|
add_benchmark(benchmark_reed_solomon core_system_parameters ${EXTRA_BENCHMARK_DEPENDENCIES})
|
2020-06-29 10:32:35 +00:00
|
|
|
|
2020-06-30 11:41:20 +00:00
|
|
|
if(has_std_plus_void)
|
|
|
|
target_compile_definitions(benchmark_detector PRIVATE -DCOMPILER_HAS_STD_PLUS_VOID=1)
|
2020-06-29 10:32:35 +00:00
|
|
|
endif()
|
2020-07-01 21:05:33 +00:00
|
|
|
if(has_transform_reduce)
|
|
|
|
target_compile_definitions(benchmark_detector PRIVATE -DCOMPILER_HAS_STD_TRANSFORM_REDUCE=1)
|
|
|
|
endif()
|
|
|
|
if(has_transform_reduce_with_execution_policy)
|
|
|
|
target_compile_definitions(benchmark_detector PRIVATE -DCOMPILER_HAS_STD_TRANSFORM_REDUCE_WITH_POLICY=1)
|
|
|
|
endif()
|