Skip to content

Commit

Permalink
Verbosity added to asserts to see if we get more info from race condi…
Browse files Browse the repository at this point in the history
…tion

Signed-off-by: Alberto Cabrera <[email protected]>
  • Loading branch information
Alcpz committed Nov 4, 2024
1 parent a464fd0 commit 1f9f67e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
9 changes: 7 additions & 2 deletions sycl/test-e2e/syclcompat/math/math_fixt.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,20 @@ template <typename... ValueT> struct should_skip {

#define CHECK(ResultT, RESULT, EXPECTED) \
if constexpr (std::is_integral_v<ResultT>) { \
assert(RESULT == EXPECTED); \
assert(RESULT == EXPECTED || \
!(std::cerr << "-- " << RESULT << " - " << EXPECTED << " --")); \
} else if constexpr (contained_is_integral_v<ResultT>) { \
for (size_t i = 0; i < RESULT.size(); i++) \
assert(RESULT[i] == EXPECTED[i]); \
assert(RESULT[i] == EXPECTED[i] || \
!(std::cerr << "-- " << RESULT[i] << " - " << EXPECTED[i] \
<< " --")); \
} else if constexpr (syclcompat::is_floating_point_v<ResultT>) { \
if (syclcompat::detail::isnan(RESULT)) \
assert(syclcompat::detail::isnan(EXPECTED)); \
else \
assert(fabs(RESULT - EXPECTED) < ERROR_TOLERANCE); \
!(std::cerr << "-- " << RESULT << " - " << EXPECTED \
<< " < " << ERROR_TOLERANCE << "-- ")); \
} else if constexpr (contained_is_floating_point_v<ResultT>) { \
for (size_t i = 0; i < RESULT.size(); i++) { \
if (syclcompat::detail::isnan(RESULT[i])) { \
Expand Down
5 changes: 4 additions & 1 deletion sycl/test-e2e/syclcompat/math/math_length_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,10 @@ class LengthLauncher {
float sum =
std::inner_product(result.begin(), result.end(), result.begin(), 0.0f);
float diff = fabs(sqrtf(sum)) - host_result_;
assert(diff <= 1.e-5);
assert(diff <= 1.e-5 || !(std::cerr << "-- " << fabs(sqrtf(sum)) << " - "
<< host_result_ << " < "
<< "1.e-5"
<< " --"));
}

template <auto F> void launch(std::vector<float> vec) {
Expand Down
4 changes: 3 additions & 1 deletion sycl/test-e2e/syclcompat/math/repro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ void test_container_syclcompat_fmax_nan() {

constexpr float ERROR_TOLERANCE = 1e-6;
for (size_t i = 0; i < 2; i++) {
assert((res[i] - expected[i]) < ERROR_TOLERANCE);
assert((res[i] - expected[i]) < ERROR_TOLERANCE ||
!(std::cerr << "-- " << res[i] << " - " << expected[i] << " < "
<< ERROR_TOLERANCE << " --"));
}

const sycl::vec<float, 2> op3 = {sycl::nan(static_cast<unsigned int>(0)),
Expand Down

0 comments on commit 1f9f67e

Please sign in to comment.