---
name: "hwloc_cudart_get_device_osdev_by_index"
section: "3"
platform: "linux"
package: "hwloc"
version: "2.15.0-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/hwlocality_cudart"
---

# hwloc\_cudart\_get\_device\_osdev\_by\_index(3)

Interoperability with the CUDA Runtime API

Part of [hwlocality\_cudart(3)](/hwlocality_cudart/3.md).

## NAME

hwlocality\_cudart - Interoperability with the CUDA Runtime API

## SYNOPSIS

### Functions

int **hwloc\_cudart\_get\_device\_pci\_ids** (**hwloc\_topology\_t** topology, int idx, int \*domain, int \*bus, int \*dev)\
 int **hwloc\_cudart\_get\_device\_cpuset** (**hwloc\_topology\_t** topology, int idx, **hwloc\_cpuset\_t** set)\
 **hwloc\_obj\_t** **hwloc\_cudart\_get\_device\_pcidev** (**hwloc\_topology\_t** topology, int idx)\
 **hwloc\_obj\_t** **hwloc\_cudart\_get\_device\_osdev\_by\_index** (**hwloc\_topology\_t** topology, unsigned idx)\

## Detailed Description

This interface offers ways to retrieve topology information about CUDA devices when using the CUDA Runtime API.

## Function Documentation

### int hwloc\_cudart\_get\_device\_cpuset (hwloc\_topology\_t topology, int idx, hwloc\_cpuset\_t set) \[inline\]

Get the CPU set of processors that are physically close to device idx. Store in set the CPU-set describing the locality of the CUDA device whose index is idx.

Topology topology and device idx must match the local machine. I/O devices detection and the CUDA component are not needed in the topology.

The function only returns the locality of the device. If more information about the device is needed, OS objects should be used instead, see **hwloc\_cudart\_get\_device\_osdev\_by\_index()**.

This function is currently only implemented in a meaningful way for Linux; other systems will simply get the cpuset of the entire topology.

**Returns**

0 on success.

\-1 on error, for instance if device information could not be found.

### hwloc\_obj\_t hwloc\_cudart\_get\_device\_osdev\_by\_index (hwloc\_topology\_t topology, unsigned idx) \[inline\]

Get the hwloc OS device object corresponding to the CUDA device whose index is idx.

**Returns**

The hwloc OS device object describing the CUDA device whose index is idx.

NULL if none could be found.

The topology topology does not necessarily have to match the current machine. For instance the topology may be an XML import of a remote host. I/O devices detection and the CUDA component must be enabled in the topology. If not, the locality of the object may still be found using **hwloc\_cudart\_get\_device\_cpuset()**.

**Note**

The corresponding PCI device object can be obtained by looking at the OS device parent object (unless PCI devices are filtered out).

This function is identical to **hwloc\_cuda\_get\_device\_osdev\_by\_index()**.

### int hwloc\_cudart\_get\_device\_pci\_ids (hwloc\_topology\_t topology, int idx, int \* domain, int \* bus, int \* dev) \[inline\]

Return the domain, bus and device IDs of the CUDA device whose index is idx. Device index idx must match the local machine.

**Returns**

0 on success.

\-1 on error, for instance if device information could not be found.

### hwloc\_obj\_t hwloc\_cudart\_get\_device\_pcidev (hwloc\_topology\_t topology, int idx) \[inline\]

Get the hwloc PCI device object corresponding to the CUDA device whose index is idx.

**Returns**

The hwloc PCI device object describing the CUDA device whose index is idx.

NULL if none could be found.

Topology topology and device idx must match the local machine. I/O devices detection must be enabled in topology topology. The CUDA component is not needed in the topology.

## Author

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