Numa abstraction - libfork documentation (original) (raw)
Toggle table of contents sidebar
An abstraction over hwloc.
struct hwloc_error : public std::runtime_error¶
An exception thrown when hwloc fails.
enum class lf::numa_strategy¶
Enum to control distribution strategy of workers among numa nodes.
Values:
enumerator fan¶
Put workers as far away from each other as possible (maximize cache.)
enumerator seq¶
Fill up each numa node sequentially (ignoring SMT).
class numa_topology¶
A shared description of a computers topology.
Objects of this type have shared-pointer semantics.
Public Functions
inline numa_topology()¶
Construct a topology.
If hwloc is not installed this topology is empty.
template<typename T>
inline auto distribute(std::vector<std::shared_ptr<T>> const &data, numa_strategy strategy = numa_strategy::fan) -> std::vector<numa_node<T>>¶
Distribute a vector of objects over this topology.
This function returns a vector of [numa_node](#structlf%5F1%5F1ext%5F1%5F1numa%5F%5Ftopology%5F1%5F1numa%5F%5Fnode)s. Each [numa_node](#structlf%5F1%5F1ext%5F1%5F1numa%5F%5Ftopology%5F1%5F1numa%5F%5Fnode) contains a hierarchical view of the elements in data.
inline explicit operator bool() const noexcept¶
Test if this topology is empty.
inline auto split(std::size_t n, numa_strategy strategy = numa_strategy::fan) const -> std::vector<numa_handle>¶
Split a topology into n uniformly distributed handles to single processing units.
Here the definition of “uniformly” depends on strategy. If strategy == [numa_strategy::seq](#namespacelf%5F1%5F1ext%5F1aba86997efa22b04faa8eb23d33c2d00bae068c2de26d760f20cf10afc4b87ef0f) we try to use the minimum number of numa nodes then divided each node such that each PU has as much cache as possible. If strategy == [numa_strategy::fan](#namespacelf%5F1%5F1ext%5F1aba86997efa22b04faa8eb23d33c2d00ba50bd8c21bfafa6e4e962f6a948b1ef92) we try and maximize the amount of cache each PI gets.
If this topology is empty then this function returns a vector of n empty handles.
class numa_handle¶
A handle to a single processing unit in a NUMA computer.
Subclassed by lf::ext::numa_topology::numa_node< T >
Public Functions
inline void bind() const¶
Bind the calling thread to the set of processing units in this cpuset.
If hwloc is not installed both handles are null and this is a noop.
Public Members
unique_cpup cpup = nullptr¶
A unique handle to processing units that this handle represents.
std::size_t numa = 0¶
The index of the numa node this handle belongs to, on [0, n).
shared_topo topo = nullptr¶
A shared handle to topology this handle belongs to.
template<typename T>
struct numa_node : public lf::ext::numa_topology::numa_handle¶
A single-threads hierarchical view of a set of objects.
This is a [numa_handle](#classlf%5F1%5F1ext%5F1%5F1numa%5F%5Ftopology%5F1%5F1numa%5F%5Fhandle) augmented with list of neighbors-lists each neighbors-list has equidistant neighbors. The first neighbors-list always exists and contains only one element, the one “owned” by the thread. Each subsequent neighbors-list has elements that are topologically more distant from the element in the first neighbour-list.
Public Members
std::vector<std::vector<std::shared_ptr<T>>> neighbors¶
A list of neighbors-lists.