13 #ifndef HWLOC_HELPER_H 14 #define HWLOC_HELPER_H 17 #error Please include the main hwloc.h instead 221 int depth,
unsigned idx) __hwloc_attribute_pure;
224 int depth,
unsigned idx)
279 static __hwloc_inline
unsigned 281 int depth) __hwloc_attribute_pure;
282 static __hwloc_inline
unsigned 311 static __hwloc_inline
int 314 static __hwloc_inline
int 342 static __hwloc_inline
int 345 static __hwloc_inline
int 494 if (obj->
depth < depth)
496 while (ancestor && ancestor->
depth > depth)
497 ancestor = ancestor->
parent;
520 while (ancestor && ancestor->
type != type)
521 ancestor = ancestor->
parent;
541 while (obj1 != obj2) {
546 if (obj1 != obj2 && obj1->
depth == obj2->
depth) {
561 static __hwloc_inline
int 563 static __hwloc_inline
int 595 if (!obj && state == 0) {
599 if (!obj && state == 1) {
603 if (!obj && state == 2) {
641 static __hwloc_inline
int 647 for (depth=0; ; depth++) {
684 current = current->
parent;
706 current = current->
parent;
861 for(i=0; i<nr; i++) {
910 unsigned long flags);
951 static __hwloc_inline
int 956 int until,
unsigned long flags)
960 unsigned given, givenweight;
969 for (i = 0; i < n_roots; i++)
972 for (i = 0, given = 0, givenweight = 0; i < n_roots; i++) {
973 unsigned chunk, weight;
984 chunk = (( (givenweight+weight) * n + tot_weight-1) / tot_weight)
985 - (( givenweight * n + tot_weight-1) / tot_weight);
986 if (!root->
arity || chunk <= 1 || root->depth >= until) {
991 for (j=0; j < chunk; j++)
1007 givenweight += weight;
1146 static __hwloc_inline
int 1173 static __hwloc_inline
int 1217 while (obj && !obj->
cpuset) {
1242 unsigned domain,
unsigned bus,
unsigned dev,
unsigned func)
1263 unsigned domain = 0;
1264 unsigned bus, dev, func;
1266 if (sscanf(busid,
"%x:%x.%x", &bus, &dev, &func) != 3
1267 && sscanf(busid,
"%x:%x:%x.%x", &domain, &bus, &dev, &func) != 4) {
1303 static __hwloc_inline
int 1305 unsigned domain,
unsigned bus)
static hwloc_obj_t hwloc_get_next_obj_inside_cpuset_by_depth(hwloc_topology_t topology, hwloc_const_cpuset_t set, int depth, hwloc_obj_t prev)
Return the next object at depth depth included in CPU set set.
Definition: helper.h:170
int hwloc_bitmap_isset(hwloc_const_bitmap_t bitmap, unsigned id)
Test whether index id is part of bitmap bitmap.
unsigned char func
Function number (t in the PCI BDF notation xxxx:yy:zz.t).
Definition: hwloc.h:678
static hwloc_obj_t hwloc_get_obj_inside_cpuset_by_depth(hwloc_topology_t topology, hwloc_const_cpuset_t set, int depth, unsigned idx)
Return the (logically) idx -th object at depth depth included in CPU set set.
Definition: helper.h:223
static hwloc_obj_t hwloc_get_cache_covering_cpuset(hwloc_topology_t topology, hwloc_const_cpuset_t set)
Get the first data (or unified) cache covering a cpuset set.
Definition: helper.h:678
hwloc_nodeset_t nodeset
NUMA nodes covered by this object or containing this object.
Definition: hwloc.h:575
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:580
int depth
Vertical index in the hierarchy.
Definition: hwloc.h:454
No object of given type exists in the topology.
Definition: hwloc.h:879
Structure of a topology object.
Definition: hwloc.h:431
hwloc_cpuset_t cpuset
CPUs covered by this object.
Definition: hwloc.h:547
hwloc_bitmap_t hwloc_bitmap_dup(hwloc_const_bitmap_t bitmap)
Duplicate bitmap bitmap by allocating a new bitmap and copying bitmap contents.
int hwloc_obj_type_is_cache(hwloc_obj_type_t type)
Check whether an object type is a CPU Cache (Data, Unified or Instruction).
void hwloc_bitmap_zero(hwloc_bitmap_t bitmap)
Empty the bitmap bitmap.
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:200
int hwloc_obj_type_is_icache(hwloc_obj_type_t type)
Check whether an object type is a CPU Instruction Cache,.
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:517
union hwloc_obj_attr_u::hwloc_bridge_attr_s::@1 downstream
static int 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.
Definition: helper.h:1174
hwloc_obj_bridge_type_t downstream_type
Downstream Bridge type.
Definition: hwloc.h:711
Objects of given type exist at different depth in the topology (only for Groups). ...
Definition: hwloc.h:880
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:1282
Miscellaneous objects (filtered out by default). Objects without particular meaning, that can e.g. be added by the application for its own use, or by hwloc for miscellaneous objects such as MemoryModule (DIMMs).
Definition: hwloc.h:316
static hwloc_obj_t hwloc_get_next_obj_covering_cpuset_by_depth(hwloc_topology_t topology, hwloc_const_cpuset_t set, int depth, hwloc_obj_t prev)
Iterate through same-depth objects covering at least CPU set set.
Definition: helper.h:428
static hwloc_obj_t hwloc_get_shared_cache_covering_obj(hwloc_topology_t topology, hwloc_obj_t obj)
Get the first data (or unified) cache shared between an object and somebody else. ...
Definition: helper.h:697
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:781
struct hwloc_obj_attr_u::hwloc_pcidev_attr_s pcidev
struct hwloc_obj * misc_first_child
First Misc child. Misc objects are listed here (misc_arity and misc_first_child) instead of in the no...
Definition: hwloc.h:540
hwloc_const_nodeset_t hwloc_topology_get_complete_nodeset(hwloc_topology_t topology)
Get complete node set.
hwloc_obj_cache_type_t type
Cache type.
Definition: hwloc.h:657
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_const_cpuset_t hwloc_topology_get_complete_cpuset(hwloc_topology_t topology)
Get complete CPU set.
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:123
struct hwloc_obj_attr_u::hwloc_bridge_attr_s bridge
struct hwloc_obj * first_child
First normal child.
Definition: hwloc.h:492
static hwloc_obj_t hwloc_get_next_obj_by_depth(hwloc_topology_t topology, int depth, hwloc_obj_t prev)
Returns the next object at depth depth.
PCI-side of a bridge.
Definition: hwloc.h:367
int hwloc_bitmap_iszero(hwloc_const_bitmap_t bitmap)
Test whether bitmap bitmap is empty.
unsigned short domain
Domain number (xxxx in the PCI BDF notation xxxx:yy:zz.t). Only 16bits PCI domains are supported by d...
Definition: hwloc.h:670
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:161
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:259
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.
Distrib in reverse order, starting from the last objects.
Definition: helper.h:926
hwloc_const_nodeset_t hwloc_topology_get_topology_nodeset(hwloc_topology_t topology)
Get topology node set.
Processing Unit, or (Logical) Processor. An execution unit (may share a core with some other logical ...
Definition: hwloc.h:222
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:346
int 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.
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.
static int hwloc_bridge_covers_pcibus(hwloc_obj_t bridge, unsigned domain, unsigned bus)
Definition: helper.h:1304
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:1261
NUMA node. An object that contains memory that is directly and byte-accessible to the host processors...
Definition: hwloc.h:257
hwloc_const_bitmap_t hwloc_const_cpuset_t
A non-modifiable hwloc_cpuset_t.
Definition: hwloc.h:163
hwloc_const_bitmap_t hwloc_const_nodeset_t
A non-modifiable hwloc_nodeset_t.
Definition: hwloc.h:181
PCI device (filtered out by default).
Definition: hwloc.h:295
union hwloc_obj_attr_u * attr
Object type-specific Attributes, may be NULL if no attribute value was found.
Definition: hwloc.h:450
Bridge (filtered out by default). Any bridge (or PCI switch) that connects the host or an I/O bus...
Definition: hwloc.h:283
Operating system device (filtered out by default).
Definition: hwloc.h:305
int hwloc_obj_type_is_normal(hwloc_obj_type_t type)
Check whether an object type is Normal.
int hwloc_get_type_depth(hwloc_topology_t topology, hwloc_obj_type_t type)
Returns the depth of objects of type type.
hwloc_obj_type_t
Type of topology object.
Definition: hwloc.h:197
hwloc_const_nodeset_t hwloc_topology_get_allowed_nodeset(hwloc_topology_t topology)
Get allowed node set.
struct hwloc_obj ** children
Normal children, children[0 .. arity -1].
Definition: hwloc.h:491
unsigned os_index
OS-provided physical index number. It is not guaranteed unique across the entire machine, except for PUs and NUMA nodes. Set to HWLOC_UNKNOWN_INDEX if unknown or irrelevant for this object.
Definition: hwloc.h:436
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:1230
char * subtype
Subtype string to better describe the type field.
Definition: hwloc.h:434
enum hwloc_obj_cache_type_e hwloc_obj_cache_type_t
Cache type.
int hwloc_obj_type_is_memory(hwloc_obj_type_t type)
Check whether an object type is Memory.
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:857
hwloc_const_cpuset_t hwloc_topology_get_allowed_cpuset(hwloc_topology_t topology)
Get allowed CPU set.
static unsigned hwloc_get_nbobjs_inside_cpuset_by_depth(hwloc_topology_t topology, hwloc_const_cpuset_t set, int depth)
Return the number of objects at depth depth included in CPU set set.
Definition: helper.h:283
hwloc_obj_type_t type
Type of object.
Definition: hwloc.h:433
unsigned char dev
Device number (zz in the PCI BDF notation xxxx:yy:zz.t).
Definition: hwloc.h:677
hwloc_const_cpuset_t hwloc_topology_get_topology_cpuset(hwloc_topology_t topology)
Get topology CPU set.
struct hwloc_obj * parent
Parent, NULL if root (Machine object)
Definition: hwloc.h:481
Unified cache.
Definition: hwloc.h:359
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:534
hwloc_obj_t hwloc_get_obj_with_same_locality(hwloc_topology_t topology, hwloc_obj_t src, hwloc_obj_type_t type, const char *subtype, const char *nameprefix, unsigned long flags)
Return an object of a different type with same locality.
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:1241
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.
static int hwloc_distrib(hwloc_topology_t topology, hwloc_obj_t *roots, unsigned n_roots, hwloc_cpuset_t *set, unsigned n, int until, unsigned long flags)
Distribute n items over the topology under roots.
Definition: helper.h:952
struct hwloc_topology * hwloc_topology_t
Topology context.
Definition: hwloc.h:742
int hwloc_bitmap_isequal(hwloc_const_bitmap_t bitmap1, hwloc_const_bitmap_t bitmap2)
Test whether bitmap bitmap1 is equal to bitmap bitmap2.
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:1213
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:378
hwloc_obj_t hwloc_get_obj_by_depth(hwloc_topology_t topology, int depth, unsigned idx)
Returns the topology object at logical index idx from depth depth.
unsigned depth
Depth of cache (e.g., L1, L2, ...etc.)
Definition: hwloc.h:653
unsigned char bus
Bus number (yy in the PCI BDF notation xxxx:yy:zz.t).
Definition: hwloc.h:676
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:315
unsigned arity
Number of normal children. Memory, Misc and I/O children are not listed here but rather in their dedi...
Definition: hwloc.h:487
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:178
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:758
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 level and type.
Definition: helper.h:642
struct hwloc_bitmap_s * hwloc_bitmap_t
Set of bits represented as an opaque pointer to an internal bitmap.
Definition: bitmap.h:69
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:401
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:456
struct hwloc_obj * next_sibling
Next object below the same parent (inside the same list of children).
Definition: hwloc.h:483
hwloc_distrib_flags_e
Flags to be given to hwloc_distrib().
Definition: helper.h:922
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:823
static hwloc_obj_t hwloc_get_ancestor_obj_by_depth(hwloc_topology_t topology, int depth, hwloc_obj_t obj)
Returns the ancestor object of obj at depth depth.
Definition: helper.h:491
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.
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:564
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:1294
int hwloc_obj_type_is_io(hwloc_obj_type_t type)
Check whether an object type is I/O.
struct hwloc_obj * memory_first_child
First Memory child. NUMA nodes and Memory-side caches are listed here (memory_arity and memory_first_...
Definition: hwloc.h:510
static hwloc_obj_t hwloc_get_root_obj(hwloc_topology_t topology)
Returns the top-object of the topology-tree.
int hwloc_bitmap_set(hwloc_bitmap_t bitmap, unsigned id)
Add index id in bitmap bitmap.
int hwloc_bitmap_singlify_per_core(hwloc_topology_t topology, hwloc_bitmap_t cpuset, unsigned which)
Remove simultaneous multithreading PUs from a CPU set.
static int 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.
Definition: helper.h:1147
struct hwloc_obj * io_first_child
First I/O child. Bridges, PCI and OS devices are listed here (io_arity and io_first_child) instead of...
Definition: hwloc.h:528
struct hwloc_obj_attr_u::hwloc_cache_attr_s cache
struct hwloc_pcidev_attr_s pci
PCI attribute of the upstream part as a PCI device.
Definition: hwloc.h:695
struct hwloc_obj * prev_cousin
Previous object of same type and depth.
Definition: hwloc.h:478
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.
struct hwloc_obj * next_cousin
Next object of same type and depth.
Definition: hwloc.h:477
int hwloc_obj_type_is_dcache(hwloc_obj_type_t type)
Check whether an object type is a CPU Data or Unified Cache.
int hwloc_bitmap_intersects(hwloc_const_bitmap_t bitmap1, hwloc_const_bitmap_t bitmap2)
Test whether bitmaps bitmap1 and bitmap2 intersects.