helper.h
/*
* Copyright © 2009 CNRS
* Copyright © 2009-2016 Inria. All rights reserved.
* Copyright © 2009-2012 Université Bordeaux
* Copyright © 2009-2010 Cisco Systems, Inc. All rights reserved.
* See COPYING in top-level directory.
*/
#ifndef HWLOC_HELPER_H
#define HWLOC_HELPER_H
#ifndef HWLOC_H
#error Please include the main hwloc.h instead
#endif
#include <stdlib.h>
#include <errno.h>
#ifdef __cplusplus
extern "C" {
#endif
static __hwloc_inline hwloc_obj_t
hwloc_get_first_largest_obj_inside_cpuset(hwloc_topology_t topology, hwloc_const_cpuset_t set)
{
hwloc_obj_t obj = hwloc_get_root_obj(topology);
if (!obj->cpuset || !hwloc_bitmap_intersects(obj->cpuset, set))
return NULL;
while (!hwloc_bitmap_isincluded(obj->cpuset, set)) {
/* while the object intersects without being included, look at its children */
hwloc_obj_t child = obj->first_child;
while (child) {
if (child->cpuset && hwloc_bitmap_intersects(child->cpuset, set))
break;
child = child->next_sibling;
}
if (!child)
/* no child intersects, return their father */
return obj;
/* found one intersecting child, look at its children */
obj = child;
}
/* obj is included, return it */
return obj;
}
HWLOC_DECLSPEC int hwloc_get_largest_objs_inside_cpuset (hwloc_topology_t topology, hwloc_const_cpuset_t set,
hwloc_obj_t * __hwloc_restrict objs, int max);
static __hwloc_inline hwloc_obj_t
hwloc_get_next_obj_inside_cpuset_by_depth (hwloc_topology_t topology, hwloc_const_cpuset_t set,
unsigned depth, hwloc_obj_t prev)
{
hwloc_obj_t next = hwloc_get_next_obj_by_depth(topology, depth, prev);
if (!next || !next->cpuset)
return NULL;
while (next && (hwloc_bitmap_iszero(next->cpuset) || !hwloc_bitmap_isincluded(next->cpuset, set)))
next = next->next_cousin;
return next;
}
static __hwloc_inline hwloc_obj_t
hwloc_get_next_obj_inside_cpuset_by_type (hwloc_topology_t topology, hwloc_const_cpuset_t set,
hwloc_obj_type_t type, hwloc_obj_t prev)
{
int depth = hwloc_get_type_depth(topology, type);
if (depth == HWLOC_TYPE_DEPTH_UNKNOWN || depth == HWLOC_TYPE_DEPTH_MULTIPLE)
return NULL;
return hwloc_get_next_obj_inside_cpuset_by_depth(topology, set, depth, prev);
}
static __hwloc_inline hwloc_obj_t
hwloc_get_obj_inside_cpuset_by_depth (hwloc_topology_t topology, hwloc_const_cpuset_t set,
unsigned depth, unsigned idx) __hwloc_attribute_pure;
static __hwloc_inline hwloc_obj_t
hwloc_get_obj_inside_cpuset_by_depth (hwloc_topology_t topology, hwloc_const_cpuset_t set,
unsigned depth, unsigned idx)
{
hwloc_obj_t obj = hwloc_get_obj_by_depth (topology, depth, 0);
unsigned count = 0;
if (!obj || !obj->cpuset)
return NULL;
while (obj) {
if (!hwloc_bitmap_iszero(obj->cpuset) && hwloc_bitmap_isincluded(obj->cpuset, set)) {
if (count == idx)
return obj;
count++;
}
obj = obj->next_cousin;
}
return NULL;
}
static __hwloc_inline hwloc_obj_t
hwloc_get_obj_inside_cpuset_by_type (hwloc_topology_t topology, hwloc_const_cpuset_t set,
hwloc_obj_type_t type, unsigned idx) __hwloc_attribute_pure;
static __hwloc_inline hwloc_obj_t
hwloc_get_obj_inside_cpuset_by_type (hwloc_topology_t topology, hwloc_const_cpuset_t set,
hwloc_obj_type_t type, unsigned idx)
{
int depth = hwloc_get_type_depth(topology, type);
if (depth == HWLOC_TYPE_DEPTH_UNKNOWN || depth == HWLOC_TYPE_DEPTH_MULTIPLE)
return NULL;
return hwloc_get_obj_inside_cpuset_by_depth(topology, set, depth, idx);
}
static __hwloc_inline unsigned
hwloc_get_nbobjs_inside_cpuset_by_depth (hwloc_topology_t topology, hwloc_const_cpuset_t set,
unsigned depth) __hwloc_attribute_pure;
static __hwloc_inline unsigned
hwloc_get_nbobjs_inside_cpuset_by_depth (hwloc_topology_t topology, hwloc_const_cpuset_t set,
unsigned depth)
{
hwloc_obj_t obj = hwloc_get_obj_by_depth (topology, depth, 0);
unsigned count = 0;
if (!obj || !obj->cpuset)
return 0;
while (obj) {
if (!hwloc_bitmap_iszero(obj->cpuset) && hwloc_bitmap_isincluded(obj->cpuset, set))
count++;
obj = obj->next_cousin;
}
return count;
}
static __hwloc_inline int
hwloc_get_nbobjs_inside_cpuset_by_type (hwloc_topology_t topology, hwloc_const_cpuset_t set,
hwloc_obj_type_t type) __hwloc_attribute_pure;
static __hwloc_inline int
hwloc_get_nbobjs_inside_cpuset_by_type (hwloc_topology_t topology, hwloc_const_cpuset_t set,
hwloc_obj_type_t type)
{
int depth = hwloc_get_type_depth(topology, type);
if (depth == HWLOC_TYPE_DEPTH_UNKNOWN)
return 0;
if (depth == HWLOC_TYPE_DEPTH_MULTIPLE)
return -1; /* FIXME: agregate nbobjs from different levels? */
return hwloc_get_nbobjs_inside_cpuset_by_depth(topology, set, depth);
}
static __hwloc_inline int
hwloc_get_obj_index_inside_cpuset (hwloc_topology_t topology __hwloc_attribute_unused, hwloc_const_cpuset_t set,
hwloc_obj_t obj) __hwloc_attribute_pure;
static __hwloc_inline int
hwloc_get_obj_index_inside_cpuset (hwloc_topology_t topology __hwloc_attribute_unused, hwloc_const_cpuset_t set,
hwloc_obj_t obj)
{
int idx = 0;
if (!hwloc_bitmap_isincluded(obj->cpuset, set))
return -1;
/* count how many objects are inside the cpuset on the way from us to the beginning of the level */
while ((obj = obj->prev_cousin) != NULL)
if (!hwloc_bitmap_iszero(obj->cpuset) && hwloc_bitmap_isincluded(obj->cpuset, set))
idx++;
return idx;
}
static __hwloc_inline hwloc_obj_t
hwloc_get_child_covering_cpuset (hwloc_topology_t topology __hwloc_attribute_unused, hwloc_const_cpuset_t set,
hwloc_obj_t parent) __hwloc_attribute_pure;
static __hwloc_inline hwloc_obj_t
hwloc_get_child_covering_cpuset (hwloc_topology_t topology __hwloc_attribute_unused, hwloc_const_cpuset_t set,
hwloc_obj_t parent)
{
hwloc_obj_t child;
if (!parent->cpuset || hwloc_bitmap_iszero(set))
return NULL;
child = parent->first_child;
while (child) {
if (child->cpuset && hwloc_bitmap_isincluded(set, child->cpuset))
return child;
child = child->next_sibling;
}
return NULL;
}
static __hwloc_inline hwloc_obj_t
hwloc_get_obj_covering_cpuset (hwloc_topology_t topology, hwloc_const_cpuset_t set) __hwloc_attribute_pure;
static __hwloc_inline hwloc_obj_t
hwloc_get_obj_covering_cpuset (hwloc_topology_t topology, hwloc_const_cpuset_t set)
{
struct hwloc_obj *current = hwloc_get_root_obj(topology);
if (hwloc_bitmap_iszero(set) || !current->cpuset || !hwloc_bitmap_isincluded(set, current->cpuset))
return NULL;
while (1) {
hwloc_obj_t child = hwloc_get_child_covering_cpuset(topology, set, current);
if (!child)
return current;
current = child;
}
}
static __hwloc_inline hwloc_obj_t
hwloc_get_next_obj_covering_cpuset_by_depth(hwloc_topology_t topology, hwloc_const_cpuset_t set,
unsigned depth, hwloc_obj_t prev)
{
hwloc_obj_t next = hwloc_get_next_obj_by_depth(topology, depth, prev);
if (!next || !next->cpuset)
return NULL;
while (next && !hwloc_bitmap_intersects(set, next->cpuset))
next = next->next_cousin;
return next;
}
static __hwloc_inline hwloc_obj_t
hwloc_get_next_obj_covering_cpuset_by_type(hwloc_topology_t topology, hwloc_const_cpuset_t set,
hwloc_obj_type_t type, hwloc_obj_t prev)
{
int depth = hwloc_get_type_depth(topology, type);
if (depth == HWLOC_TYPE_DEPTH_UNKNOWN || depth == HWLOC_TYPE_DEPTH_MULTIPLE)
return NULL;
return hwloc_get_next_obj_covering_cpuset_by_depth(topology, set, depth, prev);
}
static __hwloc_inline hwloc_obj_t
hwloc_get_ancestor_obj_by_depth (hwloc_topology_t topology __hwloc_attribute_unused, unsigned depth, hwloc_obj_t obj) __hwloc_attribute_pure;
static __hwloc_inline hwloc_obj_t
hwloc_get_ancestor_obj_by_depth (hwloc_topology_t topology __hwloc_attribute_unused, unsigned depth, hwloc_obj_t obj)
{
hwloc_obj_t ancestor = obj;
if (obj->depth < depth)
return NULL;
while (ancestor && ancestor->depth > depth)
ancestor = ancestor->parent;
return ancestor;
}
static __hwloc_inline hwloc_obj_t
hwloc_get_ancestor_obj_by_type (hwloc_topology_t topology __hwloc_attribute_unused, hwloc_obj_type_t type, hwloc_obj_t obj) __hwloc_attribute_pure;
static __hwloc_inline hwloc_obj_t
hwloc_get_ancestor_obj_by_type (hwloc_topology_t topology __hwloc_attribute_unused, hwloc_obj_type_t type, hwloc_obj_t obj)
{
hwloc_obj_t ancestor = obj->parent;
while (ancestor && ancestor->type != type)
ancestor = ancestor->parent;
return ancestor;
}
static __hwloc_inline hwloc_obj_t
hwloc_get_common_ancestor_obj (hwloc_topology_t topology __hwloc_attribute_unused, hwloc_obj_t obj1, hwloc_obj_t obj2) __hwloc_attribute_pure;
static __hwloc_inline hwloc_obj_t
hwloc_get_common_ancestor_obj (hwloc_topology_t topology __hwloc_attribute_unused, hwloc_obj_t obj1, hwloc_obj_t obj2)
{
/* the loop isn't so easy since intermediate ancestors may have
* different depth, causing us to alternate between using obj1->parent
* and obj2->parent. Also, even if at some point we find ancestors of
* of the same depth, their ancestors may have different depth again.
*/
while (obj1 != obj2) {
while (obj1->depth > obj2->depth)
obj1 = obj1->parent;
while (obj2->depth > obj1->depth)
obj2 = obj2->parent;
if (obj1 != obj2 && obj1->depth == obj2->depth) {
obj1 = obj1->parent;
obj2 = obj2->parent;
}
}
return obj1;
}
static __hwloc_inline int
hwloc_obj_is_in_subtree (hwloc_topology_t topology __hwloc_attribute_unused, hwloc_obj_t obj, hwloc_obj_t subtree_root) __hwloc_attribute_pure;
static __hwloc_inline int
hwloc_obj_is_in_subtree (hwloc_topology_t topology __hwloc_attribute_unused, hwloc_obj_t obj, hwloc_obj_t subtree_root)
{
return hwloc_bitmap_isincluded(obj->cpuset, subtree_root->cpuset);
}
static __hwloc_inline hwloc_obj_t
hwloc_get_next_child (hwloc_topology_t topology __hwloc_attribute_unused, hwloc_obj_t parent, hwloc_obj_t prev)
{
if (!prev)
return parent->first_child;
if (prev->parent != parent)
return NULL;
return prev->next_sibling;
}
static __hwloc_inline int
hwloc_get_cache_type_depth (hwloc_topology_t topology,
unsigned cachelevel, hwloc_obj_cache_type_t cachetype)
{
int depth;
int found = HWLOC_TYPE_DEPTH_UNKNOWN;
for (depth=0; ; depth++) {
hwloc_obj_t obj = hwloc_get_obj_by_depth(topology, depth, 0);
if (!obj)
break;
if (obj->type != HWLOC_OBJ_CACHE || obj->attr->cache.depth != cachelevel)
/* doesn't match, try next depth */
continue;
if (cachetype == (hwloc_obj_cache_type_t) -1) {
if (found != HWLOC_TYPE_DEPTH_UNKNOWN) {
/* second match, return MULTIPLE */
return HWLOC_TYPE_DEPTH_MULTIPLE;
}
/* first match, mark it as found */
found = depth;
continue;
}
if (obj->attr->cache.type == cachetype || obj->attr->cache.type == HWLOC_OBJ_CACHE_UNIFIED)
/* exact match (either unified is alone, or we match instruction or data), return immediately */
return depth;
}
/* went to the bottom, return what we found */
return found;
}
static __hwloc_inline hwloc_obj_t
hwloc_get_cache_covering_cpuset (hwloc_topology_t topology, hwloc_const_cpuset_t set) __hwloc_attribute_pure;
static __hwloc_inline hwloc_obj_t
hwloc_get_cache_covering_cpuset (hwloc_topology_t topology, hwloc_const_cpuset_t set)
{
hwloc_obj_t current = hwloc_get_obj_covering_cpuset(topology, set);
while (current) {
if (current->type == HWLOC_OBJ_CACHE)
return current;
current = current->parent;
}
return NULL;
}
static __hwloc_inline hwloc_obj_t
hwloc_get_shared_cache_covering_obj (hwloc_topology_t topology __hwloc_attribute_unused, hwloc_obj_t obj) __hwloc_attribute_pure;
static __hwloc_inline hwloc_obj_t
hwloc_get_shared_cache_covering_obj (hwloc_topology_t topology __hwloc_attribute_unused, hwloc_obj_t obj)
{
hwloc_obj_t current = obj->parent;
if (!obj->cpuset)
return NULL;
while (current && current->cpuset) {
if (!hwloc_bitmap_isequal(current->cpuset, obj->cpuset)
&& current->type == HWLOC_OBJ_CACHE)
return current;
current = current->parent;
}
return NULL;
}
static __hwloc_inline hwloc_obj_t
hwloc_get_pu_obj_by_os_index(hwloc_topology_t topology, unsigned os_index) __hwloc_attribute_pure;
static __hwloc_inline hwloc_obj_t
hwloc_get_pu_obj_by_os_index(hwloc_topology_t topology, unsigned os_index)
{
hwloc_obj_t obj = NULL;
while ((obj = hwloc_get_next_obj_by_type(topology, HWLOC_OBJ_PU, obj)) != NULL)
if (obj->os_index == os_index)
return obj;
return NULL;
}
static __hwloc_inline hwloc_obj_t
hwloc_get_numanode_obj_by_os_index(hwloc_topology_t topology, unsigned os_index) __hwloc_attribute_pure;
static __hwloc_inline hwloc_obj_t
hwloc_get_numanode_obj_by_os_index(hwloc_topology_t topology, unsigned os_index)
{
hwloc_obj_t obj = NULL;
while ((obj = hwloc_get_next_obj_by_type(topology, HWLOC_OBJ_NUMANODE, obj)) != NULL)
if (obj->os_index == os_index)
return obj;
return NULL;
}
/* TODO: rather provide an iterator? Provide a way to know how much should be allocated? By returning the total number of objects instead? */
HWLOC_DECLSPEC unsigned hwloc_get_closest_objs (hwloc_topology_t topology, hwloc_obj_t src, hwloc_obj_t * __hwloc_restrict objs, unsigned max);
static __hwloc_inline hwloc_obj_t
hwloc_get_obj_below_by_type (hwloc_topology_t topology,
hwloc_obj_type_t type1, unsigned idx1,
hwloc_obj_type_t type2, unsigned idx2) __hwloc_attribute_pure;
static __hwloc_inline hwloc_obj_t
hwloc_get_obj_below_by_type (hwloc_topology_t topology,
hwloc_obj_type_t type1, unsigned idx1,
hwloc_obj_type_t type2, unsigned idx2)
{
hwloc_obj_t obj;
obj = hwloc_get_obj_by_type (topology, type1, idx1);
if (!obj || !obj->cpuset)
return NULL;
return hwloc_get_obj_inside_cpuset_by_type(topology, obj->cpuset, type2, idx2);
}
static __hwloc_inline hwloc_obj_t
hwloc_get_obj_below_array_by_type (hwloc_topology_t topology, int nr, hwloc_obj_type_t *typev, unsigned *idxv) __hwloc_attribute_pure;
static __hwloc_inline hwloc_obj_t
hwloc_get_obj_below_array_by_type (hwloc_topology_t topology, int nr, hwloc_obj_type_t *typev, unsigned *idxv)
{
hwloc_obj_t obj = hwloc_get_root_obj(topology);
int i;
for(i=0; i<nr; i++) {
if (!obj || !obj->cpuset)
return NULL;
obj = hwloc_get_obj_inside_cpuset_by_type(topology, obj->cpuset, typev[i], idxv[i]);
}
return obj;
}
enum hwloc_distrib_flags_e {
HWLOC_DISTRIB_FLAG_REVERSE = (1UL<<0)
};
static __hwloc_inline int
hwloc_distrib(hwloc_topology_t topology,
hwloc_obj_t *roots, unsigned n_roots,
hwloc_cpuset_t *set,
unsigned n,
unsigned until, unsigned long flags)
{
unsigned i;
unsigned tot_weight;
unsigned given, givenweight;
hwloc_cpuset_t *cpusetp = set;
if (flags & ~HWLOC_DISTRIB_FLAG_REVERSE) {
errno = EINVAL;
return -1;
}
tot_weight = 0;
for (i = 0; i < n_roots; i++)
if (roots[i]->cpuset)
tot_weight += hwloc_bitmap_weight(roots[i]->cpuset);
for (i = 0, given = 0, givenweight = 0; i < n_roots; i++) {
unsigned chunk, weight;
hwloc_obj_t root = roots[flags & HWLOC_DISTRIB_FLAG_REVERSE ? n_roots-1-i : i];
hwloc_cpuset_t cpuset = root->cpuset;
if (!cpuset)
continue;
weight = hwloc_bitmap_weight(cpuset);
if (!weight)
continue;
/* Give to root a chunk proportional to its weight.
* If previous chunks got rounded-up, we may get a bit less. */
chunk = (( (givenweight+weight) * n + tot_weight-1) / tot_weight)
- (( givenweight * n + tot_weight-1) / tot_weight);
if (!root->arity || chunk <= 1 || root->depth >= until) {
/* We can't split any more, put everything there. */
if (chunk) {
/* Fill cpusets with ours */
unsigned j;
for (j=0; j < chunk; j++)
cpusetp[j] = hwloc_bitmap_dup(cpuset);
} else {
/* We got no chunk, just merge our cpuset to a previous one
* (the first chunk cannot be empty)
* so that this root doesn't get ignored.
*/
assert(given);
hwloc_bitmap_or(cpusetp[-1], cpusetp[-1], cpuset);
}
} else {
/* Still more to distribute, recurse into children */
hwloc_distrib(topology, root->children, root->arity, cpusetp, chunk, until, flags);
}
cpusetp += chunk;
given += chunk;
givenweight += weight;
}
return 0;
}
static __hwloc_inline hwloc_const_cpuset_t
hwloc_topology_get_complete_cpuset(hwloc_topology_t topology) __hwloc_attribute_pure;
static __hwloc_inline hwloc_const_cpuset_t
hwloc_topology_get_complete_cpuset(hwloc_topology_t topology)
{
return hwloc_get_root_obj(topology)->complete_cpuset;
}
static __hwloc_inline hwloc_const_cpuset_t
hwloc_topology_get_topology_cpuset(hwloc_topology_t topology) __hwloc_attribute_pure;
static __hwloc_inline hwloc_const_cpuset_t
hwloc_topology_get_topology_cpuset(hwloc_topology_t topology)
{
return hwloc_get_root_obj(topology)->cpuset;
}
static __hwloc_inline hwloc_const_cpuset_t
hwloc_topology_get_online_cpuset(hwloc_topology_t topology) __hwloc_attribute_pure;
static __hwloc_inline hwloc_const_cpuset_t
hwloc_topology_get_online_cpuset(hwloc_topology_t topology)
{
return hwloc_get_root_obj(topology)->online_cpuset;
}
static __hwloc_inline hwloc_const_cpuset_t
hwloc_topology_get_allowed_cpuset(hwloc_topology_t topology) __hwloc_attribute_pure;
static __hwloc_inline hwloc_const_cpuset_t
hwloc_topology_get_allowed_cpuset(hwloc_topology_t topology)
{
return hwloc_get_root_obj(topology)->allowed_cpuset;
}
static __hwloc_inline hwloc_const_nodeset_t
hwloc_topology_get_complete_nodeset(hwloc_topology_t topology) __hwloc_attribute_pure;
static __hwloc_inline hwloc_const_nodeset_t
hwloc_topology_get_complete_nodeset(hwloc_topology_t topology)
{
return hwloc_get_root_obj(topology)->complete_nodeset;
}
static __hwloc_inline hwloc_const_nodeset_t
hwloc_topology_get_topology_nodeset(hwloc_topology_t topology) __hwloc_attribute_pure;
static __hwloc_inline hwloc_const_nodeset_t
hwloc_topology_get_topology_nodeset(hwloc_topology_t topology)
{
return hwloc_get_root_obj(topology)->nodeset;
}
static __hwloc_inline hwloc_const_nodeset_t
hwloc_topology_get_allowed_nodeset(hwloc_topology_t topology) __hwloc_attribute_pure;
static __hwloc_inline hwloc_const_nodeset_t
hwloc_topology_get_allowed_nodeset(hwloc_topology_t topology)
{
return hwloc_get_root_obj(topology)->allowed_nodeset;
}
static __hwloc_inline void
hwloc_cpuset_to_nodeset(hwloc_topology_t topology, hwloc_const_cpuset_t _cpuset, hwloc_nodeset_t nodeset)
{
int depth = hwloc_get_type_depth(topology, HWLOC_OBJ_NUMANODE);
hwloc_obj_t obj;
if (depth == HWLOC_TYPE_DEPTH_UNKNOWN) {
if (hwloc_bitmap_iszero(_cpuset))
hwloc_bitmap_zero(nodeset);
else
/* Assume the whole system */
hwloc_bitmap_fill(nodeset);
return;
}
hwloc_bitmap_zero(nodeset);
obj = NULL;
while ((obj = hwloc_get_next_obj_covering_cpuset_by_depth(topology, _cpuset, depth, obj)) != NULL)
hwloc_bitmap_set(nodeset, obj->os_index);
}
static __hwloc_inline void
hwloc_cpuset_to_nodeset_strict(struct hwloc_topology *topology, hwloc_const_cpuset_t _cpuset, hwloc_nodeset_t nodeset)
{
int depth = hwloc_get_type_depth(topology, HWLOC_OBJ_NUMANODE);
hwloc_obj_t obj;
if (depth == HWLOC_TYPE_DEPTH_UNKNOWN )
return;
hwloc_bitmap_zero(nodeset);
obj = NULL;
while ((obj = hwloc_get_next_obj_covering_cpuset_by_depth(topology, _cpuset, depth, obj)) != NULL)
hwloc_bitmap_set(nodeset, obj->os_index);
}
static __hwloc_inline void
hwloc_cpuset_from_nodeset(hwloc_topology_t topology, hwloc_cpuset_t _cpuset, hwloc_const_nodeset_t nodeset)
{
int depth = hwloc_get_type_depth(topology, HWLOC_OBJ_NUMANODE);
hwloc_obj_t obj;
if (depth == HWLOC_TYPE_DEPTH_UNKNOWN ) {
if (hwloc_bitmap_iszero(nodeset))
hwloc_bitmap_zero(_cpuset);
else
/* Assume the whole system */
hwloc_bitmap_fill(_cpuset);
return;
}
hwloc_bitmap_zero(_cpuset);
obj = NULL;
while ((obj = hwloc_get_next_obj_by_depth(topology, depth, obj)) != NULL) {
if (hwloc_bitmap_isset(nodeset, obj->os_index))
/* no need to check obj->cpuset because objects in levels always have a cpuset */
hwloc_bitmap_or(_cpuset, _cpuset, obj->cpuset);
}
}
static __hwloc_inline void
hwloc_cpuset_from_nodeset_strict(struct hwloc_topology *topology, hwloc_cpuset_t _cpuset, hwloc_const_nodeset_t nodeset)
{
int depth = hwloc_get_type_depth(topology, HWLOC_OBJ_NUMANODE);
hwloc_obj_t obj;
if (depth == HWLOC_TYPE_DEPTH_UNKNOWN )
return;
hwloc_bitmap_zero(_cpuset);
obj = NULL;
while ((obj = hwloc_get_next_obj_by_depth(topology, depth, obj)) != NULL)
if (hwloc_bitmap_isset(nodeset, obj->os_index))
/* no need to check obj->cpuset because objects in levels always have a cpuset */
hwloc_bitmap_or(_cpuset, _cpuset, obj->cpuset);
}
static __hwloc_inline const struct hwloc_distances_s *
hwloc_get_whole_distance_matrix_by_depth(hwloc_topology_t topology, unsigned depth)
{
hwloc_obj_t root = hwloc_get_root_obj(topology);
unsigned i;
for(i=0; i<root->distances_count; i++)
if (root->distances[i]->relative_depth == depth)
return root->distances[i];
return NULL;
}
static __hwloc_inline const struct hwloc_distances_s *
hwloc_get_whole_distance_matrix_by_type(hwloc_topology_t topology, hwloc_obj_type_t type)
{
int depth = hwloc_get_type_depth(topology, type);
if (depth < 0)
return NULL;
return hwloc_get_whole_distance_matrix_by_depth(topology, depth);
}
static __hwloc_inline const struct hwloc_distances_s *
hwloc_get_distance_matrix_covering_obj_by_depth(hwloc_topology_t topology,
hwloc_obj_t obj, unsigned depth,
unsigned *firstp)
{
while (obj && obj->cpuset) {
unsigned i;
for(i=0; i<obj->distances_count; i++)
if (obj->distances[i]->relative_depth == depth - obj->depth) {
if (!obj->distances[i]->nbobjs)
continue;
*firstp = hwloc_get_next_obj_inside_cpuset_by_depth(topology, obj->cpuset, depth, NULL)->logical_index;
return obj->distances[i];
}
obj = obj->parent;
}
return NULL;
}
static __hwloc_inline int
hwloc_get_latency(hwloc_topology_t topology,
hwloc_obj_t obj1, hwloc_obj_t obj2,
float *latency, float *reverse_latency)
{
hwloc_obj_t ancestor;
const struct hwloc_distances_s * distances;
unsigned first_logical ;
if (obj1->depth != obj2->depth) {
errno = EINVAL;
return -1;
}
ancestor = hwloc_get_common_ancestor_obj(topology, obj1, obj2);
distances = hwloc_get_distance_matrix_covering_obj_by_depth(topology, ancestor, obj1->depth, &first_logical);
if (distances && distances->latency) {
const float * latency_matrix = distances->latency;
unsigned nbobjs = distances->nbobjs;
unsigned l1 = obj1->logical_index - first_logical;
unsigned l2 = obj2->logical_index - first_logical;
*latency = latency_matrix[l1*nbobjs+l2];
*reverse_latency = latency_matrix[l2*nbobjs+l1];
return 0;
}
errno = ENOSYS;
return -1;
}
static __hwloc_inline hwloc_obj_t
hwloc_get_non_io_ancestor_obj(hwloc_topology_t topology __hwloc_attribute_unused,
hwloc_obj_t ioobj)
{
hwloc_obj_t obj = ioobj;
while (obj && !obj->cpuset) {
obj = obj->parent;
}
return obj;
}
static __hwloc_inline hwloc_obj_t
hwloc_get_next_pcidev(hwloc_topology_t topology, hwloc_obj_t prev)
{
return hwloc_get_next_obj_by_type(topology, HWLOC_OBJ_PCI_DEVICE, prev);
}
static __hwloc_inline hwloc_obj_t
hwloc_get_pcidev_by_busid(hwloc_topology_t topology,
unsigned domain, unsigned bus, unsigned dev, unsigned func)
{
hwloc_obj_t obj = NULL;
while ((obj = hwloc_get_next_pcidev(topology, obj)) != NULL) {
if (obj->attr->pcidev.domain == domain
&& obj->attr->pcidev.bus == bus
&& obj->attr->pcidev.dev == dev
&& obj->attr->pcidev.func == func)
return obj;
}
return NULL;
}
static __hwloc_inline hwloc_obj_t
hwloc_get_pcidev_by_busidstring(hwloc_topology_t topology, const char *busid)
{
unsigned domain = 0; /* default */
unsigned bus, dev, func;
if (sscanf(busid, "%x:%x.%x", &bus, &dev, &func) != 3
&& sscanf(busid, "%x:%x:%x.%x", &domain, &bus, &dev, &func) != 4) {
errno = EINVAL;
return NULL;
}
return hwloc_get_pcidev_by_busid(topology, domain, bus, dev, func);
}
static __hwloc_inline hwloc_obj_t
hwloc_get_next_osdev(hwloc_topology_t topology, hwloc_obj_t prev)
{
return hwloc_get_next_obj_by_type(topology, HWLOC_OBJ_OS_DEVICE, prev);
}
static __hwloc_inline hwloc_obj_t
hwloc_get_next_bridge(hwloc_topology_t topology, hwloc_obj_t prev)
{
return hwloc_get_next_obj_by_type(topology, HWLOC_OBJ_BRIDGE, prev);
}
/* \brief Checks whether a given bridge covers a given PCI bus.
*/
static __hwloc_inline int
hwloc_bridge_covers_pcibus(hwloc_obj_t bridge,
unsigned domain, unsigned bus)
{
return bridge->type == HWLOC_OBJ_BRIDGE
&& bridge->attr->bridge.downstream_type == HWLOC_OBJ_BRIDGE_PCI
&& bridge->attr->bridge.downstream.pci.domain == domain
&& bridge->attr->bridge.downstream.pci.secondary_bus <= bus
&& bridge->attr->bridge.downstream.pci.subordinate_bus >= bus;
}
static __hwloc_inline hwloc_obj_t
hwloc_get_hostbridge_by_pcibus(hwloc_topology_t topology,
unsigned domain, unsigned bus)
{
hwloc_obj_t obj = NULL;
while ((obj = hwloc_get_next_bridge(topology, obj)) != NULL) {
if (hwloc_bridge_covers_pcibus(obj, domain, bus)) {
/* found bridge covering this pcibus, make sure it's a hostbridge */
assert(obj->attr->bridge.upstream_type == HWLOC_OBJ_BRIDGE_HOST);
assert(obj->parent->type != HWLOC_OBJ_BRIDGE);
assert(obj->parent->cpuset);
return obj;
}
}
return NULL;
}
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* HWLOC_HELPER_H */
HWLOC_OBJ_OS_DEVICE
Operating system device. These objects have neither CPU sets nor node sets. They are not added to the...
Definition: hwloc.h:251
hwloc_get_shared_cache_covering_obj
static hwloc_obj_t hwloc_get_shared_cache_covering_obj(hwloc_topology_t topology, hwloc_obj_t obj)
Get the first cache shared between an object and somebody else.
Definition: helper.h:538
hwloc_get_pcidev_by_busidstring
static hwloc_obj_t hwloc_get_pcidev_by_busidstring(hwloc_topology_t topology, const char *busid)
Find the PCI device object matching the PCI bus id given as a string xxxx:yy:zz.t or yy:zz...
Definition: helper.h:1233
HWLOC_OBJ_PU
Processing Unit, or (Logical) Processor. An execution unit (may share a core with some other logical ...
Definition: hwloc.h:211
hwloc_get_hostbridge_by_pcibus
static hwloc_obj_t hwloc_get_hostbridge_by_pcibus(hwloc_topology_t topology, unsigned domain, unsigned bus)
Find the hostbridge that covers the given PCI bus.
Definition: helper.h:1286
hwloc_get_latency
static int hwloc_get_latency(hwloc_topology_t topology, hwloc_obj_t obj1, hwloc_obj_t obj2, float *latency, float *reverse_latency)
Get the latency in both directions between two objects.
Definition: helper.h:1147
hwloc_bitmap_set
void hwloc_bitmap_set(hwloc_bitmap_t bitmap, unsigned id)
Add index id in bitmap bitmap.
hwloc_get_obj_by_type
static hwloc_obj_t hwloc_get_obj_by_type(hwloc_topology_t topology, hwloc_obj_type_t type, unsigned idx)
Returns the topology object at logical index idx with type type.
hwloc_get_nbobjs_inside_cpuset_by_depth
static unsigned hwloc_get_nbobjs_inside_cpuset_by_depth(hwloc_topology_t topology, hwloc_const_cpuset_t set, unsigned depth)
Return the number of objects at depth depth included in CPU set set.
Definition: helper.h:191
HWLOC_TYPE_DEPTH_MULTIPLE
Objects of given type exist at different depth in the topology.
Definition: hwloc.h:1224
hwloc_obj::parent
struct hwloc_obj * parent
Parent, NULL if root (system object)
Definition: hwloc.h:403
hwloc_get_next_obj_by_type
static hwloc_obj_t hwloc_get_next_obj_by_type(hwloc_topology_t topology, hwloc_obj_type_t type, hwloc_obj_t prev)
Returns the next object of type type.
hwloc_obj::depth
unsigned depth
Vertical index in the hierarchy.
Definition: hwloc.h:377
HWLOC_DISTRIB_FLAG_REVERSE
Distrib in reverse order, starting from the last objects.
Definition: helper.h:696
HWLOC_OBJ_PCI_DEVICE
PCI device. These objects have neither CPU sets nor node sets. They are not added to the topology unl...
Definition: hwloc.h:246
HWLOC_OBJ_BRIDGE
Bridge. Any bridge that connects the host or an I/O bus, to another I/O bus. Bridge objects have neit...
Definition: hwloc.h:239
hwloc_distances_s
Distances between objects.
Definition: hwloc.h:583
HWLOC_TYPE_DEPTH_UNKNOWN
No object of given type exists in the topology.
Definition: hwloc.h:1223
hwloc_obj_attr_u::bridge
struct hwloc_obj_attr_u::hwloc_bridge_attr_s bridge
hwloc_cpuset_from_nodeset_strict
static void hwloc_cpuset_from_nodeset_strict(struct hwloc_topology *topology, hwloc_cpuset_t _cpuset, hwloc_const_nodeset_t nodeset)
Convert a NUMA node set into a CPU set without handling non-NUMA cases.
Definition: helper.h:1023
hwloc_get_obj_below_by_type
static hwloc_obj_t hwloc_get_obj_below_by_type(hwloc_topology_t topology, hwloc_obj_type_t type1, unsigned idx1, hwloc_obj_type_t type2, unsigned idx2)
Find an object below another object, both specified by types and indexes.
Definition: helper.h:638
HWLOC_OBJ_BRIDGE_HOST
Host-side of a bridge, only possible upstream.
Definition: hwloc.h:279
hwloc_get_next_obj_covering_cpuset_by_type
static hwloc_obj_t hwloc_get_next_obj_covering_cpuset_by_type(hwloc_topology_t topology, hwloc_const_cpuset_t set, hwloc_obj_type_t type, hwloc_obj_t prev)
Iterate through same-type objects covering at least CPU set set.
Definition: helper.h:355
HWLOC_OBJ_CACHE_UNIFIED
Unified cache.
Definition: hwloc.h:271
hwloc_obj::next_cousin
struct hwloc_obj * next_cousin
Next object of same type and depth.
Definition: hwloc.h:399
hwloc_obj_attr_u::hwloc_pcidev_attr_s::bus
unsigned char bus
Definition: hwloc.h:543
hwloc_obj::allowed_nodeset
hwloc_nodeset_t allowed_nodeset
The set of allowed NUMA memory nodes.
Definition: hwloc.h:495
hwloc_obj::attr
union hwloc_obj_attr_u * attr
Object type-specific Attributes, may be NULL if no attribute value was found.
Definition: hwloc.h:373
hwloc_obj::distances
struct hwloc_distances_s ** distances
Distances between all objects at same depth below this object.
Definition: hwloc.h:508
hwloc_topology_get_online_cpuset
static hwloc_const_cpuset_t hwloc_topology_get_online_cpuset(hwloc_topology_t topology)
Get online CPU set.
Definition: helper.h:838
hwloc_get_obj_below_array_by_type
static hwloc_obj_t hwloc_get_obj_below_array_by_type(hwloc_topology_t topology, int nr, hwloc_obj_type_t *typev, unsigned *idxv)
Find an object below a chain of objects specified by types and indexes.
Definition: helper.h:670
hwloc_obj::logical_index
unsigned logical_index
Horizontal index in the whole list of similar objects, hence guaranteed unique across the entire mach...
Definition: hwloc.h:392
hwloc_obj::prev_cousin
struct hwloc_obj * prev_cousin
Previous object of same type and depth.
Definition: hwloc.h:400
hwloc_topology_get_complete_cpuset
static hwloc_const_cpuset_t hwloc_topology_get_complete_cpuset(hwloc_topology_t topology)
Get complete CPU set.
Definition: helper.h:803
hwloc_get_pcidev_by_busid
static hwloc_obj_t hwloc_get_pcidev_by_busid(hwloc_topology_t topology, unsigned domain, unsigned bus, unsigned dev, unsigned func)
Find the PCI device object matching the PCI bus id given domain, bus device and function PCI bus id...
Definition: helper.h:1215
hwloc_const_cpuset_t
hwloc_const_bitmap_t hwloc_const_cpuset_t
A non-modifiable hwloc_cpuset_t.
Definition: hwloc.h:134
hwloc_distances_s::nbobjs
unsigned nbobjs
Number of objects considered in the matrix. It is the number of descendant objects at relative_depth ...
Definition: hwloc.h:586
hwloc_cpuset_to_nodeset_strict
static void hwloc_cpuset_to_nodeset_strict(struct hwloc_topology *topology, hwloc_const_cpuset_t _cpuset, hwloc_nodeset_t nodeset)
Convert a CPU set into a NUMA node set without handling non-NUMA cases.
Definition: helper.h:971
hwloc_obj::arity
unsigned arity
Number of children.
Definition: hwloc.h:409
hwloc_topology_get_topology_nodeset
static hwloc_const_nodeset_t hwloc_topology_get_topology_nodeset(hwloc_topology_t topology)
Get topology node set.
Definition: helper.h:890
hwloc_get_non_io_ancestor_obj
static hwloc_obj_t hwloc_get_non_io_ancestor_obj(hwloc_topology_t topology, hwloc_obj_t ioobj)
Get the first non-I/O ancestor object.
Definition: helper.h:1191
hwloc_get_next_obj_by_depth
static hwloc_obj_t hwloc_get_next_obj_by_depth(hwloc_topology_t topology, unsigned depth, hwloc_obj_t prev)
Returns the next object at depth depth.
hwloc_get_closest_objs
unsigned hwloc_get_closest_objs(hwloc_topology_t topology, hwloc_obj_t src, hwloc_obj_t *restrict objs, unsigned max)
Do a depth-first traversal of the topology to find and sort.
hwloc_get_child_covering_cpuset
static hwloc_obj_t hwloc_get_child_covering_cpuset(hwloc_topology_t topology, hwloc_const_cpuset_t set, hwloc_obj_t parent)
Get the child covering at least CPU set set.
Definition: helper.h:279
hwloc_topology_t
struct hwloc_topology * hwloc_topology_t
Topology context.
Definition: hwloc.h:632
hwloc_obj_attr_u::pcidev
struct hwloc_obj_attr_u::hwloc_pcidev_attr_s pcidev
hwloc_obj_attr_u::hwloc_pcidev_attr_s::dev
unsigned char dev
Definition: hwloc.h:543
hwloc_obj_attr_u::hwloc_pcidev_attr_s::func
unsigned char func
Definition: hwloc.h:543
hwloc_topology_get_allowed_cpuset
static hwloc_const_cpuset_t hwloc_topology_get_allowed_cpuset(hwloc_topology_t topology)
Get allowed CPU set.
Definition: helper.h:855
hwloc_get_whole_distance_matrix_by_depth
static const struct hwloc_distances_s * hwloc_get_whole_distance_matrix_by_depth(hwloc_topology_t topology, unsigned depth)
Get the distances between all objects at the given depth.
Definition: helper.h:1065
hwloc_cpuset_t
hwloc_bitmap_t hwloc_cpuset_t
A CPU set is a bitmap whose bits are set according to CPU physical OS indexes.
Definition: hwloc.h:132
hwloc_obj_attr_u::hwloc_cache_attr_s::type
hwloc_obj_cache_type_t type
Cache type.
Definition: hwloc.h:534
hwloc_obj::distances_count
unsigned distances_count
Definition: hwloc.h:509
hwloc_obj_attr_u::hwloc_pcidev_attr_s::domain
unsigned short domain
Definition: hwloc.h:542
hwloc_get_root_obj
static hwloc_obj_t hwloc_get_root_obj(hwloc_topology_t topology)
Returns the top-object of the topology-tree.
hwloc_distrib
static int hwloc_distrib(hwloc_topology_t topology, hwloc_obj_t *roots, unsigned n_roots, hwloc_cpuset_t *set, unsigned n, unsigned until, unsigned long flags)
Distribute n items over the topology under roots.
Definition: helper.h:723
hwloc_get_obj_covering_cpuset
static hwloc_obj_t hwloc_get_obj_covering_cpuset(hwloc_topology_t topology, hwloc_const_cpuset_t set)
Get the lowest object covering at least CPU set set.
Definition: helper.h:304
hwloc_get_next_pcidev
static hwloc_obj_t hwloc_get_next_pcidev(hwloc_topology_t topology, hwloc_obj_t prev)
Get the next PCI device in the system.
Definition: helper.h:1206
hwloc_bitmap_isincluded
int hwloc_bitmap_isincluded(hwloc_const_bitmap_t sub_bitmap, hwloc_const_bitmap_t super_bitmap)
Test whether bitmap sub_bitmap is part of bitmap super_bitmap.
hwloc_obj::cpuset
hwloc_cpuset_t cpuset
CPUs covered by this object.
Definition: hwloc.h:421
hwloc_obj::allowed_cpuset
hwloc_cpuset_t allowed_cpuset
The CPU set of allowed logical processors.
Definition: hwloc.h:453
hwloc_obj::complete_cpuset
hwloc_cpuset_t complete_cpuset
The complete CPU set of logical processors of this object,.
Definition: hwloc.h:434
hwloc_obj_attr_u::hwloc_bridge_attr_s::downstream
union hwloc_obj_attr_u::hwloc_bridge_attr_s::@1 downstream
hwloc_bitmap_iszero
int hwloc_bitmap_iszero(hwloc_const_bitmap_t bitmap)
Test whether bitmap bitmap is empty.
hwloc_bitmap_isequal
int hwloc_bitmap_isequal(hwloc_const_bitmap_t bitmap1, hwloc_const_bitmap_t bitmap2)
Test whether bitmap bitmap1 is equal to bitmap bitmap2.
hwloc_obj::os_index
unsigned os_index
OS-provided physical index number. It is not guaranteed unique across the entire machine, except for PUs and NUMA nodes.
Definition: hwloc.h:362
hwloc_bitmap_dup
hwloc_bitmap_t hwloc_bitmap_dup(hwloc_const_bitmap_t bitmap)
Duplicate bitmap bitmap by allocating a new bitmap and copying bitmap contents.
hwloc_get_largest_objs_inside_cpuset
int hwloc_get_largest_objs_inside_cpuset(hwloc_topology_t topology, hwloc_const_cpuset_t set, hwloc_obj_t *restrict objs, int max)
Get the set of largest objects covering exactly a given cpuset set.
hwloc_get_next_obj_inside_cpuset_by_depth
static hwloc_obj_t hwloc_get_next_obj_inside_cpuset_by_depth(hwloc_topology_t topology, hwloc_const_cpuset_t set, unsigned depth, hwloc_obj_t prev)
Return the next object at depth depth included in CPU set set.
Definition: helper.h:91
hwloc_get_numanode_obj_by_os_index
static hwloc_obj_t hwloc_get_numanode_obj_by_os_index(hwloc_topology_t topology, unsigned os_index)
Returns the object of type HWLOC_OBJ_NUMANODE with os_index.
Definition: helper.h:598
hwloc_obj_attr_u::hwloc_bridge_attr_s::upstream_type
hwloc_obj_bridge_type_t upstream_type
Definition: hwloc.h:554
hwloc_cpuset_from_nodeset
static void hwloc_cpuset_from_nodeset(hwloc_topology_t topology, hwloc_cpuset_t _cpuset, hwloc_const_nodeset_t nodeset)
Convert a NUMA node set into a CPU set and handle non-NUMA cases.
Definition: helper.h:992
HWLOC_OBJ_CACHE
Cache. Can be L1i, L1d, L2, L3, ...
Definition: hwloc.h:204
hwloc_obj::complete_nodeset
hwloc_nodeset_t complete_nodeset
The complete NUMA node set of this object,.
Definition: hwloc.h:481
hwloc_obj_type_t
hwloc_obj_type_t
Type of topology object.
Definition: hwloc.h:170
hwloc_const_nodeset_t
hwloc_const_bitmap_t hwloc_const_nodeset_t
A non-modifiable hwloc_nodeset_t.
Definition: hwloc.h:154
hwloc_obj_attr_u::hwloc_bridge_attr_s::downstream_type
hwloc_obj_bridge_type_t downstream_type
Definition: hwloc.h:561
hwloc_topology_get_topology_cpuset
static hwloc_const_cpuset_t hwloc_topology_get_topology_cpuset(hwloc_topology_t topology)
Get topology CPU set.
Definition: helper.h:821
hwloc_get_first_largest_obj_inside_cpuset
static hwloc_obj_t hwloc_get_first_largest_obj_inside_cpuset(hwloc_topology_t topology, hwloc_const_cpuset_t set)
Get the first largest object included in the given cpuset set.
Definition: helper.h:45
hwloc_get_ancestor_obj_by_type
static hwloc_obj_t hwloc_get_ancestor_obj_by_type(hwloc_topology_t topology, hwloc_obj_type_t type, hwloc_obj_t obj)
Returns the ancestor object of obj with type type.
Definition: helper.h:395
hwloc_get_type_depth
int hwloc_get_type_depth(hwloc_topology_t topology, hwloc_obj_type_t type)
Returns the depth of objects of type type.
hwloc_topology_get_allowed_nodeset
static hwloc_const_nodeset_t hwloc_topology_get_allowed_nodeset(hwloc_topology_t topology)
Get allowed node set.
Definition: helper.h:907
hwloc_get_obj_inside_cpuset_by_depth
static hwloc_obj_t hwloc_get_obj_inside_cpuset_by_depth(hwloc_topology_t topology, hwloc_const_cpuset_t set, unsigned depth, unsigned idx)
Return the (logically) idx -th object at depth depth included in CPU set set.
Definition: helper.h:136
hwloc_get_cache_covering_cpuset
static hwloc_obj_t hwloc_get_cache_covering_cpuset(hwloc_topology_t topology, hwloc_const_cpuset_t set)
Get the first cache covering a cpuset set.
Definition: helper.h:520
hwloc_bitmap_isset
int hwloc_bitmap_isset(hwloc_const_bitmap_t bitmap, unsigned id)
Test whether index id is part of bitmap bitmap.
hwloc_obj::online_cpuset
hwloc_cpuset_t online_cpuset
The CPU set of online logical processors.
Definition: hwloc.h:445
hwloc_obj_attr_u::cache
struct hwloc_obj_attr_u::hwloc_cache_attr_s cache
hwloc_distances_s::latency
float * latency
Matrix of latencies between objects, stored as a one-dimension array. May be NULL if the distances co...
Definition: hwloc.h:591
hwloc_bitmap_zero
void hwloc_bitmap_zero(hwloc_bitmap_t bitmap)
Empty the bitmap bitmap.
hwloc_get_obj_index_inside_cpuset
static int hwloc_get_obj_index_inside_cpuset(hwloc_topology_t topology, hwloc_const_cpuset_t set, hwloc_obj_t obj)
Return the logical index among the objects included in CPU set set.
Definition: helper.h:248
HWLOC_OBJ_BRIDGE_PCI
PCI-side of a bridge.
Definition: hwloc.h:280
hwloc_bitmap_or
void hwloc_bitmap_or(hwloc_bitmap_t res, hwloc_const_bitmap_t bitmap1, hwloc_const_bitmap_t bitmap2)
Or bitmaps bitmap1 and bitmap2 and store the result in bitmap res.
hwloc_get_whole_distance_matrix_by_type
static const struct hwloc_distances_s * hwloc_get_whole_distance_matrix_by_type(hwloc_topology_t topology, hwloc_obj_type_t type)
Get the distances between all objects of a given type.
Definition: helper.h:1095
hwloc_obj::next_sibling
struct hwloc_obj * next_sibling
Next object below the same parent.
Definition: hwloc.h:405
hwloc_get_obj_by_depth
hwloc_obj_t hwloc_get_obj_by_depth(hwloc_topology_t topology, unsigned depth, unsigned idx)
Returns the topology object at logical index idx from depth depth.
hwloc_obj_is_in_subtree
static int hwloc_obj_is_in_subtree(hwloc_topology_t topology, hwloc_obj_t obj, hwloc_obj_t subtree_root)
Returns true if obj is inside the subtree beginning with ancestor object subtree_root.
Definition: helper.h:434
hwloc_distrib_flags_e
hwloc_distrib_flags_e
Flags to be given to hwloc_distrib().
Definition: helper.h:692
hwloc_bitmap_fill
void hwloc_bitmap_fill(hwloc_bitmap_t bitmap)
Fill bitmap bitmap with all possible indexes (even if those objects don&#39;t exist or are otherwise unav...
hwloc_get_next_child
static hwloc_obj_t hwloc_get_next_child(hwloc_topology_t topology, hwloc_obj_t parent, hwloc_obj_t prev)
Return the next child.
Definition: helper.h:444
hwloc_get_ancestor_obj_by_depth
static hwloc_obj_t hwloc_get_ancestor_obj_by_depth(hwloc_topology_t topology, unsigned depth, hwloc_obj_t obj)
Returns the ancestor object of obj at depth depth.
Definition: helper.h:381
hwloc_obj::type
hwloc_obj_type_t type
Type of object.
Definition: hwloc.h:360
hwloc_bitmap_weight
int hwloc_bitmap_weight(hwloc_const_bitmap_t bitmap)
Compute the "weight" of bitmap bitmap (i.e., number of indexes that are in the bitmap).
hwloc_obj_cache_type_t
enum hwloc_obj_cache_type_e hwloc_obj_cache_type_t
Cache type.
HWLOC_OBJ_NUMANODE
NUMA node. An object that contains memory that is directly and byte-accessible to the host processors...
Definition: hwloc.h:190
hwloc_obj::nodeset
hwloc_nodeset_t nodeset
NUMA nodes covered by this object or containing this object.
Definition: hwloc.h:464
hwloc_cpuset_to_nodeset
static void hwloc_cpuset_to_nodeset(hwloc_topology_t topology, hwloc_const_cpuset_t _cpuset, hwloc_nodeset_t nodeset)
Convert a CPU set into a NUMA node set and handle non-NUMA cases.
Definition: helper.h:943
hwloc_obj::first_child
struct hwloc_obj * first_child
First child.
Definition: hwloc.h:411
hwloc_get_next_obj_inside_cpuset_by_type
static hwloc_obj_t hwloc_get_next_obj_inside_cpuset_by_type(hwloc_topology_t topology, hwloc_const_cpuset_t set, hwloc_obj_type_t type, hwloc_obj_t prev)
Return the next object of type type included in CPU set set.
Definition: helper.h:115
hwloc_topology_get_complete_nodeset
static hwloc_const_nodeset_t hwloc_topology_get_complete_nodeset(hwloc_topology_t topology)
Get complete node set.
Definition: helper.h:872
hwloc_obj_attr_u::hwloc_cache_attr_s::depth
unsigned depth
Depth of cache (e.g., L1, L2, ...etc.)
Definition: hwloc.h:530
hwloc_get_obj_inside_cpuset_by_type
static hwloc_obj_t hwloc_get_obj_inside_cpuset_by_type(hwloc_topology_t topology, hwloc_const_cpuset_t set, hwloc_obj_type_t type, unsigned idx)
Return the idx -th object of type type included in CPU set set.
Definition: helper.h:170
hwloc_nodeset_t
hwloc_bitmap_t hwloc_nodeset_t
A node set is a bitmap whose bits are set according to NUMA memory node physical OS indexes...
Definition: hwloc.h:151
hwloc_obj_attr_u::hwloc_bridge_attr_s::pci
struct hwloc_pcidev_attr_s pci
Definition: hwloc.h:552
hwloc_bridge_covers_pcibus
static int hwloc_bridge_covers_pcibus(hwloc_obj_t bridge, unsigned domain, unsigned bus)
Definition: helper.h:1270
hwloc_get_next_osdev
static hwloc_obj_t hwloc_get_next_osdev(hwloc_topology_t topology, hwloc_obj_t prev)
Get the next OS device in the system.
Definition: helper.h:1252
hwloc_get_cache_type_depth
static int hwloc_get_cache_type_depth(hwloc_topology_t topology, unsigned cachelevel, hwloc_obj_cache_type_t cachetype)
Find the depth of cache objects matching cache depth and type.
Definition: helper.h:481
hwloc_obj
Structure of a topology object.
Definition: hwloc.h:358
hwloc_get_common_ancestor_obj
static hwloc_obj_t hwloc_get_common_ancestor_obj(hwloc_topology_t topology, hwloc_obj_t obj1, hwloc_obj_t obj2)
Returns the common parent object to objects obj1 and obj2.
Definition: helper.h:407
hwloc_get_next_bridge
static hwloc_obj_t hwloc_get_next_bridge(hwloc_topology_t topology, hwloc_obj_t prev)
Get the next bridge in the system.
Definition: helper.h:1262
hwloc_get_nbobjs_inside_cpuset_by_type
static int hwloc_get_nbobjs_inside_cpuset_by_type(hwloc_topology_t topology, hwloc_const_cpuset_t set, hwloc_obj_type_t type)
Return the number of objects of type type included in CPU set set.
Definition: helper.h:222
hwloc_obj::children
struct hwloc_obj ** children
Children, children[0 .. arity -1].
Definition: hwloc.h:410
hwloc_get_next_obj_covering_cpuset_by_depth
static hwloc_obj_t hwloc_get_next_obj_covering_cpuset_by_depth(hwloc_topology_t topology, hwloc_const_cpuset_t set, unsigned depth, hwloc_obj_t prev)
Iterate through same-depth objects covering at least CPU set set.
Definition: helper.h:328
hwloc_bitmap_intersects
int hwloc_bitmap_intersects(hwloc_const_bitmap_t bitmap1, hwloc_const_bitmap_t bitmap2)
Test whether bitmaps bitmap1 and bitmap2 intersects.
hwloc_get_pu_obj_by_os_index
static hwloc_obj_t hwloc_get_pu_obj_by_os_index(hwloc_topology_t topology, unsigned os_index)
Returns the object of type HWLOC_OBJ_PU with os_index.
Definition: helper.h:577
hwloc_get_distance_matrix_covering_obj_by_depth
static const struct hwloc_distances_s * hwloc_get_distance_matrix_covering_obj_by_depth(hwloc_topology_t topology, hwloc_obj_t obj, unsigned depth, unsigned *firstp)
Get distances for the given depth and covering some objects.
Definition: helper.h:1117
hwloc_distances_s::relative_depth
unsigned relative_depth
Relative depth of the considered objects below the object containing this distance information...
Definition: hwloc.h:584