Hardware Locality (hwloc): helper.h Source File

Hardware Locality (hwloc) 2.11.2

helper.h
1/*
2 * Copyright © 2009 CNRS
3 * Copyright © 2009-2024 Inria. All rights reserved.
4 * Copyright © 2009-2012 Université Bordeaux
5 * Copyright © 2009-2010 Cisco Systems, Inc. All rights reserved.
6 * See COPYING in top-level directory.
7 */
8
13#ifndef HWLOC_HELPER_H
14#define HWLOC_HELPER_H
15
16#ifndef HWLOC_H
17#error Please include the main hwloc.h instead
18#endif
19
20#include <stdlib.h>
21#include <errno.h>
22
23
24#ifdef __cplusplus
25extern "C" {
26#endif
27
28
53HWLOC_DECLSPEC int
54hwloc_obj_type_is_normal(hwloc_obj_type_t type);
55
64HWLOC_DECLSPEC int
65hwloc_obj_type_is_io(hwloc_obj_type_t type);
66
75HWLOC_DECLSPEC int
76hwloc_obj_type_is_memory(hwloc_obj_type_t type);
77
84HWLOC_DECLSPEC int
85hwloc_obj_type_is_cache(hwloc_obj_type_t type);
86
93HWLOC_DECLSPEC int
94hwloc_obj_type_is_dcache(hwloc_obj_type_t type);
95
102HWLOC_DECLSPEC int
103hwloc_obj_type_is_icache(hwloc_obj_type_t type);
104
122static __hwloc_inline hwloc_obj_t
123hwloc_get_first_largest_obj_inside_cpuset(hwloc_topology_t topology, hwloc_const_cpuset_t set)
124{
125 hwloc_obj_t obj = hwloc_get_root_obj(topology);
126 if (!hwloc_bitmap_intersects(obj->cpuset, set))
127 return NULL;
128 while (!hwloc_bitmap_isincluded(obj->cpuset, set)) {
129 /* while the object intersects without being included, look at its children */
130 hwloc_obj_t child = obj->first_child;
131 while (child) {
132 if (hwloc_bitmap_intersects(child->cpuset, set))
133 break;
134 child = child->next_sibling;
135 }
136 if (!child)
137 /* no child intersects, return their father */
138 return obj;
139 /* found one intersecting child, look at its children */
140 obj = child;
141 }
142 /* obj is included, return it */
143 return obj;
144}
145
151HWLOC_DECLSPEC int hwloc_get_largest_objs_inside_cpuset (hwloc_topology_t topology, hwloc_const_cpuset_t set,
152 hwloc_obj_t * __hwloc_restrict objs, int max);
153
169static __hwloc_inline hwloc_obj_t
170hwloc_get_next_obj_inside_cpuset_by_depth (hwloc_topology_t topology, hwloc_const_cpuset_t set,
171 int depth, hwloc_obj_t prev)
172{
173 hwloc_obj_t next = hwloc_get_next_obj_by_depth(topology, depth, prev);
174 if (!next)
175 return NULL;
176 while (next && (hwloc_bitmap_iszero(next->cpuset) || !hwloc_bitmap_isincluded(next->cpuset, set)))
177 next = next->next_cousin;
178 return next;
179}
180
199static __hwloc_inline hwloc_obj_t
200hwloc_get_next_obj_inside_cpuset_by_type (hwloc_topology_t topology, hwloc_const_cpuset_t set,
201 hwloc_obj_type_t type, hwloc_obj_t prev)
202{
203 int depth = hwloc_get_type_depth(topology, type);
204 if (depth == HWLOC_TYPE_DEPTH_UNKNOWN || depth == HWLOC_TYPE_DEPTH_MULTIPLE)
205 return NULL;
206 return hwloc_get_next_obj_inside_cpuset_by_depth(topology, set, depth, prev);
207}
208
219static __hwloc_inline hwloc_obj_t
220 hwloc_get_obj_inside_cpuset_by_depth (hwloc_topology_t topology, hwloc_const_cpuset_t set,
221 int depth, unsigned idx) __hwloc_attribute_pure;
222static __hwloc_inline hwloc_obj_t
223hwloc_get_obj_inside_cpuset_by_depth (hwloc_topology_t topology, hwloc_const_cpuset_t set,
224 int depth, unsigned idx)
225{
226 hwloc_obj_t obj = hwloc_get_obj_by_depth (topology, depth, 0);
227 unsigned count = 0;
228 if (!obj)
229 return NULL;
230 while (obj) {
231 if (!hwloc_bitmap_iszero(obj->cpuset) && hwloc_bitmap_isincluded(obj->cpuset, set)) {
232 if (count == idx)
233 return obj;
234 count++;
235 }
236 obj = obj->next_cousin;
237 }
238 return NULL;
239}
240
255static __hwloc_inline hwloc_obj_t
256 hwloc_get_obj_inside_cpuset_by_type (hwloc_topology_t topology, hwloc_const_cpuset_t set,
257 hwloc_obj_type_t type, unsigned idx) __hwloc_attribute_pure;
258static __hwloc_inline hwloc_obj_t
259hwloc_get_obj_inside_cpuset_by_type (hwloc_topology_t topology, hwloc_const_cpuset_t set,
260 hwloc_obj_type_t type, unsigned idx)
261{
262 int depth = hwloc_get_type_depth(topology, type);
263 if (depth == HWLOC_TYPE_DEPTH_UNKNOWN || depth == HWLOC_TYPE_DEPTH_MULTIPLE)
264 return NULL;
265 return hwloc_get_obj_inside_cpuset_by_depth(topology, set, depth, idx);
266}
267
279static __hwloc_inline unsigned
280 hwloc_get_nbobjs_inside_cpuset_by_depth (hwloc_topology_t topology, hwloc_const_cpuset_t set,
281 int depth) __hwloc_attribute_pure;
282static __hwloc_inline unsigned
283hwloc_get_nbobjs_inside_cpuset_by_depth (hwloc_topology_t topology, hwloc_const_cpuset_t set,
284 int depth)
285{
286 hwloc_obj_t obj = hwloc_get_obj_by_depth (topology, depth, 0);
287 unsigned count = 0;
288 if (!obj)
289 return 0;
290 while (obj) {
291 if (!hwloc_bitmap_iszero(obj->cpuset) && hwloc_bitmap_isincluded(obj->cpuset, set))
292 count++;
293 obj = obj->next_cousin;
294 }
295 return count;
296}
297
311static __hwloc_inline int
312 hwloc_get_nbobjs_inside_cpuset_by_type (hwloc_topology_t topology, hwloc_const_cpuset_t set,
313 hwloc_obj_type_t type) __hwloc_attribute_pure;
314static __hwloc_inline int
315hwloc_get_nbobjs_inside_cpuset_by_type (hwloc_topology_t topology, hwloc_const_cpuset_t set,
316 hwloc_obj_type_t type)
317{
318 int depth = hwloc_get_type_depth(topology, type);
319 if (depth == HWLOC_TYPE_DEPTH_UNKNOWN)
320 return 0;
321 if (depth == HWLOC_TYPE_DEPTH_MULTIPLE)
322 return -1; /* FIXME: agregate nbobjs from different levels? */
323 return (int) hwloc_get_nbobjs_inside_cpuset_by_depth(topology, set, depth);
324}
325
342static __hwloc_inline int
343 hwloc_get_obj_index_inside_cpuset (hwloc_topology_t topology __hwloc_attribute_unused, hwloc_const_cpuset_t set,
344 hwloc_obj_t obj) __hwloc_attribute_pure;
345static __hwloc_inline int
346hwloc_get_obj_index_inside_cpuset (hwloc_topology_t topology __hwloc_attribute_unused, hwloc_const_cpuset_t set,
347 hwloc_obj_t obj)
348{
349 int idx = 0;
350 if (!hwloc_bitmap_isincluded(obj->cpuset, set))
351 return -1;
352 /* count how many objects are inside the cpuset on the way from us to the beginning of the level */
353 while ((obj = obj->prev_cousin) != NULL)
354 if (!hwloc_bitmap_iszero(obj->cpuset) && hwloc_bitmap_isincluded(obj->cpuset, set))
355 idx++;
356 return idx;
357}
358
374static __hwloc_inline hwloc_obj_t
375 hwloc_get_child_covering_cpuset (hwloc_topology_t topology __hwloc_attribute_unused, hwloc_const_cpuset_t set,
376 hwloc_obj_t parent) __hwloc_attribute_pure;
377static __hwloc_inline hwloc_obj_t
378hwloc_get_child_covering_cpuset (hwloc_topology_t topology __hwloc_attribute_unused, hwloc_const_cpuset_t set,
379 hwloc_obj_t parent)
380{
381 hwloc_obj_t child;
382 if (hwloc_bitmap_iszero(set))
383 return NULL;
384 child = parent->first_child;
385 while (child) {
386 if (child->cpuset && hwloc_bitmap_isincluded(set, child->cpuset))
387 return child;
388 child = child->next_sibling;
389 }
390 return NULL;
391}
392
398static __hwloc_inline hwloc_obj_t
399 hwloc_get_obj_covering_cpuset (hwloc_topology_t topology, hwloc_const_cpuset_t set) __hwloc_attribute_pure;
400static __hwloc_inline hwloc_obj_t
401hwloc_get_obj_covering_cpuset (hwloc_topology_t topology, hwloc_const_cpuset_t set)
402{
403 struct hwloc_obj *current = hwloc_get_root_obj(topology);
404 if (hwloc_bitmap_iszero(set) || !hwloc_bitmap_isincluded(set, current->cpuset))
405 return NULL;
406 while (1) {
407 hwloc_obj_t child = hwloc_get_child_covering_cpuset(topology, set, current);
408 if (!child)
409 return current;
410 current = child;
411 }
412}
413
427static __hwloc_inline hwloc_obj_t
428hwloc_get_next_obj_covering_cpuset_by_depth(hwloc_topology_t topology, hwloc_const_cpuset_t set,
429 int depth, hwloc_obj_t prev)
430{
431 hwloc_obj_t next = hwloc_get_next_obj_by_depth(topology, depth, prev);
432 if (!next)
433 return NULL;
434 while (next && !hwloc_bitmap_intersects(set, next->cpuset))
435 next = next->next_cousin;
436 return next;
437}
438
455static __hwloc_inline hwloc_obj_t
456hwloc_get_next_obj_covering_cpuset_by_type(hwloc_topology_t topology, hwloc_const_cpuset_t set,
457 hwloc_obj_type_t type, hwloc_obj_t prev)
458{
459 int depth = hwloc_get_type_depth(topology, type);
460 if (depth == HWLOC_TYPE_DEPTH_UNKNOWN || depth == HWLOC_TYPE_DEPTH_MULTIPLE)
461 return NULL;
462 return hwloc_get_next_obj_covering_cpuset_by_depth(topology, set, depth, prev);
463}
464
488static __hwloc_inline hwloc_obj_t
489 hwloc_get_ancestor_obj_by_depth (hwloc_topology_t topology __hwloc_attribute_unused, int depth, hwloc_obj_t obj) __hwloc_attribute_pure;
490static __hwloc_inline hwloc_obj_t
491hwloc_get_ancestor_obj_by_depth (hwloc_topology_t topology __hwloc_attribute_unused, int depth, hwloc_obj_t obj)
492{
493 hwloc_obj_t ancestor = obj;
494 if (obj->depth < depth)
495 return NULL;
496 while (ancestor && ancestor->depth > depth)
497 ancestor = ancestor->parent;
498 return ancestor;
499}
500
514static __hwloc_inline hwloc_obj_t
515 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;
516static __hwloc_inline hwloc_obj_t
517hwloc_get_ancestor_obj_by_type (hwloc_topology_t topology __hwloc_attribute_unused, hwloc_obj_type_t type, hwloc_obj_t obj)
518{
519 hwloc_obj_t ancestor = obj->parent;
520 while (ancestor && ancestor->type != type)
521 ancestor = ancestor->parent;
522 return ancestor;
523}
524
531static __hwloc_inline hwloc_obj_t
532 hwloc_get_common_ancestor_obj (hwloc_topology_t topology __hwloc_attribute_unused, hwloc_obj_t obj1, hwloc_obj_t obj2) __hwloc_attribute_pure;
533static __hwloc_inline hwloc_obj_t
534hwloc_get_common_ancestor_obj (hwloc_topology_t topology __hwloc_attribute_unused, hwloc_obj_t obj1, hwloc_obj_t obj2)
535{
536 /* the loop isn't so easy since intermediate ancestors may have
537 * different depth, causing us to alternate between using obj1->parent
538 * and obj2->parent. Also, even if at some point we find ancestors of
539 * of the same depth, their ancestors may have different depth again.
540 */
541 while (obj1 != obj2) {
542 while (obj1->depth > obj2->depth)
543 obj1 = obj1->parent;
544 while (obj2->depth > obj1->depth)
545 obj2 = obj2->parent;
546 if (obj1 != obj2 && obj1->depth == obj2->depth) {
547 obj1 = obj1->parent;
548 obj2 = obj2->parent;
549 }
550 }
551 return obj1;
552}
553
561static __hwloc_inline int
562 hwloc_obj_is_in_subtree (hwloc_topology_t topology __hwloc_attribute_unused, hwloc_obj_t obj, hwloc_obj_t subtree_root) __hwloc_attribute_pure;
563static __hwloc_inline int
564hwloc_obj_is_in_subtree (hwloc_topology_t topology __hwloc_attribute_unused, hwloc_obj_t obj, hwloc_obj_t subtree_root)
565{
566 return obj->cpuset && subtree_root->cpuset && hwloc_bitmap_isincluded(obj->cpuset, subtree_root->cpuset);
567}
568
579static __hwloc_inline hwloc_obj_t
580hwloc_get_next_child (hwloc_topology_t topology __hwloc_attribute_unused, hwloc_obj_t parent, hwloc_obj_t prev)
581{
582 hwloc_obj_t obj;
583 int state = 0;
584 if (prev) {
585 if (prev->type == HWLOC_OBJ_MISC)
586 state = 3;
587 else if (hwloc_obj_type_is_io(prev->type))
588 state = 2;
589 else if (hwloc_obj_type_is_memory(prev->type))
590 state = 1;
591 obj = prev->next_sibling;
592 } else {
593 obj = parent->first_child;
594 }
595 if (!obj && state == 0) {
596 obj = parent->memory_first_child;
597 state = 1;
598 }
599 if (!obj && state == 1) {
600 obj = parent->io_first_child;
601 state = 2;
602 }
603 if (!obj && state == 2) {
604 obj = parent->misc_first_child;
605 state = 3;
606 }
607 return obj;
608}
609
641static __hwloc_inline int
642hwloc_get_cache_type_depth (hwloc_topology_t topology,
643 unsigned cachelevel, hwloc_obj_cache_type_t cachetype)
644{
645 int depth;
646 int found = HWLOC_TYPE_DEPTH_UNKNOWN;
647 for (depth=0; ; depth++) {
648 hwloc_obj_t obj = hwloc_get_obj_by_depth(topology, depth, 0);
649 if (!obj)
650 break;
651 if (!hwloc_obj_type_is_dcache(obj->type) || obj->attr->cache.depth != cachelevel)
652 /* doesn't match, try next depth */
653 continue;
654 if (cachetype == (hwloc_obj_cache_type_t) -1) {
655 if (found != HWLOC_TYPE_DEPTH_UNKNOWN) {
656 /* second match, return MULTIPLE */
657 return HWLOC_TYPE_DEPTH_MULTIPLE;
658 }
659 /* first match, mark it as found */
660 found = depth;
661 continue;
662 }
663 if (obj->attr->cache.type == cachetype || obj->attr->cache.type == HWLOC_OBJ_CACHE_UNIFIED)
664 /* exact match (either unified is alone, or we match instruction or data), return immediately */
665 return depth;
666 }
667 /* went to the bottom, return what we found */
668 return found;
669}
670
675static __hwloc_inline hwloc_obj_t
676 hwloc_get_cache_covering_cpuset (hwloc_topology_t topology, hwloc_const_cpuset_t set) __hwloc_attribute_pure;
677static __hwloc_inline hwloc_obj_t
678hwloc_get_cache_covering_cpuset (hwloc_topology_t topology, hwloc_const_cpuset_t set)
679{
680 hwloc_obj_t current = hwloc_get_obj_covering_cpuset(topology, set);
681 while (current) {
682 if (hwloc_obj_type_is_dcache(current->type))
683 return current;
684 current = current->parent;
685 }
686 return NULL;
687}
688
694static __hwloc_inline hwloc_obj_t
695 hwloc_get_shared_cache_covering_obj (hwloc_topology_t topology __hwloc_attribute_unused, hwloc_obj_t obj) __hwloc_attribute_pure;
696static __hwloc_inline hwloc_obj_t
697hwloc_get_shared_cache_covering_obj (hwloc_topology_t topology __hwloc_attribute_unused, hwloc_obj_t obj)
698{
699 hwloc_obj_t current = obj->parent;
700 if (!obj->cpuset)
701 return NULL;
702 while (current) {
703 if (!hwloc_bitmap_isequal(current->cpuset, obj->cpuset)
704 && hwloc_obj_type_is_dcache(current->type))
705 return current;
706 current = current->parent;
707 }
708 return NULL;
709}
710
742HWLOC_DECLSPEC int hwloc_bitmap_singlify_per_core(hwloc_topology_t topology, hwloc_bitmap_t cpuset, unsigned which);
743
755static __hwloc_inline hwloc_obj_t
756 hwloc_get_pu_obj_by_os_index(hwloc_topology_t topology, unsigned os_index) __hwloc_attribute_pure;
757static __hwloc_inline hwloc_obj_t
758hwloc_get_pu_obj_by_os_index(hwloc_topology_t topology, unsigned os_index)
759{
760 hwloc_obj_t obj = NULL;
761 while ((obj = hwloc_get_next_obj_by_type(topology, HWLOC_OBJ_PU, obj)) != NULL)
762 if (obj->os_index == os_index)
763 return obj;
764 return NULL;
765}
766
778static __hwloc_inline hwloc_obj_t
779 hwloc_get_numanode_obj_by_os_index(hwloc_topology_t topology, unsigned os_index) __hwloc_attribute_pure;
780static __hwloc_inline hwloc_obj_t
781hwloc_get_numanode_obj_by_os_index(hwloc_topology_t topology, unsigned os_index)
782{
783 hwloc_obj_t obj = NULL;
784 while ((obj = hwloc_get_next_obj_by_type(topology, HWLOC_OBJ_NUMANODE, obj)) != NULL)
785 if (obj->os_index == os_index)
786 return obj;
787 return NULL;
788}
789
801/* TODO: rather provide an iterator? Provide a way to know how much should be allocated? By returning the total number of objects instead? */
802HWLOC_DECLSPEC unsigned hwloc_get_closest_objs (hwloc_topology_t topology, hwloc_obj_t src, hwloc_obj_t * __hwloc_restrict objs, unsigned max);
803
818static __hwloc_inline hwloc_obj_t
819 hwloc_get_obj_below_by_type (hwloc_topology_t topology,
820 hwloc_obj_type_t type1, unsigned idx1,
821 hwloc_obj_type_t type2, unsigned idx2) __hwloc_attribute_pure;
822static __hwloc_inline hwloc_obj_t
823hwloc_get_obj_below_by_type (hwloc_topology_t topology,
824 hwloc_obj_type_t type1, unsigned idx1,
825 hwloc_obj_type_t type2, unsigned idx2)
826{
827 hwloc_obj_t obj;
828 obj = hwloc_get_obj_by_type (topology, type1, idx1);
829 if (!obj)
830 return NULL;
831 return hwloc_get_obj_inside_cpuset_by_type(topology, obj->cpuset, type2, idx2);
832}
833
854static __hwloc_inline hwloc_obj_t
855 hwloc_get_obj_below_array_by_type (hwloc_topology_t topology, int nr, hwloc_obj_type_t *typev, unsigned *idxv) __hwloc_attribute_pure;
856static __hwloc_inline hwloc_obj_t
857hwloc_get_obj_below_array_by_type (hwloc_topology_t topology, int nr, hwloc_obj_type_t *typev, unsigned *idxv)
858{
859 hwloc_obj_t obj = hwloc_get_root_obj(topology);
860 int i;
861 for(i=0; i<nr; i++) {
862 if (!obj)
863 return NULL;
864 obj = hwloc_get_obj_inside_cpuset_by_type(topology, obj->cpuset, typev[i], idxv[i]);
865 }
866 return obj;
867}
868
907HWLOC_DECLSPEC hwloc_obj_t
908hwloc_get_obj_with_same_locality(hwloc_topology_t topology, hwloc_obj_t src,
909 hwloc_obj_type_t type, const char *subtype, const char *nameprefix,
910 unsigned long flags);
911
922 enum hwloc_distrib_flags_e {
926 HWLOC_DISTRIB_FLAG_REVERSE = (1UL<<0)
927};
928
959static __hwloc_inline int
960hwloc_distrib(hwloc_topology_t topology,
961 hwloc_obj_t *roots, unsigned n_roots,
962 hwloc_cpuset_t *set,
963 unsigned n,
964 int until, unsigned long flags)
965{
966 unsigned i;
967 unsigned tot_weight;
968 unsigned given, givenweight;
969 hwloc_cpuset_t *cpusetp = set;
970
971 if (!n || (flags & ~HWLOC_DISTRIB_FLAG_REVERSE)) {
972 errno = EINVAL;
973 return -1;
974 }
975
976 tot_weight = 0;
977 for (i = 0; i < n_roots; i++)
978 tot_weight += (unsigned) hwloc_bitmap_weight(roots[i]->cpuset);
979
980 for (i = 0, given = 0, givenweight = 0; i < n_roots; i++) {
981 unsigned chunk, weight;
982 hwloc_obj_t root = roots[flags & HWLOC_DISTRIB_FLAG_REVERSE ? n_roots-1-i : i];
983 hwloc_cpuset_t cpuset = root->cpuset;
984 while (!hwloc_obj_type_is_normal(root->type))
985 /* If memory/io/misc, walk up to normal parent */
986 root = root->parent;
987 weight = (unsigned) hwloc_bitmap_weight(cpuset);
988 if (!weight)
989 continue;
990 /* Give to root a chunk proportional to its weight.
991 * If previous chunks got rounded-up, we may get a bit less. */
992 chunk = (( (givenweight+weight) * n + tot_weight-1) / tot_weight)
993 - (( givenweight * n + tot_weight-1) / tot_weight);
994 if (!root->arity || chunk <= 1 || root->depth >= until) {
995 /* We can't split any more, put everything there. */
996 if (chunk) {
997 /* Fill cpusets with ours */
998 unsigned j;
999 for (j=0; j < chunk; j++)
1000 cpusetp[j] = hwloc_bitmap_dup(cpuset);
1001 } else {
1002 /* We got no chunk, just merge our cpuset to a previous one
1003 * (the first chunk cannot be empty)
1004 * so that this root doesn't get ignored.
1005 */
1006 assert(given);
1007 hwloc_bitmap_or(cpusetp[-1], cpusetp[-1], cpuset);
1008 }
1009 } else {
1010 /* Still more to distribute, recurse into children */
1011 hwloc_distrib(topology, root->children, root->arity, cpusetp, chunk, until, flags);
1012 }
1013 cpusetp += chunk;
1014 given += chunk;
1015 givenweight += weight;
1016 }
1017
1018 return 0;
1019}
1020
1040HWLOC_DECLSPEC hwloc_const_cpuset_t
1041hwloc_topology_get_complete_cpuset(hwloc_topology_t topology) __hwloc_attribute_pure;
1042
1056HWLOC_DECLSPEC hwloc_const_cpuset_t
1057hwloc_topology_get_topology_cpuset(hwloc_topology_t topology) __hwloc_attribute_pure;
1058
1077HWLOC_DECLSPEC hwloc_const_cpuset_t
1078hwloc_topology_get_allowed_cpuset(hwloc_topology_t topology) __hwloc_attribute_pure;
1079
1091HWLOC_DECLSPEC hwloc_const_nodeset_t
1092hwloc_topology_get_complete_nodeset(hwloc_topology_t topology) __hwloc_attribute_pure;
1093
1107HWLOC_DECLSPEC hwloc_const_nodeset_t
1108hwloc_topology_get_topology_nodeset(hwloc_topology_t topology) __hwloc_attribute_pure;
1109
1128HWLOC_DECLSPEC hwloc_const_nodeset_t
1129hwloc_topology_get_allowed_nodeset(hwloc_topology_t topology) __hwloc_attribute_pure;
1130
1154static __hwloc_inline int
1155hwloc_cpuset_to_nodeset(hwloc_topology_t topology, hwloc_const_cpuset_t _cpuset, hwloc_nodeset_t nodeset)
1156{
1157 int depth = hwloc_get_type_depth(topology, HWLOC_OBJ_NUMANODE);
1158 hwloc_obj_t obj = NULL;
1159 assert(depth != HWLOC_TYPE_DEPTH_UNKNOWN);
1160 hwloc_bitmap_zero(nodeset);
1161 while ((obj = hwloc_get_next_obj_covering_cpuset_by_depth(topology, _cpuset, depth, obj)) != NULL)
1162 if (hwloc_bitmap_set(nodeset, obj->os_index) < 0)
1163 return -1;
1164 return 0;
1165}
1166
1181static __hwloc_inline int
1182hwloc_cpuset_from_nodeset(hwloc_topology_t topology, hwloc_cpuset_t _cpuset, hwloc_const_nodeset_t nodeset)
1183{
1184 int depth = hwloc_get_type_depth(topology, HWLOC_OBJ_NUMANODE);
1185 hwloc_obj_t obj = NULL;
1186 assert(depth != HWLOC_TYPE_DEPTH_UNKNOWN);
1187 hwloc_bitmap_zero(_cpuset);
1188 while ((obj = hwloc_get_next_obj_by_depth(topology, depth, obj)) != NULL) {
1189 if (hwloc_bitmap_isset(nodeset, obj->os_index))
1190 /* no need to check obj->cpuset because objects in levels always have a cpuset */
1191 if (hwloc_bitmap_or(_cpuset, _cpuset, obj->cpuset) < 0)
1192 return -1;
1193 }
1194 return 0;
1195}
1196
1220static __hwloc_inline hwloc_obj_t
1221hwloc_get_non_io_ancestor_obj(hwloc_topology_t topology __hwloc_attribute_unused,
1222 hwloc_obj_t ioobj)
1223{
1224 hwloc_obj_t obj = ioobj;
1225 while (obj && !obj->cpuset) {
1226 obj = obj->parent;
1227 }
1228 return obj;
1229}
1230
1237static __hwloc_inline hwloc_obj_t
1238hwloc_get_next_pcidev(hwloc_topology_t topology, hwloc_obj_t prev)
1239{
1240 return hwloc_get_next_obj_by_type(topology, HWLOC_OBJ_PCI_DEVICE, prev);
1241}
1242
1248static __hwloc_inline hwloc_obj_t
1249hwloc_get_pcidev_by_busid(hwloc_topology_t topology,
1250 unsigned domain, unsigned bus, unsigned dev, unsigned func)
1251{
1252 hwloc_obj_t obj = NULL;
1253 while ((obj = hwloc_get_next_pcidev(topology, obj)) != NULL) {
1254 if (obj->attr->pcidev.domain == domain
1255 && obj->attr->pcidev.bus == bus
1256 && obj->attr->pcidev.dev == dev
1257 && obj->attr->pcidev.func == func)
1258 return obj;
1259 }
1260 return NULL;
1261}
1262
1268static __hwloc_inline hwloc_obj_t
1269hwloc_get_pcidev_by_busidstring(hwloc_topology_t topology, const char *busid)
1270{
1271 unsigned domain = 0; /* default */
1272 unsigned bus, dev, func;
1273
1274 if (sscanf(busid, "%x:%x.%x", &bus, &dev, &func) != 3
1275 && sscanf(busid, "%x:%x:%x.%x", &domain, &bus, &dev, &func) != 4) {
1276 errno = EINVAL;
1277 return NULL;
1278 }
1279
1280 return hwloc_get_pcidev_by_busid(topology, domain, bus, dev, func);
1281}
1282
1289static __hwloc_inline hwloc_obj_t
1290hwloc_get_next_osdev(hwloc_topology_t topology, hwloc_obj_t prev)
1291{
1292 return hwloc_get_next_obj_by_type(topology, HWLOC_OBJ_OS_DEVICE, prev);
1293}
1294
1301static __hwloc_inline hwloc_obj_t
1302hwloc_get_next_bridge(hwloc_topology_t topology, hwloc_obj_t prev)
1303{
1304 return hwloc_get_next_obj_by_type(topology, HWLOC_OBJ_BRIDGE, prev);
1305}
1306
1307/* \brief Checks whether a given bridge covers a given PCI bus.
1308 *
1309 * \return 1 if it covers, 0 if not.
1310 */
1311static __hwloc_inline int
1312hwloc_bridge_covers_pcibus(hwloc_obj_t bridge,
1313 unsigned domain, unsigned bus)
1314{
1315 return bridge->type == HWLOC_OBJ_BRIDGE
1316 && bridge->attr->bridge.downstream_type == HWLOC_OBJ_BRIDGE_PCI
1317 && bridge->attr->bridge.downstream.pci.domain == domain
1318 && bridge->attr->bridge.downstream.pci.secondary_bus <= bus
1319 && bridge->attr->bridge.downstream.pci.subordinate_bus >= bus;
1320}
1321
1326#ifdef __cplusplus
1327} /* extern "C" */
1328#endif
1329
1330
1331#endif /* HWLOC_HELPER_H */
hwloc_const_cpuset_t
hwloc_const_bitmap_t hwloc_const_cpuset_t
A non-modifiable hwloc_cpuset_t.
Definition hwloc.h:163
hwloc_const_nodeset_t
hwloc_const_bitmap_t hwloc_const_nodeset_t
A non-modifiable hwloc_nodeset_t.
Definition hwloc.h:181
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:178
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:161
hwloc_obj_cache_type_t
enum hwloc_obj_cache_type_e hwloc_obj_cache_type_t
Cache type.
hwloc_obj_type_t
hwloc_obj_type_t
Type of topology object.
Definition hwloc.h:197
HWLOC_OBJ_BRIDGE_PCI
@ HWLOC_OBJ_BRIDGE_PCI
PCI-side of a bridge.
Definition hwloc.h:367
HWLOC_OBJ_CACHE_UNIFIED
@ HWLOC_OBJ_CACHE_UNIFIED
Unified cache.
Definition hwloc.h:359
HWLOC_OBJ_MISC
@ HWLOC_OBJ_MISC
Miscellaneous objects (filtered out by default). Objects without particular meaning,...
Definition hwloc.h:316
HWLOC_OBJ_OS_DEVICE
@ HWLOC_OBJ_OS_DEVICE
Operating system device (filtered out by default).
Definition hwloc.h:305
HWLOC_OBJ_PCI_DEVICE
@ HWLOC_OBJ_PCI_DEVICE
PCI device (filtered out by default).
Definition hwloc.h:295
HWLOC_OBJ_BRIDGE
@ HWLOC_OBJ_BRIDGE
Bridge (filtered out by default). Any bridge (or PCI switch) that connects the host or an I/O bus,...
Definition hwloc.h:283
HWLOC_OBJ_NUMANODE
@ HWLOC_OBJ_NUMANODE
NUMA node. An object that contains memory that is directly and byte-accessible to the host processors...
Definition hwloc.h:257
HWLOC_OBJ_PU
@ HWLOC_OBJ_PU
Processing Unit, or (Logical) Processor. An execution unit (may share a core with some other logical ...
Definition hwloc.h:222
hwloc_topology_t
struct hwloc_topology * hwloc_topology_t
Topology context.
Definition hwloc.h:742
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_get_obj_by_depth
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.
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_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_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_get_next_obj_by_depth
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.
HWLOC_TYPE_DEPTH_UNKNOWN
@ HWLOC_TYPE_DEPTH_UNKNOWN
No object of given type exists in the topology.
Definition hwloc.h:879
HWLOC_TYPE_DEPTH_MULTIPLE
@ HWLOC_TYPE_DEPTH_MULTIPLE
Objects of given type exist at different depth in the topology (only for Groups).
Definition hwloc.h:880
hwloc_obj_type_is_memory
int hwloc_obj_type_is_memory(hwloc_obj_type_t type)
Check whether an object type is Memory.
hwloc_obj_type_is_cache
int hwloc_obj_type_is_cache(hwloc_obj_type_t type)
Check whether an object type is a CPU Cache (Data, Unified or Instruction).
hwloc_obj_type_is_dcache
int hwloc_obj_type_is_dcache(hwloc_obj_type_t type)
Check whether an object type is a CPU Data or Unified Cache.
hwloc_obj_type_is_normal
int hwloc_obj_type_is_normal(hwloc_obj_type_t type)
Check whether an object type is Normal.
hwloc_obj_type_is_icache
int hwloc_obj_type_is_icache(hwloc_obj_type_t type)
Check whether an object type is a CPU Instruction Cache,.
hwloc_obj_type_is_io
int hwloc_obj_type_is_io(hwloc_obj_type_t type)
Check whether an object type is I/O.
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:315
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:259
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_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:346
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:123
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, int depth, hwloc_obj_t prev)
Return the next object at depth depth included in CPU set set.
Definition helper.h:170
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, int depth)
Return the number of objects at depth depth included in CPU set set.
Definition helper.h:283
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, int depth, unsigned idx)
Return the (logically) idx -th object at depth depth included in CPU set set.
Definition helper.h:223
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:200
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:378
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:401
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:456
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, int depth, hwloc_obj_t prev)
Iterate through same-depth objects covering at least CPU set set.
Definition helper.h:428
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:580
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:564
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:517
hwloc_get_ancestor_obj_by_depth
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
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:534
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 data (or unified) cache shared between an object and somebody else.
Definition helper.h:697
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 data (or unified) cache covering a cpuset set.
Definition helper.h:678
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 level and type.
Definition helper.h:642
hwloc_bitmap_singlify_per_core
int hwloc_bitmap_singlify_per_core(hwloc_topology_t topology, hwloc_bitmap_t cpuset, unsigned which)
Remove simultaneous multithreading PUs from a CPU set.
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_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:758
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:823
hwloc_get_obj_with_same_locality
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.
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:781
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:857
hwloc_distrib
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:960
hwloc_distrib_flags_e
hwloc_distrib_flags_e
Flags to be given to hwloc_distrib().
Definition helper.h:922
HWLOC_DISTRIB_FLAG_REVERSE
@ HWLOC_DISTRIB_FLAG_REVERSE
Distrib in reverse order, starting from the last objects.
Definition helper.h:926
hwloc_topology_get_allowed_nodeset
hwloc_const_nodeset_t hwloc_topology_get_allowed_nodeset(hwloc_topology_t topology)
Get allowed node set.
hwloc_topology_get_topology_nodeset
hwloc_const_nodeset_t hwloc_topology_get_topology_nodeset(hwloc_topology_t topology)
Get topology node set.
hwloc_topology_get_allowed_cpuset
hwloc_const_cpuset_t hwloc_topology_get_allowed_cpuset(hwloc_topology_t topology)
Get allowed CPU set.
hwloc_topology_get_complete_nodeset
hwloc_const_nodeset_t hwloc_topology_get_complete_nodeset(hwloc_topology_t topology)
Get complete node set.
hwloc_topology_get_topology_cpuset
hwloc_const_cpuset_t hwloc_topology_get_topology_cpuset(hwloc_topology_t topology)
Get topology CPU set.
hwloc_topology_get_complete_cpuset
hwloc_const_cpuset_t hwloc_topology_get_complete_cpuset(hwloc_topology_t topology)
Get complete CPU set.
hwloc_cpuset_to_nodeset
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:1155
hwloc_cpuset_from_nodeset
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:1182
hwloc_bridge_covers_pcibus
static int hwloc_bridge_covers_pcibus(hwloc_obj_t bridge, unsigned domain, unsigned bus)
Definition helper.h:1312
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:1269
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:1238
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:1290
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:1302
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:1249
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:1221
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_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_bitmap_set
int hwloc_bitmap_set(hwloc_bitmap_t bitmap, unsigned id)
Add index id in bitmap bitmap.
hwloc_bitmap_isset
int hwloc_bitmap_isset(hwloc_const_bitmap_t bitmap, unsigned id)
Test whether index id is part of bitmap bitmap.
hwloc_bitmap_or
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.
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_bitmap_iszero
int hwloc_bitmap_iszero(hwloc_const_bitmap_t bitmap)
Test whether bitmap bitmap is empty.
hwloc_bitmap_t
struct hwloc_bitmap_s * hwloc_bitmap_t
Set of bits represented as an opaque pointer to an internal bitmap.
Definition bitmap.h:69
hwloc_bitmap_zero
void hwloc_bitmap_zero(hwloc_bitmap_t bitmap)
Empty the bitmap bitmap.
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_bitmap_intersects
int hwloc_bitmap_intersects(hwloc_const_bitmap_t bitmap1, hwloc_const_bitmap_t bitmap2)
Test whether bitmaps bitmap1 and bitmap2 intersects.
hwloc_obj
Structure of a topology object.
Definition hwloc.h:431
hwloc_obj::children
struct hwloc_obj ** children
Normal children, children[0 .. arity -1].
Definition hwloc.h:491
hwloc_obj::nodeset
hwloc_nodeset_t nodeset
NUMA nodes covered by this object or containing this object.
Definition hwloc.h:575
hwloc_obj::depth
int depth
Vertical index in the hierarchy.
Definition hwloc.h:454
hwloc_obj::misc_first_child
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_obj::subtype
char * subtype
Subtype string to better describe the type field.
Definition hwloc.h:434
hwloc_obj::os_index
unsigned os_index
OS-provided physical index number. It is not guaranteed unique across the entire machine,...
Definition hwloc.h:436
hwloc_obj::cpuset
hwloc_cpuset_t cpuset
CPUs covered by this object.
Definition hwloc.h:547
hwloc_obj::next_sibling
struct hwloc_obj * next_sibling
Next object below the same parent (inside the same list of children).
Definition hwloc.h:483
hwloc_obj::next_cousin
struct hwloc_obj * next_cousin
Next object of same type and depth.
Definition hwloc.h:477
hwloc_obj::io_first_child
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
hwloc_obj::arity
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_obj::memory_first_child
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
hwloc_obj::prev_cousin
struct hwloc_obj * prev_cousin
Previous object of same type and depth.
Definition hwloc.h:478
hwloc_obj::type
hwloc_obj_type_t type
Type of object.
Definition hwloc.h:433
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:450
hwloc_obj::parent
struct hwloc_obj * parent
Parent, NULL if root (Machine object)
Definition hwloc.h:481
hwloc_obj::first_child
struct hwloc_obj * first_child
First normal child.
Definition hwloc.h:492
hwloc_obj_attr_u::pcidev
struct hwloc_obj_attr_u::hwloc_pcidev_attr_s pcidev
hwloc_obj_attr_u::bridge
struct hwloc_obj_attr_u::hwloc_bridge_attr_s bridge
hwloc_obj_attr_u::cache
struct hwloc_obj_attr_u::hwloc_cache_attr_s cache
hwloc_obj_attr_u::hwloc_cache_attr_s::depth
unsigned depth
Depth of cache (e.g., L1, L2, ...etc.)
Definition hwloc.h:653
hwloc_obj_attr_u::hwloc_cache_attr_s::type
hwloc_obj_cache_type_t type
Cache type.
Definition hwloc.h:657
hwloc_obj_attr_u::hwloc_pcidev_attr_s::dev
unsigned char dev
Device number (zz in the PCI BDF notation xxxx:yy:zz.t).
Definition hwloc.h:677
hwloc_obj_attr_u::hwloc_pcidev_attr_s::func
unsigned char func
Function number (t in the PCI BDF notation xxxx:yy:zz.t).
Definition hwloc.h:678
hwloc_obj_attr_u::hwloc_pcidev_attr_s::domain
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_obj_attr_u::hwloc_pcidev_attr_s::bus
unsigned char bus
Bus number (yy in the PCI BDF notation xxxx:yy:zz.t).
Definition hwloc.h:676
hwloc_obj_attr_u::hwloc_bridge_attr_s::pci
struct hwloc_pcidev_attr_s pci
PCI attribute of the upstream part as a PCI device.
Definition hwloc.h:695
hwloc_obj_attr_u::hwloc_bridge_attr_s::downstream
union hwloc_obj_attr_u::hwloc_bridge_attr_s::@3 downstream
hwloc_obj_attr_u::hwloc_bridge_attr_s::downstream_type
hwloc_obj_bridge_type_t downstream_type
Downstream Bridge type.
Definition hwloc.h:711