Skip to content

Commit 0575e1a

Browse files
committed
[L0 v2] Implement missing kernel functionality
to enable StreamMemory and QuickSilver benchmarks
1 parent 5a6ad4b commit 0575e1a

File tree

3 files changed

+121
-40
lines changed

3 files changed

+121
-40
lines changed

source/adapters/level_zero/v2/api.cpp

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -184,39 +184,13 @@ ur_result_t urPhysicalMemRelease(ur_physical_mem_handle_t hPhysicalMem) {
184184
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
185185
}
186186

187-
ur_result_t
188-
urKernelSetArgLocal(ur_kernel_handle_t hKernel, uint32_t argIndex,
189-
size_t argSize,
190-
const ur_kernel_arg_local_properties_t *pProperties) {
191-
logger::error("{} function not implemented!", __FUNCTION__);
192-
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
193-
}
194-
195187
ur_result_t urKernelGetInfo(ur_kernel_handle_t hKernel,
196188
ur_kernel_info_t propName, size_t propSize,
197189
void *pPropValue, size_t *pPropSizeRet) {
198190
logger::error("{} function not implemented!", __FUNCTION__);
199191
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
200192
}
201193

202-
ur_result_t urKernelGetGroupInfo(ur_kernel_handle_t hKernel,
203-
ur_device_handle_t hDevice,
204-
ur_kernel_group_info_t propName,
205-
size_t propSize, void *pPropValue,
206-
size_t *pPropSizeRet) {
207-
logger::error("{} function not implemented!", __FUNCTION__);
208-
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
209-
}
210-
211-
ur_result_t urKernelGetSubGroupInfo(ur_kernel_handle_t hKernel,
212-
ur_device_handle_t hDevice,
213-
ur_kernel_sub_group_info_t propName,
214-
size_t propSize, void *pPropValue,
215-
size_t *pPropSizeRet) {
216-
logger::error("{} function not implemented!", __FUNCTION__);
217-
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
218-
}
219-
220194
ur_result_t
221195
urKernelSetArgSampler(ur_kernel_handle_t hKernel, uint32_t argIndex,
222196
const ur_kernel_arg_sampler_properties_t *pProperties,

source/adapters/level_zero/v2/kernel.cpp

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,17 @@ urKernelSetArgMemObj(ur_kernel_handle_t hKernel, uint32_t argIndex,
324324
}
325325
}
326326

327+
ur_result_t
328+
urKernelSetArgLocal(ur_kernel_handle_t hKernel, uint32_t argIndex,
329+
size_t argSize,
330+
const ur_kernel_arg_local_properties_t *pProperties) {
331+
TRACK_SCOPE_LATENCY("ur_kernel_handle_t_::setArgLocal");
332+
333+
std::ignore = pProperties;
334+
335+
return hKernel->setArgValue(argIndex, argSize, nullptr, nullptr);
336+
}
337+
327338
ur_result_t urKernelSetExecInfo(
328339
ur_kernel_handle_t hKernel, ///< [in] handle of the kernel object
329340
ur_kernel_exec_info_t propName, ///< [in] name of the execution attribute
@@ -338,4 +349,114 @@ ur_result_t urKernelSetExecInfo(
338349

339350
return hKernel->setExecInfo(propName, pPropValue);
340351
}
352+
353+
ur_result_t urKernelGetGroupInfo(
354+
ur_kernel_handle_t hKernel, ///< [in] handle of the Kernel object
355+
ur_device_handle_t hDevice, ///< [in] handle of the Device object
356+
ur_kernel_group_info_t
357+
paramName, ///< [in] name of the work Group property to query
358+
size_t
359+
paramValueSize, ///< [in] size of the Kernel Work Group property value
360+
void *pParamValue, ///< [in,out][optional][range(0, propSize)] value of the
361+
///< Kernel Work Group property.
362+
size_t *pParamValueSizeRet ///< [out][optional] pointer to the actual size
363+
///< in bytes of data being queried by propName.
364+
) {
365+
UrReturnHelper returnValue(paramValueSize, pParamValue, pParamValueSizeRet);
366+
367+
std::shared_lock<ur_shared_mutex> Guard(hKernel->Mutex);
368+
switch (paramName) {
369+
case UR_KERNEL_GROUP_INFO_GLOBAL_WORK_SIZE: {
370+
// TODO: To revisit after level_zero/issues/262 is resolved
371+
struct {
372+
size_t Arr[3];
373+
} GlobalWorkSize = {{(hDevice->ZeDeviceComputeProperties->maxGroupSizeX *
374+
hDevice->ZeDeviceComputeProperties->maxGroupCountX),
375+
(hDevice->ZeDeviceComputeProperties->maxGroupSizeY *
376+
hDevice->ZeDeviceComputeProperties->maxGroupCountY),
377+
(hDevice->ZeDeviceComputeProperties->maxGroupSizeZ *
378+
hDevice->ZeDeviceComputeProperties->maxGroupCountZ)}};
379+
return returnValue(GlobalWorkSize);
380+
}
381+
case UR_KERNEL_GROUP_INFO_WORK_GROUP_SIZE: {
382+
ZeStruct<ze_kernel_max_group_size_properties_ext_t> workGroupProperties;
383+
workGroupProperties.maxGroupSize = 0;
384+
385+
ZeStruct<ze_kernel_properties_t> kernelProperties;
386+
kernelProperties.pNext = &workGroupProperties;
387+
388+
auto zeDevice = hKernel->getZeHandle(hDevice);
389+
if (zeDevice) {
390+
auto zeResult =
391+
ZE_CALL_NOCHECK(zeKernelGetProperties, (zeDevice, &kernelProperties));
392+
if (zeResult == ZE_RESULT_SUCCESS &&
393+
workGroupProperties.maxGroupSize != 0) {
394+
return returnValue(workGroupProperties.maxGroupSize);
395+
}
396+
return returnValue(
397+
uint64_t{hDevice->ZeDeviceComputeProperties->maxTotalGroupSize});
398+
}
399+
}
400+
case UR_KERNEL_GROUP_INFO_COMPILE_WORK_GROUP_SIZE: {
401+
auto props = hKernel->getProperties(hDevice);
402+
struct {
403+
size_t Arr[3];
404+
} WgSize = {{props.requiredGroupSizeX, props.requiredGroupSizeY,
405+
props.requiredGroupSizeZ}};
406+
return returnValue(WgSize);
407+
}
408+
case UR_KERNEL_GROUP_INFO_LOCAL_MEM_SIZE: {
409+
auto props = hKernel->getProperties(hDevice);
410+
return returnValue(uint32_t{props.localMemSize});
411+
}
412+
case UR_KERNEL_GROUP_INFO_PREFERRED_WORK_GROUP_SIZE_MULTIPLE: {
413+
return returnValue(
414+
size_t{hDevice->ZeDeviceProperties->physicalEUSimdWidth});
415+
}
416+
case UR_KERNEL_GROUP_INFO_PRIVATE_MEM_SIZE: {
417+
auto props = hKernel->getProperties(hDevice);
418+
return returnValue(uint32_t{props.privateMemSize});
419+
}
420+
default: {
421+
logger::error(
422+
"Unknown ParamName in urKernelGetGroupInfo: ParamName={}(0x{})",
423+
paramName, logger::toHex(paramName));
424+
return UR_RESULT_ERROR_INVALID_VALUE;
425+
}
426+
}
427+
return UR_RESULT_SUCCESS;
428+
}
429+
430+
ur_result_t urKernelGetSubGroupInfo(
431+
ur_kernel_handle_t hKernel, ///< [in] handle of the Kernel object
432+
ur_device_handle_t hDevice, ///< [in] handle of the Device object
433+
ur_kernel_sub_group_info_t
434+
propName, ///< [in] name of the SubGroup property to query
435+
size_t propSize, ///< [in] size of the Kernel SubGroup property value
436+
void *pPropValue, ///< [in,out][range(0, propSize)][optional] value of the
437+
///< Kernel SubGroup property.
438+
size_t *pPropSizeRet ///< [out][optional] pointer to the actual size in
439+
///< bytes of data being queried by propName.
440+
) {
441+
std::ignore = hDevice;
442+
443+
UrReturnHelper returnValue(propSize, pPropValue, pPropSizeRet);
444+
445+
auto props = hKernel->getProperties(hDevice);
446+
447+
std::shared_lock<ur_shared_mutex> Guard(hKernel->Mutex);
448+
if (propName == UR_KERNEL_SUB_GROUP_INFO_MAX_SUB_GROUP_SIZE) {
449+
returnValue(uint32_t{props.maxSubgroupSize});
450+
} else if (propName == UR_KERNEL_SUB_GROUP_INFO_MAX_NUM_SUB_GROUPS) {
451+
returnValue(uint32_t{props.maxNumSubgroups});
452+
} else if (propName == UR_KERNEL_SUB_GROUP_INFO_COMPILE_NUM_SUB_GROUPS) {
453+
returnValue(uint32_t{props.requiredNumSubGroups});
454+
} else if (propName == UR_KERNEL_SUB_GROUP_INFO_SUB_GROUP_SIZE_INTEL) {
455+
returnValue(uint32_t{props.requiredSubgroupSize});
456+
} else {
457+
die("urKernelGetSubGroupInfo: parameter not implemented");
458+
return {};
459+
}
460+
return UR_RESULT_SUCCESS;
461+
}
341462
} // namespace ur::level_zero

test/conformance/kernel/kernel_adapter_level_zero_v2.match

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
urKernelGetGroupInfoTest.Success/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}___UR_KERNEL_GROUP_INFO_GLOBAL_WORK_SIZE
2-
urKernelGetGroupInfoTest.Success/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}___UR_KERNEL_GROUP_INFO_WORK_GROUP_SIZE
3-
urKernelGetGroupInfoTest.Success/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}___UR_KERNEL_GROUP_INFO_COMPILE_WORK_GROUP_SIZE
4-
urKernelGetGroupInfoTest.Success/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}___UR_KERNEL_GROUP_INFO_LOCAL_MEM_SIZE
5-
urKernelGetGroupInfoTest.Success/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}___UR_KERNEL_GROUP_INFO_PREFERRED_WORK_GROUP_SIZE_MULTIPLE
6-
urKernelGetGroupInfoTest.Success/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}___UR_KERNEL_GROUP_INFO_PRIVATE_MEM_SIZE
7-
urKernelGetGroupInfoSingleTest.CompileWorkGroupSizeEmpty/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}_
8-
urKernelGetGroupInfoWgSizeTest.CompileWorkGroupSize/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}_
91
urKernelGetInfoTest.Success/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}___UR_KERNEL_INFO_FUNCTION_NAME
102
urKernelGetInfoTest.Success/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}___UR_KERNEL_INFO_NUM_ARGS
113
urKernelGetInfoTest.Success/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}___UR_KERNEL_INFO_REFERENCE_COUNT
@@ -36,12 +28,6 @@ urKernelGetInfoTest.InvalidNullPointerPropValue/Intel_R__oneAPI_Unified_Runtime_
3628
urKernelGetInfoTest.InvalidNullPointerPropValue/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}___UR_KERNEL_INFO_NUM_REGS
3729
urKernelGetInfoSingleTest.KernelNameCorrect/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}_
3830
urKernelGetInfoSingleTest.KernelContextCorrect/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}_
39-
urKernelGetSubGroupInfoTest.Success/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}___UR_KERNEL_SUB_GROUP_INFO_MAX_SUB_GROUP_SIZE
40-
urKernelGetSubGroupInfoTest.Success/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}___UR_KERNEL_SUB_GROUP_INFO_MAX_NUM_SUB_GROUPS
41-
urKernelGetSubGroupInfoTest.Success/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}___UR_KERNEL_SUB_GROUP_INFO_COMPILE_NUM_SUB_GROUPS
42-
urKernelGetSubGroupInfoTest.Success/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}___UR_KERNEL_SUB_GROUP_INFO_SUB_GROUP_SIZE_INTEL
43-
urKernelGetSubGroupInfoSingleTest.CompileNumSubgroupsIsZero/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}_
44-
urKernelSetArgLocalTest.Success/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}_
4531
urKernelSetArgLocalTest.InvalidKernelArgumentIndex/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}_
4632
urKernelSetArgMemObjTest.InvalidKernelArgumentIndex/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}_
4733
urKernelSetArgPointerNegativeTest.InvalidKernelArgumentIndex/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}_

0 commit comments

Comments
 (0)