Skip to content

[SYCL] Implement SYCL 2020 multi_ptr #6893

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 22 commits into from
Oct 13, 2022

Conversation

steffenlarsen
Copy link
Contributor

@steffenlarsen steffenlarsen commented Sep 28, 2022

This commit adds implementations of SYCL 2020 multi_ptr and address_space_cast. Likewise it adds the legacy decoration for SYCL 1.2.1 style multi_ptr as deprecated.
To prevent breaking user code the legacy decoration is made the default.

Test-suite changes: intel/llvm-test-suite#1293

This commit adds implementations of SYCL 2020 multi_ptr and
address_space_cast. Likewise it adds the legacy decoration for SYCL
1.2.1 style multi_ptr as deprecated.
To prevent breaking user code the legacy decoration is made the default.

Signed-off-by: Larsen, Steffen <[email protected]>
Signed-off-by: Larsen, Steffen <[email protected]>
Signed-off-by: Larsen, Steffen <[email protected]>
getPointerAdjusted would accidentally drop the address space of the
qualified pointer, in turn causing an address-space cast when creating
a multi_ptr from it. To avoid this, getPointerAdjusted is made auto to
pick return type based on getQualifiedPtr rather than always
address-space-less.

Signed-off-by: Larsen, Steffen <[email protected]>
Copy link
Contributor

@Naghasan Naghasan left a comment

Choose a reason for hiding this comment

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

Nice work which highlighted some spec issues.

You seem to pick by default the decorated interface regardless of whether you need the interface to return decorated pointers or not. I would advice to favour the decorated::no over decorated::yes. The reason is decorated::yes uses types that requires extension to C++ to be built therefore it requires the user to understand this for them to cope with this. The version with decorated::no doesn't require require any extension from a user perspective (unless they use get_decorated). While your patch doesn't trigger unintended exposure, it implicitly encourages it.

Comment on lines 369 to 372
auto DestP = multi_ptr<VecT, DestS, DestIsDecorated>(
reinterpret_cast<VecT *>(Dest.get()));
auto SrcP = multi_ptr<VecT, SrcS, SrcIsDecorated>(
reinterpret_cast<VecT *>(Src.get()));
Copy link
Contributor

Choose a reason for hiding this comment

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

that's not using the spec interface, spec is missing a cast operator ...

spec compliant work around

Suggested change
auto DestP = multi_ptr<VecT, DestS, DestIsDecorated>(
reinterpret_cast<VecT *>(Dest.get()));
auto SrcP = multi_ptr<VecT, SrcS, SrcIsDecorated>(
reinterpret_cast<VecT *>(Src.get()));
auto DestP = address_space_cast<VecT, DestS, DestIsDecorated>(
reinterpret_cast<VecT *>(Dest.get()));
auto SrcP = address_space_cast<VecT, SrcS, SrcIsDecorated>(
reinterpret_cast<VecT *>(Src.get()));

(potentially uses DPC++ extension to strip away address space via the reinterpret cast)

Ideally you would have

Suggested change
auto DestP = multi_ptr<VecT, DestS, DestIsDecorated>(
reinterpret_cast<VecT *>(Dest.get()));
auto SrcP = multi_ptr<VecT, SrcS, SrcIsDecorated>(
reinterpret_cast<VecT *>(Src.get()));
auto DestP = address_space_cast<VecT, DestS, DestIsDecorated>(
reinterpret_cast<VecT *>(Dest.get_raw()));
auto SrcP = address_space_cast<VecT, SrcS, SrcIsDecorated>(
reinterpret_cast<VecT *>(Src.get_raw()));

but we would need to add get_raw to the legacy interface.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have made the first changes, i.e. the work-around. Should this be brought to SYCL-Docs?

@steffenlarsen steffenlarsen requested a review from a team as a code owner September 30, 2022 14:21
@steffenlarsen steffenlarsen requested a review from a team as a code owner October 5, 2022 09:29
Copy link
Contributor

@gmlueck gmlueck left a comment

Choose a reason for hiding this comment

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

Changes to extension specifications LGTM.

Copy link
Contributor

@smanna12 smanna12 left a comment

Choose a reason for hiding this comment

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

FE changes LGTM

Copy link
Contributor

@dkhaldi dkhaldi left a comment

Choose a reason for hiding this comment

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

Changes in matrix LGTM

@steffenlarsen steffenlarsen requested a review from Naghasan October 7, 2022 10:01
@bader
Copy link
Contributor

bader commented Oct 7, 2022

@steffenlarsen, please, resolve merge conflicts. It looks easy to do, but I think I'll mess-up formatting.

@steffenlarsen
Copy link
Contributor Author

@intel/llvm-reviewers-runtime | @KseniyaTikhomirova - Friendly ping.

Signed-off-by: Larsen, Steffen <[email protected]>
Copy link
Contributor

@Naghasan Naghasan left a comment

Choose a reason for hiding this comment

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

Thanks for the updates :)

@steffenlarsen
Copy link
Contributor Author

/verify with intel/llvm-test-suite#1293

@steffenlarsen
Copy link
Contributor Author

/verify with intel/llvm-test-suite#1293

1 similar comment
@steffenlarsen
Copy link
Contributor Author

/verify with intel/llvm-test-suite#1293

@steffenlarsen steffenlarsen merged commit 8700b76 into intel:sycl Oct 13, 2022
steffenlarsen added a commit to steffenlarsen/llvm that referenced this pull request Oct 13, 2022
intel#6893 added support for SYCL 2020
multi_ptr as well as a fix to one of the operators. The fixed operator
did however retain an unused parameter. This commit removes this unused
parameter.

Signed-off-by: Larsen, Steffen <[email protected]>
steffenlarsen added a commit that referenced this pull request Oct 13, 2022
#6893 added support for SYCL 2020
multi_ptr as well as a fix to one of the operators. The fixed operator
did however retain an unused parameter. This commit removes this unused
parameter.

Signed-off-by: Larsen, Steffen <[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.