Skip to content

Commit eb578e5

Browse files
committed
Signed-off-by: kbobrovs <[email protected]>
Fix test failures: - fix vertical stride in replicate - allow unary logical negation for simd with integer element type - use data() to access M_data in non-constructors
1 parent 841ea9c commit eb578e5

File tree

3 files changed

+22
-15
lines changed

3 files changed

+22
-15
lines changed

sycl/include/sycl/ext/intel/experimental/esimd/detail/simd_obj_impl.hpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -534,9 +534,17 @@ template <typename Ty, int N, class Derived, class SFINAE> class simd_obj_impl {
534534
/// @} // Memory operations
535535

536536
/// Bitwise inversion, available in all subclasses.
537-
template <class T1 = Ty> Derived operator~() {
538-
static_assert(std::is_integral_v<T1>, "'~' applies only to integral types");
539-
return Derived(~M_data);
537+
template <class T1 = Ty, class = std::enable_if_t<std::is_integral_v<T1>>>
538+
Derived operator~() {
539+
return Derived(~data());
540+
}
541+
542+
/// Unary logical negation operator, available in all subclasses.
543+
template <class T1 = Ty, class = std::enable_if_t<std::is_integral_v<T1>>>
544+
simd_mask<N> operator!() {
545+
using MaskVecT = typename simd_mask<N>::vector_type;
546+
auto R = data() == vector_type(0);
547+
return simd_mask<N>{__builtin_convertvector(R, MaskVecT) & MaskVecT(1)};
540548
}
541549

542550
#define __ESIMD_DEF_SIMD_OBJ_IMPL_OPASSIGN(BINOP, OPASSIGN, COND) \

sycl/include/sycl/ext/intel/experimental/esimd/detail/simd_view_impl.hpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -277,11 +277,14 @@ template <typename BaseTy, typename RegionTy> class simd_view_impl {
277277

278278
#undef __ESIMD_DEF_UNARY_OP
279279

280-
template <class T = element_type, class SimdT = BaseTy,
281-
class = std::enable_if_t<is_simd_mask_type_v<SimdT>>>
280+
/// Unary logical negeation operator. Applies only to integer element types.
281+
template <class T = element_type,
282+
class = std::enable_if_t<std::is_integral_v<T>>>
282283
auto operator!() {
284+
using MaskVecT = typename simd_mask_type<length>::vector_type;
283285
auto V = read().data() == 0;
284-
return get_simd_t<element_type, length>(V);
286+
return simd_mask_type<length>{__builtin_convertvector(V, MaskVecT) &
287+
MaskVecT(1)};
285288
}
286289

287290
/// @{
@@ -290,9 +293,12 @@ template <typename BaseTy, typename RegionTy> class simd_view_impl {
290293
return write(Other.read());
291294
}
292295

296+
Derived &operator=(const Derived &Other) { return write(Other.read()); }
297+
293298
Derived &operator=(const value_type &Val) { return write(Val); }
294299

295300
/// Move assignment operator.
301+
Derived &operator=(Derived &&Other) { return write(Other.read()); }
296302
simd_view_impl &operator=(simd_view_impl &&Other) {
297303
return write(Other.read());
298304
}
@@ -406,7 +412,7 @@ template <typename BaseTy, typename RegionTy> class simd_view_impl {
406412
/// \return replicated simd instance.
407413
template <int Rep, int W>
408414
get_simd_t<element_type, Rep * W> replicate(uint16_t OffsetX) {
409-
return replicate<Rep, 1, W>(0, OffsetX);
415+
return replicate<Rep, 0, W>(0, OffsetX);
410416
}
411417

412418
/// \tparam Rep is number of times region has to be replicated.
@@ -417,7 +423,7 @@ template <typename BaseTy, typename RegionTy> class simd_view_impl {
417423
template <int Rep, int W>
418424
get_simd_t<element_type, Rep * W> replicate(uint16_t OffsetY,
419425
uint16_t OffsetX) {
420-
return replicate<Rep, 1, W>(OffsetY, OffsetX);
426+
return replicate<Rep, 0, W>(OffsetY, OffsetX);
421427
}
422428

423429
/// \tparam Rep is number of times region has to be replicated.

sycl/include/sycl/ext/intel/experimental/esimd/simd.hpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -200,13 +200,6 @@ class simd_mask_impl
200200
operator bool() {
201201
return base_type::data()[0] != 0;
202202
}
203-
204-
/// Unary logical negation operator.
205-
simd_mask_impl operator!() {
206-
auto R = base_type::data() == vector_type(0);
207-
return simd_mask_impl{__builtin_convertvector(R, vector_type) &
208-
vector_type(1)};
209-
}
210203
};
211204

212205
} // namespace detail

0 commit comments

Comments
 (0)