From 65d028f31a6994b1d4dbcdb2206d5dbb8872ec51 Mon Sep 17 00:00:00 2001 From: "Larsen, Steffen" Date: Fri, 17 Nov 2023 05:20:58 -0800 Subject: [PATCH] Test marray on device This commit makes marray tests run checks on both device and host, where they would only run on host previously. Signed-off-by: Larsen, Steffen --- tests/marray/marray_common.h | 5 + tests/marray/marray_constructor.h | 124 ++-- tests/marray/marray_members.h | 150 +++-- tests/marray/marray_operators.h | 538 ++++++++++++++++-- ...y_operators_arithmetic_assignment_core.cpp | 34 ++ ...y_operators_arithmetic_assignment_fp16.cpp | 46 ++ ...y_operators_arithmetic_assignment_fp64.cpp | 45 ++ ...array_operators_arithmetic_binary_core.cpp | 34 ++ ...array_operators_arithmetic_binary_fp16.cpp | 45 ++ ...array_operators_arithmetic_binary_fp64.cpp | 45 ++ ...rray_operators_bitwise_assignment_core.cpp | 34 ++ ...rray_operators_bitwise_assignment_fp16.cpp | 46 ++ ...rray_operators_bitwise_assignment_fp64.cpp | 45 ++ .../marray_operators_bitwise_binary_core.cpp | 34 ++ .../marray_operators_bitwise_binary_fp16.cpp | 45 ++ .../marray_operators_bitwise_binary_fp64.cpp | 45 ++ .../marray_operators_post_unary_core.cpp | 34 ++ .../marray_operators_post_unary_fp16.cpp | 45 ++ .../marray_operators_post_unary_fp64.cpp | 45 ++ ...pp => marray_operators_pre_unary_core.cpp} | 8 +- ...pp => marray_operators_pre_unary_fp16.cpp} | 8 +- ...pp => marray_operators_pre_unary_fp64.cpp} | 8 +- ...array_operators_relational_binary_core.cpp | 34 ++ ...array_operators_relational_binary_fp16.cpp | 45 ++ ...array_operators_relational_binary_fp64.cpp | 45 ++ 25 files changed, 1432 insertions(+), 155 deletions(-) create mode 100644 tests/marray/marray_operators_arithmetic_assignment_core.cpp create mode 100644 tests/marray/marray_operators_arithmetic_assignment_fp16.cpp create mode 100644 tests/marray/marray_operators_arithmetic_assignment_fp64.cpp create mode 100644 tests/marray/marray_operators_arithmetic_binary_core.cpp create mode 100644 tests/marray/marray_operators_arithmetic_binary_fp16.cpp create mode 100644 tests/marray/marray_operators_arithmetic_binary_fp64.cpp create mode 100644 tests/marray/marray_operators_bitwise_assignment_core.cpp create mode 100644 tests/marray/marray_operators_bitwise_assignment_fp16.cpp create mode 100644 tests/marray/marray_operators_bitwise_assignment_fp64.cpp create mode 100644 tests/marray/marray_operators_bitwise_binary_core.cpp create mode 100644 tests/marray/marray_operators_bitwise_binary_fp16.cpp create mode 100644 tests/marray/marray_operators_bitwise_binary_fp64.cpp create mode 100644 tests/marray/marray_operators_post_unary_core.cpp create mode 100644 tests/marray/marray_operators_post_unary_fp16.cpp create mode 100644 tests/marray/marray_operators_post_unary_fp64.cpp rename tests/marray/{marray_operators_core.cpp => marray_operators_pre_unary_core.cpp} (82%) rename tests/marray/{marray_operators_fp16.cpp => marray_operators_pre_unary_fp16.cpp} (85%) rename tests/marray/{marray_operators_fp64.cpp => marray_operators_pre_unary_fp64.cpp} (86%) create mode 100644 tests/marray/marray_operators_relational_binary_core.cpp create mode 100644 tests/marray/marray_operators_relational_binary_fp16.cpp create mode 100644 tests/marray/marray_operators_relational_binary_fp64.cpp diff --git a/tests/marray/marray_common.h b/tests/marray/marray_common.h index 9cf2b3601..27750e78c 100644 --- a/tests/marray/marray_common.h +++ b/tests/marray/marray_common.h @@ -77,6 +77,11 @@ constexpr sycl::marray iota_marray() { std::make_index_sequence()); } +template +void iota(ForwardIt first, ForwardIt last, T value) { + for (; first != last; ++first) *first = value++; +} + } // namespace marray_common #endif // SYCL_CTS_TEST_MARRAY_MARRAY_COMMON_H diff --git a/tests/marray/marray_constructor.h b/tests/marray/marray_constructor.h index 33524078e..894d1e460 100644 --- a/tests/marray/marray_constructor.h +++ b/tests/marray/marray_constructor.h @@ -31,52 +31,32 @@ template class run_marray_constructor_test { static constexpr std::size_t NumElements = NumElementsT::value; - using marray_t = sycl::marray; + static constexpr size_t num_test_cases = 7; - private: - template = true> - void check_constexpr_single_element() {} + static constexpr const char* check_names[num_test_cases] = { + "default constructor", + "scalar constructor", + "variadic constructor (NumElements DataT instances)", + "variadic constructor (one DataT instance, one marray instance)", + "variadic constructor (one marray instance, one DataT instance)", + "copy constructor", + "copy constructor rval reference"}; - template = true> - void check_constexpr_single_element() { - // one DataT instance, one marray instance - { - constexpr sycl::marray ma_const = - marray_common::iota_marray(); - constexpr marray_t ma{1, ma_const}; - marray_t ma_inc; - std::iota(ma_inc.begin(), ma_inc.end(), 1); - CHECK(value_operations::are_equal(ma_inc, ma)); - } - - // one marray instance, one DataT instance - { - constexpr sycl::marray ma_const = - marray_common::iota_marray(); - constexpr marray_t ma{ma_const, DataT(num_elements)}; - marray_t ma_inc; - std::iota(ma_inc.begin(), ma_inc.end(), 1); - CHECK(value_operations::are_equal(ma_inc, ma)); - } - } - - public: - void operator()(const std::string&) { - INFO("for number of elements \"" << NumElements << "\": "); + using marray_t = sycl::marray; + template + static void run_checks(IteratorT results) { // default constructor { marray_t ma; - CHECK(value_operations::are_equal(ma, DataT{})); + *(results++) = value_operations::are_equal(ma, DataT{}); } // scalar constructor { constexpr DataT value{1}; constexpr marray_t ma{value}; - CHECK(value_operations::are_equal(ma, value)); + *(results++) = value_operations::are_equal(ma, value); } // variadic constructor @@ -84,11 +64,35 @@ class run_marray_constructor_test { // NumElements DataT instances constexpr auto a = marray_common::iota_marray(); marray_t ma_inc; - std::iota(ma_inc.begin(), ma_inc.end(), 1); - CHECK(value_operations::are_equal(ma_inc, a)); + marray_common::iota(ma_inc.begin(), ma_inc.end(), 1); + *(results++) = value_operations::are_equal(ma_inc, a); // only compiled when NumElements != 1 - check_constexpr_single_element(); + if constexpr (NumElements != 1) { + // one DataT instance, one marray instance + { + constexpr sycl::marray ma_const = + marray_common::iota_marray(); + constexpr marray_t ma{1, ma_const}; + marray_t ma_inc; + marray_common::iota(ma_inc.begin(), ma_inc.end(), 1); + *(results++) = value_operations::are_equal(ma_inc, ma); + } + + // one marray instance, one DataT instance + { + constexpr sycl::marray ma_const = + marray_common::iota_marray(); + constexpr marray_t ma{ma_const, DataT(NumElements)}; + marray_t ma_inc; + marray_common::iota(ma_inc.begin(), ma_inc.end(), 1); + *(results++) = value_operations::are_equal(ma_inc, ma); + } + } else { + // Two checks were skipped. + *(results++) = true; + *(results++) = true; + } } // copy constructor @@ -96,7 +100,7 @@ class run_marray_constructor_test { constexpr DataT value{1}; constexpr marray_t rhs{value}; constexpr marray_t ma{rhs}; - CHECK(value_operations::are_equal(ma, value)); + *(results++) = value_operations::are_equal(ma, value); } // copy constructor rval reference @@ -104,8 +108,48 @@ class run_marray_constructor_test { constexpr marray_t ma{ marray_common::iota_marray()}; marray_t ma_inc; - std::iota(ma_inc.begin(), ma_inc.end(), 1); - CHECK(value_operations::are_equal(ma_inc, ma)); + marray_common::iota(ma_inc.begin(), ma_inc.end(), 1); + *(results++) = value_operations::are_equal(ma_inc, ma); + } + } + + public: + void operator()(const std::string&) { + INFO("for number of elements \"" << NumElements << "\": "); + + { + INFO("validation on host"); + + bool check_results[num_test_cases] = {false}; + run_checks(check_results); + for (size_t i = 0; i < num_test_cases; ++i) { + INFO(check_names[i]); + CHECK(check_results[i]); + } + } + + { + INFO("validation on device"); + + auto queue = sycl_cts::util::get_cts_object::queue(); + bool check_results[num_test_cases] = {false}; + { + sycl::buffer check_results_buff{ + check_results, sycl::range<1>{num_test_cases}}; + + queue + .submit([&](sycl::handler& cgh) { + sycl::accessor check_results_acc{check_results_buff, cgh, + sycl::read_write}; + cgh.single_task([=]() { run_checks(check_results_acc.begin()); }); + }) + .wait_and_throw(); + } + run_checks(check_results); + for (size_t i = 0; i < num_test_cases; ++i) { + INFO(check_names[i]); + CHECK(check_results[i]); + } } } }; diff --git a/tests/marray/marray_members.h b/tests/marray/marray_members.h index 6c763e34e..49ad9f60a 100644 --- a/tests/marray/marray_members.h +++ b/tests/marray/marray_members.h @@ -32,116 +32,176 @@ template class run_marray_members_test { static constexpr std::size_t NumElements = NumElementsT::value; - using marray_t = sycl::marray; - - private: - template = true> - void check_conversion() {} - - template = true> - void check_conversion() { - marray_t ma_inc; - std::iota(ma_inc.begin(), ma_inc.end(), 1); - DataT t{ma_inc}; - CHECK((t == DataT{1})); - } + static constexpr size_t num_test_cases = 19; + + static constexpr const char* check_names[num_test_cases] = { + "implicit conversion", + "size() (noexcept)", + "size() (result)", + "operator[] (before write)", + "operator[] (after write)", + "const operator[]", + "operator=(marray)", + "operator=(T)", + "iterator (increment)", + "iterator (decrement)", + "iterator (equivalence)", + "const iterator (increment)", + "const iterator (decrement)", + "const iterator (equivalence)", + "value_type", + "reference", + "const_reference", + "iterator", + "const_iterator", + }; - public: - void operator()(const std::string&) { - INFO("for number of elements \"" << NumElements << "\": "); + using marray_t = sycl::marray; + template + static void run_checks(IteratorT results) { // implicit conversion { // only compiled when NumElements == 1 - check_conversion(); + if constexpr (NumElements == 1) { + marray_t ma_inc; + marray_common::iota(ma_inc.begin(), ma_inc.end(), 1); + DataT t{ma_inc}; + *(results++) = (t == DataT{1}); + } else { + // One check were skipped. + *(results++) = true; + } } // size() { marray_t ma_inc; - std::iota(ma_inc.begin(), ma_inc.end(), 1); - CHECK(noexcept(ma_inc.size())); - CHECK((ma_inc.size() == NumElements)); + marray_common::iota(ma_inc.begin(), ma_inc.end(), 1); + *(results++) = noexcept(ma_inc.size()); + *(results++) = (ma_inc.size() == NumElements); } // operator[] { marray_t ma_inc; - std::iota(ma_inc.begin(), ma_inc.end(), 1); - CHECK((ma_inc[0] == DataT{1})); + marray_common::iota(ma_inc.begin(), ma_inc.end(), 1); + *(results++) = (ma_inc[0] == DataT{1}); ma_inc[0] = DataT{0}; - CHECK((ma_inc[0] == DataT{0})); + *(results++) = (ma_inc[0] == DataT{0}); } // const operator[] { marray_t ma_inc; - std::iota(ma_inc.begin(), ma_inc.end(), 1); + marray_common::iota(ma_inc.begin(), ma_inc.end(), 1); const marray_t ma_const{ma_inc}; - CHECK((ma_const[0] == DataT{1})); + *(results++) = (ma_const[0] == DataT{1}); } // operator=(marray) { marray_t ma_inc; - std::iota(ma_inc.begin(), ma_inc.end(), 1); + marray_common::iota(ma_inc.begin(), ma_inc.end(), 1); const marray_t ma_const{ma_inc}; marray_t ma_tmp{DataT{0}}; ma_tmp = ma_const; - CHECK(value_operations::are_equal(ma_tmp, ma_const)); + *(results++) = value_operations::are_equal(ma_tmp, ma_const); } // operator=(T) { marray_t ma_tmp{DataT{0}}; ma_tmp = DataT{1}; - CHECK(value_operations::are_equal(ma_tmp, marray_t(DataT(1)))); + *(results++) = value_operations::are_equal(ma_tmp, marray_t(DataT(1))); } // iterator { marray_t ma_inc; - std::iota(ma_inc.begin(), ma_inc.end(), 1); + marray_common::iota(ma_inc.begin(), ma_inc.end(), 1); auto it_ma = ma_inc.begin(); auto it_ma_tmp = it_ma; it_ma++; if (NumElements > 1) { - CHECK((*it_ma == DataT(2))); + *(results++) = (*it_ma == DataT(2)); + } else { + *(results++) = true; } it_ma--; - CHECK((*it_ma == DataT(1))); - CHECK((it_ma == it_ma_tmp)); + *(results++) = (*it_ma == DataT(1)); + *(results++) = (it_ma == it_ma_tmp); } // const iterator { marray_t ma_inc; - std::iota(ma_inc.begin(), ma_inc.end(), 1); + marray_common::iota(ma_inc.begin(), ma_inc.end(), 1); const marray_t ma_const = ma_inc; auto it_ma = ma_const.begin(); auto it_ma_tmp = it_ma; it_ma++; if (NumElements > 1) { - CHECK((*it_ma == DataT(2))); + *(results++) = (*it_ma == DataT(2)); + } else { + *(results++) = true; } it_ma--; - CHECK((*it_ma == DataT(1))); - CHECK((it_ma == it_ma_tmp)); + *(results++) = (*it_ma == DataT(1)); + *(results++) = (it_ma == it_ma_tmp); } // member types { - STATIC_CHECK(std::is_same_v); - STATIC_CHECK(std::is_same_v); - STATIC_CHECK( - std::is_same_v); - STATIC_CHECK(std::is_same_v); - STATIC_CHECK( - std::is_same_v); + *(results++) = std::is_same_v; + *(results++) = std::is_same_v; + *(results++) = + std::is_same_v; + *(results++) = std::is_same_v; + *(results++) = + std::is_same_v; + } + } + + public: + void operator()(const std::string&) { + INFO("for number of elements \"" << NumElements << "\": "); + + { + INFO("validation on host"); + + bool check_results[num_test_cases] = {false}; + run_checks(check_results); + for (size_t i = 0; i < num_test_cases; ++i) { + INFO(check_names[i]); + CHECK(check_results[i]); + } + } + + { + INFO("validation on device"); + + auto queue = sycl_cts::util::get_cts_object::queue(); + bool check_results[num_test_cases] = {false}; + { + sycl::buffer check_results_buff{ + check_results, sycl::range<1>{num_test_cases}}; + + queue + .submit([&](sycl::handler& cgh) { + sycl::accessor check_results_acc{check_results_buff, cgh, + sycl::read_write}; + cgh.single_task([=]() { run_checks(check_results_acc.begin()); }); + }) + .wait_and_throw(); + } + run_checks(check_results); + for (size_t i = 0; i < num_test_cases; ++i) { + INFO(check_names[i]); + CHECK(check_results[i]); + } } } }; diff --git a/tests/marray/marray_operators.h b/tests/marray/marray_operators.h index ae2c281d0..f18fa6edf 100644 --- a/tests/marray/marray_operators.h +++ b/tests/marray/marray_operators.h @@ -49,6 +49,31 @@ struct operators_helper { } }; +// Division operations on floating points make no precision guarantees, so +// similar to native::divide we can skip checking them. +template +struct skip_result_check + : std::bool_constant< + (std::is_same_v || std::is_same_v)&&( + std::is_same_v || std::is_same_v || + std::is_same_v)> {}; + +template +constexpr bool skip_result_check_v = skip_result_check::value; + +template +bool are_equal_ignore_division(const T1& lhs, const T1& rhs) { + // Division operations on floating points make no precision guarantees, so + // similar to native::divide we can skip checking them here. + constexpr bool is_div = + std::is_same_v || std::is_same_v; + constexpr bool is_sycl_floating_point = std::is_same_v || + std::is_same_v || + std::is_same_v; + if constexpr (is_div && is_sycl_floating_point) return true; + return value_operations::are_equal(lhs, rhs); +} + /** * @brief Define several sequences to initialize array instances. */ @@ -116,6 +141,47 @@ template ; + template + static void run_on_host(const ResT& res_expected) { + INFO("validation on host"); + + OpT op; + + typename helper::marray_t val_actual; + helper::template init(val_actual); + auto res_actual = op(val_actual); + + CHECK(value_operations::are_equal(res_expected, res_actual)); + } + + template + static void run_on_device(const std::valarray& res_expected) { + INFO("validation on device"); + + auto queue = sycl_cts::util::get_cts_object::queue(); + + sycl::marray res_actual; + { + sycl::buffer res_actual_buff{&res_actual, + sycl::range<1>{1}}; + + queue + .submit([&](sycl::handler& cgh) { + sycl::accessor res_actual_acc{res_actual_buff, cgh, + sycl::write_only}; + cgh.single_task([=]() { + OpT op; + typename helper::marray_t val_actual; + helper::template init(val_actual); + res_actual_acc[0] = op(val_actual); + }); + }) + .wait_and_throw(); + } + + CHECK(value_operations::are_equal(res_expected, res_actual)); + } + public: void operator()(const std::string& function_name) { INFO("for input (sequence) \"" << function_name << "\": "); @@ -126,11 +192,9 @@ class run_unary_sequence { helper::template init(val_expected); auto res_expected = op(val_expected); - typename helper::marray_t val_actual; - helper::template init(val_actual); - auto res_actual = op(val_actual); + run_on_host(res_expected); - CHECK(value_operations::are_equal(res_expected, res_actual)); + run_on_device(res_expected); } }; @@ -161,16 +225,13 @@ template ; - public: - void operator()(const std::string& function_name) { - INFO("for input (sequence) \"" << function_name << "\": "); + template + static void run_on_host(const typename helper::varray_t& val_expected, + const ResT& res_expected) { + INFO("validation on host"); OpT op; - typename helper::varray_t val_expected(helper::NumElements); - helper::template init(val_expected); - auto res_expected = op(val_expected); - typename helper::marray_t val_actual; helper::template init(val_actual); auto res_actual = op(val_actual); @@ -180,6 +241,57 @@ class run_unary_post_sequence { // check the modified input CHECK(value_operations::are_equal(val_expected, val_actual)); } + + template + static void run_on_device(const typename helper::varray_t& val_expected, + const std::valarray& res_expected) { + INFO("validation on device"); + + auto queue = sycl_cts::util::get_cts_object::queue(); + + typename helper::marray_t val_actual; + sycl::marray res_actual; + { + sycl::buffer val_actual_buff{&val_actual, + sycl::range<1>{1}}; + sycl::buffer res_actual_buff{&res_actual, + sycl::range<1>{1}}; + + queue + .submit([&](sycl::handler& cgh) { + sycl::accessor val_actual_acc{val_actual_buff, cgh, + sycl::read_write}; + sycl::accessor res_actual_acc{res_actual_buff, cgh, + sycl::write_only}; + cgh.single_task([=]() { + OpT op; + helper::template init(val_actual_acc[0]); + res_actual_acc[0] = op(val_actual_acc[0]); + }); + }) + .wait_and_throw(); + } + + // check the returned output + CHECK(value_operations::are_equal(res_expected, res_actual)); + // check the modified input + CHECK(value_operations::are_equal(val_expected, val_actual)); + } + + public: + void operator()(const std::string& function_name) { + INFO("for input (sequence) \"" << function_name << "\": "); + + OpT op; + + typename helper::varray_t val_expected(helper::NumElements); + helper::template init(val_expected); + auto res_expected = op(val_expected); + + run_on_host(val_expected, res_expected); + + run_on_device(val_expected, res_expected); + } }; template @@ -199,6 +311,52 @@ template ; + template + static void run_on_host(const ResT& res_expected) { + INFO("validation on host"); + + OpT op; + + typename helper::marray_t lhs_actual; + helper::template init(lhs_actual); + DataT rhs_actual; + helper::template init(rhs_actual); + auto res_actual = op(lhs_actual, rhs_actual); + + CHECK(value_operations::are_equal(res_expected, res_actual)); + } + + template + static void run_on_device(const std::valarray& res_expected) { + INFO("validation on device"); + + auto queue = sycl_cts::util::get_cts_object::queue(); + + sycl::marray res_actual; + { + sycl::buffer res_actual_buff{&res_actual, + sycl::range<1>{1}}; + + queue + .submit([&](sycl::handler& cgh) { + sycl::accessor res_actual_acc{res_actual_buff, cgh, + sycl::write_only}; + cgh.single_task([=]() { + OpT op; + typename helper::marray_t lhs_actual; + helper::template init(lhs_actual); + DataT rhs_actual; + helper::template init(rhs_actual); + res_actual_acc[0] = op(lhs_actual, rhs_actual); + }); + }) + .wait_and_throw(); + } + + if constexpr (!skip_result_check_v) + CHECK(value_operations::are_equal(res_expected, res_actual)); + } + public: void operator()(const std::string& function_name, const std::string& constant_name) { @@ -213,13 +371,9 @@ class run_binary_sequence_scalar { helper::template init(rhs_expected); auto res_expected = op(lhs_expected, rhs_expected); - typename helper::marray_t lhs_actual; - helper::template init(lhs_actual); - DataT rhs_actual; - helper::template init(rhs_actual); - auto res_actual = op(lhs_actual, rhs_actual); + run_on_host(res_expected); - CHECK(value_operations::are_equal(res_expected, res_actual)); + run_on_device(res_expected); } }; @@ -274,6 +428,52 @@ template ; + template + static void run_on_host(const ResT& res_expected) { + INFO("validation on host"); + + OpT op; + + DataT lhs_actual; + helper::template init(lhs_actual); + typename helper::marray_t rhs_actual; + helper::template init(rhs_actual); + auto res_actual = op(lhs_actual, rhs_actual); + + CHECK(value_operations::are_equal(res_expected, res_actual)); + } + + template + static void run_on_device(const std::valarray& res_expected) { + INFO("validation on device"); + + auto queue = sycl_cts::util::get_cts_object::queue(); + + sycl::marray res_actual; + { + sycl::buffer res_actual_buff{&res_actual, + sycl::range<1>{1}}; + + queue + .submit([&](sycl::handler& cgh) { + sycl::accessor res_actual_acc{res_actual_buff, cgh, + sycl::write_only}; + cgh.single_task([=]() { + OpT op; + DataT lhs_actual; + helper::template init(lhs_actual); + typename helper::marray_t rhs_actual; + helper::template init(rhs_actual); + res_actual_acc[0] = op(lhs_actual, rhs_actual); + }); + }) + .wait_and_throw(); + } + + if constexpr (!skip_result_check_v) + CHECK(value_operations::are_equal(res_expected, res_actual)); + } + public: void operator()(const std::string& constant_name, const std::string& function_name) { @@ -294,13 +494,9 @@ class run_binary_scalar_sequence { helper::template init(rhs_expected); auto res_expected = op(lhs_expected, rhs_expected); - DataT lhs_actual; - helper::template init(lhs_actual); - typename helper::marray_t rhs_actual; - helper::template init(rhs_actual); - auto res_actual = op(lhs_actual, rhs_actual); + run_on_host(res_expected); - CHECK(value_operations::are_equal(res_expected, res_actual)); + run_on_device(res_expected); } }; @@ -309,6 +505,52 @@ template ; + template + static void run_on_host(const ResT& res_expected) { + INFO("validation on host"); + + OpT op; + + typename helper::marray_t lhs_actual; + helper::template init(lhs_actual); + typename helper::marray_t rhs_actual; + helper::template init(rhs_actual); + auto res_actual = op(lhs_actual, rhs_actual); + + CHECK(value_operations::are_equal(res_expected, res_actual)); + } + + template + static void run_on_device(const std::valarray& res_expected) { + INFO("validation on device"); + + auto queue = sycl_cts::util::get_cts_object::queue(); + + sycl::marray res_actual; + { + sycl::buffer res_actual_buff{&res_actual, + sycl::range<1>{1}}; + + queue + .submit([&](sycl::handler& cgh) { + sycl::accessor res_actual_acc{res_actual_buff, cgh, + sycl::write_only}; + cgh.single_task([=]() { + OpT op; + typename helper::marray_t lhs_actual; + helper::template init(lhs_actual); + typename helper::marray_t rhs_actual; + helper::template init(rhs_actual); + res_actual_acc[0] = op(lhs_actual, rhs_actual); + }); + }) + .wait_and_throw(); + } + + if constexpr (!skip_result_check_v) + CHECK(value_operations::are_equal(res_expected, res_actual)); + } + public: void operator()(const std::string& function_name_1, const std::string& function_name_2) { @@ -329,13 +571,9 @@ class run_binary_sequence_sequence { helper::template init(rhs_expected); auto res_expected = op(lhs_expected, rhs_expected); - typename helper::marray_t lhs_actual; - helper::template init(lhs_actual); - typename helper::marray_t rhs_actual; - helper::template init(rhs_actual); - auto res_actual = op(lhs_actual, rhs_actual); + run_on_host(res_expected); - CHECK(value_operations::are_equal(res_expected, res_actual)); + run_on_device(res_expected); } }; @@ -375,6 +613,66 @@ template ; + template + static void run_on_host(const typename helper::varray_t& lhs_expected, + const ResT& res_expected) { + INFO("validation on host"); + + OpT op; + + typename helper::marray_t lhs_actual; + helper::template init(lhs_actual); + DataT rhs_actual; + helper::template init(rhs_actual); + auto res_actual = op(lhs_actual, rhs_actual); + + // check the returned output + CHECK(value_operations::are_equal(res_expected, res_actual)); + // check the modified input + CHECK(value_operations::are_equal(lhs_expected, lhs_actual)); + } + + template + static void run_on_device(const typename helper::varray_t& lhs_expected, + const std::valarray& res_expected) { + INFO("validation on device"); + + auto queue = sycl_cts::util::get_cts_object::queue(); + + typename helper::marray_t lhs_actual; + sycl::marray res_actual; + { + sycl::buffer lhs_actual_buff{&lhs_actual, + sycl::range<1>{1}}; + sycl::buffer res_actual_buff{&res_actual, + sycl::range<1>{1}}; + + queue + .submit([&](sycl::handler& cgh) { + sycl::accessor lhs_actual_acc{lhs_actual_buff, cgh, + sycl::read_write}; + sycl::accessor res_actual_acc{res_actual_buff, cgh, + sycl::write_only}; + cgh.single_task([=]() { + OpT op; + typename helper::marray_t lhs_actual; + helper::template init(lhs_actual_acc[0]); + DataT rhs_actual; + helper::template init(rhs_actual); + res_actual_acc[0] = op(lhs_actual_acc[0], rhs_actual); + }); + }) + .wait_and_throw(); + } + + if constexpr (!skip_result_check_v) { + // check the returned output + CHECK(value_operations::are_equal(res_expected, res_actual)); + // check the modified input + CHECK(value_operations::are_equal(lhs_expected, lhs_actual)); + } + } + public: void operator()(const std::string& function_name, const std::string& constant_name) { @@ -389,10 +687,28 @@ class run_binary_assignment_sequence_scalar { helper::template init(rhs_expected); auto res_expected = op(lhs_expected, rhs_expected); + run_on_host(lhs_expected, res_expected); + + run_on_device(lhs_expected, res_expected); + } +}; + +template +class run_binary_assignment_sequence_sequence { + using helper = operators_helper; + + template + static void run_on_host(const typename helper::varray_t& lhs_expected, + const ResT& res_expected) { + INFO("validation on host"); + + OpT op; + typename helper::marray_t lhs_actual; - helper::template init(lhs_actual); - DataT rhs_actual; - helper::template init(rhs_actual); + helper::template init(lhs_actual); + typename helper::marray_t rhs_actual; + helper::template init(rhs_actual); auto res_actual = op(lhs_actual, rhs_actual); // check the returned output @@ -400,12 +716,47 @@ class run_binary_assignment_sequence_scalar { // check the modified input CHECK(value_operations::are_equal(lhs_expected, lhs_actual)); } -}; -template -class run_binary_assignment_sequence_sequence { - using helper = operators_helper; + template + static void run_on_device(const typename helper::varray_t& lhs_expected, + const std::valarray& res_expected) { + INFO("validation on device"); + + auto queue = sycl_cts::util::get_cts_object::queue(); + + typename helper::marray_t lhs_actual; + sycl::marray res_actual; + { + sycl::buffer lhs_actual_buff{&lhs_actual, + sycl::range<1>{1}}; + sycl::buffer res_actual_buff{&res_actual, + sycl::range<1>{1}}; + + queue + .submit([&](sycl::handler& cgh) { + sycl::accessor lhs_actual_acc{lhs_actual_buff, cgh, + sycl::read_write}; + sycl::accessor res_actual_acc{res_actual_buff, cgh, + sycl::write_only}; + cgh.single_task([=]() { + OpT op; + typename helper::marray_t lhs_actual; + helper::template init(lhs_actual_acc[0]); + typename helper::marray_t rhs_actual; + helper::template init(rhs_actual); + res_actual_acc[0] = op(lhs_actual_acc[0], rhs_actual); + }); + }) + .wait_and_throw(); + } + + if constexpr (!skip_result_check_v) { + // check the returned output + CHECK(value_operations::are_equal(res_expected, res_actual)); + // check the modified input + CHECK(value_operations::are_equal(lhs_expected, lhs_actual)); + } + } public: void operator()(const std::string& function_name_1, @@ -427,16 +778,9 @@ class run_binary_assignment_sequence_sequence { helper::template init(rhs_expected); auto res_expected = op(lhs_expected, rhs_expected); - typename helper::marray_t lhs_actual; - helper::template init(lhs_actual); - typename helper::marray_t rhs_actual; - helper::template init(rhs_actual); - auto res_actual = op(lhs_actual, rhs_actual); + run_on_host(lhs_expected, res_expected); - // check the returned output - CHECK(value_operations::are_equal(res_expected, res_actual)); - // check the modified input - CHECK(value_operations::are_equal(lhs_expected, lhs_actual)); + run_on_device(lhs_expected, res_expected); } }; @@ -472,10 +816,10 @@ class run_binary_assignment< }; template -class check_marray_operators_for_type { +class check_marray_pre_unary_operators_for_type { public: void operator()(const std::string& type_name) { - INFO("for type \"" << type_name << "\": "); + INFO("prefix unary operators for type \"" << type_name << "\": "); const auto num_elements = marray_common::get_num_elements(); @@ -484,28 +828,106 @@ class check_marray_operators_for_type { op_bnot>::generate("unary +", "unary -", "pre ++", "pre --", "!", "~"); for_all_combinations(num_elements, unary_operators); + } +}; + +template +class check_marray_post_unary_operators_for_type { + public: + void operator()(const std::string& type_name) { + INFO("suffix unary operators for type \"" << type_name << "\": "); + + const auto num_elements = marray_common::get_num_elements(); static const auto unary_post_operators = named_type_pack::generate("post ++", "post --"); for_all_combinations(num_elements, unary_post_operators); + } +}; + +template +class check_marray_arithmetic_binary_operators_for_type { + public: + void operator()(const std::string& type_name) { + INFO("arithmetic binary operators for type \"" << type_name << "\": "); + + const auto num_elements = marray_common::get_num_elements(); + + static const auto binary_operators = + named_type_pack::generate( + "+", "-", "*", "/", "%"); + + for_all_combinations(num_elements, binary_operators); + } +}; + +template +class check_marray_bitwise_binary_operators_for_type { + public: + void operator()(const std::string& type_name) { + INFO("bitwise binary operators for type \"" << type_name << "\": "); + + const auto num_elements = marray_common::get_num_elements(); + + static const auto binary_operators = + named_type_pack::generate( + "|", "&", "^", "<<", ">>"); + + for_all_combinations(num_elements, binary_operators); + } +}; + +template +class check_marray_relational_binary_operators_for_type { + public: + void operator()(const std::string& type_name) { + INFO("relational binary operators for type \"" << type_name << "\": "); + + const auto num_elements = marray_common::get_num_elements(); + static const auto binary_operators = - named_type_pack::generate("+", "-", "*", "/", "%", "|", "&", - "^", "<<", ">>", "==", "!=", "<", ">", - "<=", ">=", "&&", "||"); + named_type_pack::generate("==", "!=", + "<", ">", "<=", + ">=", "&&", + "||"); for_all_combinations(num_elements, binary_operators); + } +}; + +template +class check_marray_arithmetic_assignment_operators_for_type { + public: + void operator()(const std::string& type_name) { + INFO("arithmetic assignment for type \"" << type_name << "\": "); + + const auto num_elements = marray_common::get_num_elements(); static const auto binary_assignment_operators = named_type_pack::generate("+=", "-=", "*=", "/=", "%=", - "|=", "&=", "^=", "<<=", ">>="); + op_assign_div, op_assign_mod>::generate("+=", "-=", + "*=", "/=", + "%="); + for_all_combinations( + num_elements, binary_assignment_operators); + } +}; + +template +class check_marray_bitwise_assignment_operators_for_type { + public: + void operator()(const std::string& type_name) { + INFO("bitwise assignment for type \"" << type_name << "\": "); + + const auto num_elements = marray_common::get_num_elements(); + + static const auto binary_assignment_operators = + named_type_pack::generate("|=", "&=", "^=", + "<<=", ">>="); for_all_combinations( num_elements, binary_assignment_operators); } diff --git a/tests/marray/marray_operators_arithmetic_assignment_core.cpp b/tests/marray/marray_operators_arithmetic_assignment_core.cpp new file mode 100644 index 000000000..71efe0caa --- /dev/null +++ b/tests/marray/marray_operators_arithmetic_assignment_core.cpp @@ -0,0 +1,34 @@ +/******************************************************************************* +// +// SYCL 2020 Conformance Test Suite +// +// Copyright (c) 2023 The Khronos Group Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +*******************************************************************************/ + +#include "../common/type_coverage.h" +#include "marray_common.h" +#include "marray_operators.h" + +namespace marray_operators_arithmetic_assignment_core { + +using namespace marray_operators; + +TEST_CASE("arithmetic assignment operators core", "[marray]") { + const auto types = marray_common::get_types(); + for_all_types(types); +} + +} // namespace marray_operators_arithmetic_assignment_core diff --git a/tests/marray/marray_operators_arithmetic_assignment_fp16.cpp b/tests/marray/marray_operators_arithmetic_assignment_fp16.cpp new file mode 100644 index 000000000..99d7b1bf3 --- /dev/null +++ b/tests/marray/marray_operators_arithmetic_assignment_fp16.cpp @@ -0,0 +1,46 @@ +/******************************************************************************* +// +// SYCL 2020 Conformance Test Suite +// +// Copyright (c) 2023 The Khronos Group Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +*******************************************************************************/ + +#include "../../util/extensions.h" +#include "../common/type_coverage.h" +#include "marray_common.h" +#include "marray_operators.h" + +namespace marray_operators_arithmetic_assignment_fp16 { + +using namespace sycl_cts; +using namespace marray_operators; + +TEST_CASE("arithmetic assignment operators fp16", "[marray]") { + auto queue = util::get_cts_object::queue(); + using availability = + util::extensions::availability; + if (!availability::check(queue)) { + WARN( + "Device does not support half precision floating point operations." + "Skipping the test case."); + return; + } + + check_marray_arithmetic_assignment_operators_for_type{}( + "sycl::half"); +} + +} // namespace marray_operators_arithmetic_assignment_fp16 diff --git a/tests/marray/marray_operators_arithmetic_assignment_fp64.cpp b/tests/marray/marray_operators_arithmetic_assignment_fp64.cpp new file mode 100644 index 000000000..f1cfa655a --- /dev/null +++ b/tests/marray/marray_operators_arithmetic_assignment_fp64.cpp @@ -0,0 +1,45 @@ +/******************************************************************************* +// +// SYCL 2020 Conformance Test Suite +// +// Copyright (c) 2023 The Khronos Group Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +*******************************************************************************/ + +#include "../../util/extensions.h" +#include "../common/type_coverage.h" +#include "marray_common.h" +#include "marray_operators.h" + +namespace marray_operators_arithmetic_assignment_fp64 { + +using namespace sycl_cts; +using namespace marray_operators; + +TEST_CASE("arithmetic assignment operators fp64", "[marray]") { + auto queue = util::get_cts_object::queue(); + using availability = + util::extensions::availability; + if (!availability::check(queue)) { + WARN( + "Device does not support double precision floating point operations." + "Skipping the test case."); + return; + } + + check_marray_arithmetic_assignment_operators_for_type{}("double"); +} + +} // namespace marray_operators_arithmetic_assignment_fp64 diff --git a/tests/marray/marray_operators_arithmetic_binary_core.cpp b/tests/marray/marray_operators_arithmetic_binary_core.cpp new file mode 100644 index 000000000..70aec8261 --- /dev/null +++ b/tests/marray/marray_operators_arithmetic_binary_core.cpp @@ -0,0 +1,34 @@ +/******************************************************************************* +// +// SYCL 2020 Conformance Test Suite +// +// Copyright (c) 2023 The Khronos Group Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +*******************************************************************************/ + +#include "../common/type_coverage.h" +#include "marray_common.h" +#include "marray_operators.h" + +namespace marray_operators_arithmetic_binary_core { + +using namespace marray_operators; + +TEST_CASE("arithmetic binary operators core", "[marray]") { + const auto types = marray_common::get_types(); + for_all_types(types); +} + +} // namespace marray_operators_arithmetic_binary_core diff --git a/tests/marray/marray_operators_arithmetic_binary_fp16.cpp b/tests/marray/marray_operators_arithmetic_binary_fp16.cpp new file mode 100644 index 000000000..db37523ef --- /dev/null +++ b/tests/marray/marray_operators_arithmetic_binary_fp16.cpp @@ -0,0 +1,45 @@ +/******************************************************************************* +// +// SYCL 2020 Conformance Test Suite +// +// Copyright (c) 2023 The Khronos Group Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +*******************************************************************************/ + +#include "../../util/extensions.h" +#include "../common/type_coverage.h" +#include "marray_common.h" +#include "marray_operators.h" + +namespace marray_operators_arithmetic_binary_fp16 { + +using namespace sycl_cts; +using namespace marray_operators; + +TEST_CASE("arithmetic binary operators fp16", "[marray]") { + auto queue = util::get_cts_object::queue(); + using availability = + util::extensions::availability; + if (!availability::check(queue)) { + WARN( + "Device does not support half precision floating point operations." + "Skipping the test case."); + return; + } + + check_marray_arithmetic_binary_operators_for_type{}("sycl::half"); +} + +} // namespace marray_operators_arithmetic_binary_fp16 diff --git a/tests/marray/marray_operators_arithmetic_binary_fp64.cpp b/tests/marray/marray_operators_arithmetic_binary_fp64.cpp new file mode 100644 index 000000000..133106244 --- /dev/null +++ b/tests/marray/marray_operators_arithmetic_binary_fp64.cpp @@ -0,0 +1,45 @@ +/******************************************************************************* +// +// SYCL 2020 Conformance Test Suite +// +// Copyright (c) 2023 The Khronos Group Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +*******************************************************************************/ + +#include "../../util/extensions.h" +#include "../common/type_coverage.h" +#include "marray_common.h" +#include "marray_operators.h" + +namespace marray_operators_arithmetic_binary_fp64 { + +using namespace sycl_cts; +using namespace marray_operators; + +TEST_CASE("arithmetic binary operators fp64", "[marray]") { + auto queue = util::get_cts_object::queue(); + using availability = + util::extensions::availability; + if (!availability::check(queue)) { + WARN( + "Device does not support double precision floating point operations." + "Skipping the test case."); + return; + } + + check_marray_arithmetic_binary_operators_for_type{}("double"); +} + +} // namespace marray_operators_arithmetic_binary_fp64 diff --git a/tests/marray/marray_operators_bitwise_assignment_core.cpp b/tests/marray/marray_operators_bitwise_assignment_core.cpp new file mode 100644 index 000000000..831680058 --- /dev/null +++ b/tests/marray/marray_operators_bitwise_assignment_core.cpp @@ -0,0 +1,34 @@ +/******************************************************************************* +// +// SYCL 2020 Conformance Test Suite +// +// Copyright (c) 2023 The Khronos Group Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +*******************************************************************************/ + +#include "../common/type_coverage.h" +#include "marray_common.h" +#include "marray_operators.h" + +namespace marray_operators_bitwise_assignment_core { + +using namespace marray_operators; + +TEST_CASE("bitwise assignment operators core", "[marray]") { + const auto types = marray_common::get_types(); + for_all_types(types); +} + +} // namespace marray_operators_bitwise_assignment_core diff --git a/tests/marray/marray_operators_bitwise_assignment_fp16.cpp b/tests/marray/marray_operators_bitwise_assignment_fp16.cpp new file mode 100644 index 000000000..561ba1467 --- /dev/null +++ b/tests/marray/marray_operators_bitwise_assignment_fp16.cpp @@ -0,0 +1,46 @@ +/******************************************************************************* +// +// SYCL 2020 Conformance Test Suite +// +// Copyright (c) 2023 The Khronos Group Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +*******************************************************************************/ + +#include "../../util/extensions.h" +#include "../common/type_coverage.h" +#include "marray_common.h" +#include "marray_operators.h" + +namespace marray_operators_bitwise_assignment_fp16 { + +using namespace sycl_cts; +using namespace marray_operators; + +TEST_CASE("bitwise assignment operators fp16", "[marray]") { + auto queue = util::get_cts_object::queue(); + using availability = + util::extensions::availability; + if (!availability::check(queue)) { + WARN( + "Device does not support half precision floating point operations." + "Skipping the test case."); + return; + } + + check_marray_bitwise_assignment_operators_for_type{}( + "sycl::half"); +} + +} // namespace marray_operators_bitwise_assignment_fp16 diff --git a/tests/marray/marray_operators_bitwise_assignment_fp64.cpp b/tests/marray/marray_operators_bitwise_assignment_fp64.cpp new file mode 100644 index 000000000..19315cdc2 --- /dev/null +++ b/tests/marray/marray_operators_bitwise_assignment_fp64.cpp @@ -0,0 +1,45 @@ +/******************************************************************************* +// +// SYCL 2020 Conformance Test Suite +// +// Copyright (c) 2023 The Khronos Group Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +*******************************************************************************/ + +#include "../../util/extensions.h" +#include "../common/type_coverage.h" +#include "marray_common.h" +#include "marray_operators.h" + +namespace marray_operators_bitwise_assignment_fp64 { + +using namespace sycl_cts; +using namespace marray_operators; + +TEST_CASE("bitwise assignment operators fp64", "[marray]") { + auto queue = util::get_cts_object::queue(); + using availability = + util::extensions::availability; + if (!availability::check(queue)) { + WARN( + "Device does not support double precision floating point operations." + "Skipping the test case."); + return; + } + + check_marray_bitwise_assignment_operators_for_type{}("double"); +} + +} // namespace marray_operators_bitwise_assignment_fp64 diff --git a/tests/marray/marray_operators_bitwise_binary_core.cpp b/tests/marray/marray_operators_bitwise_binary_core.cpp new file mode 100644 index 000000000..4d60d581c --- /dev/null +++ b/tests/marray/marray_operators_bitwise_binary_core.cpp @@ -0,0 +1,34 @@ +/******************************************************************************* +// +// SYCL 2020 Conformance Test Suite +// +// Copyright (c) 2023 The Khronos Group Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +*******************************************************************************/ + +#include "../common/type_coverage.h" +#include "marray_common.h" +#include "marray_operators.h" + +namespace marray_operators_bitwise_binary_core { + +using namespace marray_operators; + +TEST_CASE("bitwise binary operators core", "[marray]") { + const auto types = marray_common::get_types(); + for_all_types(types); +} + +} // namespace marray_operators_bitwise_binary_core diff --git a/tests/marray/marray_operators_bitwise_binary_fp16.cpp b/tests/marray/marray_operators_bitwise_binary_fp16.cpp new file mode 100644 index 000000000..6f671d10d --- /dev/null +++ b/tests/marray/marray_operators_bitwise_binary_fp16.cpp @@ -0,0 +1,45 @@ +/******************************************************************************* +// +// SYCL 2020 Conformance Test Suite +// +// Copyright (c) 2023 The Khronos Group Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +*******************************************************************************/ + +#include "../../util/extensions.h" +#include "../common/type_coverage.h" +#include "marray_common.h" +#include "marray_operators.h" + +namespace marray_operators_bitwise_binary_fp16 { + +using namespace sycl_cts; +using namespace marray_operators; + +TEST_CASE("bitwise binary operators fp16", "[marray]") { + auto queue = util::get_cts_object::queue(); + using availability = + util::extensions::availability; + if (!availability::check(queue)) { + WARN( + "Device does not support half precision floating point operations." + "Skipping the test case."); + return; + } + + check_marray_bitwise_binary_operators_for_type{}("sycl::half"); +} + +} // namespace marray_operators_bitwise_binary_fp16 diff --git a/tests/marray/marray_operators_bitwise_binary_fp64.cpp b/tests/marray/marray_operators_bitwise_binary_fp64.cpp new file mode 100644 index 000000000..ac1b36924 --- /dev/null +++ b/tests/marray/marray_operators_bitwise_binary_fp64.cpp @@ -0,0 +1,45 @@ +/******************************************************************************* +// +// SYCL 2020 Conformance Test Suite +// +// Copyright (c) 2023 The Khronos Group Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +*******************************************************************************/ + +#include "../../util/extensions.h" +#include "../common/type_coverage.h" +#include "marray_common.h" +#include "marray_operators.h" + +namespace marray_operators_bitwise_binary_fp64 { + +using namespace sycl_cts; +using namespace marray_operators; + +TEST_CASE("bitwise binary operators fp64", "[marray]") { + auto queue = util::get_cts_object::queue(); + using availability = + util::extensions::availability; + if (!availability::check(queue)) { + WARN( + "Device does not support double precision floating point operations." + "Skipping the test case."); + return; + } + + check_marray_bitwise_binary_operators_for_type{}("double"); +} + +} // namespace marray_operators_bitwise_binary_fp64 diff --git a/tests/marray/marray_operators_post_unary_core.cpp b/tests/marray/marray_operators_post_unary_core.cpp new file mode 100644 index 000000000..2c3c8e089 --- /dev/null +++ b/tests/marray/marray_operators_post_unary_core.cpp @@ -0,0 +1,34 @@ +/******************************************************************************* +// +// SYCL 2020 Conformance Test Suite +// +// Copyright (c) 2023 The Khronos Group Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +*******************************************************************************/ + +#include "../common/type_coverage.h" +#include "marray_common.h" +#include "marray_operators.h" + +namespace marray_operators_post_unary_core { + +using namespace marray_operators; + +TEST_CASE("suffix unary operators core", "[marray]") { + const auto types = marray_common::get_types(); + for_all_types(types); +} + +} // namespace marray_operators_post_unary_core diff --git a/tests/marray/marray_operators_post_unary_fp16.cpp b/tests/marray/marray_operators_post_unary_fp16.cpp new file mode 100644 index 000000000..c20e55359 --- /dev/null +++ b/tests/marray/marray_operators_post_unary_fp16.cpp @@ -0,0 +1,45 @@ +/******************************************************************************* +// +// SYCL 2020 Conformance Test Suite +// +// Copyright (c) 2023 The Khronos Group Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +*******************************************************************************/ + +#include "../../util/extensions.h" +#include "../common/type_coverage.h" +#include "marray_common.h" +#include "marray_operators.h" + +namespace marray_operators_post_unary_fp16 { + +using namespace sycl_cts; +using namespace marray_operators; + +TEST_CASE("suffix unary operators fp16", "[marray]") { + auto queue = util::get_cts_object::queue(); + using availability = + util::extensions::availability; + if (!availability::check(queue)) { + WARN( + "Device does not support half precision floating point operations." + "Skipping the test case."); + return; + } + + check_marray_post_unary_operators_for_type{}("sycl::half"); +} + +} // namespace marray_operators_post_unary_fp16 diff --git a/tests/marray/marray_operators_post_unary_fp64.cpp b/tests/marray/marray_operators_post_unary_fp64.cpp new file mode 100644 index 000000000..e60a44115 --- /dev/null +++ b/tests/marray/marray_operators_post_unary_fp64.cpp @@ -0,0 +1,45 @@ +/******************************************************************************* +// +// SYCL 2020 Conformance Test Suite +// +// Copyright (c) 2023 The Khronos Group Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +*******************************************************************************/ + +#include "../../util/extensions.h" +#include "../common/type_coverage.h" +#include "marray_common.h" +#include "marray_operators.h" + +namespace marray_operators_post_unary_fp64 { + +using namespace sycl_cts; +using namespace marray_operators; + +TEST_CASE("suffix unary operators fp64", "[marray]") { + auto queue = util::get_cts_object::queue(); + using availability = + util::extensions::availability; + if (!availability::check(queue)) { + WARN( + "Device does not support double precision floating point operations." + "Skipping the test case."); + return; + } + + check_marray_post_unary_operators_for_type{}("double"); +} + +} // namespace marray_operators_post_unary_fp64 diff --git a/tests/marray/marray_operators_core.cpp b/tests/marray/marray_operators_pre_unary_core.cpp similarity index 82% rename from tests/marray/marray_operators_core.cpp rename to tests/marray/marray_operators_pre_unary_core.cpp index c7060104f..ffd05f707 100644 --- a/tests/marray/marray_operators_core.cpp +++ b/tests/marray/marray_operators_pre_unary_core.cpp @@ -22,13 +22,13 @@ #include "marray_common.h" #include "marray_operators.h" -namespace marray_operators_core { +namespace marray_operators_pre_unary_core { using namespace marray_operators; -TEST_CASE("operators core", "[marray]") { +TEST_CASE("prefix unary operators core", "[marray]") { const auto types = marray_common::get_types(); - for_all_types(types); + for_all_types(types); } -} // namespace marray_operators_core +} // namespace marray_operators_pre_unary_core diff --git a/tests/marray/marray_operators_fp16.cpp b/tests/marray/marray_operators_pre_unary_fp16.cpp similarity index 85% rename from tests/marray/marray_operators_fp16.cpp rename to tests/marray/marray_operators_pre_unary_fp16.cpp index ba8f4ffc3..c87505095 100644 --- a/tests/marray/marray_operators_fp16.cpp +++ b/tests/marray/marray_operators_pre_unary_fp16.cpp @@ -23,12 +23,12 @@ #include "marray_common.h" #include "marray_operators.h" -namespace marray_operators_fp16 { +namespace marray_operators_pre_unary_fp16 { using namespace sycl_cts; using namespace marray_operators; -TEST_CASE("operators fp16", "[marray]") { +TEST_CASE("prefix unary operators fp16", "[marray]") { auto queue = util::get_cts_object::queue(); using availability = util::extensions::availability; @@ -39,7 +39,7 @@ TEST_CASE("operators fp16", "[marray]") { return; } - check_marray_operators_for_type{}("sycl::half"); + check_marray_pre_unary_operators_for_type{}("sycl::half"); } -} // namespace marray_operators_fp16 +} // namespace marray_operators_pre_unary_fp16 diff --git a/tests/marray/marray_operators_fp64.cpp b/tests/marray/marray_operators_pre_unary_fp64.cpp similarity index 86% rename from tests/marray/marray_operators_fp64.cpp rename to tests/marray/marray_operators_pre_unary_fp64.cpp index 7d4d5d573..2d2cc8d61 100644 --- a/tests/marray/marray_operators_fp64.cpp +++ b/tests/marray/marray_operators_pre_unary_fp64.cpp @@ -23,12 +23,12 @@ #include "marray_common.h" #include "marray_operators.h" -namespace marray_operators_fp64 { +namespace marray_operators_pre_unary_fp64 { using namespace sycl_cts; using namespace marray_operators; -TEST_CASE("operators fp64", "[marray]") { +TEST_CASE("prefix unary operators fp64", "[marray]") { auto queue = util::get_cts_object::queue(); using availability = util::extensions::availability; @@ -39,7 +39,7 @@ TEST_CASE("operators fp64", "[marray]") { return; } - check_marray_operators_for_type{}("double"); + check_marray_pre_unary_operators_for_type{}("double"); } -} // namespace marray_operators_fp64 +} // namespace marray_operators_pre_unary_fp64 diff --git a/tests/marray/marray_operators_relational_binary_core.cpp b/tests/marray/marray_operators_relational_binary_core.cpp new file mode 100644 index 000000000..bcd64d566 --- /dev/null +++ b/tests/marray/marray_operators_relational_binary_core.cpp @@ -0,0 +1,34 @@ +/******************************************************************************* +// +// SYCL 2020 Conformance Test Suite +// +// Copyright (c) 2023 The Khronos Group Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +*******************************************************************************/ + +#include "../common/type_coverage.h" +#include "marray_common.h" +#include "marray_operators.h" + +namespace marray_operators_relational_binary_core { + +using namespace marray_operators; + +TEST_CASE("relational binary operators core", "[marray]") { + const auto types = marray_common::get_types(); + for_all_types(types); +} + +} // namespace marray_operators_relational_binary_core diff --git a/tests/marray/marray_operators_relational_binary_fp16.cpp b/tests/marray/marray_operators_relational_binary_fp16.cpp new file mode 100644 index 000000000..d409e6721 --- /dev/null +++ b/tests/marray/marray_operators_relational_binary_fp16.cpp @@ -0,0 +1,45 @@ +/******************************************************************************* +// +// SYCL 2020 Conformance Test Suite +// +// Copyright (c) 2023 The Khronos Group Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +*******************************************************************************/ + +#include "../../util/extensions.h" +#include "../common/type_coverage.h" +#include "marray_common.h" +#include "marray_operators.h" + +namespace marray_operators_relational_binary_fp16 { + +using namespace sycl_cts; +using namespace marray_operators; + +TEST_CASE("relational binary operators fp16", "[marray]") { + auto queue = util::get_cts_object::queue(); + using availability = + util::extensions::availability; + if (!availability::check(queue)) { + WARN( + "Device does not support half precision floating point operations." + "Skipping the test case."); + return; + } + + check_marray_relational_binary_operators_for_type{}("sycl::half"); +} + +} // namespace marray_operators_relational_binary_fp16 diff --git a/tests/marray/marray_operators_relational_binary_fp64.cpp b/tests/marray/marray_operators_relational_binary_fp64.cpp new file mode 100644 index 000000000..fbf28aa59 --- /dev/null +++ b/tests/marray/marray_operators_relational_binary_fp64.cpp @@ -0,0 +1,45 @@ +/******************************************************************************* +// +// SYCL 2020 Conformance Test Suite +// +// Copyright (c) 2023 The Khronos Group Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +*******************************************************************************/ + +#include "../../util/extensions.h" +#include "../common/type_coverage.h" +#include "marray_common.h" +#include "marray_operators.h" + +namespace marray_operators_relational_binary_fp64 { + +using namespace sycl_cts; +using namespace marray_operators; + +TEST_CASE("relational binary operators fp64", "[marray]") { + auto queue = util::get_cts_object::queue(); + using availability = + util::extensions::availability; + if (!availability::check(queue)) { + WARN( + "Device does not support double precision floating point operations." + "Skipping the test case."); + return; + } + + check_marray_relational_binary_operators_for_type{}("double"); +} + +} // namespace marray_operators_relational_binary_fp64