From a3eae4d12458a5101223920f3ee3ce34556a352c Mon Sep 17 00:00:00 2001 From: Artur Gainullin Date: Fri, 28 Mar 2025 12:27:28 -0700 Subject: [PATCH] [UR][CUDA] Use different throttle reasons API based on CUDA version Our pre-commit CI uses CUDA 12.6 but nightly uses CUDA 12.1, it turns out nvml which is part of CUDA 12.6 has nvmlDeviceGetCurrentClocksEventReasons API, but nvml which is part of CUDA 12.1 doesn't have it, but only supports older deprecated nvmlDeviceGetCurrentClocksThrottleReasons. NVML doesn't provide a version macro to check the support for that API, so use new API nvmlDeviceGetCurrentClocksEventReasons based on cuda version. --- unified-runtime/source/adapters/cuda/device.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/unified-runtime/source/adapters/cuda/device.cpp b/unified-runtime/source/adapters/cuda/device.cpp index d984ad03ad7ed..ffc54d987aa68 100644 --- a/unified-runtime/source/adapters/cuda/device.cpp +++ b/unified-runtime/source/adapters/cuda/device.cpp @@ -1089,8 +1089,13 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice, return UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION; case UR_DEVICE_INFO_CURRENT_CLOCK_THROTTLE_REASONS: { unsigned long long ClocksEventReasons; +#if (CUDA_VERSION >= 12060) UR_CHECK_ERROR(nvmlDeviceGetCurrentClocksEventReasons(hDevice->getNVML(), &ClocksEventReasons)); +#else + UR_CHECK_ERROR(nvmlDeviceGetCurrentClocksThrottleReasons( + hDevice->getNVML(), &ClocksEventReasons)); +#endif ur_device_throttle_reasons_flags_t ThrottleReasons = 0; constexpr unsigned long long NVMLThrottleFlags[] = { nvmlClocksThrottleReasonSwPowerCap,