Device Index Extension

Device Index Extension#

Introduced in Level Zero version 1.20

API#

Device Index Overview#

The Device Index extension provides the ability to query the device index (GPU ID), an integer identifier for a Sysman device handle.

Applications can retrieve the device index by passing the extension structure via the pNext chain when querying device properties.

The device index is set at zesInit(), subsequent calls may add new devices but will not change existing indexes. To identify a device across processes or reboots, it is recommended that devices be looked up by their PCI IDs or UUID.

The following pseudo-code demonstrates the usage pattern for querying the device index.

Querying Device Index

// Query device properties with device index extension
zes_device_properties_t deviceProps = {};
deviceProps.stype = ZES_STRUCTURE_TYPE_DEVICE_PROPERTIES;

zes_device_index_ext_properties_t deviceIndexProps = {};
deviceIndexProps.stype = ZES_STRUCTURE_TYPE_DEVICE_INDEX_EXT_PROPERTIES;
deviceIndexProps.pNext = nullptr;

deviceProps.pNext = &deviceIndexProps;

if (zesDeviceGetProperties(hDevice, &deviceProps) == ZE_RESULT_SUCCESS) {
    output("Device Index: %u\n", deviceIndexProps.deviceIndex);
}