17 #include "../tbb/tbb_assert_impl.h" 20 #if _MSC_VER && !__INTEL_COMPILER 21 #pragma warning( push ) 22 #pragma warning( disable : 4100 ) 25 #if _MSC_VER && !__INTEL_COMPILER 26 #pragma warning( pop ) 33 #define assertion_hwloc_wrapper(command, ...) \ 34 __TBB_ASSERT_EX( (command(__VA_ARGS__)) >= 0, "Error occurred during call to hwloc API."); 75 if ( hwloc_topology_init( &
topology ) == 0 ) {
77 if ( hwloc_topology_load(
topology ) == 0 ) {
123 unsigned counter = 0;
125 int max_numa_index = -1;
127 hwloc_obj_t node_buffer;
129 node_buffer = hwloc_get_obj_by_type(
topology, HWLOC_OBJ_NUMANODE, i);
137 } hwloc_bitmap_foreach_end();
138 __TBB_ASSERT(max_numa_index >= 0,
"Maximal NUMA index must not be negative");
146 node_buffer = hwloc_get_obj_by_type(
topology, HWLOC_OBJ_NUMANODE, i);
147 index = static_cast<int>(node_buffer->logical_index);
150 current_mask = hwloc_bitmap_dup(node_buffer->cpuset);
153 __TBB_ASSERT(!hwloc_bitmap_iszero(current_mask),
"hwloc detected unavailable NUMA node");
155 } hwloc_bitmap_foreach_end();
175 static void fill(
int& nodes_count,
int*& indexes_list,
int*& concurrency_list ) {
188 hwloc_bitmap_free(mask_to_free);
196 "Current affinity mask must intersects with process affinity mask");
205 "Trying to get affinity mask for uninitialized NUMA node");
244 "The slot number is greater than the number of slots in the arena");
246 "Trying to get access to uninitialized platform_topology");
255 "Trying to get access to uninitialized platform_topology");
264 int& nodes_count,
int*& indexes_list,
int*& concurrency_list ) {
270 __TBB_ASSERT(slot_num > 0,
"Trying to create numa handler for 0 threads.");
275 __TBB_ASSERT(handler_ptr != NULL,
"Trying to deallocate NULL pointer.");
280 __TBB_ASSERT(handler_ptr != NULL,
"Trying to get access to uninitialized metadata.");
282 "to uninitialized platform_topology.");
287 __TBB_ASSERT(handler_ptr != NULL,
"Trying to get access to uninitialized metadata.");
289 "to uninitialized platform_topology.");
298 #undef assertion_hwloc_wrapper void bind_thread_to_node(unsigned slot_num, unsigned numa_node_id)
static affinity_mask allocate_process_affinity_mask()
hwloc_cpuset_t affinity_mask
affinity_masks_container affinity_backup
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 void fill(int &nodes_count, int *&indexes_list, int *&concurrency_list)
void restore_previous_affinity_mask(unsigned slot_num)
hwloc_const_cpuset_t const_affinity_mask
friend class numa_affinity_handler
binding_handler(size_t size)
std::vector< platform_topology::affinity_mask > affinity_masks_container
static void initialize(size_t groups_num)
void bind_to_node(binding_handler *handler_ptr, int slot_num, int numa_id)
void initialize_numa_topology(size_t groups_num, int &nodes_count, int *&indexes_list, int *&concurrency_list)
static bool intergroup_binding_allowed(size_t groups_num)
void deallocate_binding_handler(binding_handler *handler_ptr)
static void free_affinity_mask(affinity_mask mask_to_free)
static const_affinity_mask get_node_affinity_mask(int node_index)
static int numa_nodes_count
binding_handler * allocate_binding_handler(int slot_num)
#define assertion_hwloc_wrapper(command,...)
static void set_new_affinity_mask(const_affinity_mask new_mask)
static void store_current_affinity_mask(affinity_mask current_mask)
static hwloc_nodeset_t process_node_affinity_mask
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
void restore_affinity(binding_handler *handler_ptr, int slot_num)
static std::vector< int > numa_indexes_list
static hwloc_topology_t topology
static bool is_topology_parsed()
static hwloc_cpuset_t process_cpu_affinity_mask
static std::vector< int > default_concurrency_list
static std::vector< hwloc_cpuset_t > affinity_masks_list
static init_stages initialization_state