# Basic Traversal Helpers

## Functions
static __hwloc_inline hwloc_obj_t __hwloc_attribute_pure | hwloc_get_root_obj (hwloc_topology_t topology)
| Returns the top-object of the topology-tree.
static __hwloc_inline hwloc_obj_t __hwloc_attribute_pure | hwloc_get_ancestor_obj_by_depth (hwloc_topology_t topology __hwloc_attribute_unused, unsigned depth, hwloc_obj_t obj)
| Returns the ancestor object of `obj` at depth `depth`.
static __hwloc_inline hwloc_obj_t __hwloc_attribute_pure | hwloc_get_ancestor_obj_by_type (hwloc_topology_t topology __hwloc_attribute_unused, hwloc_obj_type_t type, hwloc_obj_t obj)
| Returns the ancestor object of `obj` with type `type`.
static __hwloc_inline 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`.
static __hwloc_inline 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 __hwloc_inline hwloc_obj_t __hwloc_attribute_pure | 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`.
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)
| Return the next child.
static __hwloc_inline hwloc_obj_t __hwloc_attribute_pure | hwloc_get_common_ancestor_obj (hwloc_topology_t topology __hwloc_attribute_unused, hwloc_obj_t obj1, hwloc_obj_t obj2)
| Returns the common parent object to objects lvl1 and lvl2.
static __hwloc_inline int __hwloc_attribute_pure | hwloc_obj_is_in_subtree (hwloc_topology_t topology __hwloc_attribute_unused, hwloc_obj_t obj, hwloc_obj_t subtree_root)
| Returns true if _obj_ is inside the subtree beginning with `subtree_root`.

## Function Documentation

static __hwloc_inline hwloc_obj_t __hwloc_attribute_pure hwloc_get_ancestor_obj_by_depth | ( | hwloc_topology_t topology | __hwloc_attribute_unused,
|  | unsigned | depth,
|  | hwloc_obj_t | obj |
| ) |  |  | `[static]`

Returns the ancestor object of `obj` at depth `depth`.

static __hwloc_inline hwloc_obj_t __hwloc_attribute_pure hwloc_get_ancestor_obj_by_type | ( | hwloc_topology_t topology | __hwloc_attribute_unused,
|  | hwloc_obj_type_t | type,
|  | hwloc_obj_t | obj |
| ) |  |  | `[static]`

Returns the ancestor object of `obj` with type `type`.

static __hwloc_inline hwloc_obj_t __hwloc_attribute_pure hwloc_get_common_ancestor_obj | ( | hwloc_topology_t topology | __hwloc_attribute_unused,
|  | hwloc_obj_t | obj1,
|  | hwloc_obj_t | obj2 |
| ) |  |  | `[static]`

Returns the common parent object to objects lvl1 and lvl2.

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 |
| ) |  |  | `[static]`

Return the next child.

If `prev` is `NULL`, return the first child.

static __hwloc_inline hwloc_obj_t hwloc_get_next_obj_by_depth | ( | hwloc_topology_t | topology,
|  | unsigned | depth,
|  | hwloc_obj_t | prev |
| ) |  |  | `[static]`

Returns the next object at depth `depth`.

If `prev` is `NULL`, return the first object at depth `depth`.

static __hwloc_inline hwloc_obj_t hwloc_get_next_obj_by_type | ( | hwloc_topology_t | topology,
|  | hwloc_obj_type_t | type,
|  | hwloc_obj_t | prev |
| ) |  |  | `[static]`

Returns the next object of type `type`.

If `prev` is `NULL`, return the first object at type `type`. If there are multiple or no depth for given type, return `NULL` and let the caller fallback to hwloc_get_next_obj_by_depth().

static __hwloc_inline hwloc_obj_t __hwloc_attribute_pure hwloc_get_pu_obj_by_os_index | ( | hwloc_topology_t | topology,
|  | unsigned | os_index |
| ) |  |  | `[static]`

Returns the object of type HWLOC_OBJ_PU with `os_index`.

Note:
  The `os_index` field of object should most of the times only be used for pretty-printing purpose. Type HWLOC_OBJ_PU is the only case where `os_index` could actually be useful, when manually binding to processors. However, using CPU sets to hide this complexity should often be preferred.

static __hwloc_inline hwloc_obj_t __hwloc_attribute_pure hwloc_get_root_obj | ( | hwloc_topology_t | topology | ) | `[static]`

Returns the top-object of the topology-tree.

Its type is typically HWLOC_OBJ_MACHINE but it could be different for complex topologies. This function replaces the old deprecated hwloc_get_system_obj().

static __hwloc_inline int __hwloc_attribute_pure hwloc_obj_is_in_subtree | ( | hwloc_topology_t topology | __hwloc_attribute_unused,
|  | hwloc_obj_t | obj,
|  | hwloc_obj_t | subtree_root |
| ) |  |  | `[static]`

Returns true if _obj_ is inside the subtree beginning with `subtree_root`.