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

Extend helper assert with generic comparison and print message on success #383

Merged
merged 2 commits into from
Dec 18, 2024

Conversation

rafbiels
Copy link
Contributor

In a recent workshop participants were repeatedly confused by the lack of output in the exercises and kept asking if no output means success. Make the SYCLACADEMY_ASSERT macro print [SUCCESS] Test passed on success and [FAILURE] ... with the same message as before on failure.

There was a lot of code like:

for (int i = 0; i < 1024; ++i) {
  SYCLACADEMY_ASSERT(out[i] == i * 4.0f);
}

It would be silly for the program to print 1024 lines of the same success message, so replace this kind of comparison with a new SYCL_ACADEMY_ASSERT_EQUAL macro which implements a generic comparison function supporting element-wise comparison of arrays/vectors and only calls the SYCLACADEMY_ASSERT once, and therefore prints SUCCESS/FAILURE once.

Code_Exercises/helpers.hpp Outdated Show resolved Hide resolved
Enforce a semicolon is placed after the macro call
and that the code formats correctly in conditional
statements.
@DuncanMcBain DuncanMcBain merged commit 36710e3 into codeplaysoftware:main Dec 18, 2024
1 check 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.

2 participants