Skip to content

[SYCL] Fix operator- for sycl::vec<bool, N> #11816

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 1 commit into from
Nov 8, 2023

Conversation

frasercrmck
Copy link
Contributor

Since bool vectors have a backing storage of chars, the unary minus operator was in fact producing (char)-1, and thus not adhering to the ABI where bools should be either 0 or 1.

This could manifest itself in bugs, for instance where the "bool" elements wouldn't compare equal to other bools, such as those in arrays.

This only manifested itself in device code (possibly because the array of bools is also an array of bytes under the hood), hence the test case that differs in style somewhat from the rest.

Since bool vectors have a backing storage of chars, the unary minus
operator was in fact producing `(char)-1`, and thus not adhering to the
ABI where bools should be either 0 or 1.

This could manifest itself in bugs, for instance where the "bool"
elements wouldn't compare equal to other bools, such as those in arrays.

This only manifested itself in device code (possibly because the array
of bools is also an array of bytes under the hood), hence the test case
that differs in style somewhat from the rest.
@frasercrmck frasercrmck requested a review from a team as a code owner November 8, 2023 15:18
Copy link
Contributor

@steffenlarsen steffenlarsen left a comment

Choose a reason for hiding this comment

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

Good catch! 🚀

@againull againull merged commit 1b201d8 into intel:sycl Nov 8, 2023
@frasercrmck frasercrmck deleted the fix-operator-minus-vec-bool branch November 8, 2023 18:40
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