hpx/compute_local/host/numa_binding_allocator.hpp#

Defined in header hpx/compute_local/host/numa_binding_allocator.hpp.

See Public API for a list of names and headers that are part of the public HPX API.

namespace hpx

Functions

inline hpx::debug::enable_print< NUMA_BINDING_ALLOCATOR_DEBUG > nba_deb ("NUM_B_A")
namespace compute
namespace host

Typedefs

template<typename T>
using numa_binding_helper_ptr = std::shared_ptr<numa_binding_helper<T>>#
template<typename T>
struct numa_binding_helper#

Public Functions

inline virtual std::size_t operator()(T const*const, T const*const, std::size_t const, std::size_t const) const#
virtual ~numa_binding_helper() = default#
inline virtual std::string const &pool_name() const#
inline virtual std::size_t memory_bytes() const#
inline virtual std::size_t array_rank() const#
inline virtual std::size_t array_size(std::size_t) const#
inline virtual std::size_t memory_step(std::size_t) const#
inline virtual std::size_t display_step(std::size_t) const#
inline virtual std::string description() const#

Public Members

std::string pool_name_ = "default"#
template<typename T>
struct numa_binding_allocator#
#include <numa_binding_allocator.hpp>

The numa_binding_allocator allocates memory using a policy based on hwloc flags for memory binding. This allocator can be used to request data that is bound to one or more numa domains via the bitmap mask supplied

Public Types

using value_type = T#
using pointer = T*#
using const_pointer = T const*#
using reference = T&#
using const_reference = T const&#
using size_type = std::size_t#
using difference_type = std::ptrdiff_t#
using numa_binding_helper_ptr = std::shared_ptr<numa_binding_helper<T>>#

Public Functions

numa_binding_allocator() = default#
inline numa_binding_allocator(threads::hpx_hwloc_membind_policy policy, unsigned int flags)#
inline numa_binding_allocator(numa_binding_helper_ptr bind_func, threads::hpx_hwloc_membind_policy policy, unsigned int flags)#
inline numa_binding_allocator(numa_binding_allocator const &rhs)#
template<typename U>
inline numa_binding_allocator(numa_binding_allocator<U> const &rhs)#
inline numa_binding_allocator(numa_binding_allocator &&rhs) noexcept#
inline numa_binding_allocator &operator=(numa_binding_allocator const &rhs)#
inline numa_binding_allocator &operator=(numa_binding_allocator &&rhs) noexcept#
inline pointer allocate(size_type n)#
template<typename U, typename ...A>
inline void construct(U *p, A&&... args)#
template<class U>
inline void destroy(U *const p)#
inline void initialize_pages(pointer p, size_t n) const#

Touches every page of the allocation starting at p so that each page is physically bound to the NUMA domain assigned to it by binding_helper_. One first-touch task per NUMA domain is dispatched and the call blocks until all of them complete.

Parameters:
  • p – pointer to the start of the allocation to initialize.

  • n – number of elements to initialize.

Pre:

Must be called from an HPX thread. init_mutex serializes concurrent calls to this function and is intentionally held across hpx::wait_all() below, which is a suspension point that may resume the calling HPX thread on a different OS worker thread. hpx::mutex (unlike std::mutex) supports this safely, and ignore_while_checking silences the HPX lock-checking layer’s warning about a lock spanning a suspension point.

inline std::string display_binding(pointer p, numa_binding_helper_ptr helper)#

Builds a human-readable, page-by-page description of how the allocation starting at p is bound across NUMA domains, suitable for debug output. init_mutex is held only for the duration of this synchronous call; unlike initialize_pages(), no suspension point is crossed while it is held.

Parameters:
  • p – pointer to the start of the allocation to describe.

  • helper – binding helper describing the array layout used to compute per-page offsets.

Returns:

a formatted string describing the domain binding of each page in the allocation.

template<typename Binder>
inline std::shared_ptr<Binder> get_binding_helper_cast() const#

Public Members

std::shared_ptr<numa_binding_helper<T>> binding_helper_#
threads::hpx_hwloc_membind_policy policy_#
unsigned int flags_#

Public Static Functions

static inline pointer address(reference x) noexcept#
static inline const_pointer address(const_reference x) noexcept#
static inline void deallocate(pointer p, size_type n) noexcept#
static inline size_type max_size() noexcept#
static inline int get_numa_domain(void *page)#
static inline std::string get_page_numa_domains([[maybe_unused]] void *addr, [[maybe_unused]] std::size_t len)#

Protected Functions

inline void touch_pages(pointer p, size_t n, numa_binding_helper_ptr helper, size_type numa_domain, std::vector<threads::hwloc_bitmap_ptr> const &nodesets) const#
inline void bind_pages(pointer p, size_t n, numa_binding_helper_ptr helper, size_type numa_domain, std::vector<threads::hwloc_bitmap_ptr> const &nodesets) const#

Protected Static Functions

static inline std::vector<threads::hwloc_bitmap_ptr> create_nodesets(threads::hwloc_bitmap_ptr const &bitmap)#

Private Members

mutable hpx::mutex init_mutex#
template<typename U>
struct rebind#

Public Types

using other = numa_binding_allocator<U>#
namespace execution
namespace experimental
struct numa_binding_allocator_tag#
template<>
struct pool_numa_hint<numa_binding_allocator_tag>#

Public Functions

inline int operator()(int const &domain) const#