Skip to content

Commit

Permalink
[ESIMD] Fix negation operator to return a mask (#4353)
Browse files Browse the repository at this point in the history
  • Loading branch information
DenisBakhvalov authored Aug 19, 2021
1 parent b3db5e5 commit 4cb8561
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,6 @@ template <typename BaseTy, typename RegionTy> class simd_view_impl {
auto V = UNARY_OP(read().data()); \
return simd<element_type, length>(V); \
}
DEF_UNARY_OP(!)
DEF_UNARY_OP(~)
DEF_UNARY_OP(+)
DEF_UNARY_OP(-)
Expand Down
4 changes: 3 additions & 1 deletion sycl/include/sycl/ext/intel/experimental/esimd/simd.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -352,13 +352,15 @@ template <typename Ty, int N> class simd {
auto V = UNARY_OP(data()); \
return simd(V); \
}
DEF_UNARY_OP(!)
DEF_UNARY_OP(~)
DEF_UNARY_OP(+)
DEF_UNARY_OP(-)

#undef DEF_UNARY_OP

// negation operator
auto operator!() { return *this == 0; }

/// \name Replicate
/// Replicate simd instance given a region.
/// @{
Expand Down
6 changes: 6 additions & 0 deletions sycl/include/sycl/ext/intel/experimental/esimd/simd_view.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ class simd_view : public detail::simd_view_impl<BaseTy, RegionTy> {
DEF_RELOP(!=)

#undef DEF_RELOP

// negation operator
auto operator!() { return *this == 0; }
};

/// This is a specialization of simd_view class with a single element.
Expand Down Expand Up @@ -142,6 +145,9 @@ class simd_view<BaseTy, region_base_1<typename BaseTy::element_type>>
DEF_RELOP(!=)

#undef DEF_RELOP

// negation operator
auto operator!() { return *this == 0; }
};

} // namespace esimd
Expand Down
2 changes: 1 addition & 1 deletion sycl/test/esimd/simd_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ SYCL_ESIMD_FUNCTION bool test_simd_view_unary_ops() {
ref0 <<= ref1;
ref1 = -ref0;
ref0 = ~ref1;
ref1 = !ref0;
auto mask = !ref0;
return v1[0] == 1;
}

Expand Down

0 comments on commit 4cb8561

Please sign in to comment.