---
name: "hwlocality_helper_traversal"
section: "3"
platform: "linux"
package: "libhwloc-doc"
version: "1.4.1-4"
release: "Debian 7 (Wheezy)"
platforms: ["linux"]
url: "https://new.carta.tech/hwlocality_helper_traversal"
---

# hwlocality\_helper\_traversal(3)

## NAME

Advanced Traversal Helpers -

### Functions

 unsigned **hwloc\_get\_closest\_objs** (**hwloc\_topology\_t** topology, **hwloc\_obj\_t** src, **hwloc\_obj\_t** \*restrict objs, unsigned max)\
 static 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) \
 static inline **hwloc\_obj\_t** **hwloc\_get\_obj\_below\_array\_by\_type** (**hwloc\_topology\_t** topology, int nr, **hwloc\_obj\_type\_t** \*typev, unsigned \*idxv) \

## Detailed Description

Be sure to see the figure in **Terms and Definitions** that shows a complete topology tree, including depths, child/sibling/cousin relationships, and an example of an asymmetric topology where one socket has fewer caches than its peers.

## Function Documentation

### unsigned hwloc\_get\_closest\_objs (hwloc\_topology\_ttopology, hwloc\_obj\_tsrc, hwloc\_obj\_t \*restrictobjs, unsignedmax)

Do a depth-first traversal of the topology to find and sort. all objects that are at the same depth than `src`. Report in `objs` up to `max` physically closest ones to `src`.

**Returns:**

the number of objects returned in `objs`.

0 if `src` is an I/O object.

**Note:**

This function requires the `src` object to have a CPU set.

### static inline hwloc\_obj\_t hwloc\_get\_obj\_below\_array\_by\_type (hwloc\_topology\_ttopology, intnr, hwloc\_obj\_type\_t \*typev, unsigned \*idxv)` [static]`

Find an object below a chain of objects specified by types and indexes. This is a generalized version of **hwloc\_get\_obj\_below\_by\_type()**.

Arrays `typev` and `idxv` must contain `nr` types and indexes.

Start from the top system object and walk the arrays `typev` and `idxv`. For each type and logical index couple in the arrays, look under the previously found object to find the index-th object of the given type. Indexes are specified within the parent, not withing the entire system.

For instance, if nr is 3, typev contains NODE, SOCKET and CORE, and idxv contains 0, 1 and 2, return the third core object below the second socket below the first NUMA node.

**Note:**

This function requires all these objects and the root object to have a CPU set.

### static inline hwloc\_obj\_t hwloc\_get\_obj\_below\_by\_type (hwloc\_topology\_ttopology, hwloc\_obj\_type\_ttype1, unsignedidx1, hwloc\_obj\_type\_ttype2, unsignedidx2)` [static]`

Find an object below another object, both specified by types and indexes. Start from the top system object and find object of type `type1` and logical index `idx1`. Then look below this object and find another object of type `type2` and logical index `idx2`. Indexes are specified within the parent, not withing the entire system.

For instance, if type1 is SOCKET, idx1 is 2, type2 is CORE and idx2 is 3, return the fourth core object below the third socket.

**Note:**

This function requires these objects to have a CPU set.

## Author

Generated automatically by Doxygen for Hardware Locality (hwloc) from the source code.
