DPC++ Runtime
Runtime libraries for oneAPI DPC++
simd_obj_impl.hpp
Go to the documentation of this file.
1 //==------------ - simd_obj_impl.hpp - DPC++ Explicit SIMD API -------------==//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 // Implement Explicit SIMD vector APIs.
9 //===----------------------------------------------------------------------===//
10 
11 #pragma once
12 
20 
21 namespace sycl {
23 namespace ext::intel::esimd {
24 
27 
44 
46 
49 
54  template <typename VT, typename ET = detail::element_type_t<VT>>
55  static constexpr unsigned alignment = alignof(ET);
56 };
57 
62  template <typename VT> static constexpr unsigned alignment = alignof(VT);
63 };
64 
69 template <unsigned N> struct overaligned_tag {
70  static_assert(
72  "Alignment value N for overaligned_tag<N> must be a power of two");
73  template <typename> static constexpr unsigned alignment = N;
74 };
75 
76 inline constexpr element_aligned_tag element_aligned = {};
77 
78 inline constexpr vector_aligned_tag vector_aligned = {};
79 
80 template <unsigned N> inline constexpr overaligned_tag<N> overaligned = {};
81 
83 template <typename T> struct is_simd_flag_type : std::false_type {};
84 
85 template <> struct is_simd_flag_type<element_aligned_tag> : std::true_type {};
86 
87 template <> struct is_simd_flag_type<vector_aligned_tag> : std::true_type {};
88 
89 template <unsigned N>
90 struct is_simd_flag_type<overaligned_tag<N>> : std::true_type {};
91 
94 template <typename T>
95 static inline constexpr bool is_simd_flag_type_v = is_simd_flag_type<T>::value;
96 
98 
99 namespace detail {
100 
105 struct dqword_element_aligned_tag {
106  template <typename VT, typename ET = detail::element_type_t<VT>>
107  static constexpr unsigned alignment = alignof(ET) > 4 ? alignof(ET) : 4;
108 };
109 
110 inline constexpr dqword_element_aligned_tag dqword_element_aligned = {};
111 
112 // Functions to support efficient simd constructors - avoiding internal loop
113 // over elements.
114 template <class T, int N, size_t... Is>
115 constexpr vector_type_t<T, N> make_vector_impl(const T (&&Arr)[N],
116  std::index_sequence<Is...>) {
117  return vector_type_t<T, N>{Arr[Is]...};
118 }
119 
120 template <class T, int N>
121 constexpr vector_type_t<T, N> make_vector(const T (&&Arr)[N]) {
122  return make_vector_impl<T, N>(std::move(Arr), std::make_index_sequence<N>{});
123 }
124 
125 template <class T, int N, size_t... Is>
126 constexpr vector_type_t<T, N> make_vector_impl(T Base, T Stride,
127  std::index_sequence<Is...>) {
128  return vector_type_t<T, N>{(T)(Base + ((T)Is) * Stride)...};
129 }
130 
131 template <class T, int N>
132 constexpr vector_type_t<T, N> make_vector(T Base, T Stride) {
133  return make_vector_impl<T, N>(Base, Stride, std::make_index_sequence<N>{});
134 }
135 
137 
140 
163 template <typename RawTy, int N, class Derived, class SFINAE>
166 
167  // For the is_simd_obj_impl_derivative helper to work correctly, all derived
168  // classes must be templated by element type and number of elements. If fewer
169  // template arguments are needed, template aliases can be used
170  // (simd_mask_type).
171  //
172  template <typename, typename> friend class simd_view;
173  template <typename, typename> friend class simd_view_impl;
174  template <typename, int> friend class simd;
175  template <typename, int> friend class simd_mask_impl;
176 
178 
179 public:
181  using element_type = get_vector_element_type<Derived>;
182 
184  using raw_vector_type = vector_type_t<RawTy, N>;
185 
187  using raw_element_type = RawTy;
188 
190  static constexpr int length = N;
191 
192 protected:
194  using Ty = element_type;
195 
196  template <bool UseSet = true>
197  void init_from_array(const Ty (&&Arr)[N]) noexcept {
198  raw_vector_type tmp;
199 
200  if constexpr (is_wrapper_elem_type_v<Ty>) {
201  for (auto I = 0; I < N; ++I) {
202  tmp[I] = bitcast_to_raw_type(Arr[I]);
203  }
204  } else {
205  tmp = make_vector(std::move(Arr));
206  }
207  if constexpr (UseSet) {
208  set(std::move(tmp));
209  } else {
210  M_data = std::move(tmp);
211  }
212  }
213 
214  explicit operator raw_vector_type() const {
215  __esimd_dbg_print(explicit operator raw_vector_type());
216  return data();
217  }
218 
219 private:
220  Derived &cast_this_to_derived() { return reinterpret_cast<Derived &>(*this); }
221  const Derived &cast_this_to_derived() const {
222  return reinterpret_cast<const Derived &>(*this);
223  }
224 
226 
227 public:
230  simd_obj_impl() = default;
231 
234  simd_obj_impl(const simd_obj_impl &other) {
236  set(other.data());
237  }
238 
245  template <class Ty1, typename Derived1>
247  __esimd_dbg_print(simd_obj_impl(const simd_obj_impl... > &other));
248  set(convert_vector<Ty, element_type_t<Derived1>, N>(other.data()));
249  }
250 
255  set(Val);
256  }
257 
264  simd_obj_impl(Ty Val, Ty Step) noexcept {
265  __esimd_dbg_print(simd_obj_impl(Ty Val, Ty Step));
266  if constexpr (is_wrapper_elem_type_v<Ty> || !std::is_integral_v<Ty>) {
267  for (int i = 0; i < N; ++i) {
268  M_data[i] = bitcast_to_raw_type(Val);
269  Val = binary_op<BinOp::add, Ty>(Val, Step);
270  }
271  } else {
272  M_data = make_vector<Ty, N>(Val, Step);
273  }
274  }
275 
281  template <class T1,
282  class = std::enable_if_t<detail::is_valid_simd_elem_type_v<T1>>>
283  simd_obj_impl(T1 Val) noexcept {
285  M_data = bitcast_to_raw_type(detail::convert_scalar<Ty>(Val));
286  }
287 
292  template <int N1, class = std::enable_if_t<N1 == N>>
293  simd_obj_impl(const Ty (&&Arr)[N1]) noexcept {
294  __esimd_dbg_print(simd_obj_impl(const Ty(&&Arr)[N1]));
295  init_from_array<false /*init M_data w/o using set(...)*/>(std::move(Arr));
296  // It is OK not to mark a write to M_data with __esimd_vstore (via 'set')
297  // here because:
298  // - __esimd_vstore/vload are need only to mark ESIMD_PRIVATE variable
299  // access for the VC BE to generate proper code for them.
300  // - initializers are not allowed for ESIMD_PRIVATE vars, so only the
301  // default ctor can be used for them
302  }
303 
310  template <typename Flags = element_aligned_tag,
311  typename = std::enable_if_t<is_simd_flag_type_v<Flags>>>
312  simd_obj_impl(const Ty *ptr, Flags = {}) noexcept {
313  __esimd_dbg_print(simd_obj_impl(const Ty *ptr, Flags));
314  copy_from(ptr, Flags{});
315  }
316 
327  template <
328  typename AccessorT, typename Flags = element_aligned_tag,
329  typename = std::enable_if_t<
330  detail::is_sycl_accessor_with<AccessorT, accessor_mode_cap::can_read,
331  sycl::access::target::device>::value &&
332  is_simd_flag_type_v<Flags>>>
333  simd_obj_impl(AccessorT acc, uint32_t offset, Flags = {}) noexcept {
334  __esimd_dbg_print(simd_obj_impl(AccessorT acc, uint32_t offset, Flags));
335  copy_from(acc, offset, Flags{});
336  }
337 
340  template <typename T = simd_obj_impl,
341  typename = std::enable_if_t<T::length == 1>>
342  operator Ty() const {
343  __esimd_dbg_print(operator Ty());
344  return bitcast_to_wrapper_type<Ty>(data()[0]);
345  }
346 
350 #ifndef __SYCL_DEVICE_ONLY__
351  return M_data;
352 #else
353  return __esimd_vload<RawTy, N>(&M_data);
354 #endif
355  }
356 
360  raw_vector_type &data_ref() { return M_data; }
361 
365  "commit is deprecated and will be removed in a future release")
366  void commit() {}
367 
370  Derived read() const { return Derived{data()}; }
371 
374  Derived &write(const Derived &Val) {
375  set(Val.data());
376  return cast_this_to_derived();
377  }
378 
385  void merge(const Derived &Val, const simd_mask_type<N> &Mask) {
386  set(__esimd_wrregion<RawTy, N, N, 0 /*VS*/, N, 1, N>(data(), Val.data(), 0,
387  Mask.data()));
388  }
389 
397  void merge(const Derived &Val1, Derived Val2, const simd_mask_type<N> &Mask) {
398  Val2.merge(Val1, Mask);
399  set(Val2.data());
400  }
401 
408  template <typename EltTy> auto bit_cast_view() &[[clang::lifetimebound]] {
409  using TopRegionTy = compute_format_type_t<Derived, EltTy>;
410  using RetTy = simd_view<Derived, TopRegionTy>;
411  return RetTy{cast_this_to_derived(), TopRegionTy{0}};
412  }
413 
424  template <typename EltTy, int Height, int Width>
425  auto bit_cast_view() &[[clang::lifetimebound]] {
426  using TopRegionTy = compute_format_type_2d_t<Derived, EltTy, Height, Width>;
427  using RetTy = simd_view<Derived, TopRegionTy>;
428  return RetTy{cast_this_to_derived(), TopRegionTy{0, 0}};
429  }
430 
438  template <int Size, int Stride>
440  select(uint16_t Offset = 0) &[[clang::lifetimebound]] {
441  static_assert(Size > 1 || Stride == 1,
442  "Stride must be 1 in single-element region");
443  region1d_t<Ty, Size, Stride> Reg(Offset);
444  return {cast_this_to_derived(), std::move(Reg)};
445  }
446 
454  template <int Size, int Stride>
455  resize_a_simd_type_t<Derived, Size> select(uint16_t Offset = 0) && {
456  static_assert(Size > 1 || Stride == 1,
457  "Stride must be 1 in single-element region");
458  Derived &&Val = std::move(cast_this_to_derived());
459  return __esimd_rdregion<RawTy, N, Size, /*VS*/ 0, Size, Stride>(Val.data(),
460  Offset);
461  }
462 
466  Ty operator[](int i) const { return bitcast_to_wrapper_type<Ty>(data()[i]); }
467 
472  [[clang::lifetimebound]] {
473  return select<1, 1>(i);
474  }
475 
481  template <int Size>
482  resize_a_simd_type_t<Derived, Size>
483  iselect(const simd<uint16_t, Size> &Indices) {
484  vector_type_t<uint16_t, Size> Offsets = Indices.data() * sizeof(RawTy);
485  return __esimd_rdindirect<RawTy, N, Size>(data(), Offsets);
486  }
487 
491  void iupdate(ushort Index, Ty V) {
492  auto Val = data();
493  Val[Index] = bitcast_to_raw_type(V);
494  set(Val);
495  }
496 
502  template <int Size>
503  void iupdate(const simd<uint16_t, Size> &Indices,
504  const resize_a_simd_type_t<Derived, Size> &Val,
505  const simd_mask_type<Size> &Mask) {
506  vector_type_t<uint16_t, Size> Offsets = Indices.data() * sizeof(RawTy);
507  set(__esimd_wrindirect<RawTy, N, Size>(data(), Val.data(), Offsets,
508  Mask.data()));
509  }
510 
514  template <int Rep> resize_a_simd_type_t<Derived, Rep * N> replicate() const {
515  return replicate_w<Rep, N>(0);
516  }
517 
525  template <int Rep, int W>
526  resize_a_simd_type_t<Derived, Rep * W> replicate_w(uint16_t Offset) const {
527  return replicate_vs_w_hs<Rep, 0, W, 1>(Offset);
528  }
529 
539  template <int Rep, int VS, int W>
540  resize_a_simd_type_t<Derived, Rep * W> replicate_vs_w(uint16_t Offset) const {
541  return replicate_vs_w_hs<Rep, VS, W, 1>(Offset);
542  }
543 
592  template <int Rep, int VS, int W, int HS>
593  resize_a_simd_type_t<Derived, Rep * W>
594  replicate_vs_w_hs(uint16_t Offset) const {
595  return __esimd_rdregion<RawTy, N, Rep * W, VS, W, HS, N>(
596  data(), Offset * sizeof(RawTy));
597  }
598 
602  template <typename T1 = Ty,
603  typename = std::enable_if_t<std::is_integral_v<T1>>>
604  uint16_t any() const {
605  return __esimd_any<Ty, N>(data());
606  }
607 
611  template <typename T1 = Ty,
612  typename = std::enable_if_t<std::is_integral_v<T1>>>
613  uint16_t all() const {
614  return __esimd_all<Ty, N>(data());
615  }
616 
617 protected:
620  template <typename RTy, class ElemTy = __raw_t<typename RTy::element_type>>
621  ESIMD_INLINE void writeRegion(RTy Region,
622  const vector_type_t<ElemTy, RTy::length> &Val) {
623 
624  if constexpr (N * sizeof(RawTy) == RTy::length * sizeof(ElemTy))
625  // update the entire vector
626  set(bitcast<RawTy, ElemTy, RTy::length>(Val));
627  else {
628  static_assert(!RTy::Is_2D);
629  // If element type differs, do bitcast conversion first.
630  auto Base = bitcast<ElemTy, RawTy, N>(data());
631  constexpr int BN = (N * sizeof(RawTy)) / sizeof(ElemTy);
632  // Access the region information.
633  constexpr int M = RTy::Size_x;
634  constexpr int Stride = RTy::Stride_x;
635  uint16_t Offset = Region.M_offset_x * sizeof(ElemTy);
636 
637  // Merge and update.
638  auto Merged = __esimd_wrregion<ElemTy, BN, M,
639  /*VS*/ 0, M, Stride>(Base, Val, Offset);
640  // Convert back to the original element type, if needed.
641  set(bitcast<RawTy, ElemTy, BN>(Merged));
642  }
643  }
644 
647  template <typename TR, typename UR,
648  class ElemTy = __raw_t<typename TR::element_type>>
649  ESIMD_INLINE void writeRegion(std::pair<TR, UR> Region,
650  const vector_type_t<ElemTy, TR::length> &Val) {
651  // parent-region type
652  using PaTy = typename shape_type<UR>::type;
653  using BT = __raw_t<typename PaTy::element_type>;
654  constexpr int BN = PaTy::length;
655 
656  if constexpr (PaTy::Size_in_bytes == TR::Size_in_bytes) {
657  writeRegion(Region.second, bitcast<BT, ElemTy, TR::length>(Val));
658  } else {
659  // Recursively read the base
660  auto Base = readRegion<RawTy, N>(data(), Region.second);
661  // If element type differs, do bitcast conversion first.
662  auto Base1 = bitcast<ElemTy, BT, BN>(Base);
663  constexpr int BN1 = PaTy::Size_in_bytes / sizeof(ElemTy);
664 
665  if constexpr (!TR::Is_2D) {
666  // Access the region information.
667  constexpr int M = TR::Size_x;
668  constexpr int Stride = TR::Stride_x;
669  uint16_t Offset = Region.first.M_offset_x * sizeof(ElemTy);
670 
671  // Merge and update.
672  Base1 = __esimd_wrregion<ElemTy, BN1, M,
673  /*VS*/ 0, M, Stride>(Base1, Val, Offset);
674  } else {
675  static_assert(std::is_same<ElemTy, BT>::value);
676  // Read columns with non-trivial horizontal stride.
677  constexpr int M = TR::length;
678  constexpr int VS = PaTy::Size_x * TR::Stride_y;
679  constexpr int W = TR::Size_x;
680  constexpr int HS = TR::Stride_x;
681  constexpr int ParentWidth = PaTy::Size_x;
682 
683  // Compute the byte offset for the starting element.
684  uint16_t Offset = static_cast<uint16_t>(
685  (Region.first.M_offset_y * PaTy::Size_x + Region.first.M_offset_x) *
686  sizeof(ElemTy));
687 
688  // Merge and update.
689  Base1 = __esimd_wrregion<ElemTy, BN1, M, VS, W, HS, ParentWidth>(
690  Base1, Val, Offset);
691  }
692  // Convert back to the original element type, if needed.
693  auto Merged1 = bitcast<BT, ElemTy, BN1>(Base1);
694  // recursively write it back to the base
695  writeRegion(Region.second, Merged1);
696  }
697  }
698 
699 public:
710  template <typename Flags = element_aligned_tag, int ChunkSize = 32,
711  typename = std::enable_if_t<is_simd_flag_type_v<Flags>>>
712  ESIMD_INLINE void copy_from(const Ty *addr, Flags = {}) SYCL_ESIMD_FUNCTION;
713 
725  template <typename AccessorT, typename Flags = element_aligned_tag,
726  int ChunkSize = 32,
727  typename = std::enable_if_t<is_simd_flag_type_v<Flags>>>
728  ESIMD_INLINE EnableIfAccessor<AccessorT, accessor_mode_cap::can_read,
729  sycl::access::target::device, void>
730  copy_from(AccessorT acc, uint32_t offset, Flags = {}) SYCL_ESIMD_FUNCTION;
731 
738  template <typename Flags = element_aligned_tag, int ChunkSize = 32,
739  typename = std::enable_if_t<is_simd_flag_type_v<Flags>>>
740  ESIMD_INLINE void copy_to(Ty *addr, Flags = {}) const SYCL_ESIMD_FUNCTION;
741 
751  template <typename AccessorT, typename Flags = element_aligned_tag,
752  int ChunkSize = 32,
753  typename = std::enable_if_t<is_simd_flag_type_v<Flags>>>
754  ESIMD_INLINE EnableIfAccessor<AccessorT, accessor_mode_cap::can_write,
755  sycl::access::target::device, void>
756  copy_to(AccessorT acc, uint32_t offset, Flags = {}) const SYCL_ESIMD_FUNCTION;
757 
758  // Unary operations.
759 
763  template <class T1 = Ty, class = std::enable_if_t<std::is_integral_v<T1>>>
764  Derived operator~() const {
765  return Derived{
766  detail::vector_unary_op<detail::UnaryOp::bit_not, T1, N>(data())};
767  }
768 
775  template <class T1 = Ty, class = std::enable_if_t<std::is_integral_v<T1>>>
776  simd_mask_type<N> operator!() const {
777  return *this == 0;
778  }
779 
780 #define __ESIMD_DEF_SIMD_OBJ_IMPL_OPASSIGN(BINOP, OPASSIGN, COND) \
781  \
782  \
783  \
784  \
785  \
786  template <class T1, class SimdT, \
787  class = std::enable_if_t<(is_simd_type_v<Derived> == \
788  is_simd_type_v<SimdT>)&&COND>> \
789  Derived &operator OPASSIGN( \
790  const __ESIMD_DNS::simd_obj_impl<T1, N, SimdT> &RHS) { \
791  auto Res = *this BINOP RHS; \
792  using ResT = decltype(Res); \
793  set(__ESIMD_DNS::convert_vector<element_type, typename ResT::element_type, \
794  length>(Res.data())); \
795  return cast_this_to_derived(); \
796  } \
797  \
798  \
799  \
800  \
801  \
802  \
803  template <class SimdT1, class RegionT1, \
804  class T1 = typename RegionT1::element_type, \
805  class = std::enable_if_t< \
806  (is_simd_type_v<Derived> == \
807  is_simd_type_v<SimdT1>)&&(RegionT1::length == length) && \
808  COND>> \
809  Derived &operator OPASSIGN( \
810  const __ESIMD_NS::simd_view<SimdT1, RegionT1> &RHS) { \
811  auto Res = *this BINOP RHS.read(); \
812  using ResT = decltype(Res); \
813  set(__ESIMD_DNS::convert_vector<element_type, typename ResT::element_type, \
814  length>(Res.data())); \
815  return cast_this_to_derived(); \
816  } \
817  \
818  \
819  \
820  \
821  template <class T1, class = std::enable_if_t<COND>> \
822  Derived &operator OPASSIGN(T1 RHS) { \
823  if constexpr (is_simd_type_v<Derived>) { \
824  using RHSVecT = __ESIMD_DNS::construct_a_simd_type_t<Derived, T1, N>; \
825  return *this OPASSIGN RHSVecT(RHS); \
826  } else { \
827  return *this OPASSIGN Derived((RawTy)RHS); \
828  } \
829  }
830 
831 // Bitwise operations are defined for simd objects and masks, and both operands
832 // must be integral
833 #define __ESIMD_BITWISE_OP_FILTER \
834  std::is_integral_v<element_type> &&std::is_integral_v<T1>
847 #undef __ESIMD_BITWISE_OP_FILTER
848 
849 // Bit shift operations are defined only for simd objects (not for masks), and
850 // both operands must be integral
851 #define __ESIMD_SHIFT_OP_FILTER \
852  std::is_integral_v<element_type> &&std::is_integral_v<T1> \
853  &&__ESIMD_DNS::is_simd_type_v<Derived>
854 
862 #undef __ESIMD_SHIFT_OP_FILTER
863 
864 // Arithmetic operations are defined only for simd objects, and the second
865 // operand's element type must be vectorizable. This requirement for 'this'
866 // is fulfilled, because otherwise 'this' couldn't have been constructed.
867 #define __ESIMD_ARITH_OP_FILTER \
868  __ESIMD_DNS::is_simd_type_v<Derived> &&__ESIMD_DNS::is_vectorizable_v<T1>
869 
878 #undef __ESIMD_ARITH_OP_FILTER
879 #undef __ESIMD_DEF_SIMD_OBJ_IMPL_OPASSIGN
880 
881  // Getter for the test proxy member, if enabled
882  __ESIMD_DECLARE_TEST_PROXY_ACCESS
883 
884 private:
885  // The underlying data for this vector.
886  raw_vector_type M_data;
887 
888 protected:
889  // The test proxy if enabled
890  __ESIMD_DECLARE_TEST_PROXY
891 
892  void set(const raw_vector_type &Val) {
893 #ifndef __SYCL_DEVICE_ONLY__
894  M_data = Val;
895 #else
896  __esimd_vstore<RawTy, N>(&M_data, Val);
897 #endif
898  }
899 };
901 
902 } // namespace detail
903 
904 template <>
905 struct is_simd_flag_type<detail::dqword_element_aligned_tag> : std::true_type {
906 };
907 } // namespace ext::intel::esimd
908 } // __SYCL_INLINE_VER_NAMESPACE(_V1)
909 } // namespace sycl
sycl::_V1::ext::intel::esimd::detail::simd_obj_impl::writeRegion
ESIMD_INLINE void writeRegion(RTy Region, const vector_type_t< ElemTy, RTy::length > &Val)
Write a simd_obj_impl-vector into a basic region of a simd_obj_impl object.
Definition: simd_obj_impl.hpp:621
sycl::_V1::ext::intel::esimd::overaligned_tag
overaligned_tag type.
Definition: simd_obj_impl.hpp:69
sycl::_V1::ext::intel::esimd::detail::simd_obj_impl::__SYCL_DEPRECATED
__SYCL_DEPRECATED("commit is deprecated and will be removed in a future release") void commit()
Commit the current stored underlying raw vector to memory.
Definition: simd_obj_impl.hpp:364
sycl::_V1::ext::intel::esimd::detail::simd_obj_impl::simd_obj_impl
simd_obj_impl(const raw_vector_type &Val)
Implicit conversion constructor from a raw vector object.
Definition: simd_obj_impl.hpp:253
sycl::_V1::ext::intel::esimd::detail::simd_obj_impl::writeRegion
ESIMD_INLINE void writeRegion(std::pair< TR, UR > Region, const vector_type_t< ElemTy, TR::length > &Val)
Write a simd_obj_impl-vector into a nested region of a simd_obj_impl object.
Definition: simd_obj_impl.hpp:649
__ESIMD_BITWISE_OP_FILTER
#define __ESIMD_BITWISE_OP_FILTER
Definition: simd_obj_impl.hpp:833
sycl::_V1::ext::intel::esimd::detail::simd_obj_impl::any
uint16_t any() const
See if any element is non-zero.
Definition: simd_obj_impl.hpp:604
sycl::_V1::ext::intel::esimd::detail::simd_obj_impl::replicate_w
resize_a_simd_type_t< Derived, Rep *W > replicate_w(uint16_t Offset) const
Shortcut to replicate_vs_w_hs with VS=0 and HS=1 to replicate a single "dense" (w/o gaps between elem...
Definition: simd_obj_impl.hpp:526
simd_view.hpp
sycl::_V1::ext::intel::esimd::detail::simd_obj_impl< T, N, simd_mask_impl< T, N >, std::enable_if_t< std::is_same_v< simd_mask_elem_type, T > > >::element_type
get_vector_element_type< simd_mask_impl< T, N > > element_type
Element type of the derived (user) class.
Definition: simd_obj_impl.hpp:181
__SYCL_INLINE_VER_NAMESPACE
#define __SYCL_INLINE_VER_NAMESPACE(X)
Definition: defines_elementary.hpp:11
sycl::_V1::ext::oneapi::experimental::alignment
constexpr alignment_key::value_t< K > alignment
Definition: properties.hpp:349
sycl::_V1::ext::intel::esimd::simd
The main simd vector class.
Definition: types.hpp:34
sycl::_V1::ext::intel::esimd::detail::simd_obj_impl::set
__ESIMD_DECLARE_TEST_PROXY void set(const raw_vector_type &Val)
Definition: simd_obj_impl.hpp:892
__ESIMD_DEF_SIMD_OBJ_IMPL_OPASSIGN
#define __ESIMD_DEF_SIMD_OBJ_IMPL_OPASSIGN(BINOP, OPASSIGN, COND)
Definition: simd_obj_impl.hpp:780
sycl
---— Error handling, matching OpenCL plugin semantics.
Definition: access.hpp:14
sycl::_V1::ext::intel::esimd::simd_view
This class represents a reference to a sub-region of a base simd object.
Definition: types.hpp:35
vector_aligned
constexpr vector_aligned_tag vector_aligned
Definition: simd.hpp:1036
sycl::_V1::ext::intel::esimd::detail::simd_obj_impl::iselect
resize_a_simd_type_t< Derived, Size > iselect(const simd< uint16_t, Size > &Indices)
Indirect select - select and extract multiple elements with given variable indices.
Definition: simd_obj_impl.hpp:483
sycl::_V1::ext::intel::esimd::detail::simd_obj_impl::all
uint16_t all() const
See if all elements are non-zero.
Definition: simd_obj_impl.hpp:613
element_aligned_tag
Definition: simd.hpp:1031
sycl::_V1::ext::intel::esimd::detail::simd_obj_impl
This is a base class for all ESIMD simd classes with real storage (simd, simd_mask_impl).
Definition: simd_obj_impl.hpp:164
overaligned
constexpr overaligned_tag< _Np > overaligned
Definition: simd.hpp:1038
sycl::_V1::ext::intel::esimd::detail::simd_obj_impl::data
raw_vector_type data() const
Definition: simd_obj_impl.hpp:348
intrin.hpp
sycl::_V1::ext::intel::esimd::detail::simd_obj_impl::simd_obj_impl
simd_obj_impl(const Ty *ptr, Flags={}) noexcept
Pointer-based load constructor.
Definition: simd_obj_impl.hpp:312
sycl::_V1::ext::intel::esimd::detail::simd_obj_impl< T, N, simd_mask_impl< T, N >, std::enable_if_t< std::is_same_v< simd_mask_elem_type, T > > >::raw_element_type
T raw_element_type
The element type of the raw storage vector.
Definition: simd_obj_impl.hpp:187
test_proxy.hpp
sycl::_V1::ext::intel::esimd::is_simd_flag_type
Checks if type is a simd load/store flag.
Definition: simd_obj_impl.hpp:83
__esimd_dbg_print
#define __esimd_dbg_print(a)
Definition: types.hpp:24
sycl::_V1::ext::intel::esimd::detail::simd_obj_impl::simd_obj_impl
simd_obj_impl(const Ty(&&Arr)[N1]) noexcept
Rvalue array-based constructor.
Definition: simd_obj_impl.hpp:293
sycl::_V1::ext::intel::esimd::vector_aligned_tag
vector_aligned_tag type.
Definition: simd_obj_impl.hpp:61
sycl::_V1::ext::intel::esimd::detail::simd_obj_impl::iupdate
void iupdate(const simd< uint16_t, Size > &Indices, const resize_a_simd_type_t< Derived, Size > &Val, const simd_mask_type< Size > &Mask)
Indirect update - update multiple elements with given variable indices.
Definition: simd_obj_impl.hpp:503
sycl::_V1::ext::intel::esimd::detail::simd_obj_impl::replicate
resize_a_simd_type_t< Derived, Rep *N > replicate() const
Replicates contents of this vector a number of times into a new vector.
Definition: simd_obj_impl.hpp:514
sycl::_V1::ext::intel::esimd::detail::simd_obj_impl::simd_obj_impl
simd_obj_impl(const simd_obj_impl &other)
Copy constructor.
Definition: simd_obj_impl.hpp:234
sycl::_V1::ext::intel::esimd::detail::simd_obj_impl::bit_cast_view
auto bit_cast_view() &
Create a 2-dimensional view of this object.
Definition: simd_obj_impl.hpp:425
sycl::_V1::ext::intel::esimd::detail::simd_obj_impl::bit_cast_view
auto bit_cast_view() &
Create a 1-dimensional view of this object.
Definition: simd_obj_impl.hpp:408
sycl::_V1::ext::intel::esimd::detail::simd_obj_impl::merge
void merge(const Derived &Val, const simd_mask_type< N > &Mask)
"Merges" this object's value with another object: replaces part of the underlying data with the one t...
Definition: simd_obj_impl.hpp:385
sycl::_V1::ext::intel::esimd::detail::isPowerOf2
constexpr ESIMD_INLINE bool isPowerOf2(unsigned int n)
Check if a given 32 bit positive integer is a power of 2 at compile time.
Definition: common.hpp:79
sycl::_V1::ext::intel::esimd::detail::simd_obj_impl::simd_obj_impl
simd_obj_impl(AccessorT acc, uint32_t offset, Flags={}) noexcept
Accessor-based load constructor.
Definition: simd_obj_impl.hpp:333
sycl::_V1::ext::intel::esimd::detail::simd_obj_impl::operator[]
Ty operator[](int i) const
Get value of this vector's element.
Definition: simd_obj_impl.hpp:466
sycl::_V1::ext::intel::esimd::detail::simd_obj_impl::write
Derived & write(const Derived &Val)
Replaces the underlying data with the one taken from another object.
Definition: simd_obj_impl.hpp:374
elem_type_traits.hpp
sycl::_V1::ext::intel::esimd::detail::simd_obj_impl::data_ref
raw_vector_type & data_ref()
Definition: simd_obj_impl.hpp:360
sycl::_V1::ext::intel::esimd::detail::simd_obj_impl::operator~
Derived operator~() const
Per-element bitwise inversion, available in all subclasses, but only for integral element types (simd...
Definition: simd_obj_impl.hpp:764
sycl::_V1::ext::intel::esimd::detail::simd_obj_impl::simd_obj_impl
simd_obj_impl(const simd_obj_impl< Ty1, N, Derived1, SFINAE > &other)
Implicit conversion constructor from another simd_obj_impl object.
Definition: simd_obj_impl.hpp:246
sycl::_V1::ext::intel::esimd::detail::simd_obj_impl::simd_obj_impl
simd_obj_impl(T1 Val) noexcept
Broadcast constructor.
Definition: simd_obj_impl.hpp:283
sycl::_V1::ext::intel::esimd::detail::simd_obj_impl::operator[]
simd_view< Derived, region1d_scalar_t< Ty > > operator[](int i)
Return writable view of a single element.
Definition: simd_obj_impl.hpp:471
__ESIMD_SHIFT_OP_FILTER
#define __ESIMD_SHIFT_OP_FILTER
Definition: simd_obj_impl.hpp:851
sycl::_V1::ext::intel::esimd::detail::simd_obj_impl::iupdate
void iupdate(ushort Index, Ty V)
Update single element with variable index.
Definition: simd_obj_impl.hpp:491
__ESIMD_ARITH_OP_FILTER
#define __ESIMD_ARITH_OP_FILTER
Definition: simd_obj_impl.hpp:867
sycl::_V1::ext::intel::esimd::ushort
unsigned short ushort
Definition: common.hpp:42
sycl::_V1::ext::intel::esimd::detail::simd_obj_impl::select
resize_a_simd_type_t< Derived, Size > select(uint16_t Offset=0) &&
Select and extract a subregion of this object's elements and return it as a new vector object.
Definition: simd_obj_impl.hpp:455
sycl::_V1::ext::intel::esimd::detail::simd_obj_impl::select
simd_view< Derived, region1d_t< Ty, Size, Stride > > select(uint16_t Offset=0) &
Select elements of this object into a subregion and create a 1D view for for it.
Definition: simd_obj_impl.hpp:440
sycl::_V1::ext::intel::esimd::detail::simd_obj_impl::replicate_vs_w_hs
resize_a_simd_type_t< Derived, Rep *W > replicate_vs_w_hs(uint16_t Offset) const
This function "replicates" a portion of this object's elements into a new object.
Definition: simd_obj_impl.hpp:594
sycl_util.hpp
element_aligned
constexpr element_aligned_tag element_aligned
Definition: simd.hpp:1035
sycl::_V1::ext::intel::esimd::detail::simd_obj_impl::read
Derived read() const
Definition: simd_obj_impl.hpp:370
sycl::_V1::ext::intel::esimd::detail::simd_obj_impl::operator!
simd_mask_type< N > operator!() const
Unary logical negation operator, available in all subclasses, but only for integral element types (si...
Definition: simd_obj_impl.hpp:776
memory_intrin.hpp
sycl::_V1::ext::intel::esimd::element_aligned_tag
element_aligned_tag type.
Definition: simd_obj_impl.hpp:53
sycl::_V1::ext::intel::esimd::detail::simd_obj_impl::merge
void merge(const Derived &Val1, Derived Val2, const simd_mask_type< N > &Mask)
Merges given two objects with a mask and writes resulting data into this object.
Definition: simd_obj_impl.hpp:397
vector_type_t< T, N >
is_simd_flag_type_v
constexpr bool is_simd_flag_type_v
Definition: simd.hpp:1083
sycl::_V1::ext::intel::esimd::detail::simd_obj_impl::replicate_vs_w
resize_a_simd_type_t< Derived, Rep *W > replicate_vs_w(uint16_t Offset) const
Shortcut to replicate_vs_w_hs with HS=1 to replicate dense blocks.
Definition: simd_obj_impl.hpp:540
sycl::_V1::ext::intel::esimd::detail::simd_mask_impl
This class is a simd_obj_impl specialization representing a simd mask, which is basically a simd_obj_...
Definition: simd_mask_impl.hpp:56
sycl::_V1::ext::intel::esimd::detail::simd_obj_impl::simd_obj_impl
simd_obj_impl(Ty Val, Ty Step) noexcept
Arithmetic progression constructor.
Definition: simd_obj_impl.hpp:264
type_format.hpp
sycl::_V1::ext::intel::esimd::detail::simd_view_impl
Base class for "simd view" types.
Definition: simd_view_impl.hpp:41