26 template<
typename TView>
45 template<concepts::View TView>
50 using pointer = value_type*;
51 using const_pointer = value_type
const*;
52 using reference = value_type&;
53 using const_reference = value_type
const&;
105 return getExtents(*
static_cast<TView const*
>(
this))[0];
110 return getExtents(*
static_cast<TView const*
>(
this)).prod();
115 return getExtents(*
static_cast<TView const*
>(
this))[dim];
121# pragma clang diagnostic push
122# if __has_warning("-Wunsafe-buffer-usage-in-container")
123# pragma clang diagnostic ignored "-Wunsafe-buffer-usage-in-container"
126 ALPAKA_FN_HOST operator std::span<value_type const>() const requires(Dim::value == 1)
128 return std::span<value_type const>{
begin(),
end()};
133 return std::span<value_type>{
begin(),
end()};
136# pragma clang diagnostic pop
140 template<concepts::View TView>
143 template<concepts::View TView>
148 using pointer = value_type*;
149 using const_pointer = value_type
const*;
150 using reference = value_type&;
151 using const_reference = value_type
const&;
158 static_assert(Dim::value == 0,
"operator* is only valid for Buffers and Views of dimension 0");
159 return *(this->
data());
164 static_assert(Dim::value == 0,
"operator* is only valid for Buffers and Views of dimension 0");
165 return *(this->
data());
170 static_assert(Dim::value == 0,
"operator-> is only valid for Buffers and Views of dimension 0");
176 static_assert(Dim::value == 0,
"operator-> is only valid for Buffers and Views of dimension 0");
182 static_assert(Dim::value == 1,
"operator[i] is only valid for Buffers and Views of dimension 1");
183 return this->
data()[i];
188 static_assert(Dim::value == 1,
"operator[i] is only valid for Buffers and Views of dimension 1");
189 return this->
data()[i];
193 template<
typename TIdx>
197 std::is_convertible_v<TIdx, Idx>,
198 "the index type must be convertible to the index of the Buffer or View");
200 auto ptr =
reinterpret_cast<std::uintptr_t
>(this->
data());
201 if constexpr(Dim::value > 0)
203 ptr +=
static_cast<std::uintptr_t
>(
206 return reinterpret_cast<const_pointer
>(ptr);
210 template<
typename TIdx>
213 return *
const_cast<pointer
>(ptr_at(index));
216 template<
typename TIdx>
219 return *ptr_at(index);
222 template<
typename TIdx>
226 if(!(index <
extent).all())
228 std::stringstream msg;
229 msg <<
"index " << index <<
" is outside of the Buffer or View extent " <<
extent;
230 throw std::out_of_range(msg.str());
232 return *
const_cast<pointer
>(ptr_at(index));
235 template<
typename TIdx>
239 if(!(index <
extent).all())
241 std::stringstream msg;
242 msg <<
"index " << index <<
" is outside of the Buffer or View extent " <<
extent;
243 throw std::out_of_range(msg.str());
245 return *ptr_at(index);
249 template<
typename TDev>
252 template<concepts::View TView>
259 template<concepts::View TView>
263#ifdef ALPAKA_ACC_SYCL_ENABLED
267 template<concepts::View TView>
272 template<
typename TDev, concepts::View TView>
typename ViewAccessor< TDev >::template AccessorType< TView > ViewAccessorType
The alpaka accelerator library.
std::remove_volatile_t< typename trait::ElemType< TView >::type > Elem
The element type trait alias template to remove the ::type.
ALPAKA_FN_HOST auto getPitchesInBytes(TView const &view) -> Vec< Dim< TView >, Idx< TView > >
ALPAKA_NO_HOST_ACC_WARNING ALPAKA_FN_HOST_ACC constexpr auto castVec(TVec const &vec)
typename trait::IdxType< T >::type Idx
ALPAKA_FN_HOST auto getPtrNative(TView const &view) -> Elem< TView > const *
Gets the native pointer of the memory view.
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