---
name: "hwloc_get_whole_distance_matrix_by_type"
section: "3"
platform: "linux"
package: "libhwloc-doc"
version: "1.11.12-3"
release: "Debian 10 (Buster)"
platforms: ["linux"]
url: "https://new.carta.tech/hwlocality_distances"
---

# hwloc\_get\_whole\_distance\_matrix\_by\_type(3)

Part of [hwlocality\_distances(3)](/hwlocality_distances/3.md).

## NAME

hwlocality\_distances

## SYNOPSIS

### Functions

static const struct **hwloc\_distances\_s** \* **hwloc\_get\_whole\_distance\_matrix\_by\_depth** (**hwloc\_topology\_t** topology, unsigned depth)\
 static const struct **hwloc\_distances\_s** \* **hwloc\_get\_whole\_distance\_matrix\_by\_type** (**hwloc\_topology\_t** topology, **hwloc\_obj\_type\_t** type)\
 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)\
 static int **hwloc\_get\_latency** (**hwloc\_topology\_t** topology, **hwloc\_obj\_t** obj1, **hwloc\_obj\_t** obj2, float \*latency, float \*reverse\_latency)\

## Detailed Description

## Function Documentation

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

Get distances for the given depth and covering some objects. Return a distance matrix that describes depth `depth` and covers at least object `obj` and all its children.

When looking for the distance between some objects, a common ancestor should be passed in `obj`.

`firstp` is set to logical index of the first object described by the matrix.

The returned structure belongs to the hwloc library. The caller should not modify or free it.

### static int hwloc\_get\_latency (hwloc\_topology\_t topology, hwloc\_obj\_t obj1, hwloc\_obj\_t obj2, float \* latency, float \* reverse\_latency)` [inline]`, ` [static]`

Get the latency in both directions between two objects. Look at ancestor objects from the bottom to the top until one of them contains a distance matrix that matches the objects exactly.

`latency` gets the value from object `obj1` to `obj2`, while `reverse_latency` gets the reverse-direction value, which may be different on some architectures.

**Returns:**

\-1 if no ancestor contains a matching latency matrix.

### static const struct hwloc\_distances\_s\* hwloc\_get\_whole\_distance\_matrix\_by\_depth (hwloc\_topology\_t topology, unsigned depth)` [static]`

Get the distances between all objects at the given depth.

**Returns:**

a distances structure containing a matrix with all distances between all objects at the given depth.

Slot i+nbobjs\*j contains the distance from the object of logical index i the object of logical index j.

**Note:**

This function only returns matrices covering the whole topology, without any unknown distance value. Those matrices are available in top-level object of the hierarchy. Matrices of lower objects are not reported here since they cover only part of the machine.

The returned structure belongs to the hwloc library. The caller should not modify or free it.

**Returns:**

`NULL` if no such distance matrix exists.

### static const struct hwloc\_distances\_s\* hwloc\_get\_whole\_distance\_matrix\_by\_type (hwloc\_topology\_t topology, hwloc\_obj\_type\_t type)` [static]`

Get the distances between all objects of a given type.

**Returns:**

a distances structure containing a matrix with all distances between all objects of the given type.

Slot i+nbobjs\*j contains the distance from the object of logical index i the object of logical index j.

**Note:**

This function only returns matrices covering the whole topology, without any unknown distance value. Those matrices are available in top-level object of the hierarchy. Matrices of lower objects are not reported here since they cover only part of the machine.

The returned structure belongs to the hwloc library. The caller should not modify or free it.

**Returns:**

`NULL` if no such distance matrix exists.

## Author

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