Skip to content

Add new benchmarks #899

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

Merged
merged 1 commit into from
Dec 3, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/reusable_gpu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ jobs:
run: ctest --output-on-failure --test-dir examples -C ${{matrix.build_type}}

- name: Run benchmarks
if: matrix.build_type == 'Release'
working-directory: ${{env.BUILD_DIR}}
run: ctest --output-on-failure --test-dir benchmark -C ${{matrix.build_type}} --exclude-regex umf-bench-multithreaded

Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ endif()
# compiler is required. Moreover, if these options are not set, CMake will set
# up a strict C build, without C++ support.
set(OPTIONS_REQUIRING_CXX "UMF_BUILD_TESTS" "UMF_BUILD_LIBUMF_POOL_DISJOINT"
"UMF_BUILD_BENCHMARKS_MT")
"UMF_BUILD_BENCHMARKS_MT" "UMF_BUILD_BENCHMARKS")
foreach(option_name ${OPTIONS_REQUIRING_CXX})
if(${option_name})
enable_language(CXX)
Expand Down
53 changes: 40 additions & 13 deletions benchmark/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,24 @@
# Copyright (C) 2023 Intel Corporation
# Copyright (C) 2023-2024 Intel Corporation
# Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

include(FetchContent)
FetchContent_Declare(
googlebenchmark
GIT_REPOSITORY https://github.com/google/benchmark.git
GIT_TAG v1.9.0)

set(BENCHMARK_ENABLE_GTEST_TESTS
OFF
CACHE BOOL "" FORCE)
set(BENCHMARK_ENABLE_TESTING
OFF
CACHE BOOL "" FORCE)
set(BENCHMARK_ENABLE_INSTALL
OFF
CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(googlebenchmark)

# In MSVC builds, there is no way to determine the actual build type during the
# CMake configuration step. Therefore, this message is printed in all MSVC
# builds.
Expand Down Expand Up @@ -32,7 +49,7 @@ function(add_umf_benchmark)
"${multiValueArgs}"
${ARGN})

set(BENCH_NAME umf-bench-${ARG_NAME})
set(BENCH_NAME umf-${ARG_NAME})

set(BENCH_LIBS ${ARG_LIBS} umf)

Expand All @@ -52,13 +69,17 @@ function(add_umf_benchmark)
COMMAND ${BENCH_NAME}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})

# Benchmark passes if it prints "PASSED" in the output, because ubench of
# scalable pool fails if the confidence interval exceeds maximum permitted
# 2.5%.
set_tests_properties(
${BENCH_NAME} PROPERTIES
LABELS "benchmark"
PASS_REGULAR_EXPRESSION "PASSED")
if("${BENCH_NAME}" STREQUAL "umf-ubench")
# Benchmark passes if it prints "PASSED" in the output, because ubench
# of scalable pool fails if the confidence interval exceeds maximum
# permitted 2.5%.
set_tests_properties(
${BENCH_NAME} PROPERTIES
LABELS "benchmark"
PASS_REGULAR_EXPRESSION "PASSED")
else()
set_tests_properties(${BENCH_NAME} PROPERTIES LABELS "benchmark")
endif()

if(WINDOWS)
# append PATH to DLLs
Expand All @@ -68,19 +89,19 @@ function(add_umf_benchmark)

if(UMF_BUILD_LIBUMF_POOL_DISJOINT)
target_compile_definitions(${BENCH_NAME}
PRIVATE UMF_BUILD_LIBUMF_POOL_DISJOINT=1)
PRIVATE UMF_POOL_DISJOINT_ENABLED=1)
endif()
if(UMF_BUILD_LIBUMF_POOL_JEMALLOC)
if(UMF_POOL_JEMALLOC_ENABLED)
target_compile_definitions(${BENCH_NAME}
PRIVATE UMF_BUILD_LIBUMF_POOL_JEMALLOC=1)
PRIVATE UMF_POOL_JEMALLOC_ENABLED=1)
endif()
if(UMF_POOL_SCALABLE_ENABLED)
target_compile_definitions(${BENCH_NAME}
PRIVATE UMF_POOL_SCALABLE_ENABLED=1)
endif()
if(UMF_BUILD_LEVEL_ZERO_PROVIDER)
target_compile_definitions(${BENCH_NAME}
PRIVATE UMF_BUILD_LEVEL_ZERO_PROVIDER=1)
PRIVATE UMF_PROVIDER_LEVEL_ZERO_ENABLED=1)
target_include_directories(
${BENCH_NAME} PRIVATE ${UMF_CMAKE_SOURCE_DIR}/test/common
${LEVEL_ZERO_INCLUDE_DIRS})
Expand Down Expand Up @@ -121,6 +142,12 @@ add_umf_benchmark(
LIBS ${LIBS_OPTIONAL}
LIBDIRS ${LIB_DIRS})

add_umf_benchmark(
NAME benchmark
SRCS benchmark.cpp
LIBS ${LIBS_OPTIONAL} benchmark::benchmark
LIBDIRS ${LIB_DIRS})

if(UMF_BUILD_BENCHMARKS_MT)
add_umf_benchmark(
NAME multithreaded
Expand Down
Loading
Loading