From d7a20febb364e70e894f8fb4d9057ee61a55c8a3 Mon Sep 17 00:00:00 2001 From: Katarzyna Kaczmarska Date: 2026年2月16日 17:05:08 +0100 Subject: [PATCH] [UR][CUDA][HIP][OpenCL] Return UNSUPPORTED_ENUMERATION for unknown device info queries Handle unknown device info queries gracefully by returning UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION instead of UR_RESULT_ERROR_INVALID_ENUMERATION or breaking to unreachable code. This provides forward compatibility when newer SYCL runtimes query device info enums that don't exist in older UR adapters yet. Changes: - CUDA adapter: Return UNSUPPORTED_ENUMERATION + add error logging - HIP adapter: Return UNSUPPORTED_ENUMERATION + add error logging - OpenCL adapter: Return UNSUPPORTED_ENUMERATION - Remove unreachable return statements after default cases --- unified-runtime/source/adapters/cuda/device.cpp | 6 +++++- unified-runtime/source/adapters/hip/device.cpp | 6 +++++- unified-runtime/source/adapters/opencl/device.cpp | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/unified-runtime/source/adapters/cuda/device.cpp b/unified-runtime/source/adapters/cuda/device.cpp index dd722925ca12..b97ae9b6c261 100644 --- a/unified-runtime/source/adapters/cuda/device.cpp +++ b/unified-runtime/source/adapters/cuda/device.cpp @@ -1242,8 +1242,12 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice, case UR_DEVICE_INFO_GRAPH_RECORD_AND_REPLAY_SUPPORT_EXP: return ReturnValue(static_cast(false)); default: - break; + UR_LOG(ERR, "Unsupported ParamName in urDeviceGetInfo"); + UR_LOG(ERR, "ParamName={}(0x{})", propName, logger::toHex(propName)); + return UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION; } + + // Unreachable - all cases return, but compiler needs this return UR_RESULT_ERROR_INVALID_ENUMERATION; } catch (...) { return exceptionToResult(std::current_exception()); diff --git a/unified-runtime/source/adapters/hip/device.cpp b/unified-runtime/source/adapters/hip/device.cpp index 98cbddd23bfd..9ba3c79ffd8b 100644 --- a/unified-runtime/source/adapters/hip/device.cpp +++ b/unified-runtime/source/adapters/hip/device.cpp @@ -1056,8 +1056,12 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice, case UR_DEVICE_INFO_GRAPH_RECORD_AND_REPLAY_SUPPORT_EXP: return ReturnValue(false); default: - break; + UR_LOG(ERR, "Unsupported ParamName in urDeviceGetInfo"); + UR_LOG(ERR, "ParamName={}(0x{})", propName, logger::toHex(propName)); + return UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION; } + + // Unreachable - all cases return, but compiler needs this return UR_RESULT_ERROR_INVALID_ENUMERATION; } diff --git a/unified-runtime/source/adapters/opencl/device.cpp b/unified-runtime/source/adapters/opencl/device.cpp index a19dff7c8103..6ab7b9be174a 100644 --- a/unified-runtime/source/adapters/opencl/device.cpp +++ b/unified-runtime/source/adapters/opencl/device.cpp @@ -1587,7 +1587,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice, case UR_DEVICE_INFO_GRAPH_RECORD_AND_REPLAY_SUPPORT_EXP: return ReturnValue(false); default: { - return UR_RESULT_ERROR_INVALID_ENUMERATION; + return UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION; } } }

AltStyle によって変換されたページ (->オリジナル) /