Skip to content

Commit e774a91

Browse files
committed
[L0] Add support for reading maxGroupSize from kernel prop extension
Signed-off-by: Neil R. Spruit <[email protected]>
1 parent a7c202b commit e774a91

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

source/adapters/level_zero/common.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,11 @@ ze_structure_type_t
215215
getZeStructureType<ze_relaxed_allocation_limits_exp_desc_t>() {
216216
return ZE_STRUCTURE_TYPE_RELAXED_ALLOCATION_LIMITS_EXP_DESC;
217217
}
218+
template <>
219+
ze_structure_type_t
220+
getZeStructureType<ze_kernel_max_group_size_properties_ext_t>() {
221+
return ZE_STRUCTURE_TYPE_KERNEL_MAX_GROUP_SIZE_EXT_PROPERTIES;
222+
}
218223
template <> ze_structure_type_t getZeStructureType<ze_host_mem_alloc_desc_t>() {
219224
return ZE_STRUCTURE_TYPE_HOST_MEM_ALLOC_DESC;
220225
}

source/adapters/level_zero/kernel.cpp

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -574,10 +574,20 @@ UR_APIEXPORT ur_result_t UR_APICALL urKernelGetGroupInfo(
574574
return ReturnValue(GlobalWorkSize);
575575
}
576576
case UR_KERNEL_GROUP_INFO_WORK_GROUP_SIZE: {
577-
// As of right now, L0 is missing API to query kernel and device specific
578-
// max work group size.
579-
return ReturnValue(
580-
uint64_t{Device->ZeDeviceComputeProperties->maxTotalGroupSize});
577+
ZeStruct<ze_kernel_max_group_size_properties_ext_t> workGroupProperties;
578+
workGroupProperties.maxGroupSize = 0;
579+
580+
ZeStruct<ze_kernel_properties_t> kernelProperties;
581+
kernelProperties.pNext = &workGroupProperties;
582+
583+
auto ZeResult = ZE_CALL_NOCHECK(
584+
zeKernelGetProperties,
585+
(Kernel->ZeKernelMap[Device->ZeDevice], &kernelProperties));
586+
if (ZeResult || workGroupProperties.maxGroupSize == 0) {
587+
return ReturnValue(
588+
uint64_t{Device->ZeDeviceComputeProperties->maxTotalGroupSize});
589+
}
590+
return ReturnValue(workGroupProperties.maxGroupSize);
581591
}
582592
case UR_KERNEL_GROUP_INFO_COMPILE_WORK_GROUP_SIZE: {
583593
struct {

0 commit comments

Comments
 (0)