Skip to content

[SYCL][Doc] Update address_cast specification #12689

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
Feb 28, 2024

Conversation

Pennycook
Copy link
Contributor

This PR contains three improvements to the specification:

  • Default address_cast to no decoration.
  • Add overloads for generic multi_ptr.
  • Add address_space shorthands.

This allows developers using generic raw pointers to cast to multi_ptr without worrying about decoration:

float* ptr = ...;
auto mptr = syclex::static_address_cast<syclex::local_space>(ptr);

...or to opt-in to decoration by using a generic multi-pointer, which propagates decoration information:

multi_ptr<float, syclex::generic_space, access::decorated::yes> decorated_in = ...;
auto decorated_out = syclex::static_address_cast<syclex::local_space>(decorated_in);

@Pennycook Pennycook added the spec extension All issues/PRs related to extensions specifications label Feb 12, 2024
@Pennycook Pennycook requested a review from a team as a code owner February 12, 2024 16:22
Comment on lines +102 to 105
template <access::address_space Space,
typename ElementType>
multi_ptr<ElementType, Space, DecorateAddress>
multi_ptr<ElementType, Space, access::decorated::no>
static_address_cast(ElementType* ptr);
Copy link
Contributor

Choose a reason for hiding this comment

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

out of curiosity, why removing the possibility to select the yes/no decoration ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The logic was that there shouldn't be two ways to do the same thing, because that's harder to teach.

Before this change, *_address_cast functions could be used to cast between address spaces and to introduce decoration. Now, they can only be used to cast between address spaces, which is aligned with their name.

multi_ptr already provides interfaces to move between decorated and undecorated pointers (via implicit casts), so we don't need to handle it here as well.

@Pennycook
Copy link
Contributor Author

@intel/llvm-gatekeepers I think this can be merged now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
spec extension All issues/PRs related to extensions specifications
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants