27 template<
typename TView>
42 template<ViewType TView>
47 using pointer = value_type*;
48 using const_pointer = value_type
const*;
49 using reference = value_type&;
50 using const_reference = value_type
const&;
102 return getExtents(*
static_cast<TView const*
>(
this))[0];
107 return getExtents(*
static_cast<TView const*
>(
this)).prod();
112 return getExtents(*
static_cast<TView const*
>(
this))[dim];
118# pragma clang diagnostic push
119# if __has_warning("-Wunsafe-buffer-usage-in-container")
120# pragma clang diagnostic ignored "-Wunsafe-buffer-usage-in-container"
123 ALPAKA_FN_HOST operator std::span<value_type const>() const requires(Dim::value == 1)
125 return std::span<value_type const>{
begin(),
end()};
130 return std::span<value_type>{
begin(),
end()};
133# pragma clang diagnostic pop
137 template<ViewType TView>
140 template<ViewType TView>
145 using pointer = value_type*;
146 using const_pointer = value_type
const*;
147 using reference = value_type&;
148 using const_reference = value_type
const&;
155 static_assert(Dim::value == 0,
"operator* is only valid for Buffers and Views of dimension 0");
156 return *(this->
data());
161 static_assert(Dim::value == 0,
"operator* is only valid for Buffers and Views of dimension 0");
162 return *(this->
data());
167 static_assert(Dim::value == 0,
"operator-> is only valid for Buffers and Views of dimension 0");
168 return *(this->
data());
173 static_assert(Dim::value == 0,
"operator-> is only valid for Buffers and Views of dimension 0");
179 static_assert(Dim::value == 1,
"operator[i] is only valid for Buffers and Views of dimension 1");
180 return this->
data()[i];
185 static_assert(Dim::value == 1,
"operator[i] is only valid for Buffers and Views of dimension 1");
186 return this->
data()[i];
190 template<
typename TIdx>
194 std::is_convertible_v<TIdx, Idx>,
195 "the index type must be convertible to the index of the Buffer or View");
197 auto ptr =
reinterpret_cast<std::uintptr_t
>(this->
data());
198 if constexpr(Dim::value > 0)
200 ptr +=
static_cast<std::uintptr_t
>(
201 (
getPitchesInBytes(*
static_cast<TView const*
>(
this)) * castVec<Idx>(index)).sum());
203 return reinterpret_cast<const_pointer
>(ptr);
207 template<
typename TIdx>
210 return *
const_cast<pointer
>(ptr_at(index));
213 template<
typename TIdx>
216 return *ptr_at(index);
219 template<
typename TIdx>
223 if(!(index <
extent).all())
225 std::stringstream msg;
226 msg <<
"index " << index <<
" is outside of the Buffer or View extent " <<
extent;
227 throw std::out_of_range(msg.str());
229 return *
const_cast<pointer
>(ptr_at(index));
232 template<
typename TIdx>
236 if(!(index <
extent).all())
238 std::stringstream msg;
239 msg <<
"index " << index <<
" is outside of the Buffer or View extent " <<
extent;
240 throw std::out_of_range(msg.str());
242 return *ptr_at(index);
246 template<
typename TDev>
249 template<ViewType TView>
256 template<ViewType TView>
260#ifdef ALPAKA_ACC_SYCL_ENABLED
264 template<ViewType TView>
269 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 size() const -> Idx requires(Dim::value==1)
ALPAKA_FN_HOST auto data() const -> const_pointer
ALPAKA_FN_HOST auto cbegin() const -> const_pointer requires(Dim::value==1)
ALPAKA_FN_HOST auto size() const -> Idx requires(Dim::value > 1)
ALPAKA_FN_HOST auto extent(Idx dim) const -> Idx
ALPAKA_FN_HOST auto cend() const -> const_pointer requires(Dim::value==1)
ALPAKA_FN_HOST auto end() -> pointer requires(Dim::value==1)
ALPAKA_FN_HOST auto rank() const -> Idx
ALPAKA_FN_HOST auto extents() const -> Vec< Dim, Idx >
ALPAKA_FN_HOST auto end() const -> const_pointer requires(Dim::value==1)
ALPAKA_FN_HOST auto begin() const -> const_pointer requires(Dim::value==1)
ALPAKA_FN_HOST auto data() -> pointer
ALPAKA_FN_HOST auto begin() -> pointer requires(Dim::value==1)
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 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
DeviceViewAccessor< TView > AccessorType