Skip to content

Commit a0ce2c6

Browse files
[SYCL] Fix marray binary operator test check (#8449)
This commit makes the marray binary operator test check that all the elements of the marray resulting from the comparison operator are true. Signed-off-by: Larsen, Steffen <[email protected]>
1 parent 2a7c570 commit a0ce2c6

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

sycl/test/basic_tests/marray/marray.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,19 @@
1010
//===----------------------------------------------------------------------===//
1111

1212
#include <sycl/sycl.hpp>
13+
14+
#include <algorithm>
15+
1316
using namespace sycl;
1417

1518
#define CHECK_ALIAS_BY_SIZE(ALIAS_MTYPE, ELEM_TYPE, MARRAY_SIZE) \
1619
static_assert(std::is_same_v<sycl::marray<ELEM_TYPE, MARRAY_SIZE>, \
1720
sycl::ALIAS_MTYPE##MARRAY_SIZE>);
1821

22+
template <size_t N> bool AllTrue(sycl::marray<bool, N> M) {
23+
return std::all_of(M.begin(), M.end(), [](const bool &V) { return V; });
24+
}
25+
1926
#define CHECK_ALIAS(ALIAS_MTYPE, ELEM_TYPE) \
2027
CHECK_ALIAS_BY_SIZE(ALIAS_MTYPE, ELEM_TYPE, 2) \
2128
CHECK_ALIAS_BY_SIZE(ALIAS_MTYPE, ELEM_TYPE, 3) \
@@ -27,8 +34,9 @@ using namespace sycl;
2734
// scalar values with the marrays, which is valid as all elements in the marrays
2835
// should be the same.
2936
#define CHECK_BINOP(OP, LHS, RHS) \
30-
assert((LHS[0] OP RHS) == (LHS OP RHS) && (LHS OP RHS[0]) == (LHS OP RHS) && \
31-
(LHS[0] OP RHS[0]) == (LHS OP RHS));
37+
assert(AllTrue((LHS[0] OP RHS) == (LHS OP RHS)) && \
38+
AllTrue((LHS OP RHS[0]) == (LHS OP RHS)) && \
39+
AllTrue((LHS[0] OP RHS[0]) == (LHS OP RHS)));
3240

3341
struct NotDefaultConstructible {
3442
NotDefaultConstructible() = delete;

0 commit comments

Comments
 (0)