From c841b92185b12903394876cb66cd8907c38f41db Mon Sep 17 00:00:00 2001 From: Tianyu Liu Date: Wed, 12 Mar 2025 00:54:37 -0400 Subject: [PATCH 01/20] Add threadpool benchmark --- cpp/CMakeLists.txt | 12 +++++++ cpp/benchmarks/CMakeLists.txt | 33 +++++++++++++++++++ .../threadpool/threadpool_benchmark.cpp | 27 +++++++++++++++ python/libkvikio/CMakeLists.txt | 1 + 4 files changed, 73 insertions(+) create mode 100644 cpp/benchmarks/CMakeLists.txt create mode 100644 cpp/benchmarks/threadpool/threadpool_benchmark.cpp diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index 69c7891403..18f95f652b 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -39,6 +39,7 @@ rapids_cmake_build_type(Release) # * build options ---------------------------------------------------------------------------------- option(BUILD_SHARED_LIBS "Build KvikIO shared library" ON) +option(KvikIO_BUILD_BENCHMARKS "Configure CMake to build benchmarks" ON) option(KvikIO_BUILD_EXAMPLES "Configure CMake to build examples" ON) option(KvikIO_BUILD_TESTS "Configure CMake to build tests" ON) option(KvikIO_REMOTE_SUPPORT "Configure CMake to build with remote IO support" ON) @@ -203,6 +204,17 @@ set_target_properties( INTERFACE_POSITION_INDEPENDENT_CODE ON ) +# ################################################################################################## +# * add benchmarks -------------------------------------------------------------------------------- + +if(KvikIO_BUILD_BENCHMARKS) + # Find or install GoogleBench + include(${rapids-cmake-dir}/cpm/gbench.cmake) + rapids_cpm_gbench(BUILD_STATIC) + + add_subdirectory(benchmarks) +endif() + # ################################################################################################## # * add examples ----------------------------------------------------------------------------------- diff --git a/cpp/benchmarks/CMakeLists.txt b/cpp/benchmarks/CMakeLists.txt new file mode 100644 index 0000000000..0a8bce54b0 --- /dev/null +++ b/cpp/benchmarks/CMakeLists.txt @@ -0,0 +1,33 @@ +# ============================================================================= +# Copyright (c) 2025, NVIDIA CORPORATION. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed under the License +# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express +# or implied. See the License for the specific language governing permissions and limitations under +# the License. +# ============================================================================= + +add_executable(THREADPOOL_BENCHMARK "threadpool/threadpool_benchmark.cpp") +set_target_properties(THREADPOOL_BENCHMARK PROPERTIES INSTALL_RPATH "\$ORIGIN/../../lib") +target_include_directories(THREADPOOL_BENCHMARK PRIVATE ../include ${cuFile_INCLUDE_DIRS}) +target_link_libraries(THREADPOOL_BENCHMARK +PUBLIC benchmark::benchmark benchmark::benchmark_main kvikio) + +if(CMAKE_COMPILER_IS_GNUCXX) +set(KVIKIO_CXX_FLAGS "-Wall;-Werror;-Wno-unknown-pragmas") +target_compile_options( + THREADPOOL_BENCHMARK PRIVATE "$<$:${KVIKIO_CXX_FLAGS}>" +) +endif() + +install( +TARGETS THREADPOOL_BENCHMARK +COMPONENT testing +DESTINATION bin/benchmarks/libkvikio +EXCLUDE_FROM_ALL +) diff --git a/cpp/benchmarks/threadpool/threadpool_benchmark.cpp b/cpp/benchmarks/threadpool/threadpool_benchmark.cpp new file mode 100644 index 0000000000..f533af4c2c --- /dev/null +++ b/cpp/benchmarks/threadpool/threadpool_benchmark.cpp @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025, NVIDIA CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include + +void BM_threadpool(benchmark::State& state) +{ + for (auto _ : state) { + std::string empty_string; + } +} + +BENCHMARK(BM_threadpool)->Name("KvikIO_threadpool"); diff --git a/python/libkvikio/CMakeLists.txt b/python/libkvikio/CMakeLists.txt index 806efd2b1c..f159cffa1a 100644 --- a/python/libkvikio/CMakeLists.txt +++ b/python/libkvikio/CMakeLists.txt @@ -36,6 +36,7 @@ endif() unset(kvikio_FOUND) +set(KvikIO_BUILD_BENCHMARKS OFF) set(KvikIO_BUILD_EXAMPLES OFF) set(KvikIO_BUILD_TESTS OFF) if(USE_NVCOMP_RUNTIME_WHEEL) From 99c744bcbdc80d148528c65d7ef971b646b41ec1 Mon Sep 17 00:00:00 2001 From: Tianyu Liu Date: Wed, 12 Mar 2025 10:12:22 -0400 Subject: [PATCH 02/20] Finish threadpool benchmark --- cpp/benchmarks/CMakeLists.txt | 17 +++++---- .../threadpool/threadpool_benchmark.cpp | 35 +++++++++++++++++-- 2 files changed, 40 insertions(+), 12 deletions(-) diff --git a/cpp/benchmarks/CMakeLists.txt b/cpp/benchmarks/CMakeLists.txt index 0a8bce54b0..211502c460 100644 --- a/cpp/benchmarks/CMakeLists.txt +++ b/cpp/benchmarks/CMakeLists.txt @@ -15,19 +15,18 @@ add_executable(THREADPOOL_BENCHMARK "threadpool/threadpool_benchmark.cpp") set_target_properties(THREADPOOL_BENCHMARK PROPERTIES INSTALL_RPATH "\$ORIGIN/../../lib") target_include_directories(THREADPOOL_BENCHMARK PRIVATE ../include ${cuFile_INCLUDE_DIRS}) -target_link_libraries(THREADPOOL_BENCHMARK -PUBLIC benchmark::benchmark benchmark::benchmark_main kvikio) +target_link_libraries(THREADPOOL_BENCHMARK PUBLIC benchmark::benchmark kvikio) if(CMAKE_COMPILER_IS_GNUCXX) -set(KVIKIO_CXX_FLAGS "-Wall;-Werror;-Wno-unknown-pragmas") -target_compile_options( + set(KVIKIO_CXX_FLAGS "-Wall;-Werror;-Wno-unknown-pragmas") + target_compile_options( THREADPOOL_BENCHMARK PRIVATE "$<$:${KVIKIO_CXX_FLAGS}>" -) + ) endif() install( -TARGETS THREADPOOL_BENCHMARK -COMPONENT testing -DESTINATION bin/benchmarks/libkvikio -EXCLUDE_FROM_ALL + TARGETS THREADPOOL_BENCHMARK + COMPONENT testing + DESTINATION bin/benchmarks/libkvikio + EXCLUDE_FROM_ALL ) diff --git a/cpp/benchmarks/threadpool/threadpool_benchmark.cpp b/cpp/benchmarks/threadpool/threadpool_benchmark.cpp index f533af4c2c..6146b30259 100644 --- a/cpp/benchmarks/threadpool/threadpool_benchmark.cpp +++ b/cpp/benchmarks/threadpool/threadpool_benchmark.cpp @@ -14,14 +14,43 @@ * limitations under the License. */ +#include + #include #include -void BM_threadpool(benchmark::State& state) +void compute() +{ + std::size_t const num_compute_iterations{100'000u}; + [[maybe_unused]] double res{0.0}; + for (std::size_t i = 0u; i < num_compute_iterations; ++i) { + auto x{static_cast(i)}; + res += std::sqrt(x) + std::cbrt(x) + std::sin(x); + } +} + +void BM_threadpool_compute(benchmark::State& state) { + std::size_t const num_compute_tasks{10'000u}; for (auto _ : state) { - std::string empty_string; + state.PauseTiming(); + kvikio::defaults::set_thread_pool_nthreads(state.range(0)); + + state.ResumeTiming(); + for (std::size_t i = 0u; i < num_compute_tasks; ++i) { + [[maybe_unused]] auto fut = kvikio::defaults::thread_pool().submit_task(compute); + } + kvikio::defaults::thread_pool().wait(); } } -BENCHMARK(BM_threadpool)->Name("KvikIO_threadpool"); +int main(int argc, char** argv) +{ + benchmark::Initialize(&argc, argv); + benchmark::RegisterBenchmark("BM_threadpool_compute", BM_threadpool_compute) + ->RangeMultiplier(2) + ->Range(1, 64) + ->Unit(benchmark::kMillisecond); + benchmark::RunSpecifiedBenchmarks(); + benchmark::Shutdown(); +} From 12f0992be11ce9d8057e6e0196afefb2bfb14028 Mon Sep 17 00:00:00 2001 From: Tianyu Liu Date: Wed, 12 Mar 2025 10:47:22 -0400 Subject: [PATCH 03/20] Add threadpool io benchmark --- .../threadpool/threadpool_benchmark.cpp | 46 +++++++++++++++++-- 1 file changed, 42 insertions(+), 4 deletions(-) diff --git a/cpp/benchmarks/threadpool/threadpool_benchmark.cpp b/cpp/benchmarks/threadpool/threadpool_benchmark.cpp index 6146b30259..f4eae3e5d2 100644 --- a/cpp/benchmarks/threadpool/threadpool_benchmark.cpp +++ b/cpp/benchmarks/threadpool/threadpool_benchmark.cpp @@ -15,13 +15,15 @@ */ #include +#include #include #include +#include "kvikio/compat_mode.hpp" +#include "kvikio/file_handle.hpp" -void compute() +void task_compute(std::size_t num_compute_iterations) { - std::size_t const num_compute_iterations{100'000u}; [[maybe_unused]] double res{0.0}; for (std::size_t i = 0u; i < num_compute_iterations; ++i) { auto x{static_cast(i)}; @@ -31,26 +33,62 @@ void compute() void BM_threadpool_compute(benchmark::State& state) { - std::size_t const num_compute_tasks{10'000u}; + std::size_t const num_compute_iterations{100'000}; + std::size_t const num_compute_tasks{10'000}; for (auto _ : state) { state.PauseTiming(); kvikio::defaults::set_thread_pool_nthreads(state.range(0)); state.ResumeTiming(); for (std::size_t i = 0u; i < num_compute_tasks; ++i) { - [[maybe_unused]] auto fut = kvikio::defaults::thread_pool().submit_task(compute); + [[maybe_unused]] auto fut = kvikio::defaults::thread_pool().submit_task( + [num_compute_iterations = num_compute_iterations] { + task_compute(num_compute_iterations); + }); } kvikio::defaults::thread_pool().wait(); } } +void task_io() {} + +void BM_threadpool_io(benchmark::State& state) +{ + kvikio::defaults::set_gds_threshold(0); + kvikio::defaults::set_compat_mode(kvikio::CompatMode::ON); + + std::size_t const num_bytes{128ull * 1024ull * 1024ull}; + std::string file_path{"./test.bin"}; + std::vector buf(num_bytes, std::byte{0}); + kvikio::FileHandle fh{file_path, "w"}; + auto fut = fh.pwrite(buf.data(), num_bytes); + fut.wait(); + + for (auto _ : state) { + state.PauseTiming(); + kvikio::defaults::set_thread_pool_nthreads(state.range(0)); + + state.ResumeTiming(); + kvikio::FileHandle fh{file_path, "r"}; + auto fut = fh.pread(buf.data(), num_bytes); + fut.wait(); + } +} + int main(int argc, char** argv) { benchmark::Initialize(&argc, argv); + benchmark::RegisterBenchmark("BM_threadpool_compute", BM_threadpool_compute) ->RangeMultiplier(2) ->Range(1, 64) ->Unit(benchmark::kMillisecond); + + benchmark::RegisterBenchmark("BM_threadpool_io", BM_threadpool_io) + ->RangeMultiplier(2) + ->Range(1, 64) + ->Unit(benchmark::kMillisecond); + benchmark::RunSpecifiedBenchmarks(); benchmark::Shutdown(); } From 0cbd7c05bbba5224938d1f313b68cf245b1b4eb5 Mon Sep 17 00:00:00 2001 From: Tianyu Liu Date: Wed, 12 Mar 2025 14:17:48 -0400 Subject: [PATCH 04/20] Update --- .../threadpool/threadpool_benchmark.cpp | 37 ++++++++----------- 1 file changed, 15 insertions(+), 22 deletions(-) diff --git a/cpp/benchmarks/threadpool/threadpool_benchmark.cpp b/cpp/benchmarks/threadpool/threadpool_benchmark.cpp index f4eae3e5d2..629c535887 100644 --- a/cpp/benchmarks/threadpool/threadpool_benchmark.cpp +++ b/cpp/benchmarks/threadpool/threadpool_benchmark.cpp @@ -15,12 +15,9 @@ */ #include -#include #include #include -#include "kvikio/compat_mode.hpp" -#include "kvikio/file_handle.hpp" void task_compute(std::size_t num_compute_iterations) { @@ -31,7 +28,7 @@ void task_compute(std::size_t num_compute_iterations) } } -void BM_threadpool_compute(benchmark::State& state) +void BM_threadpool_compute_strong_scaling(benchmark::State& state) { std::size_t const num_compute_iterations{100'000}; std::size_t const num_compute_tasks{10'000}; @@ -50,28 +47,22 @@ void BM_threadpool_compute(benchmark::State& state) } } -void task_io() {} - -void BM_threadpool_io(benchmark::State& state) +void BM_threadpool_compute_weak_scaling(benchmark::State& state) { - kvikio::defaults::set_gds_threshold(0); - kvikio::defaults::set_compat_mode(kvikio::CompatMode::ON); - - std::size_t const num_bytes{128ull * 1024ull * 1024ull}; - std::string file_path{"./test.bin"}; - std::vector buf(num_bytes, std::byte{0}); - kvikio::FileHandle fh{file_path, "w"}; - auto fut = fh.pwrite(buf.data(), num_bytes); - fut.wait(); - + std::size_t const num_compute_iterations{100'000}; for (auto _ : state) { state.PauseTiming(); kvikio::defaults::set_thread_pool_nthreads(state.range(0)); + std::size_t const num_compute_tasks = 1000 * state.range(0); state.ResumeTiming(); - kvikio::FileHandle fh{file_path, "r"}; - auto fut = fh.pread(buf.data(), num_bytes); - fut.wait(); + for (std::size_t i = 0u; i < num_compute_tasks; ++i) { + [[maybe_unused]] auto fut = kvikio::defaults::thread_pool().submit_task( + [num_compute_iterations = num_compute_iterations] { + task_compute(num_compute_iterations); + }); + } + kvikio::defaults::thread_pool().wait(); } } @@ -79,12 +70,14 @@ int main(int argc, char** argv) { benchmark::Initialize(&argc, argv); - benchmark::RegisterBenchmark("BM_threadpool_compute", BM_threadpool_compute) + benchmark::RegisterBenchmark("BM_threadpool_compute_strong_scaling", + BM_threadpool_compute_strong_scaling) ->RangeMultiplier(2) ->Range(1, 64) ->Unit(benchmark::kMillisecond); - benchmark::RegisterBenchmark("BM_threadpool_io", BM_threadpool_io) + benchmark::RegisterBenchmark("BM_threadpool_compute_weak_scaling", + BM_threadpool_compute_weak_scaling) ->RangeMultiplier(2) ->Range(1, 64) ->Unit(benchmark::kMillisecond); From 93a29a9a619f388d8458c37c26a13d07d2ff3f52 Mon Sep 17 00:00:00 2001 From: Tianyu Liu Date: Wed, 12 Mar 2025 15:13:27 -0400 Subject: [PATCH 05/20] Improve --- .../threadpool/threadpool_benchmark.cpp | 58 +++++++++---------- 1 file changed, 27 insertions(+), 31 deletions(-) diff --git a/cpp/benchmarks/threadpool/threadpool_benchmark.cpp b/cpp/benchmarks/threadpool/threadpool_benchmark.cpp index 629c535887..28c0016658 100644 --- a/cpp/benchmarks/threadpool/threadpool_benchmark.cpp +++ b/cpp/benchmarks/threadpool/threadpool_benchmark.cpp @@ -15,10 +15,17 @@ */ #include +#include +#include #include #include +enum ScalingType : int64_t { + StrongScaling, + WeakScaling, +}; + void task_compute(std::size_t num_compute_iterations) { [[maybe_unused]] double res{0.0}; @@ -28,34 +35,25 @@ void task_compute(std::size_t num_compute_iterations) } } -void BM_threadpool_compute_strong_scaling(benchmark::State& state) +void BM_threadpool_compute(benchmark::State& state) { - std::size_t const num_compute_iterations{100'000}; - std::size_t const num_compute_tasks{10'000}; - for (auto _ : state) { - state.PauseTiming(); - kvikio::defaults::set_thread_pool_nthreads(state.range(0)); + auto num_threads = state.range(0); + auto compute_bench_type = state.range(1); - state.ResumeTiming(); - for (std::size_t i = 0u; i < num_compute_tasks; ++i) { - [[maybe_unused]] auto fut = kvikio::defaults::thread_pool().submit_task( - [num_compute_iterations = num_compute_iterations] { - task_compute(num_compute_iterations); - }); - } - kvikio::defaults::thread_pool().wait(); + std::string label; + std::size_t num_compute_tasks; + if (compute_bench_type == ScalingType::StrongScaling) { + num_compute_tasks = 1'0000; + label = "strong_scaling"; + } else { + num_compute_tasks = 1000 * num_threads; + label = "weak_scaling"; } -} - -void BM_threadpool_compute_weak_scaling(benchmark::State& state) -{ + state.SetLabel(label); std::size_t const num_compute_iterations{100'000}; - for (auto _ : state) { - state.PauseTiming(); - kvikio::defaults::set_thread_pool_nthreads(state.range(0)); - std::size_t const num_compute_tasks = 1000 * state.range(0); + kvikio::defaults::set_thread_pool_nthreads(num_threads); - state.ResumeTiming(); + for (auto _ : state) { for (std::size_t i = 0u; i < num_compute_tasks; ++i) { [[maybe_unused]] auto fut = kvikio::defaults::thread_pool().submit_task( [num_compute_iterations = num_compute_iterations] { @@ -64,22 +62,20 @@ void BM_threadpool_compute_weak_scaling(benchmark::State& state) } kvikio::defaults::thread_pool().wait(); } + + state.counters["threads"] = num_threads; } int main(int argc, char** argv) { benchmark::Initialize(&argc, argv); - benchmark::RegisterBenchmark("BM_threadpool_compute_strong_scaling", - BM_threadpool_compute_strong_scaling) - ->RangeMultiplier(2) - ->Range(1, 64) + benchmark::RegisterBenchmark("BM_threadpool_compute:strong_scaling", BM_threadpool_compute) + ->ArgsProduct({{1, 2, 4, 8, 16, 32, 64}, {ScalingType::StrongScaling}}) ->Unit(benchmark::kMillisecond); - benchmark::RegisterBenchmark("BM_threadpool_compute_weak_scaling", - BM_threadpool_compute_weak_scaling) - ->RangeMultiplier(2) - ->Range(1, 64) + benchmark::RegisterBenchmark("BM_threadpool_compute:weak_scaling", BM_threadpool_compute) + ->ArgsProduct({{1, 2, 4, 8, 16, 32, 64}, {ScalingType::WeakScaling}}) ->Unit(benchmark::kMillisecond); benchmark::RunSpecifiedBenchmarks(); From 27c3f4ef2344ebf1f46dba6f73347e75dc442931 Mon Sep 17 00:00:00 2001 From: Tianyu Liu Date: Wed, 12 Mar 2025 16:42:31 -0400 Subject: [PATCH 06/20] Update --- cpp/benchmarks/CMakeLists.txt | 64 +++++++++++++++++++++++++---------- 1 file changed, 47 insertions(+), 17 deletions(-) diff --git a/cpp/benchmarks/CMakeLists.txt b/cpp/benchmarks/CMakeLists.txt index 211502c460..f8fd6301dd 100644 --- a/cpp/benchmarks/CMakeLists.txt +++ b/cpp/benchmarks/CMakeLists.txt @@ -12,21 +12,51 @@ # the License. # ============================================================================= -add_executable(THREADPOOL_BENCHMARK "threadpool/threadpool_benchmark.cpp") -set_target_properties(THREADPOOL_BENCHMARK PROPERTIES INSTALL_RPATH "\$ORIGIN/../../lib") -target_include_directories(THREADPOOL_BENCHMARK PRIVATE ../include ${cuFile_INCLUDE_DIRS}) -target_link_libraries(THREADPOOL_BENCHMARK PUBLIC benchmark::benchmark kvikio) - -if(CMAKE_COMPILER_IS_GNUCXX) - set(KVIKIO_CXX_FLAGS "-Wall;-Werror;-Wno-unknown-pragmas") - target_compile_options( - THREADPOOL_BENCHMARK PRIVATE "$<$:${KVIKIO_CXX_FLAGS}>" +#[=======================================================================[.rst: +kvikio_add_benchmark +-------------------- + +Create a KvikIO benchmark. + +.. code-block:: cmake + + kvikio_add_benchmark(NAME SOURCES ) + + ``NAME`` + Benchmark name. Single-value argument. + + ``SOURCES`` + List of source files for the benchmark. Multi-value argument. +#]=======================================================================] +function(kvikio_add_benchmark) + cmake_parse_arguments( + _KVIKIO # prefix + "" # optional + "NAME" # single value + "SOURCES" # multi-value + ${ARGN} ) -endif() - -install( - TARGETS THREADPOOL_BENCHMARK - COMPONENT testing - DESTINATION bin/benchmarks/libkvikio - EXCLUDE_FROM_ALL -) + + if(DEFINED _KVIKIO_UNPARSED_ARGUMENTS) + message(FATAL_ERROR "Unknown argument: ${_KVIKIO_UNPARSED_ARGUMENTS}") + endif() + + add_executable(${_KVIKIO_NAME} ${_KVIKIO_SOURCES}) + set_target_properties(${_KVIKIO_NAME} PROPERTIES INSTALL_RPATH "\$ORIGIN/../../lib") + target_include_directories(${_KVIKIO_NAME} PRIVATE ../include ${cuFile_INCLUDE_DIRS}) + target_link_libraries(${_KVIKIO_NAME} PUBLIC benchmark::benchmark kvikio) + + if(CMAKE_COMPILER_IS_GNUCXX) + set(KVIKIO_CXX_FLAGS "-Wall;-Werror;-Wno-unknown-pragmas") + target_compile_options(${_KVIKIO_NAME} PRIVATE "$<$:${KVIKIO_CXX_FLAGS}>") + endif() + + install( + TARGETS ${_KVIKIO_NAME} + COMPONENT testing + DESTINATION bin/benchmarks/libkvikio + EXCLUDE_FROM_ALL + ) +endfunction() + +kvikio_add_benchmark(NAME THREADPOOL_BENCHMARK SOURCES "threadpool/threadpool_benchmark.cpp") From 6ef7407dcfc8d0ee9ef92291f3b9531a5cf17fb8 Mon Sep 17 00:00:00 2001 From: Tianyu Liu Date: Thu, 13 Mar 2025 00:17:47 -0400 Subject: [PATCH 07/20] Fix cmake bugs --- cpp/benchmarks/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpp/benchmarks/CMakeLists.txt b/cpp/benchmarks/CMakeLists.txt index f8fd6301dd..4edb038a01 100644 --- a/cpp/benchmarks/CMakeLists.txt +++ b/cpp/benchmarks/CMakeLists.txt @@ -42,7 +42,7 @@ function(kvikio_add_benchmark) endif() add_executable(${_KVIKIO_NAME} ${_KVIKIO_SOURCES}) - set_target_properties(${_KVIKIO_NAME} PROPERTIES INSTALL_RPATH "\$ORIGIN/../../lib") + set_target_properties(${_KVIKIO_NAME} PROPERTIES INSTALL_RPATH "\$ORIGIN/../../../lib") target_include_directories(${_KVIKIO_NAME} PRIVATE ../include ${cuFile_INCLUDE_DIRS}) target_link_libraries(${_KVIKIO_NAME} PUBLIC benchmark::benchmark kvikio) From 94cd1bd7e6fb78206fd1ecea4b7bc31c23be569b Mon Sep 17 00:00:00 2001 From: Tianyu Liu Date: Thu, 13 Mar 2025 15:34:39 -0400 Subject: [PATCH 08/20] Update --- cpp/benchmarks/CMakeLists.txt | 6 +++-- .../threadpool/threadpool_benchmark.cpp | 26 +++++++++++-------- cpp/examples/CMakeLists.txt | 9 ++++--- 3 files changed, 24 insertions(+), 17 deletions(-) diff --git a/cpp/benchmarks/CMakeLists.txt b/cpp/benchmarks/CMakeLists.txt index 4edb038a01..64b8831bc5 100644 --- a/cpp/benchmarks/CMakeLists.txt +++ b/cpp/benchmarks/CMakeLists.txt @@ -43,8 +43,10 @@ function(kvikio_add_benchmark) add_executable(${_KVIKIO_NAME} ${_KVIKIO_SOURCES}) set_target_properties(${_KVIKIO_NAME} PROPERTIES INSTALL_RPATH "\$ORIGIN/../../../lib") - target_include_directories(${_KVIKIO_NAME} PRIVATE ../include ${cuFile_INCLUDE_DIRS}) - target_link_libraries(${_KVIKIO_NAME} PUBLIC benchmark::benchmark kvikio) + + get_target_property(KVIKIO_INCLUDES kvikio::kvikio INCLUDE_DIRECTORIES) + target_include_directories(${_KVIKIO_NAME} PRIVATE "${KVIKIO_INCLUDES}") + target_link_libraries(${_KVIKIO_NAME} PUBLIC benchmark::benchmark kvikio::kvikio) if(CMAKE_COMPILER_IS_GNUCXX) set(KVIKIO_CXX_FLAGS "-Wall;-Werror;-Wno-unknown-pragmas") diff --git a/cpp/benchmarks/threadpool/threadpool_benchmark.cpp b/cpp/benchmarks/threadpool/threadpool_benchmark.cpp index 28c0016658..589e98d4ff 100644 --- a/cpp/benchmarks/threadpool/threadpool_benchmark.cpp +++ b/cpp/benchmarks/threadpool/threadpool_benchmark.cpp @@ -21,7 +21,8 @@ #include #include -enum ScalingType : int64_t { +namespace kvikio { +enum class ScalingType : uint8_t { StrongScaling, WeakScaling, }; @@ -35,21 +36,19 @@ void task_compute(std::size_t num_compute_iterations) } } +template void BM_threadpool_compute(benchmark::State& state) { - auto num_threads = state.range(0); - auto compute_bench_type = state.range(1); + auto num_threads = state.range(0); std::string label; std::size_t num_compute_tasks; - if (compute_bench_type == ScalingType::StrongScaling) { + if constexpr (scaling_type == ScalingType::StrongScaling) { num_compute_tasks = 1'0000; - label = "strong_scaling"; } else { num_compute_tasks = 1000 * num_threads; - label = "weak_scaling"; } - state.SetLabel(label); + std::size_t const num_compute_iterations{100'000}; kvikio::defaults::set_thread_pool_nthreads(num_threads); @@ -65,17 +64,22 @@ void BM_threadpool_compute(benchmark::State& state) state.counters["threads"] = num_threads; } +} // namespace kvikio int main(int argc, char** argv) { benchmark::Initialize(&argc, argv); - benchmark::RegisterBenchmark("BM_threadpool_compute:strong_scaling", BM_threadpool_compute) - ->ArgsProduct({{1, 2, 4, 8, 16, 32, 64}, {ScalingType::StrongScaling}}) + benchmark::RegisterBenchmark("BM_threadpool_compute:strong_scaling", + kvikio::BM_threadpool_compute) + ->RangeMultiplier(2) + ->Range(1, 64) ->Unit(benchmark::kMillisecond); - benchmark::RegisterBenchmark("BM_threadpool_compute:weak_scaling", BM_threadpool_compute) - ->ArgsProduct({{1, 2, 4, 8, 16, 32, 64}, {ScalingType::WeakScaling}}) + benchmark::RegisterBenchmark("BM_threadpool_compute:weak_scaling", + kvikio::BM_threadpool_compute) + ->RangeMultiplier(2) + ->Range(1, 64) ->Unit(benchmark::kMillisecond); benchmark::RunSpecifiedBenchmarks(); diff --git a/cpp/examples/CMakeLists.txt b/cpp/examples/CMakeLists.txt index 6b03b1d487..a87a9f9c09 100644 --- a/cpp/examples/CMakeLists.txt +++ b/cpp/examples/CMakeLists.txt @@ -13,14 +13,15 @@ # ============================================================================= set(TEST_INSTALL_PATH bin/tests/libkvikio) +get_target_property(KVIKIO_INCLUDES kvikio::kvikio INCLUDE_DIRECTORIES) # Example: basic_io if(CUDAToolkit_FOUND) add_executable(BASIC_IO_EXAMPLE basic_io.cpp) set_target_properties(BASIC_IO_EXAMPLE PROPERTIES INSTALL_RPATH "\$ORIGIN/../../../lib") - target_include_directories(BASIC_IO_EXAMPLE PRIVATE ../include ${cuFile_INCLUDE_DIRS}) - target_link_libraries(BASIC_IO_EXAMPLE PRIVATE kvikio CUDA::cudart) + target_include_directories(BASIC_IO_EXAMPLE PRIVATE "${KVIKIO_INCLUDES}") + target_link_libraries(BASIC_IO_EXAMPLE PRIVATE kvikio::kvikio CUDA::cudart) if(CMAKE_COMPILER_IS_GNUCXX) set(KVIKIO_CXX_FLAGS "-Wall;-Werror;-Wno-unknown-pragmas") @@ -43,8 +44,8 @@ endif() add_executable(BASIC_NO_CUDA_EXAMPLE basic_no_cuda.cpp) set_target_properties(BASIC_NO_CUDA_EXAMPLE PROPERTIES INSTALL_RPATH "\$ORIGIN/../../../lib") -target_include_directories(BASIC_NO_CUDA_EXAMPLE PRIVATE ../include) -target_link_libraries(BASIC_NO_CUDA_EXAMPLE PRIVATE kvikio) +target_include_directories(BASIC_NO_CUDA_EXAMPLE PRIVATE "${KVIKIO_INCLUDES}") +target_link_libraries(BASIC_NO_CUDA_EXAMPLE PRIVATE kvikio::kvikio) if(CMAKE_COMPILER_IS_GNUCXX) set(KVIKIO_CXX_FLAGS "-Wall;-Werror;-Wno-unknown-pragmas") From 16b5aa563b7f4473bd1ecdd69d27ef4d5bcbd74f Mon Sep 17 00:00:00 2001 From: Tianyu Liu Date: Thu, 13 Mar 2025 17:34:48 -0400 Subject: [PATCH 09/20] Minor fix --- cpp/benchmarks/threadpool/threadpool_benchmark.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/cpp/benchmarks/threadpool/threadpool_benchmark.cpp b/cpp/benchmarks/threadpool/threadpool_benchmark.cpp index 589e98d4ff..3ce896f418 100644 --- a/cpp/benchmarks/threadpool/threadpool_benchmark.cpp +++ b/cpp/benchmarks/threadpool/threadpool_benchmark.cpp @@ -16,7 +16,6 @@ #include #include -#include #include #include @@ -44,9 +43,9 @@ void BM_threadpool_compute(benchmark::State& state) std::string label; std::size_t num_compute_tasks; if constexpr (scaling_type == ScalingType::StrongScaling) { - num_compute_tasks = 1'0000; + num_compute_tasks = 10'000; } else { - num_compute_tasks = 1000 * num_threads; + num_compute_tasks = 1'000 * num_threads; } std::size_t const num_compute_iterations{100'000}; From 5a5ba4ec6cb908259840becbd49cab84dbde6315 Mon Sep 17 00:00:00 2001 From: Tianyu Liu Date: Thu, 13 Mar 2025 17:47:04 -0400 Subject: [PATCH 10/20] Add comments to the simple bench --- cpp/benchmarks/threadpool/threadpool_benchmark.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cpp/benchmarks/threadpool/threadpool_benchmark.cpp b/cpp/benchmarks/threadpool/threadpool_benchmark.cpp index 3ce896f418..19b4d01cd6 100644 --- a/cpp/benchmarks/threadpool/threadpool_benchmark.cpp +++ b/cpp/benchmarks/threadpool/threadpool_benchmark.cpp @@ -14,6 +14,13 @@ * limitations under the License. */ +// This benchmark assesses the performance of the thread pool. +// In the "strong scaling" study, the total amount of tasks is fixed, and the time to complete +// these tasks is evaluated as a function of thread count. +// In the "weak scaling" study, the expected tasks per thread is fixed, and the total amount of +// tasks is then proportional to the thread count. Again, the time is evaluated as a function of +// thread count. + #include #include From c13d16a4ea004d667e0ec7df7e9d64f633503d5a Mon Sep 17 00:00:00 2001 From: Tianyu Liu Date: Thu, 13 Mar 2025 17:58:10 -0400 Subject: [PATCH 11/20] Update cpp/examples/CMakeLists.txt Co-authored-by: Kyle Edwards --- cpp/examples/CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/cpp/examples/CMakeLists.txt b/cpp/examples/CMakeLists.txt index a87a9f9c09..1b38b56ccc 100644 --- a/cpp/examples/CMakeLists.txt +++ b/cpp/examples/CMakeLists.txt @@ -20,7 +20,6 @@ get_target_property(KVIKIO_INCLUDES kvikio::kvikio INCLUDE_DIRECTORIES) if(CUDAToolkit_FOUND) add_executable(BASIC_IO_EXAMPLE basic_io.cpp) set_target_properties(BASIC_IO_EXAMPLE PROPERTIES INSTALL_RPATH "\$ORIGIN/../../../lib") - target_include_directories(BASIC_IO_EXAMPLE PRIVATE "${KVIKIO_INCLUDES}") target_link_libraries(BASIC_IO_EXAMPLE PRIVATE kvikio::kvikio CUDA::cudart) if(CMAKE_COMPILER_IS_GNUCXX) From 60a4799a6646cf2bfd3f556ee2e5004589254fd8 Mon Sep 17 00:00:00 2001 From: Tianyu Liu Date: Thu, 13 Mar 2025 17:58:34 -0400 Subject: [PATCH 12/20] Update cpp/examples/CMakeLists.txt Co-authored-by: Kyle Edwards --- cpp/examples/CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/cpp/examples/CMakeLists.txt b/cpp/examples/CMakeLists.txt index 1b38b56ccc..99d2576583 100644 --- a/cpp/examples/CMakeLists.txt +++ b/cpp/examples/CMakeLists.txt @@ -43,7 +43,6 @@ endif() add_executable(BASIC_NO_CUDA_EXAMPLE basic_no_cuda.cpp) set_target_properties(BASIC_NO_CUDA_EXAMPLE PROPERTIES INSTALL_RPATH "\$ORIGIN/../../../lib") -target_include_directories(BASIC_NO_CUDA_EXAMPLE PRIVATE "${KVIKIO_INCLUDES}") target_link_libraries(BASIC_NO_CUDA_EXAMPLE PRIVATE kvikio::kvikio) if(CMAKE_COMPILER_IS_GNUCXX) From dd8d40b13060ea17213e6759725fa061bda215e0 Mon Sep 17 00:00:00 2001 From: Tianyu Liu Date: Thu, 13 Mar 2025 17:58:50 -0400 Subject: [PATCH 13/20] Update cpp/examples/CMakeLists.txt Co-authored-by: Kyle Edwards --- cpp/examples/CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/cpp/examples/CMakeLists.txt b/cpp/examples/CMakeLists.txt index 99d2576583..e14179cb6a 100644 --- a/cpp/examples/CMakeLists.txt +++ b/cpp/examples/CMakeLists.txt @@ -13,7 +13,6 @@ # ============================================================================= set(TEST_INSTALL_PATH bin/tests/libkvikio) -get_target_property(KVIKIO_INCLUDES kvikio::kvikio INCLUDE_DIRECTORIES) # Example: basic_io From ea0c13bbf04a1ce86fa33d54590d089dbd164339 Mon Sep 17 00:00:00 2001 From: Tianyu Liu Date: Thu, 13 Mar 2025 17:59:52 -0400 Subject: [PATCH 14/20] Update cpp/benchmarks/CMakeLists.txt Co-authored-by: Kyle Edwards --- cpp/benchmarks/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpp/benchmarks/CMakeLists.txt b/cpp/benchmarks/CMakeLists.txt index 64b8831bc5..50b38e38b5 100644 --- a/cpp/benchmarks/CMakeLists.txt +++ b/cpp/benchmarks/CMakeLists.txt @@ -48,7 +48,7 @@ function(kvikio_add_benchmark) target_include_directories(${_KVIKIO_NAME} PRIVATE "${KVIKIO_INCLUDES}") target_link_libraries(${_KVIKIO_NAME} PUBLIC benchmark::benchmark kvikio::kvikio) - if(CMAKE_COMPILER_IS_GNUCXX) + if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") set(KVIKIO_CXX_FLAGS "-Wall;-Werror;-Wno-unknown-pragmas") target_compile_options(${_KVIKIO_NAME} PRIVATE "$<$:${KVIKIO_CXX_FLAGS}>") endif() From c97e999208bc10eab03b1c34c191ae452d873d1c Mon Sep 17 00:00:00 2001 From: Tianyu Liu Date: Thu, 13 Mar 2025 18:00:09 -0400 Subject: [PATCH 15/20] Update cpp/benchmarks/CMakeLists.txt Co-authored-by: Kyle Edwards --- cpp/benchmarks/CMakeLists.txt | 2 -- 1 file changed, 2 deletions(-) diff --git a/cpp/benchmarks/CMakeLists.txt b/cpp/benchmarks/CMakeLists.txt index 50b38e38b5..665d45edfb 100644 --- a/cpp/benchmarks/CMakeLists.txt +++ b/cpp/benchmarks/CMakeLists.txt @@ -44,8 +44,6 @@ function(kvikio_add_benchmark) add_executable(${_KVIKIO_NAME} ${_KVIKIO_SOURCES}) set_target_properties(${_KVIKIO_NAME} PROPERTIES INSTALL_RPATH "\$ORIGIN/../../../lib") - get_target_property(KVIKIO_INCLUDES kvikio::kvikio INCLUDE_DIRECTORIES) - target_include_directories(${_KVIKIO_NAME} PRIVATE "${KVIKIO_INCLUDES}") target_link_libraries(${_KVIKIO_NAME} PUBLIC benchmark::benchmark kvikio::kvikio) if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") From d5c320a6904497596ba56e32d24167ee53f181bf Mon Sep 17 00:00:00 2001 From: Tianyu Liu Date: Thu, 13 Mar 2025 18:05:04 -0400 Subject: [PATCH 16/20] Replace deprecated cmake call --- cpp/examples/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cpp/examples/CMakeLists.txt b/cpp/examples/CMakeLists.txt index e14179cb6a..b7aa73dd2d 100644 --- a/cpp/examples/CMakeLists.txt +++ b/cpp/examples/CMakeLists.txt @@ -21,7 +21,7 @@ if(CUDAToolkit_FOUND) set_target_properties(BASIC_IO_EXAMPLE PROPERTIES INSTALL_RPATH "\$ORIGIN/../../../lib") target_link_libraries(BASIC_IO_EXAMPLE PRIVATE kvikio::kvikio CUDA::cudart) - if(CMAKE_COMPILER_IS_GNUCXX) + if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") set(KVIKIO_CXX_FLAGS "-Wall;-Werror;-Wno-unknown-pragmas") target_compile_options( BASIC_IO_EXAMPLE PRIVATE "$<$:${KVIKIO_CXX_FLAGS}>" @@ -44,7 +44,7 @@ add_executable(BASIC_NO_CUDA_EXAMPLE basic_no_cuda.cpp) set_target_properties(BASIC_NO_CUDA_EXAMPLE PROPERTIES INSTALL_RPATH "\$ORIGIN/../../../lib") target_link_libraries(BASIC_NO_CUDA_EXAMPLE PRIVATE kvikio::kvikio) -if(CMAKE_COMPILER_IS_GNUCXX) +if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") set(KVIKIO_CXX_FLAGS "-Wall;-Werror;-Wno-unknown-pragmas") target_compile_options( BASIC_NO_CUDA_EXAMPLE PRIVATE "$<$:${KVIKIO_CXX_FLAGS}>" From 6395f210a27429a26d3376c30b762e51216d1643 Mon Sep 17 00:00:00 2001 From: Tianyu Liu Date: Fri, 14 Mar 2025 00:46:43 -0400 Subject: [PATCH 17/20] Address comments and fix issues --- .../threadpool/threadpool_benchmark.cpp | 46 ++++++++++--------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/cpp/benchmarks/threadpool/threadpool_benchmark.cpp b/cpp/benchmarks/threadpool/threadpool_benchmark.cpp index 19b4d01cd6..9af7e6133a 100644 --- a/cpp/benchmarks/threadpool/threadpool_benchmark.cpp +++ b/cpp/benchmarks/threadpool/threadpool_benchmark.cpp @@ -14,12 +14,14 @@ * limitations under the License. */ -// This benchmark assesses the performance of the thread pool. +// This benchmark assesses the scalability of the thread pool. +// // In the "strong scaling" study, the total amount of tasks is fixed, and the time to complete // these tasks is evaluated as a function of thread count. -// In the "weak scaling" study, the expected tasks per thread is fixed, and the total amount of -// tasks is then proportional to the thread count. Again, the time is evaluated as a function of -// thread count. +// +// In the "weak scaling" study, the expected amount of tasks per thread is fixed, and the total +// amount of tasks is then proportional to the thread count. Again, the time is evaluated as a +// function of thread count. #include #include @@ -29,8 +31,8 @@ namespace kvikio { enum class ScalingType : uint8_t { - StrongScaling, - WeakScaling, + STRONG_SCALING, + WEAK_SCALING, }; void task_compute(std::size_t num_compute_iterations) @@ -38,28 +40,24 @@ void task_compute(std::size_t num_compute_iterations) [[maybe_unused]] double res{0.0}; for (std::size_t i = 0u; i < num_compute_iterations; ++i) { auto x{static_cast(i)}; - res += std::sqrt(x) + std::cbrt(x) + std::sin(x); + benchmark::DoNotOptimize(res += std::sqrt(x) + std::cbrt(x) + std::sin(x)); } } template void BM_threadpool_compute(benchmark::State& state) { - auto num_threads = state.range(0); + auto const num_threads = state.range(0); - std::string label; - std::size_t num_compute_tasks; - if constexpr (scaling_type == ScalingType::StrongScaling) { - num_compute_tasks = 10'000; - } else { - num_compute_tasks = 1'000 * num_threads; - } + std::size_t const num_compute_tasks = + (scaling_type == ScalingType::STRONG_SCALING) ? 10'000 : (1'000 * num_threads); - std::size_t const num_compute_iterations{100'000}; + std::size_t const num_compute_iterations{1'000}; kvikio::defaults::set_thread_pool_nthreads(num_threads); for (auto _ : state) { - for (std::size_t i = 0u; i < num_compute_tasks; ++i) { + // Submit a total of "num_compute_tasks" tasks to the thread pool. + for (auto i = std::size_t{0}; i < num_compute_tasks; ++i) { [[maybe_unused]] auto fut = kvikio::defaults::thread_pool().submit_task( [num_compute_iterations = num_compute_iterations] { task_compute(num_compute_iterations); @@ -77,16 +75,20 @@ int main(int argc, char** argv) benchmark::Initialize(&argc, argv); benchmark::RegisterBenchmark("BM_threadpool_compute:strong_scaling", - kvikio::BM_threadpool_compute) + kvikio::BM_threadpool_compute) ->RangeMultiplier(2) - ->Range(1, 64) - ->Unit(benchmark::kMillisecond); + ->Range(1, 64) // Increase from 1 to 64 (inclusive of both endpoints) with x2 stepping. + ->UseRealTime() // Use the wall clock to determine the number of benchmark iterations. + ->Unit(benchmark::kMillisecond) + ->MinTime(2); // Minimum of 2 seconds. benchmark::RegisterBenchmark("BM_threadpool_compute:weak_scaling", - kvikio::BM_threadpool_compute) + kvikio::BM_threadpool_compute) ->RangeMultiplier(2) ->Range(1, 64) - ->Unit(benchmark::kMillisecond); + ->UseRealTime() + ->Unit(benchmark::kMillisecond) + ->MinTime(2); benchmark::RunSpecifiedBenchmarks(); benchmark::Shutdown(); From 84c9fb903dbc580c9e9b036a2c9e3e47cbc33f96 Mon Sep 17 00:00:00 2001 From: Tianyu Liu Date: Fri, 14 Mar 2025 01:00:51 -0400 Subject: [PATCH 18/20] Make constexpr --- cpp/benchmarks/threadpool/threadpool_benchmark.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpp/benchmarks/threadpool/threadpool_benchmark.cpp b/cpp/benchmarks/threadpool/threadpool_benchmark.cpp index 9af7e6133a..1cf80ab981 100644 --- a/cpp/benchmarks/threadpool/threadpool_benchmark.cpp +++ b/cpp/benchmarks/threadpool/threadpool_benchmark.cpp @@ -52,7 +52,7 @@ void BM_threadpool_compute(benchmark::State& state) std::size_t const num_compute_tasks = (scaling_type == ScalingType::STRONG_SCALING) ? 10'000 : (1'000 * num_threads); - std::size_t const num_compute_iterations{1'000}; + std::size_t constexpr num_compute_iterations{1'000}; kvikio::defaults::set_thread_pool_nthreads(num_threads); for (auto _ : state) { From e7f10a6f77197ac5e286995c35995f4141c6f66b Mon Sep 17 00:00:00 2001 From: Tianyu Liu Date: Fri, 14 Mar 2025 09:11:02 -0400 Subject: [PATCH 19/20] Update cpp/benchmarks/threadpool/threadpool_benchmark.cpp Co-authored-by: Mads R. B. Kristensen --- cpp/benchmarks/threadpool/threadpool_benchmark.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpp/benchmarks/threadpool/threadpool_benchmark.cpp b/cpp/benchmarks/threadpool/threadpool_benchmark.cpp index 1cf80ab981..dcec0645e6 100644 --- a/cpp/benchmarks/threadpool/threadpool_benchmark.cpp +++ b/cpp/benchmarks/threadpool/threadpool_benchmark.cpp @@ -59,7 +59,7 @@ void BM_threadpool_compute(benchmark::State& state) // Submit a total of "num_compute_tasks" tasks to the thread pool. for (auto i = std::size_t{0}; i < num_compute_tasks; ++i) { [[maybe_unused]] auto fut = kvikio::defaults::thread_pool().submit_task( - [num_compute_iterations = num_compute_iterations] { + [num_compute_iterations] { task_compute(num_compute_iterations); }); } From 3f3a620ff2a68a0ec4a247384d1cb1629985d666 Mon Sep 17 00:00:00 2001 From: Tianyu Liu Date: Fri, 14 Mar 2025 09:13:56 -0400 Subject: [PATCH 20/20] Update --- cpp/benchmarks/threadpool/threadpool_benchmark.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/cpp/benchmarks/threadpool/threadpool_benchmark.cpp b/cpp/benchmarks/threadpool/threadpool_benchmark.cpp index dcec0645e6..1c90579d22 100644 --- a/cpp/benchmarks/threadpool/threadpool_benchmark.cpp +++ b/cpp/benchmarks/threadpool/threadpool_benchmark.cpp @@ -58,10 +58,8 @@ void BM_threadpool_compute(benchmark::State& state) for (auto _ : state) { // Submit a total of "num_compute_tasks" tasks to the thread pool. for (auto i = std::size_t{0}; i < num_compute_tasks; ++i) { - [[maybe_unused]] auto fut = kvikio::defaults::thread_pool().submit_task( - [num_compute_iterations] { - task_compute(num_compute_iterations); - }); + [[maybe_unused]] auto fut = + kvikio::defaults::thread_pool().submit_task([] { task_compute(num_compute_iterations); }); } kvikio::defaults::thread_pool().wait(); }