Skip to content

[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

Merged
merged 3 commits into from
Oct 16, 2019

Conversation

romanovvlad
Copy link
Contributor

In this case pitches passed to OpenCL must be 0.

  • Aligned image constructor with the SYCL specification.

Signed-off-by: Vlad Romanov [email protected]

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;
Copy link
Contributor

@AGindinson AGindinson Oct 14, 2019

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, will fix.

Copy link
Contributor Author

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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
RT::PiMemImageDesc Desc = getImageDesc((bool)UserPtr);
RT::PiMemImageDesc Desc = getImageDesc(static_cast<bool>(UserPtr));

Copy link
Contributor Author

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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, apply clang-format

Copy link
Contributor Author

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]>
sergey-semenov
sergey-semenov previously approved these changes Oct 14, 2019
Copy link
Contributor

@garimagu garimagu left a 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.
Copy link
Contributor

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 = {});

Copy link
Contributor Author

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.

Copy link
Contributor

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));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unclear... What about:

Suggested change
RT::PiMemImageDesc Desc = getImageDesc(static_cast<bool>(UserPtr));
RT::PiMemImageDesc Desc = getImageDesc(UserPtr != nullptr);

to avoid a cast?

Copy link
Contributor Author

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]>
Copy link
Contributor

@garimagu garimagu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@romanovvlad romanovvlad merged commit 665a794 into intel:sycl Oct 16, 2019
vladimirlaz pushed a commit to vladimirlaz/llvm that referenced this pull request Sep 7, 2020
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants