|
8 | 8 | //
|
9 | 9 | //===----------------------------------------------------------------------===//
|
10 | 10 | #include "common.hpp"
|
| 11 | +#include "device.hpp" |
11 | 12 |
|
12 | 13 | #include <algorithm>
|
13 | 14 | #include <cstddef>
|
@@ -189,11 +190,39 @@ urKernelGetSubGroupInfo(ur_kernel_handle_t hKernel, ur_device_handle_t hDevice,
|
189 | 190 | InputValueSize = MaxDims * sizeof(size_t);
|
190 | 191 | }
|
191 | 192 |
|
192 |
| - cl_int Ret = clGetKernelSubGroupInfo(cl_adapter::cast<cl_kernel>(hKernel), |
193 |
| - cl_adapter::cast<cl_device_id>(hDevice), |
194 |
| - mapURKernelSubGroupInfoToCL(propName), |
195 |
| - InputValueSize, InputValue.get(), |
196 |
| - sizeof(size_t), &RetVal, pPropSizeRet); |
| 193 | + // We need to allow for the possibility that this device runs an older CL and |
| 194 | + // supports the original khr subgroup extension. |
| 195 | + cl_ext::clGetKernelSubGroupInfoKHR_fn GetKernelSubGroupInfo = nullptr; |
| 196 | + |
| 197 | + oclv::OpenCLVersion DevVer; |
| 198 | + CL_RETURN_ON_FAILURE(cl_adapter::getDeviceVersion( |
| 199 | + cl_adapter::cast<cl_device_id>(hDevice), DevVer)); |
| 200 | + |
| 201 | + if (DevVer < oclv::V2_1) { |
| 202 | + bool SubgroupExtSupported = false; |
| 203 | + |
| 204 | + UR_RETURN_ON_FAILURE(cl_adapter::checkDeviceExtensions( |
| 205 | + cl_adapter::cast<cl_device_id>(hDevice), {"cl_khr_subgroups"}, |
| 206 | + SubgroupExtSupported)); |
| 207 | + if (!SubgroupExtSupported) { |
| 208 | + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; |
| 209 | + } |
| 210 | + cl_context Context = nullptr; |
| 211 | + CL_RETURN_ON_FAILURE(clGetKernelInfo(cl_adapter::cast<cl_kernel>(hKernel), |
| 212 | + CL_KERNEL_CONTEXT, sizeof(Context), |
| 213 | + &Context, nullptr)); |
| 214 | + UR_RETURN_ON_FAILURE(cl_ext::getExtFuncFromContext( |
| 215 | + Context, cl_ext::ExtFuncPtrCache->clGetKernelSubGroupInfoKHRCache, |
| 216 | + cl_ext::GetKernelSubGroupInfoName, &GetKernelSubGroupInfo)); |
| 217 | + } else { |
| 218 | + GetKernelSubGroupInfo = clGetKernelSubGroupInfo; |
| 219 | + } |
| 220 | + |
| 221 | + cl_int Ret = GetKernelSubGroupInfo(cl_adapter::cast<cl_kernel>(hKernel), |
| 222 | + cl_adapter::cast<cl_device_id>(hDevice), |
| 223 | + mapURKernelSubGroupInfoToCL(propName), |
| 224 | + InputValueSize, InputValue.get(), |
| 225 | + sizeof(size_t), &RetVal, pPropSizeRet); |
197 | 226 |
|
198 | 227 | if (Ret == CL_INVALID_OPERATION) {
|
199 | 228 | // clGetKernelSubGroupInfo returns CL_INVALID_OPERATION if the device does
|
|
0 commit comments