omp_get_device_distances (GNU libgomp)

#### 3.7.10 `omp_get_device_distances` – Obtain the NUMA distance of a device ¶

Description:

  The routine takes two arrays, devs and distances, that have at least the size ndevs. For each element of devs, the corresponding element of distances is set to an implementation-defined non-negative distance between the place on which the routine was invoked and the device number specified in devs. For the host device, the distance is zero.

  The routine must be executed on the host device and all values of devs must be conforming devices numbers other than `omp_invalid_device`.

  In GCC the distance is the value returned by the operating system for the NUMA distance between the node on which the routine was executed and the node to which the device is attached to. There are two exceptions: As required by the specification, for the host device `0` is returned. Additionally, when either the operating system reports a negative number or when GCC runtime cannot obtain the distance, the fixed value `10` is returned. The former is in particular the case when the system is virtualized. The values the operating system returns are usually based on the SLIT (System Locality Distance Information Table) of ACPI (Advanced Configuration and Power Interface) and have values between `10` and `254`. If an invalid device number is specified, GCC returns `-1`.

  Fortran note: In GCC, this routine does not support passing default-kind integer arguments with `-fdefault-integer-8`.

C/C++

  Prototype: | `void omp_get_device_distances (int ndevs, const int *devs, int *distances)`

Fortran:

  Interface: | `subroutine omp_get_device_distances (ndevs, devs, distances)`
  | `integer, intent(in) :: ndevs, devs(*)`
  | `integer, intent(out) :: distances(*)`

See also:

  `omp_get_num_devices` – Number of target devices

Reference:

  OpenMP Technical Report 15, Section 31.16