23 #if _MSC_VER && !__INTEL_COMPILER 24 #pragma warning( push ) 25 #pragma warning( disable : 4100 ) 28 #if _MSC_VER && !__INTEL_COMPILER 29 #pragma warning( pop ) 36 #define assertion_hwloc_wrapper(command, ...) \ 37 __TBB_ASSERT_EX( (command(__VA_ARGS__)) >= 0, "Error occurred during call to hwloc API."); 78 if ( hwloc_topology_init( &
topology ) == 0 ) {
80 if ( hwloc_topology_load(
topology ) == 0 ) {
126 unsigned counter = 0;
128 int max_numa_index = -1;
130 hwloc_obj_t node_buffer;
132 node_buffer = hwloc_get_obj_by_type(
topology, HWLOC_OBJ_NUMANODE, i);
140 } hwloc_bitmap_foreach_end();
141 __TBB_ASSERT(max_numa_index >= 0,
"Maximal NUMA index must not be negative");
149 node_buffer = hwloc_get_obj_by_type(
topology, HWLOC_OBJ_NUMANODE, i);
150 index = static_cast<int>(node_buffer->logical_index);
153 current_mask = hwloc_bitmap_dup(node_buffer->cpuset);
156 __TBB_ASSERT(!hwloc_bitmap_iszero(current_mask),
"hwloc detected unavailable NUMA node");
158 } hwloc_bitmap_foreach_end();
178 static void fill(
int& nodes_count,
int*& indexes_list,
int*& concurrency_list ) {
191 hwloc_bitmap_free(mask_to_free);
199 "Current affinity mask must intersects with process affinity mask");
208 "Trying to get affinity mask for uninitialized NUMA node");
247 "The slot number is greater than the number of slots in the arena");
249 "Trying to get access to uninitialized platform_topology");
258 "Trying to get access to uninitialized platform_topology");
286 int& nodes_count,
int*& indexes_list,
int*& concurrency_list ) {
293 __TBB_ASSERT(binding_observer,
"Failure during NUMA binding observer allocation and construction");
294 binding_observer->
observe(
true);
295 return binding_observer;
299 __TBB_ASSERT(binding_observer,
"Trying to deallocate NULL pointer");
300 binding_observer->
observe(
false);
301 delete binding_observer;
309 #undef assertion_hwloc_wrapper
static const_affinity_mask get_node_affinity_mask(int node_index)
numa_affinity_handler(size_t size)
static void set_new_affinity_mask(const_affinity_mask new_mask)
static void free_affinity_mask(affinity_mask mask_to_free)
static void store_current_affinity_mask(affinity_mask current_mask)
affinity_masks_container affinity_backup
task_scheduler_observer * subscribe_arena(task_arena *ta, int numa_id, int num_slots)
static std::vector< int > default_concurrency_list
static hwloc_nodeset_t process_node_affinity_mask
static hwloc_topology_t topology
void restore_previous_affinity_mask(unsigned slot_num)
static bool is_topology_parsed()
static hwloc_cpuset_t process_cpu_affinity_mask
numa_affinity_handler numa_handler
static std::vector< hwloc_cpuset_t > affinity_masks_list
static std::vector< int > numa_indexes_list
static affinity_mask allocate_process_affinity_mask()
hwloc_cpuset_t affinity_mask
void unsubscribe_arena(task_scheduler_observer *binding_observer)
void bind_thread_to_node(unsigned slot_num, unsigned numa_node_id)
static init_stages initialization_state
void initialize_numa_topology(size_t groups_num, int &nodes_count, int *&indexes_list, int *&concurrency_list)
void observe(bool state=true)
Enable or disable observation.
static void fill(int &nodes_count, int *&indexes_list, int *&concurrency_list)
void on_scheduler_exit(bool) __TBB_override
Exit notification.
hwloc_const_cpuset_t const_affinity_mask
void on_scheduler_entry(bool) __TBB_override
Entry notification.
std::vector< platform_topology::affinity_mask > affinity_masks_container
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
numa_binding_observer(task_arena *ta, int numa_id, int num_slots)
static void initialize(size_t groups_num)
#define assertion_hwloc_wrapper(command,...)
int current_thread_index()
Returns the index, aka slot number, of the calling thread in its current arena.
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t size
static int numa_nodes_count
static bool intergroup_binding_allowed(size_t groups_num)