Skip to content

Commit

Permalink
Fix build config without numa
Browse files Browse the repository at this point in the history
  • Loading branch information
maikel committed Nov 2, 2023
1 parent bb39d12 commit b17b58a
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 5 deletions.
10 changes: 8 additions & 2 deletions examples/benchmark/common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/
#include <exec/env.hpp>
#include <exec/__detail/__numa.hpp>
#include <exec/static_thread_pool.hpp>

#include <algorithm>
#include <barrier>
Expand Down Expand Up @@ -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<std::unique_ptr<char, numa_deleter>> buffers;
#endif
Pool pool(nthreads);
std::optional<Pool> pool{};
if constexpr (std::same_as<Pool, exec::static_thread_pool>) {
pool.emplace(nthreads, exec::bwos_params{}, policy);
} else {
pool.emplace(nthreads);
}
std::barrier<> barrier(nthreads + 1);
std::vector<std::thread> threads;
std::atomic<bool> stop{false};
Expand All @@ -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<std::size_t>(nthreads); ++i) {
threads.emplace_back(
RunThread{},
std::ref(pool),
std::ref(*pool),
total_scheds,
i,
std::ref(barrier),
Expand Down
2 changes: 1 addition & 1 deletion examples/benchmark/static_thread_pool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
};

Expand Down
9 changes: 8 additions & 1 deletion examples/benchmark/static_thread_pool_bulk_enqueue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<exec::static_thread_pool, RunThread>(argc, argv);
my_numa_distribution numa{};
my_main<exec::static_thread_pool, RunThread>(argc, argv, &numa);
}
#else
int main() {}
Expand Down
4 changes: 3 additions & 1 deletion include/exec/__detail/__numa.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit b17b58a

Please sign in to comment.