Skip to content
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] Changes to vec/swizzle implementation #14789

Draft
wants to merge 87 commits into
base: sycl
Choose a base branch
from

Conversation

aelovikov-intel
Copy link
Contributor

@aelovikov-intel aelovikov-intel commented Jul 26, 2024

  • Remove expression trees functionality from swizzles following the clarifications made by the SYCL 2020 specification
  • Make several previously templated functions non-templated (as they should be according to the specification) as well as aligning other availability constraints with the spec.
  • Make named single element (.x()/.r()/etc.) return a swizzle vs previously returned reference to a scalar
  • Unify implementation of certain features between sycl::vec and swizzles (named swizzles and multiple binary/unary/op-assign operators)
  • Simplified implementation of the vec::(const ArgTys... &args) ctor

Deviations from the specifications added as part of this PR:

  • Added non-standard copy-assignment operator for swizzle type. Otherwise, depending on the implementation it might either be implicitly deleted or implicitly defined (potentially with counterintuitive/unintended behavior)
  • vec::(const ArgTys... &args) ctor - add an additional NumElements > 1 requirement to resolve the following ambiguity otherwise present with the current is_convertible implementation (a pre-existing deviation from the spec, see below):
  sycl::vec<sycl::half, 1> v{1};  // float/double are ok
  v = 2;     // ambiguous
  v.x() = 3; // ambiguous

Other known remaining differences from the specification inherited from the previous implementation:

  • vec::(const ArgTys... &args) ctor requirements have been weaker (std::is_convertible_v<T, DataT>) than required by the specification (must be an exact match of the element_type). Also, unlike the specification, it allows args to be swizzles (in addition to scalars and vecs).
  • vec(const vector_t &) ctor is still templated to avoid ambiguity with vec(const DataT &) for one-element vectors
  • std::byte support, in particular how some hidden friend operators aren't available and non-standard shift operators are implemented instead, e.g. operator<<(const Self &, int)

Newly added test is mostly copied from @steffenlarsen 's #13026.

@aelovikov-intel

This comment was marked as outdated.

@aelovikov-intel aelovikov-intel changed the title [SYCL] Refactor swizzle implementation, remove expression trees [SYCL] Refactor vec/swizzle implementation, remove expression trees Jul 26, 2024
@aelovikov-intel aelovikov-intel marked this pull request as draft July 26, 2024 18:35
@aelovikov-intel aelovikov-intel marked this pull request as ready for review July 29, 2024 20:50
@aelovikov-intel

This comment was marked as outdated.

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.

7 participants