Skip to content

[SYCL] Fix marray binary operator test check #8449

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 24, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions sycl/test/basic_tests/marray/marray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,19 @@
//===----------------------------------------------------------------------===//

#include <sycl/sycl.hpp>

#include <algorithm>

using namespace sycl;

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

template <size_t N> bool AllTrue(sycl::marray<bool, N> M) {
return std::all_of(M.begin(), M.end(), [](const bool &V) { return V; });
}

#define CHECK_ALIAS(ALIAS_MTYPE, ELEM_TYPE) \
CHECK_ALIAS_BY_SIZE(ALIAS_MTYPE, ELEM_TYPE, 2) \
CHECK_ALIAS_BY_SIZE(ALIAS_MTYPE, ELEM_TYPE, 3) \
Expand All @@ -27,8 +34,9 @@ using namespace sycl;
// scalar values with the marrays, which is valid as all elements in the marrays
// should be the same.
#define CHECK_BINOP(OP, LHS, RHS) \
assert((LHS[0] OP RHS) == (LHS OP RHS) && (LHS OP RHS[0]) == (LHS OP RHS) && \
(LHS[0] OP RHS[0]) == (LHS OP RHS));
assert(AllTrue((LHS[0] OP RHS) == (LHS OP RHS)) && \
AllTrue((LHS OP RHS[0]) == (LHS OP RHS)) && \
AllTrue((LHS[0] OP RHS[0]) == (LHS OP RHS)));

struct NotDefaultConstructible {
NotDefaultConstructible() = delete;
Expand Down