Skip to content

Commit

Permalink
Further verbosity added
Browse files Browse the repository at this point in the history
Signed-off-by: Alberto Cabrera <[email protected]>
  • Loading branch information
Alcpz committed Nov 1, 2024
1 parent 8a2b72e commit 60b9108
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
39 changes: 39 additions & 0 deletions sycl/test-e2e/syclcompat/math/math_fixt.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,42 @@ template <typename... ValueT> struct should_skip {
}
};

#define CHECK_PRINT(ResultT, RESULT, EXPECTED) \
if constexpr (std::is_integral_v<ResultT>) { \
std::cerr << "RESULT == EXPECTED" << std::endl; \
std::cerr << RESULT << " == " << EXPECTED << std::endl; \
} else if constexpr (contained_is_integral_v<ResultT>) { \
for (size_t i = 0; i < RESULT.size(); i++) { \
std::cerr << i << " RESULT[i] == EXPECTED[i]" << std::endl; \
std::cerr << i << " " << RESULT[i] << " == " << EXPECTED[i] \
<< std::endl; \
} \
} else if constexpr (syclcompat::is_floating_point_v<ResultT>) { \
if (syclcompat::detail::isnan(RESULT)) { \
std::cerr << "syclcompat::detail::isnan(EXPECTED)" << std::endl; \
std::cerr << syclcompat::detail::isnan(EXPECTED) << std::endl; \
} else { \
std::cerr << "fabs(RESULT - EXPECTED) < ERROR_TOLERANCE" << std::endl; \
std::cerr << fabs(RESULT - EXPECTED) << " < " << ERROR_TOLERANCE \
<< std::endl; \
} \
} else if constexpr (contained_is_floating_point_v<ResultT>) { \
for (size_t i = 0; i < RESULT.size(); i++) { \
if (syclcompat::detail::isnan(RESULT[i])) { \
std::cerr << i << " syclcompat::detail::isnan(EXPECTED[i])" \
<< std::endl; \
std::cerr << syclcompat::detail::isnan(EXPECTED[i]) << std::endl; \
} else { \
std::cerr << i << " fabs(RESULT[i] - EXPECTED[i]) < ERROR_TOLERANCE" \
<< std::endl; \
std::cerr << i << " " << fabs(RESULT[i] - EXPECTED[i]) << " < " \
<< ERROR_TOLERANCE << std::endl; \
} \
} \
} else { \
static_assert(0, "math_fixt.hpp should not have arrived here."); \
}

#define CHECK(ResultT, RESULT, EXPECTED) \
if constexpr (std::is_integral_v<ResultT>) { \
assert(RESULT == EXPECTED); \
Expand Down Expand Up @@ -174,6 +210,7 @@ class BinaryOpTestLauncher : OpTestLauncher {
syclcompat::memcpy<ResultT>(&res_h_, res_, data_size_);

// CHECK(ResultT, res_h_, expected);
CHECK_PRINT(ResultT, res_h_, expected);
};

template <auto Kernel>
Expand All @@ -187,6 +224,7 @@ class BinaryOpTestLauncher : OpTestLauncher {
syclcompat::memcpy<ResultT>(&res_h_, res_, data_size_);

// CHECK(ResultT, res_h_, expected);
CHECK_PRINT(ResultT, res_h_, expected);
};
template <auto Kernel>
void launch_test(ValueT op1, ValueU op2, ResultT expected, bool expected_hi,
Expand All @@ -204,6 +242,7 @@ class BinaryOpTestLauncher : OpTestLauncher {
syclcompat::memcpy<bool>(&res_lo_h_, res_lo_, 1);

// CHECK(ResultT, res_h_, expected);
CHECK_PRINT(ResultT, res_h_, expected);
assert(res_hi_h_ == expected_hi);
assert(res_lo_h_ == expected_lo);
};
Expand Down
5 changes: 5 additions & 0 deletions sycl/test-e2e/syclcompat/math/math_ops.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,16 +188,21 @@ void test_container_syclcompat_fmax_nan() {
<< std::bitset<8 * sizeof(ValueTU)>(op5[1]) << std::endl;
std::cerr << "ResBitset: " << std::bitset<8 * sizeof(ValueTU)>(res2[0]) << " "
<< std::bitset<8 * sizeof(ValueTU)>(res2[1]) << std::endl;

BinaryOpTestLauncher<ContT, ContU>(grid, threads)
.template launch_test<fmax_nan_kernel<ContT, ContU>>(op4, op5, res2);

std::cerr << "Second container test: " << std::endl;
std::cerr << "Op4: " << op4[0] << " " << op4[1] << std::endl;
std::cerr << "Op6: " << op6[0] << " " << op6[1] << std::endl;
std::cerr << "Res: " << op6_res[0] << " " << op6_res[1] << std::endl;
std::cerr << "Op4: " << std::bitset<8 * sizeof(ValueTU)>(op4[0]) << " "
<< std::bitset<8 * sizeof(ValueTU)>(op4[1]) << std::endl;
std::cerr << "Op6: " << std::bitset<8 * sizeof(ValueTU)>(op6[0]) << " "
<< std::bitset<8 * sizeof(ValueTU)>(op6[1]) << std::endl;
std::cerr << "Res: " << std::bitset<8 * sizeof(ValueTU)>(op6_res[0]) << " "
<< std::bitset<8 * sizeof(ValueTU)>(op6_res[1]) << std::endl;

BinaryOpTestLauncher<ContT, ContU>(grid, threads)
.template launch_test<fmax_nan_kernel<ContT, ContU>>(op4, op6, op6_res);
}
Expand Down

0 comments on commit 60b9108

Please sign in to comment.