Skip to content

Conversation

@gmlueck
Copy link
Contributor

@gmlueck gmlueck commented Apr 17, 2025

We discovered one other problem with the vec specification during implementation. The conversion operator from a swizzle to a vec with the same number of elements currently has a constraint that disables the conversion for a 1-element swizzle. This prevents code like this from compiling:

void foo(sycl::vec<int, 1>) {}

int main() {
  sycl::vec<int, 2> v;
  foo(v.swizzle<1>());
}

I think this slipped through the cracks because at one point we were thinking that the variadic vec constructor would handle this conversion. However, we ended up adding a constraint to that variadic constructor which disables it for 1-element parameters. As a result the variadic constructor does not handle this case.

The CTS already tests this case, so the CTS will not pass in its current form unless an implementation removes the constraint as shown in this PR.

We discovered one other problem with the `vec` specification during
implementation.  The conversion operator from a swizzle to a `vec` with
the same number of elements currently has a constraint that disables
the conversion for a 1-element swizzle.  This prevents code like this
from compiling:

```
void foo(sycl::vec<int, 1>) {}

int main() {
  sycl::vec<int, 2> v;
  foo(v.swizzle<1>());
}
```

I think this slipped through the cracks because at one point we were
thinking that the variadic `vec` constructor would handle this
conversion.  However, we ended up adding a constraint to that variadic
constructor which disables it for 1-element parameters.  As a result
the variadic constructor does not handle this case.

The CTS already tests this case, so the CTS will not pass in its
current form unless an implementation removes the constraint as shown
in this PR.
Copy link
Member

@keryell keryell left a comment

Choose a reason for hiding this comment

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

Thanks!

@gmlueck
Copy link
Contributor Author

gmlueck commented Apr 24, 2025

WG approved to merge
OK to cherry-pick to SYCL-2020

@gmlueck gmlueck merged commit 9b72a4b into KhronosGroup:main Apr 24, 2025
4 checks passed
gmlueck added a commit to gmlueck/SYCL-Docs that referenced this pull request Apr 24, 2025
Cherry pick KhronosGroup#800 from main
(cherry picked from commit 9b72a4b)
@gmlueck gmlueck deleted the gmlueck/vec-swizzle-1-conversion branch April 25, 2025 12:52
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.

3 participants