Modules/Threading/public/ThreadPinning.hpp
agent 15b18a8f1f Threading: cpu topology and thread pinning
ThreadPinning reads the sibling groups from the kernel topology and pins the
calling thread to a cpu set. It is stateless and per-thread: a caller reads the
groups, picks the cpus for a thread and pins it, so any mapping of threads to
cpus is expressible.
2026-10-27 01:16:26 +03:00

13 lines
310 B
C++

#pragma once
#include <vector>
namespace tp {
class ThreadPinning {
public:
[[nodiscard]] static std::vector<int> allowedCpus();
[[nodiscard]] static std::vector<std::vector<int>> siblingGroups(const std::vector<int>& allowed = {});
static void pinCallingThread(const std::vector<int>& cpus);
};
}