Skip to content

Commit 8370e04

Browse files
DBDuncanProGTX
andauthored
[SYCL][BINDLESS][L0] Add support for usm max image width and height queries (#19529)
Added support for usm image max image width and height queries and updated test to cover this --------- Co-authored-by: Peter Žužek <[email protected]>
1 parent 5a6e769 commit 8370e04

File tree

2 files changed

+59
-16
lines changed

2 files changed

+59
-16
lines changed

sycl/test-e2e/bindless_images/image_reqs_get_info.cpp

Lines changed: 35 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
// REQUIRES: aspect-ext_oneapi_bindless_images
22

3-
// UNSUPPORTED: level_zero
4-
// UNSUPPORTED-INTENDED: The feature is not implemented in the Level Zero stack.
3+
// These features are only partly implemented in the Level Zero stack.
4+
// Only max_image_linear_width and max_image_linear_height are supported in the
5+
// Level Zero stack.
56
// https://github.com/intel/llvm/issues/17663
67

78
// RUN: %{build} -o %t.out
@@ -26,20 +27,40 @@ int main() {
2627
// These can be different depending on the device so we cannot test that the
2728
// values are correct
2829
// But we should at least see that the query itself works
29-
auto pitchAlign = dev.get_info<
30-
sycl::ext::oneapi::experimental::info::device::image_row_pitch_align>();
31-
auto maxPitch = dev.get_info<sycl::ext::oneapi::experimental::info::device::
32-
max_image_linear_row_pitch>();
33-
auto maxWidth = dev.get_info<sycl::ext::oneapi::experimental::info::device::
34-
max_image_linear_width>();
35-
auto maxheight = dev.get_info<sycl::ext::oneapi::experimental::info::
36-
device::max_image_linear_height>();
30+
31+
sycl::backend backend = dev.get_backend();
32+
33+
size_t pitchAlign = 0;
34+
size_t maxPitch = 0;
35+
size_t maxWidth = 0;
36+
size_t maxheight = 0;
37+
38+
// Level Zero does not currently support these queries. Only CUDA does.
39+
if (backend == sycl::backend::ext_oneapi_cuda) {
40+
pitchAlign = dev.get_info<sycl::ext::oneapi::experimental::info::device::
41+
image_row_pitch_align>();
42+
maxPitch = dev.get_info<sycl::ext::oneapi::experimental::info::device::
43+
max_image_linear_row_pitch>();
44+
}
45+
46+
if (backend == sycl::backend::ext_oneapi_cuda ||
47+
backend == sycl::backend::ext_oneapi_level_zero) {
48+
maxWidth = dev.get_info<sycl::ext::oneapi::experimental::info::device::
49+
max_image_linear_width>();
50+
maxheight = dev.get_info<sycl::ext::oneapi::experimental::info::device::
51+
max_image_linear_height>();
52+
}
3753

3854
#ifdef VERBOSE_PRINT
39-
std::cout << "image_row_pitch_align: " << pitchAlign
40-
<< "\nmax_image_linear_row_pitch: " << maxPitch
41-
<< "\nmax_image_linear_width: " << maxWidth
42-
<< "\nmax_image_linear_height: " << maxheight << "\n";
55+
if (backend == sycl::backend::ext_oneapi_cuda) {
56+
std::cout << "image_row_pitch_align: " << pitchAlign
57+
<< "\nmax_image_linear_row_pitch: " << maxPitch
58+
<< "\nmax_image_linear_width: " << maxWidth
59+
<< "\nmax_image_linear_height: " << maxheight << "\n";
60+
} else if (backend == sycl::backend::ext_oneapi_level_zero) {
61+
std::cout << "\nmax_image_linear_width: " << maxWidth
62+
<< "\nmax_image_linear_height: " << maxheight << "\n";
63+
}
4364
#endif
4465

4566
} catch (sycl::exception e) {

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

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1139,9 +1139,31 @@ ur_result_t urDeviceGetInfo(
11391139
return ReturnValue(Device->Platform->ZeBindlessImagesExtensionSupported &&
11401140
Device->ZeDeviceImageProperties->maxImageDims2D > 0);
11411141
}
1142+
case UR_DEVICE_INFO_MAX_IMAGE_LINEAR_WIDTH_EXP: {
1143+
ze_device_image_properties_t imageProps = {};
1144+
imageProps.stype = ZE_STRUCTURE_TYPE_DEVICE_IMAGE_PROPERTIES;
1145+
ze_device_pitched_alloc_exp_properties_t imageAllocProps = {};
1146+
imageAllocProps.stype =
1147+
ZE_STRUCTURE_TYPE_PITCHED_ALLOC_DEVICE_EXP_PROPERTIES;
1148+
imageProps.pNext = (void *)&imageAllocProps;
1149+
1150+
ZE_CALL_NOCHECK(zeDeviceGetImageProperties, (ZeDevice, &imageProps));
1151+
1152+
return ReturnValue(imageAllocProps.maxImageLinearWidth);
1153+
}
1154+
case UR_DEVICE_INFO_MAX_IMAGE_LINEAR_HEIGHT_EXP: {
1155+
ze_device_image_properties_t imageProps = {};
1156+
imageProps.stype = ZE_STRUCTURE_TYPE_DEVICE_IMAGE_PROPERTIES;
1157+
ze_device_pitched_alloc_exp_properties_t imageAllocProps = {};
1158+
imageAllocProps.stype =
1159+
ZE_STRUCTURE_TYPE_PITCHED_ALLOC_DEVICE_EXP_PROPERTIES;
1160+
imageProps.pNext = (void *)&imageAllocProps;
1161+
1162+
ZE_CALL_NOCHECK(zeDeviceGetImageProperties, (ZeDevice, &imageProps));
1163+
1164+
return ReturnValue(imageAllocProps.maxImageLinearHeight);
1165+
}
11421166
case UR_DEVICE_INFO_IMAGE_PITCH_ALIGN_EXP:
1143-
case UR_DEVICE_INFO_MAX_IMAGE_LINEAR_WIDTH_EXP:
1144-
case UR_DEVICE_INFO_MAX_IMAGE_LINEAR_HEIGHT_EXP:
11451167
case UR_DEVICE_INFO_MAX_IMAGE_LINEAR_PITCH_EXP:
11461168
UR_LOG(ERR, "Unsupported ParamName in urGetDeviceInfo");
11471169
UR_LOG(ERR, "ParamName=%{}(0x{})", ParamName, logger::toHex(ParamName));

0 commit comments

Comments
 (0)