From 761b05467d6b66c4a7c70a3a161b782cbc528f66 Mon Sep 17 00:00:00 2001 From: Alberto Cabrera Date: Mon, 4 Nov 2024 20:52:02 +0000 Subject: [PATCH] Verbosity added to asserts to see if we get more info from race condition Signed-off-by: Alberto Cabrera --- sycl/test-e2e/syclcompat/math/math_fixt.hpp | 11 ++++++++--- sycl/test-e2e/syclcompat/math/math_length_test.cpp | 5 ++++- sycl/test-e2e/syclcompat/math/repro.cpp | 4 +++- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/sycl/test-e2e/syclcompat/math/math_fixt.hpp b/sycl/test-e2e/syclcompat/math/math_fixt.hpp index f9dfb6a6c7b4..fa493f69f994 100644 --- a/sycl/test-e2e/syclcompat/math/math_fixt.hpp +++ b/sycl/test-e2e/syclcompat/math/math_fixt.hpp @@ -92,15 +92,20 @@ template struct should_skip { #define CHECK(ResultT, RESULT, EXPECTED) \ if constexpr (std::is_integral_v) { \ - assert(RESULT == EXPECTED); \ + assert(RESULT == EXPECTED || \ + !(std::cerr << "-- " << RESULT << " - " << EXPECTED << " --")); \ } else if constexpr (contained_is_integral_v) { \ 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) { \ 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) { \ for (size_t i = 0; i < RESULT.size(); i++) { \ if (syclcompat::detail::isnan(RESULT[i])) { \ @@ -108,7 +113,7 @@ template struct should_skip { } else { \ assert((fabs(RESULT[i] - EXPECTED[i]) < ERROR_TOLERANCE) || \ !(std::cerr << "-- " << RESULT[i] << " - " << EXPECTED[i] \ - << " < " << ERROR_TOLERANCE << "-- ")); \ + << " < " << ERROR_TOLERANCE << "-- "); \ } \ } \ } else { \ diff --git a/sycl/test-e2e/syclcompat/math/math_length_test.cpp b/sycl/test-e2e/syclcompat/math/math_length_test.cpp index 24effadfa539..dd43994ea08a 100644 --- a/sycl/test-e2e/syclcompat/math/math_length_test.cpp +++ b/sycl/test-e2e/syclcompat/math/math_length_test.cpp @@ -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 void launch(std::vector vec) { diff --git a/sycl/test-e2e/syclcompat/math/repro.cpp b/sycl/test-e2e/syclcompat/math/repro.cpp index bfdde546dc8a..714978280fa2 100644 --- a/sycl/test-e2e/syclcompat/math/repro.cpp +++ b/sycl/test-e2e/syclcompat/math/repro.cpp @@ -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 op3 = {sycl::nan(static_cast(0)),