-
Notifications
You must be signed in to change notification settings - Fork 91
Hoist assert from the device code. #1157
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
Conversation
SYCL standard doesn't require supporting C assert() function in device code. Move checks from the device code to the host code.
| test_move::evaluate(ptr); | ||
| ptr += test_move::result_count; | ||
| assert(static_cast<std::ptrdiff_t>(result_count) == ptr - results.data()); | ||
| assert(*ptr); |
There was a problem hiding this comment.
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:
| 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!
There was a problem hiding this comment.
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 -
SYCL-CTS/tests/common/semantics_reference.h
Lines 68 to 70 in b7c8385
| CHECK(vec[i++]); | |
| assert(result_count == i); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
keryell
left a comment
There was a problem hiding this 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); |
There was a problem hiding this comment.
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.
|
@tomdeakin, can we merge this PR? |
|
WG approved to merge. |
SYCL standard doesn't require supporting C assert() function in device
code. Move checks from the device code to the host code.