Skip to content

[SYCL][BINDLESS][L0] Add support for usm max image width and height queries #19529

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 35 additions & 14 deletions sycl/test-e2e/bindless_images/image_reqs_get_info.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// REQUIRES: aspect-ext_oneapi_bindless_images

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

// RUN: %{build} -o %t.out
Expand All @@ -26,20 +27,40 @@ int main() {
// These can be different depending on the device so we cannot test that the
// values are correct
// But we should at least see that the query itself works
auto pitchAlign = dev.get_info<
sycl::ext::oneapi::experimental::info::device::image_row_pitch_align>();
auto maxPitch = dev.get_info<sycl::ext::oneapi::experimental::info::device::
max_image_linear_row_pitch>();
auto maxWidth = dev.get_info<sycl::ext::oneapi::experimental::info::device::
max_image_linear_width>();
auto maxheight = dev.get_info<sycl::ext::oneapi::experimental::info::
device::max_image_linear_height>();

sycl::backend backend = dev.get_backend();

size_t pitchAlign = 0;
size_t maxPitch = 0;
size_t maxWidth = 0;
size_t maxheight = 0;

// Level Zero does not currently support these queries. Only CUDA does.
if (backend == sycl::backend::ext_oneapi_cuda) {
pitchAlign = dev.get_info<sycl::ext::oneapi::experimental::info::device::
image_row_pitch_align>();
maxPitch = dev.get_info<sycl::ext::oneapi::experimental::info::device::
max_image_linear_row_pitch>();
}

if (backend == sycl::backend::ext_oneapi_cuda ||
backend == sycl::backend::ext_oneapi_level_zero) {
maxWidth = dev.get_info<sycl::ext::oneapi::experimental::info::device::
max_image_linear_width>();
maxheight = dev.get_info<sycl::ext::oneapi::experimental::info::device::
max_image_linear_height>();
}

#ifdef VERBOSE_PRINT
std::cout << "image_row_pitch_align: " << pitchAlign
<< "\nmax_image_linear_row_pitch: " << maxPitch
<< "\nmax_image_linear_width: " << maxWidth
<< "\nmax_image_linear_height: " << maxheight << "\n";
if (backend == sycl::backend::ext_oneapi_cuda) {
std::cout << "image_row_pitch_align: " << pitchAlign
<< "\nmax_image_linear_row_pitch: " << maxPitch
<< "\nmax_image_linear_width: " << maxWidth
<< "\nmax_image_linear_height: " << maxheight << "\n";
} else if (backend == sycl::backend::ext_oneapi_level_zero) {
std::cout << "\nmax_image_linear_width: " << maxWidth
<< "\nmax_image_linear_height: " << maxheight << "\n";
}
#endif

} catch (sycl::exception e) {
Expand Down
26 changes: 24 additions & 2 deletions unified-runtime/source/adapters/level_zero/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1139,9 +1139,31 @@ ur_result_t urDeviceGetInfo(
return ReturnValue(Device->Platform->ZeBindlessImagesExtensionSupported &&
Device->ZeDeviceImageProperties->maxImageDims2D > 0);
}
case UR_DEVICE_INFO_MAX_IMAGE_LINEAR_WIDTH_EXP: {
ze_device_image_properties_t imageProps = {};
imageProps.stype = ZE_STRUCTURE_TYPE_DEVICE_IMAGE_PROPERTIES;
ze_device_pitched_alloc_exp_properties_t imageAllocProps = {};
imageAllocProps.stype =
ZE_STRUCTURE_TYPE_PITCHED_ALLOC_DEVICE_EXP_PROPERTIES;
imageProps.pNext = (void *)&imageAllocProps;

ZE_CALL_NOCHECK(zeDeviceGetImageProperties, (ZeDevice, &imageProps));

return ReturnValue(imageAllocProps.maxImageLinearWidth);
}
case UR_DEVICE_INFO_MAX_IMAGE_LINEAR_HEIGHT_EXP: {
ze_device_image_properties_t imageProps = {};
imageProps.stype = ZE_STRUCTURE_TYPE_DEVICE_IMAGE_PROPERTIES;
ze_device_pitched_alloc_exp_properties_t imageAllocProps = {};
imageAllocProps.stype =
ZE_STRUCTURE_TYPE_PITCHED_ALLOC_DEVICE_EXP_PROPERTIES;
imageProps.pNext = (void *)&imageAllocProps;

ZE_CALL_NOCHECK(zeDeviceGetImageProperties, (ZeDevice, &imageProps));

return ReturnValue(imageAllocProps.maxImageLinearHeight);
}
case UR_DEVICE_INFO_IMAGE_PITCH_ALIGN_EXP:
case UR_DEVICE_INFO_MAX_IMAGE_LINEAR_WIDTH_EXP:
case UR_DEVICE_INFO_MAX_IMAGE_LINEAR_HEIGHT_EXP:
case UR_DEVICE_INFO_MAX_IMAGE_LINEAR_PITCH_EXP:
UR_LOG(ERR, "Unsupported ParamName in urGetDeviceInfo");
UR_LOG(ERR, "ParamName=%{}(0x{})", ParamName, logger::toHex(ParamName));
Expand Down