-
Notifications
You must be signed in to change notification settings - Fork 809
[SYCL][L0 v2] Fix bindless array image subregion copies #20952
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
base: sycl
Are you sure you want to change the base?
Changes from all commits
17d7288
8581964
7b5df3a
39e810f
f50bfbf
2908463
5eab493
34dc5a8
d6c2865
3aac708
95e4c25
e76d246
c0fae93
e0ae69e
ecf4d1f
baa84e4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -731,47 +731,51 @@ ur_result_t getImageRegionHelper(ze_image_desc_t ZeImageDesc, | |
| UR_ASSERT(Origin, UR_RESULT_ERROR_INVALID_VALUE); | ||
| UR_ASSERT(Region, UR_RESULT_ERROR_INVALID_VALUE); | ||
|
|
||
| if (ZeImageDesc.type == ZE_IMAGE_TYPE_1D || | ||
| ZeImageDesc.type == ZE_IMAGE_TYPE_1DARRAY) { | ||
| Region->height = 1; | ||
| Region->depth = 1; | ||
| } else if (ZeImageDesc.type == ZE_IMAGE_TYPE_2D || | ||
| ZeImageDesc.type == ZE_IMAGE_TYPE_2DARRAY) { | ||
| Region->depth = 1; | ||
| } | ||
|
|
||
| #ifndef NDEBUG | ||
| // Validate Origin constraints based on image type | ||
| UR_ASSERT((ZeImageDesc.type == ZE_IMAGE_TYPE_1D && Origin->y == 0 && | ||
| Origin->z == 0) || | ||
| (ZeImageDesc.type == ZE_IMAGE_TYPE_1DARRAY && Origin->z == 0) || | ||
| (ZeImageDesc.type == ZE_IMAGE_TYPE_1DARRAY && Origin->y == 0) || | ||
| (ZeImageDesc.type == ZE_IMAGE_TYPE_2D && Origin->z == 0) || | ||
| (ZeImageDesc.type == ZE_IMAGE_TYPE_2DARRAY) || | ||
|
Comment on lines
+738
to
740
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we also need to assert
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe the current code is correct as-is. The assertions properly validate that:
|
||
| (ZeImageDesc.type == ZE_IMAGE_TYPE_3D), | ||
| UR_RESULT_ERROR_INVALID_VALUE); | ||
|
|
||
| UR_ASSERT(Region->width && Region->height && Region->depth, | ||
| // Validate Region width is non-zero | ||
| UR_ASSERT(Region->width != 0, UR_RESULT_ERROR_INVALID_VALUE); | ||
|
|
||
| // Validate Region depth for 1D arrays contains layer count | ||
| UR_ASSERT(ZeImageDesc.type != ZE_IMAGE_TYPE_1DARRAY || Region->depth != 0, | ||
| UR_RESULT_ERROR_INVALID_VALUE); | ||
|
|
||
| // Validate Region depth for 2D arrays contains layer count | ||
| UR_ASSERT(ZeImageDesc.type != ZE_IMAGE_TYPE_2DARRAY || Region->depth != 0, | ||
| UR_RESULT_ERROR_INVALID_VALUE); | ||
| UR_ASSERT( | ||
| (ZeImageDesc.type == ZE_IMAGE_TYPE_1D && Region->height == 1 && | ||
| Region->depth == 1) || | ||
| (ZeImageDesc.type == ZE_IMAGE_TYPE_1DARRAY && Region->depth == 1) || | ||
| (ZeImageDesc.type == ZE_IMAGE_TYPE_2D && Region->depth == 1) || | ||
| (ZeImageDesc.type == ZE_IMAGE_TYPE_2DARRAY) || | ||
| (ZeImageDesc.type == ZE_IMAGE_TYPE_3D), | ||
| UR_RESULT_ERROR_INVALID_VALUE); | ||
| #endif // !NDEBUG | ||
|
|
||
| uint32_t OriginX = ur_cast<uint32_t>(Origin->x); | ||
| uint32_t OriginY = ur_cast<uint32_t>(Origin->y); | ||
| uint32_t OriginZ = ur_cast<uint32_t>(Origin->z); | ||
|
|
||
| uint32_t Width = ur_cast<uint32_t>(Region->width); | ||
| uint32_t Height = (ZeImageDesc.type == ZE_IMAGE_TYPE_1DARRAY) | ||
| ? ZeImageDesc.arraylevels | ||
| : ur_cast<uint32_t>(Region->height); | ||
| uint32_t Depth = (ZeImageDesc.type == ZE_IMAGE_TYPE_2DARRAY) | ||
| ? ZeImageDesc.arraylevels | ||
| : ur_cast<uint32_t>(Region->depth); | ||
| uint32_t Height = ur_cast<uint32_t>(Region->height); | ||
| uint32_t Depth = ur_cast<uint32_t>(Region->depth); | ||
|
|
||
| // Normalize Region dimensions based on image type | ||
| if (ZeImageDesc.type == ZE_IMAGE_TYPE_1D) { | ||
| // 1D images: height and depth must be 1 | ||
| Height = 1; | ||
| Depth = 1; | ||
| } else if (ZeImageDesc.type == ZE_IMAGE_TYPE_1DARRAY) { | ||
| // UR uses depth for 1D array layers, but Level Zero uses height | ||
AlexeySachkov marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| OriginY = OriginZ; | ||
| OriginZ = 0; | ||
| Height = Depth; | ||
| Depth = 1; | ||
| } else if (ZeImageDesc.type == ZE_IMAGE_TYPE_2D) { | ||
| // 2D images: depth must be 1 | ||
| Depth = 1; | ||
| } | ||
|
|
||
| ZeRegion = {OriginX, OriginY, OriginZ, Width, Height, Depth}; | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see that L0 does not support arrays of 3d images, but briefly looking at the extension specification I couldn't find any restriction about that on the SYCL level.
Did I just missed it, or is it indeed missing from the spec?
If it is missing, I'm not asking to add it in this PR, but creating an issue to remind us about this would be helpful
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SYCL also does not support arrays of 3D images. The specification is not written clearly, but sentences like "... the 3rd dimension of the ranges represent the arrays' layer(s) being copied, regardless of whether the copy is performed on a 1D or 2D image array." indicate this. You can also see it in the code:
llvm/sycl/include/sycl/ext/oneapi/bindless_images_descriptor.hpp
Line 157 in 92aea26