26 template<
typename TView>
41 template<ViewType TView>
46 using pointer = value_type*;
47 using const_pointer = value_type
const*;
48 using reference = value_type&;
49 using const_reference = value_type
const&;
65 template<ViewType TView>
70 using pointer = value_type*;
71 using const_pointer = value_type
const*;
72 using reference = value_type&;
73 using const_reference = value_type
const&;
90 static_assert(Dim::value == 0,
"operator* is only valid for Buffers and Views of dimension 0");
96 static_assert(Dim::value == 0,
"operator* is only valid for Buffers and Views of dimension 0");
102 static_assert(Dim::value == 0,
"operator-> is only valid for Buffers and Views of dimension 0");
108 static_assert(Dim::value == 0,
"operator-> is only valid for Buffers and Views of dimension 0");
114 static_assert(Dim::value == 1,
"operator[i] is only valid for Buffers and Views of dimension 1");
120 static_assert(Dim::value == 1,
"operator[i] is only valid for Buffers and Views of dimension 1");
125 template<
typename TIdx>
129 std::is_convertible_v<TIdx, Idx>,
130 "the index type must be convertible to the index of the Buffer or View");
132 auto ptr =
reinterpret_cast<std::uintptr_t
>(
data());
133 if constexpr(Dim::value > 0)
135 ptr +=
static_cast<std::uintptr_t
>(
136 (
getPitchesInBytes(*
static_cast<TView const*
>(
this)) * castVec<Idx>(index)).sum());
138 return reinterpret_cast<const_pointer
>(ptr);
142 template<
typename TIdx>
145 return *
const_cast<pointer
>(ptr_at(index));
148 template<
typename TIdx>
151 return *ptr_at(index);
154 template<
typename TIdx>
157 auto extent =
getExtents(*
static_cast<TView*
>(
this));
158 if(!(index < extent).all())
160 std::stringstream msg;
161 msg <<
"index " << index <<
" is outside of the Buffer or View extent " << extent;
162 throw std::out_of_range(msg.str());
164 return *
const_cast<pointer
>(ptr_at(index));
167 template<
typename TIdx>
170 auto extent =
getExtents(*
static_cast<TView const*
>(
this));
171 if(!(index < extent).all())
173 std::stringstream msg;
174 msg <<
"index " << index <<
" is outside of the Buffer or View extent " << extent;
175 throw std::out_of_range(msg.str());
177 return *ptr_at(index);
181 template<
typename TDev>
184 template<ViewType TView>
191 template<ViewType TView>
195#ifdef ALPAKA_ACC_SYCL_ENABLED
199 template<ViewType TView>
204 template<
typename TDev, ViewType TView>
typename ViewAccessor< TDev >::template AccessorType< TView > ViewAccessorType
The alpaka accelerator library.
typename trait::IdxType< T >::type Idx
ALPAKA_FN_HOST auto getPitchesInBytes(TView const &view) -> Vec< Dim< TView >, Idx< TView > >
ALPAKA_FN_HOST auto getPtrNative(TView const &view) -> Elem< TView > const *
Gets the native pointer of the memory view.
std::remove_volatile_t< typename trait::ElemType< TView >::type > Elem
The element type trait alias template to remove the ::type.
ALPAKA_NO_HOST_ACC_WARNING ALPAKA_FN_HOST_ACC auto getExtents(T const &object) -> Vec< Dim< T >, Idx< T > >
typename trait::DimType< T >::type Dim
The dimension type trait alias template to remove the ::type.
ALPAKA_FN_HOST auto data() const -> const_pointer
ALPAKA_FN_HOST auto data() -> pointer
ALPAKA_FN_HOST auto at(Vec< Dim, TIdx > index) const -> const_reference
ALPAKA_FN_HOST auto operator[](Vec< Dim, TIdx > index) -> reference
ALPAKA_FN_HOST auto data() -> pointer
ALPAKA_FN_HOST auto at(Vec< Dim, TIdx > index) -> reference
ALPAKA_FN_HOST auto operator[](Idx i) -> reference
ALPAKA_FN_HOST auto operator*() const -> const_reference
ALPAKA_FN_HOST auto operator*() -> reference
ALPAKA_FN_HOST auto operator->() const -> const_pointer
ALPAKA_FN_HOST auto operator[](Vec< Dim, TIdx > index) const -> const_reference
ALPAKA_FN_HOST auto operator[](Idx i) const -> const_reference
ALPAKA_FN_HOST auto operator->() -> pointer
ALPAKA_FN_HOST auto data() const -> const_pointer
DeviceViewAccessor< TView > AccessorType