From b17b58ad6e948e1a6c72e44bbc19ba17a24cf860 Mon Sep 17 00:00:00 2001 From: Maikel Nadolski Date: Thu, 2 Nov 2023 16:13:39 +0100 Subject: [PATCH] Fix build config without numa --- examples/benchmark/common.hpp | 10 ++++++++-- examples/benchmark/static_thread_pool.cpp | 2 +- examples/benchmark/static_thread_pool_bulk_enqueue.cpp | 9 ++++++++- include/exec/__detail/__numa.hpp | 4 +++- 4 files changed, 20 insertions(+), 5 deletions(-) diff --git a/examples/benchmark/common.hpp b/examples/benchmark/common.hpp index 9e19cef00..708b85607 100644 --- a/examples/benchmark/common.hpp +++ b/examples/benchmark/common.hpp @@ -16,6 +16,7 @@ */ #include #include +#include #include #include @@ -106,7 +107,12 @@ void my_main(int argc, char** argv, exec::numa_policy* policy = exec::get_numa_p #ifndef STDEXEC_NO_MONOTONIC_BUFFER_RESOURCE std::vector> buffers; #endif - Pool pool(nthreads); + std::optional pool{}; + if constexpr (std::same_as) { + pool.emplace(nthreads, exec::bwos_params{}, policy); + } else { + pool.emplace(nthreads); + } std::barrier<> barrier(nthreads + 1); std::vector threads; std::atomic stop{false}; @@ -120,7 +126,7 @@ void my_main(int argc, char** argv, exec::numa_policy* policy = exec::get_numa_p for (std::size_t i = 0; i < static_cast(nthreads); ++i) { threads.emplace_back( RunThread{}, - std::ref(pool), + std::ref(*pool), total_scheds, i, std::ref(barrier), diff --git a/examples/benchmark/static_thread_pool.cpp b/examples/benchmark/static_thread_pool.cpp index 09e0e3917..679f5cbbb 100644 --- a/examples/benchmark/static_thread_pool.cpp +++ b/examples/benchmark/static_thread_pool.cpp @@ -85,7 +85,7 @@ struct RunThread { struct my_numa_distribution : public exec::default_numa_policy { std::size_t thread_index_to_node(std::size_t index) override { - return default_numa_policy::thread_index_to_node(2 * index); + return exec::default_numa_policy::thread_index_to_node(2 * index); } }; diff --git a/examples/benchmark/static_thread_pool_bulk_enqueue.cpp b/examples/benchmark/static_thread_pool_bulk_enqueue.cpp index ee621a582..7151bb3c6 100644 --- a/examples/benchmark/static_thread_pool_bulk_enqueue.cpp +++ b/examples/benchmark/static_thread_pool_bulk_enqueue.cpp @@ -58,8 +58,15 @@ struct RunThread { } }; +struct my_numa_distribution : public exec::default_numa_policy { + std::size_t thread_index_to_node(std::size_t index) override { + return exec::default_numa_policy::thread_index_to_node(2 * index); + } +}; + int main(int argc, char** argv) { - my_main(argc, argv); + my_numa_distribution numa{}; + my_main(argc, argv, &numa); } #else int main() {} diff --git a/include/exec/__detail/__numa.hpp b/include/exec/__detail/__numa.hpp index 6a1b0b896..381d462a9 100644 --- a/include/exec/__detail/__numa.hpp +++ b/include/exec/__detail/__numa.hpp @@ -134,8 +134,10 @@ namespace exec { } #else namespace exec { + using default_numa_policy = no_numa_policy; + inline numa_policy* get_numa_policy() noexcept { - thread_local no_numa_policy g_default_numa_policy{}; + thread_local default_numa_policy g_default_numa_policy{}; return &g_default_numa_policy; }