37 template<concepts::Alignment T_MemAlignment = Alignment<>>
42 T_MemAlignment
const memAlignment = T_MemAlignment{})
44 return MdSpan{pointer, extents, pitchBytes, memAlignment};
47 template<
typename T_ValueType, concepts::Alignment T_MemAlignment = Alignment<>>
51 T_MemAlignment
const memAlignment = T_MemAlignment{})
54 return MdSpan{pointer, extents, pitchMd, memAlignment};
64 concepts::Vector T_Extents,
65 concepts::Vector T_Pitches,
66 concepts::Alignment T_MemAlignment>
78 static_assert(std::is_convertible_v<index_type, typename T_Extents::type>);
79 static_assert(T_Extents::dim() == T_Pitches::dim());
81 static consteval uint32_t
dim()
83 return T_Extents::dim();
124 constexpr auto end()
const
157 T_Pitches
const& pitchBytes,
158 [[maybe_unused]] T_MemAlignment
const& memAlignmentInByte = T_MemAlignment{})
161 , m_pitch(pitchBytes)
165 template<
typename T_Type_Other>
166 requires internal::concepts::InnerTypeAllowedCast<T_Type, T_Type_Other>
168 : m_ptr(other.
data())
174 template<
typename T_Type_Other>
175 requires alpaka::internal::concepts::InnerTypeAllowedCast<T_Type, T_Type_Other>
177 : m_ptr(
std::move(other.
data()))
196 return T_MemAlignment{};
235 return m_pitch.getPitches();
240 using ConstValueType = std::add_const_t<value_type>;
242 static_cast<ConstValueType*
>(m_ptr),
256 [[nodiscard]]
constexpr explicit operator bool() const noexcept
275 for(uint32_t d = 0u; d <
dim() - 1u; ++d)
277 offset += m_pitch[d] * idx[d];
279 using CharPtrType = std::conditional_t<std::is_const_v<value_type>,
char const*,
char*>;
281 return reinterpret_cast<ResultPtrType
>(
reinterpret_cast<CharPtrType
>(this->m_ptr) + offset);
286 return this->m_ptr + idx.x();
291 return this->m_ptr + idx.x();
302 concepts::Vector T_Extents,
303 concepts::Vector T_Pitches,
304 concepts::Alignment T_MemAlignment>
308 <<
", pitches=" << mdSpan.
getPitches().toString()
309 <<
" , alignment=" << T_MemAlignment::template
get<T_Type>() <<
" }";
317 struct internal::CopyConstructableDataSource<MdSpan<T_Type, T_Extents, T_Pitches, T_MemAlignment>> : std::true_type
319 using InnerMutable = MdSpan<std::remove_const_t<T_Type>, T_Extents, T_Pitches, T_MemAlignment>;
320 using InnerConst = MdSpan<std::add_const_t<T_Type>, T_Extents, T_Pitches, T_MemAlignment>;
special implementation to define the end
#define ALPAKA_TYPEOF(...)
Get the type of instance.
Concept to check for an alignment object.
Check whether the specified type is a multidimensional index.
Concept to check if a type is a vector.
decltype(auto) data(auto &&any)
pointer to data of an object
decltype(auto) getExtents(auto &&any)
Object extents.
decltype(auto) getPitches(auto &&any)
Object pitches.
std::ostream & operator<<(std::ostream &os, concepts::BoundaryDirection auto const &bd)
constexpr auto calculatePitchesFromExtents(T_Vec const &extent)
Calculate the pitches purely from the extents.
constexpr auto getAlignment(auto &&any)
Get the value type alignment of an object.
constexpr auto makeMdSpan(auto *pointer, concepts::Vector auto const &extents, concepts::Vector auto const &pitchBytes, T_MemAlignment const memAlignment=T_MemAlignment{})
constexpr decltype(auto) get(concepts::SpecializationOf< Dict > auto &t) noexcept
Strongly typed and constexpr representation of a byte-alignment of memory.
Lightweight view to data in an n-dimensional array.
constexpr auto ptr(concepts::Vector auto const &idx) const
get the pointer of the value relative to the origin pointer m_ptr
constexpr MdSpan(T_Type *pointer, T_Extents extents, T_Pitches const &pitchBytes, T_MemAlignment const &memAlignmentInByte=T_MemAlignment{})
Constructor.
std::add_const_t< value_type > & const_reference
constexpr auto end() const
constexpr reference operator*()
constexpr auto cbegin() const
constexpr auto cend() const
constexpr reference operator[](concepts::IndexVec< index_type, alpaka::trait::GetDim< T_Extents >::value > auto const &idx)
constexpr const_reference operator[](concepts::IndexVec< index_type, alpaka::trait::GetDim< T_Extents >::value > auto const &idx) const
get value at the given index
constexpr MdSpan(MdSpan< T_Type_Other, T_Extents, T_Pitches, T_MemAlignment > const &other)
constexpr const_pointer ptr(concepts::Vector auto const &idx) const
constexpr MdSpan()=default
constexpr pointer ptr(concepts::Vector auto const &idx)
typename T_Pitches::type index_type
constexpr auto begin() const
constexpr MdSpan(MdSpan< T_Type_Other, T_Extents, T_Pitches, T_MemAlignment > &&other)
constexpr MdSpan(MdSpan &&)=default
constexpr auto getExtents() const
constexpr MdSpan(MdSpan const &)=default
static consteval uint32_t dim()
constexpr auto getConstMdSpan() const
constexpr const_pointer data() const
get origin pointer
constexpr T_Pitches getPitches() const
constexpr MdSpan & operator=(MdSpan const &)=default
Assignment operator keeping const-ness.
constexpr const_reference operator*() const
return value the origin pointer is pointing to
std::add_const_t< value_type > * const_pointer
constexpr const_reference operator[](std::integral auto const &idx) const
static constexpr auto getAlignment()
MdSpan< std::add_const_t< value_type >, T_Extents, T_Pitches, T_MemAlignment > ConstThis
constexpr reference operator[](std::integral auto const &idx)
constexpr MdSpan & operator=(MdSpan &&)=default
static constexpr uint32_t value