@@ -100,8 +100,13 @@ urKernelSetArgLocal(ur_kernel_handle_t hKernel, uint32_t argIndex,
100
100
return UR_RESULT_SUCCESS;
101
101
}
102
102
103
- static cl_int mapURKernelInfoToCL (ur_kernel_info_t URPropName) {
103
+ // Querying the number of registers that a kernel uses is supported unofficially
104
+ // on some devices.
105
+ #ifndef CL_KERNEL_REGISTER_COUNT_INTEL
106
+ #define CL_KERNEL_REGISTER_COUNT_INTEL 0x425B
107
+ #endif
104
108
109
+ static cl_int mapURKernelInfoToCL (ur_kernel_info_t URPropName) {
105
110
switch (static_cast <uint32_t >(URPropName)) {
106
111
case UR_KERNEL_INFO_FUNCTION_NAME:
107
112
return CL_KERNEL_FUNCTION_NAME;
@@ -115,9 +120,10 @@ static cl_int mapURKernelInfoToCL(ur_kernel_info_t URPropName) {
115
120
return CL_KERNEL_PROGRAM;
116
121
case UR_KERNEL_INFO_ATTRIBUTES:
117
122
return CL_KERNEL_ATTRIBUTES;
118
- // NUM_REGS doesn't have a CL equivalent
119
- case UR_KERNEL_INFO_NUM_REGS:
120
123
case UR_KERNEL_INFO_SPILL_MEM_SIZE:
124
+ return CL_KERNEL_SPILL_MEM_SIZE_INTEL;
125
+ case UR_KERNEL_INFO_NUM_REGS:
126
+ return CL_KERNEL_REGISTER_COUNT_INTEL;
121
127
default :
122
128
return -1 ;
123
129
}
@@ -132,10 +138,6 @@ UR_APIEXPORT ur_result_t UR_APICALL urKernelGetInfo(ur_kernel_handle_t hKernel,
132
138
UrReturnHelper ReturnValue (propSize, pPropValue, pPropSizeRet);
133
139
134
140
switch (propName) {
135
- // OpenCL doesn't have a way to support this.
136
- case UR_KERNEL_INFO_NUM_REGS: {
137
- return UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION;
138
- }
139
141
case UR_KERNEL_INFO_PROGRAM: {
140
142
return ReturnValue (hKernel->Program );
141
143
}
@@ -145,9 +147,6 @@ UR_APIEXPORT ur_result_t UR_APICALL urKernelGetInfo(ur_kernel_handle_t hKernel,
145
147
case UR_KERNEL_INFO_REFERENCE_COUNT: {
146
148
return ReturnValue (hKernel->getReferenceCount ());
147
149
}
148
- case UR_KERNEL_INFO_SPILL_MEM_SIZE: {
149
- return UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION;
150
- }
151
150
default : {
152
151
size_t CheckPropSize = 0 ;
153
152
cl_int ClResult =
@@ -156,6 +155,9 @@ UR_APIEXPORT ur_result_t UR_APICALL urKernelGetInfo(ur_kernel_handle_t hKernel,
156
155
if (pPropValue && CheckPropSize != propSize) {
157
156
return UR_RESULT_ERROR_INVALID_SIZE;
158
157
}
158
+ if (ClResult == CL_INVALID_VALUE) {
159
+ return UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION;
160
+ }
159
161
CL_RETURN_ON_FAILURE (ClResult);
160
162
if (pPropSizeRet) {
161
163
*pPropSizeRet = CheckPropSize;
@@ -428,25 +430,16 @@ UR_APIEXPORT ur_result_t UR_APICALL urKernelSetArgPointer(
428
430
ur_kernel_handle_t hKernel, uint32_t argIndex,
429
431
const ur_kernel_arg_pointer_properties_t *, const void *pArgValue) {
430
432
431
- cl_context CLContext;
432
- CL_RETURN_ON_FAILURE (clGetKernelInfo (hKernel->CLKernel , CL_KERNEL_CONTEXT,
433
- sizeof (cl_context), &CLContext,
434
- nullptr ));
435
-
436
- clSetKernelArgMemPointerINTEL_fn FuncPtr = nullptr ;
437
- UR_RETURN_ON_FAILURE (
438
- cl_ext::getExtFuncFromContext<clSetKernelArgMemPointerINTEL_fn>(
439
- CLContext,
440
- ur::cl::getAdapter ()->fnCache .clSetKernelArgMemPointerINTELCache ,
441
- cl_ext::SetKernelArgMemPointerName, &FuncPtr));
442
-
443
- if (FuncPtr) {
444
- CL_RETURN_ON_FAILURE (
445
- FuncPtr (hKernel->CLKernel , static_cast <cl_uint>(argIndex), pArgValue));
433
+ if (hKernel->clSetKernelArgMemPointerINTEL == nullptr ) {
434
+ return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
446
435
}
447
436
437
+ CL_RETURN_ON_FAILURE (hKernel->clSetKernelArgMemPointerINTEL (
438
+ hKernel->CLKernel , static_cast <cl_uint>(argIndex), pArgValue));
439
+
448
440
return UR_RESULT_SUCCESS;
449
441
}
442
+
450
443
UR_APIEXPORT ur_result_t UR_APICALL urKernelGetNativeHandle (
451
444
ur_kernel_handle_t hKernel, ur_native_handle_t *phNativeKernel) {
452
445
0 commit comments