Skip to content

Commit

Permalink
Draft: Disabled checks, added verbosity, to trigger full log in the C…
Browse files Browse the repository at this point in the history
…I at the end of specific tests

Signed-off-by: Alberto Cabrera <[email protected]>
  • Loading branch information
Alcpz committed Nov 1, 2024
1 parent 58f0069 commit 71fdf11
Show file tree
Hide file tree
Showing 3 changed files with 123 additions and 75 deletions.
109 changes: 63 additions & 46 deletions sycl/test-e2e/syclcompat/math/math_compare.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,14 @@ void compare_not_equal_vec_kernel(Container *a, Container *b, Container *r) {
*r = syclcompat::compare(*a, *b, std::not_equal_to<>());
}

template <template <typename T, int Dim> typename ContainerT,
typename ValueT> void test_compare_vec() {
template <template <typename T, int Dim> typename ContainerT, typename ValueT>
void test_compare_vec() {
std::cout << __PRETTY_FUNCTION__ << std::endl;
using Container = ContainerT<ValueT, 2>;

constexpr syclcompat::dim3 grid{1};
constexpr syclcompat::dim3 threads{1};
const Container op1 = {static_cast<ValueT>(1.0),
static_cast<ValueT>(2.0)};
const Container op1 = {static_cast<ValueT>(1.0), static_cast<ValueT>(2.0)};
Container op2 = {static_cast<ValueT>(1.0),
sycl::nan(static_cast<unsigned int>(0))};

Expand Down Expand Up @@ -178,27 +177,47 @@ void unordered_compare_not_equal_vec_kernel(Container *a, Container *b,
*r = syclcompat::unordered_compare(*a, *b, std::not_equal_to<>());
}

template <template <typename T, int Dim> typename ContainerT,
typename ValueT> void test_unordered_compare_vec() {
template <template <typename T, int Dim> typename ContainerT, typename ValueT>
void test_unordered_compare_vec() {
std::cout << __PRETTY_FUNCTION__ << std::endl;
std::cerr << __PRETTY_FUNCTION__ << std::endl;
using Container = ContainerT<ValueT, 2>;

constexpr syclcompat::dim3 grid{1};
constexpr syclcompat::dim3 threads{1};
const Container op1 = {static_cast<ValueT>(1.0),
static_cast<ValueT>(2.0)};
const Container op1 = {static_cast<ValueT>(1.0), static_cast<ValueT>(2.0)};
Container op2 = {static_cast<ValueT>(1.0),
sycl::nan(static_cast<unsigned int>(0))};

// bool2 does not exist, 1.0 and 0.0 floats are used for true
// and false instead.
// 1.0 == 1.0, 2.0 == NaN -> {true, true}
const Container res1 = {1.0, 1.0};
std::cerr << "- 1.0 == 1.0, 2.0 == NaN -> {true, true}: " << std::endl;
std::cerr << "Op1: " << op1[0] << " " << op1[1] << std::endl;
std::cerr << "op2: " << op2[0] << " " << op2[1] << std::endl;
std::cerr << "Res: " << res1[0] << " " << res1[1] << std::endl;
std::cerr << "BitSet: " << std::bitset<8 * sizeof(ValueT)>(op1[0]) << " "
<< std::bitset<8 * sizeof(ValueT)>(op1[1]) << std::endl;
std::cerr << "BitSet2: " << std::bitset<8 * sizeof(ValueT)>(op2[0]) << " "
<< std::bitset<8 * sizeof(ValueT)>(op2[1]) << std::endl;
std::cerr << "ResBitset: " << std::bitset<8 * sizeof(ValueT)>(res1[0]) << " "
<< std::bitset<8 * sizeof(ValueT)>(res1[1]) << std::endl;
BinaryOpTestLauncher<Container, Container>(grid, threads)
.template launch_test<unordered_compare_equal_vec_kernel<Container>>(
op1, op2, res1);
// 1.0 != 1.0, 2.0 != NaN -> {false, true}
const Container res2 = {0.0, 1.0};
std::cerr << "- 1.0 != 1.0, 2.0 != NaN -> {false, true}: " << std::endl;
std::cerr << "Op1: " << op1[0] << " " << op1[1] << std::endl;
std::cerr << "op2: " << op2[0] << " " << op2[1] << std::endl;
std::cerr << "Res: " << res2[0] << " " << res2[1] << std::endl;
std::cerr << "BitSet: " << std::bitset<8 * sizeof(ValueT)>(op1[0]) << " "
<< std::bitset<8 * sizeof(ValueT)>(op1[1]) << std::endl;
std::cerr << "BitSet2: " << std::bitset<8 * sizeof(ValueT)>(op2[0]) << " "
<< std::bitset<8 * sizeof(ValueT)>(op2[1]) << std::endl;
std::cerr << "ResBitset: " << std::bitset<8 * sizeof(ValueT)>(res2[0]) << " "
<< std::bitset<8 * sizeof(ValueT)>(res2[1]) << std::endl;
BinaryOpTestLauncher<Container, Container>(grid, threads)
.template launch_test<unordered_compare_not_equal_vec_kernel<Container>>(
op1, op2, res2);
Expand All @@ -209,15 +228,14 @@ void compare_both_kernel(Container *a, Container *b, bool *r) {
*r = syclcompat::compare_both(*a, *b, std::equal_to<>());
}

template <template <typename T, int Dim> typename ContainerT,
typename ValueT> void test_compare_both() {
template <template <typename T, int Dim> typename ContainerT, typename ValueT>
void test_compare_both() {
std::cout << __PRETTY_FUNCTION__ << std::endl;
using Container = ContainerT<ValueT, 2>;

constexpr syclcompat::dim3 grid{1};
constexpr syclcompat::dim3 threads{1};
const Container op1 = {static_cast<ValueT>(1.0),
static_cast<ValueT>(2.0)};
const Container op1 = {static_cast<ValueT>(1.0), static_cast<ValueT>(2.0)};
Container op2 = {static_cast<ValueT>(1.0),
sycl::nan(static_cast<unsigned int>(0))};

Expand All @@ -239,15 +257,14 @@ void unordered_compare_both_kernel(Container *a, Container *b, bool *r) {
*r = syclcompat::unordered_compare_both(*a, *b, std::equal_to<>());
}

template <template <typename T, int Dim> typename ContainerT,
typename ValueT> void test_unordered_compare_both() {
template <template <typename T, int Dim> typename ContainerT, typename ValueT>
void test_unordered_compare_both() {
std::cout << __PRETTY_FUNCTION__ << std::endl;
using Container = ContainerT<ValueT, 2>;

constexpr syclcompat::dim3 grid{1};
constexpr syclcompat::dim3 threads{1};
const Container op1 = {static_cast<ValueT>(1.0),
static_cast<ValueT>(2.0)};
const Container op1 = {static_cast<ValueT>(1.0), static_cast<ValueT>(2.0)};
Container op2 = {static_cast<ValueT>(1.0),
sycl::nan(static_cast<unsigned int>(0))};

Expand All @@ -270,21 +287,17 @@ void compare_mask_kernel(Container *a, Container *b, unsigned *r) {
*r = syclcompat::compare_mask(*a, *b, std::equal_to<>());
}

template <template <typename T, int Dim> typename ContainerT,
typename ValueT> void test_compare_mask() {
template <template <typename T, int Dim> typename ContainerT, typename ValueT>
void test_compare_mask() {
std::cout << __PRETTY_FUNCTION__ << std::endl;
using Container = ContainerT<ValueT, 2>;

constexpr syclcompat::dim3 grid{1};
constexpr syclcompat::dim3 threads{1};
const Container op1 = {static_cast<ValueT>(1.0),
static_cast<ValueT>(2.0)};
const Container op2 = {static_cast<ValueT>(2.0),
static_cast<ValueT>(1.0)};
const Container op3 = {static_cast<ValueT>(1.0),
static_cast<ValueT>(3.0)};
const Container op4 = {static_cast<ValueT>(3.0),
static_cast<ValueT>(2.0)};
const Container op1 = {static_cast<ValueT>(1.0), static_cast<ValueT>(2.0)};
const Container op2 = {static_cast<ValueT>(2.0), static_cast<ValueT>(1.0)};
const Container op3 = {static_cast<ValueT>(1.0), static_cast<ValueT>(3.0)};
const Container op4 = {static_cast<ValueT>(3.0), static_cast<ValueT>(2.0)};
Container op5 = {sycl::nan(static_cast<unsigned int>(0)),
sycl::nan(static_cast<unsigned int>(0))};

Expand Down Expand Up @@ -319,21 +332,17 @@ void unordered_compare_mask_kernel(Container *a, Container *b, unsigned *r) {
*r = syclcompat::unordered_compare_mask(*a, *b, std::equal_to<>());
}

template <template <typename T, int Dim> typename ContainerT,
typename ValueT> void test_unordered_compare_mask() {
template <template <typename T, int Dim> typename ContainerT, typename ValueT>
void test_unordered_compare_mask() {
std::cout << __PRETTY_FUNCTION__ << std::endl;
using Container = ContainerT<ValueT, 2>;

constexpr syclcompat::dim3 grid{1};
constexpr syclcompat::dim3 threads{1};
const Container op1 = {static_cast<ValueT>(1.0),
static_cast<ValueT>(2.0)};
const Container op2 = {static_cast<ValueT>(2.0),
static_cast<ValueT>(1.0)};
const Container op3 = {static_cast<ValueT>(1.0),
static_cast<ValueT>(3.0)};
const Container op4 = {static_cast<ValueT>(3.0),
static_cast<ValueT>(2.0)};
const Container op1 = {static_cast<ValueT>(1.0), static_cast<ValueT>(2.0)};
const Container op2 = {static_cast<ValueT>(2.0), static_cast<ValueT>(1.0)};
const Container op3 = {static_cast<ValueT>(1.0), static_cast<ValueT>(3.0)};
const Container op4 = {static_cast<ValueT>(3.0), static_cast<ValueT>(2.0)};
Container op5 = {sycl::nan(static_cast<unsigned int>(0)),
sycl::nan(static_cast<unsigned int>(0))};

Expand Down Expand Up @@ -368,16 +377,24 @@ int main() {
INSTANTIATE_ALL_TYPES(fp_type_list, test_unordered_compare);
INSTANTIATE_ALL_CONTAINER_TYPES(fp_type_list, sycl::vec, test_compare_vec);
INSTANTIATE_ALL_CONTAINER_TYPES(fp_type_list, sycl::marray, test_compare_vec);
INSTANTIATE_ALL_CONTAINER_TYPES(fp_type_list, sycl::vec, test_unordered_compare_vec);
INSTANTIATE_ALL_CONTAINER_TYPES(fp_type_list, sycl::marray, test_unordered_compare_vec);
INSTANTIATE_ALL_CONTAINER_TYPES(fp_type_list, sycl::vec,
test_unordered_compare_vec);
INSTANTIATE_ALL_CONTAINER_TYPES(fp_type_list, sycl::marray,
test_unordered_compare_vec);
INSTANTIATE_ALL_CONTAINER_TYPES(fp_type_list, sycl::vec, test_compare_both);
INSTANTIATE_ALL_CONTAINER_TYPES(fp_type_list, sycl::marray, test_compare_both);
INSTANTIATE_ALL_CONTAINER_TYPES(fp_type_list, sycl::vec, test_unordered_compare_both);
INSTANTIATE_ALL_CONTAINER_TYPES(fp_type_list, sycl::marray, test_unordered_compare_both);
INSTANTIATE_ALL_CONTAINER_TYPES(fp_type_list, sycl::marray,
test_compare_both);
INSTANTIATE_ALL_CONTAINER_TYPES(fp_type_list, sycl::vec,
test_unordered_compare_both);
INSTANTIATE_ALL_CONTAINER_TYPES(fp_type_list, sycl::marray,
test_unordered_compare_both);
INSTANTIATE_ALL_CONTAINER_TYPES(fp_type_list, sycl::vec, test_compare_mask);
INSTANTIATE_ALL_CONTAINER_TYPES(fp_type_list, sycl::marray, test_compare_mask);
INSTANTIATE_ALL_CONTAINER_TYPES(fp_type_list, sycl::vec, test_unordered_compare_mask);
INSTANTIATE_ALL_CONTAINER_TYPES(fp_type_list, sycl::marray, test_unordered_compare_mask);

return 0;
INSTANTIATE_ALL_CONTAINER_TYPES(fp_type_list, sycl::marray,
test_compare_mask);
INSTANTIATE_ALL_CONTAINER_TYPES(fp_type_list, sycl::vec,
test_unordered_compare_mask);
INSTANTIATE_ALL_CONTAINER_TYPES(fp_type_list, sycl::marray,
test_unordered_compare_mask);

return 1;
}
9 changes: 5 additions & 4 deletions sycl/test-e2e/syclcompat/math/math_fixt.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ template <typename T, typename U> struct container_common_type<T, U> {
template <typename T, typename U>
using container_common_type_t = typename container_common_type<T, U>::type;

template <typename ...ValueT> struct should_skip {
template <typename... ValueT> struct should_skip {
bool operator()(const sycl::device &dev) const {
if constexpr ((std::is_same_v<ValueT, double> || ...) ||
(contained_is_same_v<ValueT, double> || ...)) {
Expand Down Expand Up @@ -173,8 +173,9 @@ class BinaryOpTestLauncher : OpTestLauncher {
syclcompat::wait();
syclcompat::memcpy<ResultT>(&res_h_, res_, data_size_);

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

template <auto Kernel>
void launch_test(ValueT op1, ValueU op2, ResultT expected, bool need_relu) {
if (skip_)
Expand All @@ -185,7 +186,7 @@ class BinaryOpTestLauncher : OpTestLauncher {
syclcompat::wait();
syclcompat::memcpy<ResultT>(&res_h_, res_, data_size_);

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

CHECK(ResultT, res_h_, expected);
// CHECK(ResultT, res_h_, expected);
assert(res_hi_h_ == expected_hi);
assert(res_lo_h_ == expected_lo);
};
Expand Down
Loading

0 comments on commit 71fdf11

Please sign in to comment.