-
Notifications
You must be signed in to change notification settings - Fork 787
[SYCL] Add support for image with pitch but without host ptr provided. #723
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
[SYCL] Add support for image with pitch but without host ptr provided. #723
Conversation
In this case pitches passed to OpenCL must be 0. + Aligned image constructor with the SYCL specification. Signed-off-by: Vlad Romanov <[email protected]>
@@ -24,6 +24,9 @@ int main() { | |||
const sycl::image_channel_order ChanOrder = sycl::image_channel_order::rgba; | |||
const sycl::image_channel_type ChanType = sycl::image_channel_type::fp32; | |||
|
|||
constexpr auto SYCLRead = sycl::access::mode::read; |
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.
Is this constexpr supposed to have a different namespace specification compared to the one on the next line?
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.
No, will fix.
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.
Fixed.
@@ -283,7 +283,7 @@ class image_impl final : public SYCLMemObjT<AllocatorT> { | |||
RT::PiEvent &OutEventToWait) override { | |||
void *UserPtr = InitFromUserData ? BaseT::getUserPtr() : nullptr; | |||
|
|||
RT::PiMemImageDesc Desc = getImageDesc(); | |||
RT::PiMemImageDesc Desc = getImageDesc((bool)UserPtr); |
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.
RT::PiMemImageDesc Desc = getImageDesc((bool)UserPtr); | |
RT::PiMemImageDesc Desc = getImageDesc(static_cast<bool>(UserPtr)); |
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.
Done.
Desc.image_row_pitch = MRowPitch; | ||
Desc.image_slice_pitch = MSlicePitch; | ||
// Pitches must be 0 if host ptr is not provided. | ||
Desc.image_row_pitch = InitFromHostPtr ? MRowPitch: 0; |
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.
Please, apply clang-format
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.
Done.
Signed-off-by: Vlad Romanov <[email protected]>
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.
Need some clarifications.
RT::PiMemImageDesc Desc; | ||
Desc.image_type = getImageType(); | ||
Desc.image_width = MRange[0]; | ||
Desc.image_height = Dimensions > 1 ? MRange[1] : 1; | ||
Desc.image_depth = Dimensions > 2 ? MRange[2] : 1; | ||
// TODO handle cases with IMAGE1D_ARRAY and IMAGE2D_ARRAY | ||
Desc.image_array_size = 0; | ||
Desc.image_row_pitch = MRowPitch; | ||
Desc.image_slice_pitch = MSlicePitch; | ||
// Pitches must be 0 if host ptr is not provided. |
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 did not understand this change. How are the fields Desc.image_row_pitch and Desc.image_slice_pitch used? What happens when the user is constructing an image without host_ptr but a valid pitch?
Eg with constructor:
image(image_channel_order order, image_channel_type type, const range &range, const range<dimensions - 1> &pitch, const property_list &propList = {});
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.
How are the fields Desc.image_row_pitch and Desc.image_slice_pitch used?
There are used as arguments to clCreateImage function.
What happens when the user is constructing an image without host_ptr but a valid pitch?
For OpenCL device image is created without host ptr and with pitch == 0.
For host device image is created without host ptr and with pitches that user specifies.
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.
Read section 5.3.1.2 in OpenCL spec.
Thanks.
@@ -283,7 +283,7 @@ class image_impl final : public SYCLMemObjT<AllocatorT> { | |||
RT::PiEvent &OutEventToWait) override { | |||
void *UserPtr = InitFromUserData ? BaseT::getUserPtr() : nullptr; | |||
|
|||
RT::PiMemImageDesc Desc = getImageDesc(); | |||
RT::PiMemImageDesc Desc = getImageDesc(static_cast<bool>(UserPtr)); |
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.
Unclear... What about:
RT::PiMemImageDesc Desc = getImageDesc(static_cast<bool>(UserPtr)); | |
RT::PiMemImageDesc Desc = getImageDesc(UserPtr != nullptr); |
to avoid a cast?
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.
Done.
Signed-off-by: Vlad Romanov <[email protected]>
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.
LGTM
The assertion now gives way to a simple check until all known LLVM IR edge cases that do not accord to the condition can be handled. Signed-off-by: Artem Gindinson <[email protected]>
In this case pitches passed to OpenCL must be 0.
Signed-off-by: Vlad Romanov [email protected]