Skip to content

Commit f67122c

Browse files
committed
[L0] ensure a valid kernel handle for the device when reading max wg
Signed-off-by: Neil R. Spruit <neil.r.spruit@intel.com>
1 parent e25ada9 commit f67122c

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

source/adapters/level_zero/kernel.cpp

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -586,15 +586,26 @@ UR_APIEXPORT ur_result_t UR_APICALL urKernelGetGroupInfo(
586586

587587
ZeStruct<ze_kernel_properties_t> kernelProperties;
588588
kernelProperties.pNext = &workGroupProperties;
589-
590-
auto ZeResult = ZE_CALL_NOCHECK(
591-
zeKernelGetProperties,
592-
(Kernel->ZeKernelMap[Device->ZeDevice], &kernelProperties));
593-
if (ZeResult || workGroupProperties.maxGroupSize == 0) {
589+
// Set the Kernel to use as the ZeKernel initally for native handle support.
590+
// This makes the assumption that this device is the same device where this
591+
// kernel was created.
592+
auto ZeKernelDevice = Kernel->ZeKernel;
593+
auto It = Kernel->ZeKernelMap.find(Device->ZeDevice);
594+
if (It != Kernel->ZeKernelMap.end()) {
595+
ZeKernelDevice = Kernel->ZeKernelMap[Device->ZeDevice];
596+
}
597+
if (ZeKernelDevice) {
598+
auto ZeResult = ZE_CALL_NOCHECK(zeKernelGetProperties,
599+
(ZeKernelDevice, &kernelProperties));
600+
if (ZeResult || workGroupProperties.maxGroupSize == 0) {
601+
return ReturnValue(
602+
uint64_t{Device->ZeDeviceComputeProperties->maxTotalGroupSize});
603+
}
604+
return ReturnValue(workGroupProperties.maxGroupSize);
605+
} else {
594606
return ReturnValue(
595607
uint64_t{Device->ZeDeviceComputeProperties->maxTotalGroupSize});
596608
}
597-
return ReturnValue(workGroupProperties.maxGroupSize);
598609
}
599610
case UR_KERNEL_GROUP_INFO_COMPILE_WORK_GROUP_SIZE: {
600611
struct {

0 commit comments

Comments
 (0)