From 0a1ed83ae9e18d653e7bcf36ed983a30f2cf2bd8 Mon Sep 17 00:00:00 2001 From: Aaron Greig Date: Wed, 14 Aug 2024 17:37:04 +0100 Subject: [PATCH] Fix CL adapter assuming incorrect type for sub group query. On a fallback path used when the clGetKernelSubGroupInfo query isn't supported the adapter tries the UR_DEVICE_INFO_SUB_GROUP_SIZES_INTEL device info query via urDeviceGetInfo. It currently assumes the type returned by that query is size_t, this patch corrects that to uint32_t. --- source/adapters/opencl/kernel.cpp | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/source/adapters/opencl/kernel.cpp b/source/adapters/opencl/kernel.cpp index 41c6d6de70..9735abefbf 100644 --- a/source/adapters/opencl/kernel.cpp +++ b/source/adapters/opencl/kernel.cpp @@ -206,19 +206,14 @@ urKernelGetSubGroupInfo(ur_kernel_handle_t hKernel, ur_device_handle_t hDevice, // Two calls to urDeviceGetInfo are needed: the first determines the size // required to store the result, and the second returns the actual size // values. - ur_result_t URRet = - urDeviceGetInfo(hDevice, UR_DEVICE_INFO_SUB_GROUP_SIZES_INTEL, 0, - nullptr, &ResultSize); - if (URRet != UR_RESULT_SUCCESS) { - return URRet; - } - assert(ResultSize % sizeof(size_t) == 0); - std::vector Result(ResultSize / sizeof(size_t)); - URRet = urDeviceGetInfo(hDevice, UR_DEVICE_INFO_SUB_GROUP_SIZES_INTEL, - ResultSize, Result.data(), nullptr); - if (URRet != UR_RESULT_SUCCESS) { - return URRet; - } + UR_RETURN_ON_FAILURE(urDeviceGetInfo(hDevice, + UR_DEVICE_INFO_SUB_GROUP_SIZES_INTEL, + 0, nullptr, &ResultSize)); + assert(ResultSize % sizeof(uint32_t) == 0); + std::vector Result(ResultSize / sizeof(uint32_t)); + UR_RETURN_ON_FAILURE(urDeviceGetInfo(hDevice, + UR_DEVICE_INFO_SUB_GROUP_SIZES_INTEL, + ResultSize, Result.data(), nullptr)); RetVal = *std::max_element(Result.begin(), Result.end()); Ret = CL_SUCCESS; } else if (propName == UR_KERNEL_SUB_GROUP_INFO_SUB_GROUP_SIZE_INTEL) {