Skip to content

Commit 752678e

Browse files
authored
[UR][L0] Fix level-zero vector width queries (#17178)
Returning native and preferred vector widths using an heuristic based on native simd width is incorrect. Especially on simd8 GPUs (Intel Arc Alchemist and Flex Series), this approach doesn't match what OpenCL returns. This set of changes aligns the behavior with OpenCL, defined here: https://github.com/intel/compute-runtime/blob/291745cdf76d83f5dc40e7ef41d347366235ccdb/opencl/source/cl_device/cl_device_caps.cpp#L236
1 parent aa7dcb1 commit 752678e

File tree

1 file changed

+9
-9
lines changed
  • unified-runtime/source/adapters/level_zero

1 file changed

+9
-9
lines changed

unified-runtime/source/adapters/level_zero/device.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -670,35 +670,35 @@ ur_result_t urDeviceGetInfo(
670670
case UR_DEVICE_INFO_IMAGE_MAX_ARRAY_SIZE:
671671
return ReturnValue(
672672
size_t{Device->ZeDeviceImageProperties->maxImageArraySlices});
673-
// Handle SIMD widths.
674-
// TODO: can we do better than this?
673+
// Handle SIMD widths, matching compute-runtime OpenCL implementation:
674+
// https://github.com/intel/compute-runtime/blob/291745cdf76d83f5dc40e7ef41d347366235ccdb/opencl/source/cl_device/cl_device_caps.cpp#L236
675675
case UR_DEVICE_INFO_NATIVE_VECTOR_WIDTH_CHAR:
676676
case UR_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_CHAR:
677-
return ReturnValue(Device->ZeDeviceProperties->physicalEUSimdWidth / 1);
677+
return ReturnValue(uint32_t{16});
678678
case UR_DEVICE_INFO_NATIVE_VECTOR_WIDTH_SHORT:
679679
case UR_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_SHORT:
680-
return ReturnValue(Device->ZeDeviceProperties->physicalEUSimdWidth / 2);
680+
return ReturnValue(uint32_t{8});
681681
case UR_DEVICE_INFO_NATIVE_VECTOR_WIDTH_INT:
682682
case UR_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_INT:
683-
return ReturnValue(Device->ZeDeviceProperties->physicalEUSimdWidth / 4);
683+
return ReturnValue(uint32_t{4});
684684
case UR_DEVICE_INFO_NATIVE_VECTOR_WIDTH_LONG:
685685
case UR_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_LONG:
686-
return ReturnValue(Device->ZeDeviceProperties->physicalEUSimdWidth / 8);
686+
return ReturnValue(uint32_t{1});
687687
case UR_DEVICE_INFO_NATIVE_VECTOR_WIDTH_FLOAT:
688688
case UR_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_FLOAT:
689-
return ReturnValue(Device->ZeDeviceProperties->physicalEUSimdWidth / 4);
689+
return ReturnValue(uint32_t{1});
690690
case UR_DEVICE_INFO_NATIVE_VECTOR_WIDTH_DOUBLE:
691691
case UR_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_DOUBLE:
692692
// Must return 0 for *vector_width_double* if the device does not have fp64.
693693
if (!(Device->ZeDeviceModuleProperties->flags & ZE_DEVICE_MODULE_FLAG_FP64))
694694
return ReturnValue(uint32_t{0});
695-
return ReturnValue(Device->ZeDeviceProperties->physicalEUSimdWidth / 8);
695+
return ReturnValue(uint32_t{1});
696696
case UR_DEVICE_INFO_NATIVE_VECTOR_WIDTH_HALF:
697697
case UR_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_HALF:
698698
// Must return 0 for *vector_width_half* if the device does not have fp16.
699699
if (!(Device->ZeDeviceModuleProperties->flags & ZE_DEVICE_MODULE_FLAG_FP16))
700700
return ReturnValue(uint32_t{0});
701-
return ReturnValue(Device->ZeDeviceProperties->physicalEUSimdWidth / 2);
701+
return ReturnValue(uint32_t{8});
702702
case UR_DEVICE_INFO_MAX_NUM_SUB_GROUPS: {
703703
// Max_num_sub_Groups = maxTotalGroupSize/min(set of subGroupSizes);
704704
uint32_t MinSubGroupSize =

0 commit comments

Comments
 (0)