Skip to content

Conversation

@bader
Copy link
Contributor

@bader bader commented Dec 2, 2025

SYCL standard doesn't require supporting C assert() function in device
code. Move checks from the device code to the host code.

SYCL standard doesn't require supporting C assert() function in device
code. Move checks from the device code to the host code.
@bader bader requested a review from a team as a code owner December 2, 2025 19:36
test_move::evaluate(ptr);
ptr += test_move::result_count;
assert(static_cast<std::ptrdiff_t>(result_count) == ptr - results.data());
assert(*ptr);
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this supposed to be a property the SYCL implementation needs to uphold, in which case this should be:

Suggested change
assert(*ptr);
CHECK(*ptr);

, or is it an invariant that if broken would indicate a programming bug in the test itself? (In which case assert is fine).

Using assert for testing would be wrong because it is disabled in Release builds!

Copy link
Contributor Author

@bader bader Dec 3, 2025

Choose a reason for hiding this comment

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

I assume the later.
This seems to be a common pattern in common reference semantics checks -

CHECK(vec[i++]);
assert(result_count == i);
.

Copy link
Member

Choose a reason for hiding this comment

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

Perhaps using assert() was a bad design but it was before using Catch2.

Probably nowadays using CHECK() is better.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Both are fine if used properly. @Maetveis provided a good justification for using assert in his comment.

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 for the fix.

test_move::evaluate(ptr);
ptr += test_move::result_count;
assert(static_cast<std::ptrdiff_t>(result_count) == ptr - results.data());
assert(*ptr);
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps using assert() was a bad design but it was before using Catch2.

Probably nowadays using CHECK() is better.

@bader
Copy link
Contributor Author

bader commented Dec 11, 2025

@tomdeakin, can we merge this PR?

@tomdeakin
Copy link
Contributor

WG approved to merge.

@tomdeakin tomdeakin merged commit c4bb6e3 into KhronosGroup:main Dec 18, 2025
9 checks passed
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.

4 participants