Skip to content

Commit 8213074

Browse files
zjin-lcfJin Z
and
Jin Z
authored
[SYCL][CUDA] Support device ID and UUID in the CUDA Plugin (#8203)
This PR tries to enable the accesses to device ID and UUID with the CUDA driver APIs. Reference https://github.com/intel/llvm/blob/sycl/sycl/doc/extensions/supported/sycl_ext_intel_device_info.md --------- Co-authored-by: Jin Z <5zj@equinox.ftpn.ornl.gov>
1 parent 83b721e commit 8213074

File tree

1 file changed

+28
-5
lines changed

1 file changed

+28
-5
lines changed

sycl/plugins/cuda/pi_cuda.cpp

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1998,8 +1998,35 @@ pi_result cuda_piDeviceGetInfo(pi_device device, pi_device_info param_name,
19981998
pi_int32{1});
19991999
}
20002000

2001+
case PI_DEVICE_INFO_DEVICE_ID: {
2002+
int value = 0;
2003+
sycl::detail::pi::assertion(
2004+
cuDeviceGetAttribute(&value, CU_DEVICE_ATTRIBUTE_PCI_DEVICE_ID,
2005+
device->get()) == CUDA_SUCCESS);
2006+
sycl::detail::pi::assertion(value >= 0);
2007+
return getInfo(param_value_size, param_value, param_value_size_ret, value);
2008+
}
2009+
2010+
case PI_DEVICE_INFO_UUID: {
2011+
int driver_version = 0;
2012+
cuDriverGetVersion(&driver_version);
2013+
int major = driver_version / 1000;
2014+
int minor = driver_version % 1000 / 10;
2015+
CUuuid uuid;
2016+
if ((major > 11) || (major == 11 && minor >= 4)) {
2017+
sycl::detail::pi::assertion(cuDeviceGetUuid_v2(&uuid, device->get()) ==
2018+
CUDA_SUCCESS);
2019+
} else {
2020+
sycl::detail::pi::assertion(cuDeviceGetUuid(&uuid, device->get()) ==
2021+
CUDA_SUCCESS);
2022+
}
2023+
std::array<unsigned char, 16> name;
2024+
std::copy(uuid.bytes, uuid.bytes + 16, name.begin());
2025+
return getInfoArray(16, param_value_size, param_value, param_value_size_ret,
2026+
name.data());
2027+
}
2028+
20012029
// TODO: Investigate if this information is available on CUDA.
2002-
case PI_DEVICE_INFO_DEVICE_ID:
20032030
case PI_DEVICE_INFO_PCI_ADDRESS:
20042031
case PI_DEVICE_INFO_GPU_EU_COUNT:
20052032
case PI_DEVICE_INFO_GPU_EU_SIMD_WIDTH:
@@ -2008,10 +2035,6 @@ pi_result cuda_piDeviceGetInfo(pi_device device, pi_device_info param_name,
20082035
case PI_DEVICE_INFO_GPU_EU_COUNT_PER_SUBSLICE:
20092036
case PI_DEVICE_INFO_GPU_HW_THREADS_PER_EU:
20102037
case PI_DEVICE_INFO_MAX_MEM_BANDWIDTH:
2011-
// TODO: Check if Intel device UUID extension is utilized for CUDA.
2012-
// For details about this extension, see
2013-
// sycl/doc/extensions/supported/sycl_ext_intel_device_info.md
2014-
case PI_DEVICE_INFO_UUID:
20152038
return PI_ERROR_INVALID_VALUE;
20162039

20172040
default:

0 commit comments

Comments
 (0)