alpaka
Abstraction Library for Parallel Kernel Acceleration
Loading...
Searching...
No Matches
alpaka::MdSpan< T_Type, T_Extents, T_Pitches, T_MemAlignment > Struct Template Reference

Lightweight view to data in an n-dimensional array. More...

#include <MdSpan.hpp>

Public Types

using const_pointer = std::add_const_t<value_type>*
using const_reference = std::add_const_t<value_type>&
using ConstThis = MdSpan<std::add_const_t<value_type>, T_Extents, T_Pitches, T_MemAlignment>
using index_type = typename T_Pitches::type
using pointer = value_type*
using reference = value_type&
using value_type = T_Type

Public Member Functions

constexpr MdSpan ()=default
constexpr MdSpan (MdSpan &&)=default
constexpr MdSpan (MdSpan const &)=default
template<typename T_Type_Other>
constexpr MdSpan (MdSpan< T_Type_Other, T_Extents, T_Pitches, T_MemAlignment > &&other)
template<typename T_Type_Other>
constexpr MdSpan (MdSpan< T_Type_Other, T_Extents, T_Pitches, T_MemAlignment > const &other)
constexpr MdSpan (T_Type *pointer, T_Extents extents, T_Pitches const &pitchBytes, T_MemAlignment const &memAlignmentInByte=T_MemAlignment{})
 Constructor.
constexpr auto begin ()
constexpr auto begin () const
constexpr auto cbegin () const
constexpr auto cend () const
constexpr pointer data ()
constexpr const_pointer data () const
 get origin pointer
constexpr auto end ()
constexpr auto end () const
constexpr auto getConstMdSpan () const
constexpr auto getExtents () const
constexpr T_Pitches getPitches () const
constexpr operator bool () const noexcept
 True if MdSpan is pointing to valid memory.
constexpr reference operator* ()
constexpr const_reference operator* () const
 return value the origin pointer is pointing to
constexpr MdSpanoperator= (MdSpan &&)=default
constexpr MdSpanoperator= (MdSpan const &)=default
 Assignment operator keeping const-ness.
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 reference operator[] (std::integral auto const &idx)
constexpr const_reference operator[] (std::integral auto const &idx) const

Static Public Member Functions

static consteval uint32_t dim ()
static constexpr auto getAlignment ()

Protected Member Functions

constexpr pointer ptr (concepts::Vector auto const &idx)
constexpr const_pointer ptr (concepts::Vector auto const &idx) const
constexpr auto ptr (concepts::Vector auto const &idx) const
 get the pointer of the value relative to the origin pointer m_ptr

Detailed Description

template<typename T_Type, concepts::Vector T_Extents, concepts::Vector T_Pitches, concepts::Alignment T_MemAlignment>
struct alpaka::MdSpan< T_Type, T_Extents, T_Pitches, T_MemAlignment >

Lightweight view to data in an n-dimensional array.

Const-ness of the MdSpan instance is propagated to the data region. A constant MdSpan can be used to access non-const data.

Template Parameters
T_Typeif the type is const the data is only readable

Definition at line 67 of file MdSpan.hpp.

Member Typedef Documentation

◆ const_pointer

template<typename T_Type, concepts::Vector T_Extents, concepts::Vector T_Pitches, concepts::Alignment T_MemAlignment>
using alpaka::MdSpan< T_Type, T_Extents, T_Pitches, T_MemAlignment >::const_pointer = std::add_const_t<value_type>*

Definition at line 73 of file MdSpan.hpp.

◆ const_reference

template<typename T_Type, concepts::Vector T_Extents, concepts::Vector T_Pitches, concepts::Alignment T_MemAlignment>
using alpaka::MdSpan< T_Type, T_Extents, T_Pitches, T_MemAlignment >::const_reference = std::add_const_t<value_type>&

Definition at line 71 of file MdSpan.hpp.

◆ ConstThis

template<typename T_Type, concepts::Vector T_Extents, concepts::Vector T_Pitches, concepts::Alignment T_MemAlignment>
using alpaka::MdSpan< T_Type, T_Extents, T_Pitches, T_MemAlignment >::ConstThis = MdSpan<std::add_const_t<value_type>, T_Extents, T_Pitches, T_MemAlignment>

Definition at line 76 of file MdSpan.hpp.

◆ index_type

template<typename T_Type, concepts::Vector T_Extents, concepts::Vector T_Pitches, concepts::Alignment T_MemAlignment>
using alpaka::MdSpan< T_Type, T_Extents, T_Pitches, T_MemAlignment >::index_type = typename T_Pitches::type

Definition at line 74 of file MdSpan.hpp.

◆ pointer

template<typename T_Type, concepts::Vector T_Extents, concepts::Vector T_Pitches, concepts::Alignment T_MemAlignment>
using alpaka::MdSpan< T_Type, T_Extents, T_Pitches, T_MemAlignment >::pointer = value_type*

Definition at line 72 of file MdSpan.hpp.

◆ reference

template<typename T_Type, concepts::Vector T_Extents, concepts::Vector T_Pitches, concepts::Alignment T_MemAlignment>
using alpaka::MdSpan< T_Type, T_Extents, T_Pitches, T_MemAlignment >::reference = value_type&

Definition at line 70 of file MdSpan.hpp.

◆ value_type

template<typename T_Type, concepts::Vector T_Extents, concepts::Vector T_Pitches, concepts::Alignment T_MemAlignment>
using alpaka::MdSpan< T_Type, T_Extents, T_Pitches, T_MemAlignment >::value_type = T_Type

Definition at line 69 of file MdSpan.hpp.

Constructor & Destructor Documentation

◆ MdSpan() [1/6]

template<typename T_Type, concepts::Vector T_Extents, concepts::Vector T_Pitches, concepts::Alignment T_MemAlignment>
alpaka::MdSpan< T_Type, T_Extents, T_Pitches, T_MemAlignment >::MdSpan ( )
constexprdefault

◆ MdSpan() [2/6]

template<typename T_Type, concepts::Vector T_Extents, concepts::Vector T_Pitches, concepts::Alignment T_MemAlignment>
alpaka::MdSpan< T_Type, T_Extents, T_Pitches, T_MemAlignment >::MdSpan ( T_Type * pointer,
T_Extents extents,
T_Pitches const & pitchBytes,
T_MemAlignment const & memAlignmentInByte = T_MemAlignment{} )
inlineconstexpr

Constructor.

Parameters
pointerpointer to the memory
extentsnumber of elements
pitchBytespitch in bytes per dimension
memAlignmentInBytealignment in bytes (zero will set alignment to element alignment)

Definition at line 154 of file MdSpan.hpp.

◆ MdSpan() [3/6]

template<typename T_Type, concepts::Vector T_Extents, concepts::Vector T_Pitches, concepts::Alignment T_MemAlignment>
template<typename T_Type_Other>
alpaka::MdSpan< T_Type, T_Extents, T_Pitches, T_MemAlignment >::MdSpan ( MdSpan< T_Type_Other, T_Extents, T_Pitches, T_MemAlignment > const & other)
inlineconstexpr

Definition at line 167 of file MdSpan.hpp.

◆ MdSpan() [4/6]

template<typename T_Type, concepts::Vector T_Extents, concepts::Vector T_Pitches, concepts::Alignment T_MemAlignment>
template<typename T_Type_Other>
alpaka::MdSpan< T_Type, T_Extents, T_Pitches, T_MemAlignment >::MdSpan ( MdSpan< T_Type_Other, T_Extents, T_Pitches, T_MemAlignment > && other)
inlineconstexpr

Definition at line 176 of file MdSpan.hpp.

◆ MdSpan() [5/6]

template<typename T_Type, concepts::Vector T_Extents, concepts::Vector T_Pitches, concepts::Alignment T_MemAlignment>
alpaka::MdSpan< T_Type, T_Extents, T_Pitches, T_MemAlignment >::MdSpan ( MdSpan< T_Type, T_Extents, T_Pitches, T_MemAlignment > const & )
constexprdefault

◆ MdSpan() [6/6]

template<typename T_Type, concepts::Vector T_Extents, concepts::Vector T_Pitches, concepts::Alignment T_MemAlignment>
alpaka::MdSpan< T_Type, T_Extents, T_Pitches, T_MemAlignment >::MdSpan ( MdSpan< T_Type, T_Extents, T_Pitches, T_MemAlignment > && )
constexprdefault

Member Function Documentation

◆ begin() [1/2]

template<typename T_Type, concepts::Vector T_Extents, concepts::Vector T_Pitches, concepts::Alignment T_MemAlignment>
auto alpaka::MdSpan< T_Type, T_Extents, T_Pitches, T_MemAlignment >::begin ( )
inlineconstexpr

Definition at line 119 of file MdSpan.hpp.

◆ begin() [2/2]

template<typename T_Type, concepts::Vector T_Extents, concepts::Vector T_Pitches, concepts::Alignment T_MemAlignment>
auto alpaka::MdSpan< T_Type, T_Extents, T_Pitches, T_MemAlignment >::begin ( ) const
inlineconstexpr

Definition at line 114 of file MdSpan.hpp.

◆ cbegin()

template<typename T_Type, concepts::Vector T_Extents, concepts::Vector T_Pitches, concepts::Alignment T_MemAlignment>
auto alpaka::MdSpan< T_Type, T_Extents, T_Pitches, T_MemAlignment >::cbegin ( ) const
inlineconstexpr

Definition at line 134 of file MdSpan.hpp.

◆ cend()

template<typename T_Type, concepts::Vector T_Extents, concepts::Vector T_Pitches, concepts::Alignment T_MemAlignment>
auto alpaka::MdSpan< T_Type, T_Extents, T_Pitches, T_MemAlignment >::cend ( ) const
inlineconstexpr

Definition at line 139 of file MdSpan.hpp.

◆ data() [1/2]

template<typename T_Type, concepts::Vector T_Extents, concepts::Vector T_Pitches, concepts::Alignment T_MemAlignment>
pointer alpaka::MdSpan< T_Type, T_Extents, T_Pitches, T_MemAlignment >::data ( )
inlineconstexpr

Definition at line 109 of file MdSpan.hpp.

◆ data() [2/2]

template<typename T_Type, concepts::Vector T_Extents, concepts::Vector T_Pitches, concepts::Alignment T_MemAlignment>
const_pointer alpaka::MdSpan< T_Type, T_Extents, T_Pitches, T_MemAlignment >::data ( ) const
inlineconstexpr

get origin pointer

If the pointer is const and therefore read only depends on T_Type and not the const-ness of MdSPan.

Definition at line 104 of file MdSpan.hpp.

◆ dim()

template<typename T_Type, concepts::Vector T_Extents, concepts::Vector T_Pitches, concepts::Alignment T_MemAlignment>
consteval uint32_t alpaka::MdSpan< T_Type, T_Extents, T_Pitches, T_MemAlignment >::dim ( )
inlinestaticconsteval

Definition at line 81 of file MdSpan.hpp.

◆ end() [1/2]

template<typename T_Type, concepts::Vector T_Extents, concepts::Vector T_Pitches, concepts::Alignment T_MemAlignment>
auto alpaka::MdSpan< T_Type, T_Extents, T_Pitches, T_MemAlignment >::end ( )
inlineconstexpr

Definition at line 129 of file MdSpan.hpp.

◆ end() [2/2]

template<typename T_Type, concepts::Vector T_Extents, concepts::Vector T_Pitches, concepts::Alignment T_MemAlignment>
auto alpaka::MdSpan< T_Type, T_Extents, T_Pitches, T_MemAlignment >::end ( ) const
inlineconstexpr

Definition at line 124 of file MdSpan.hpp.

◆ getAlignment()

template<typename T_Type, concepts::Vector T_Extents, concepts::Vector T_Pitches, concepts::Alignment T_MemAlignment>
constexpr auto alpaka::MdSpan< T_Type, T_Extents, T_Pitches, T_MemAlignment >::getAlignment ( )
inlinestaticconstexpr

Definition at line 194 of file MdSpan.hpp.

◆ getConstMdSpan()

template<typename T_Type, concepts::Vector T_Extents, concepts::Vector T_Pitches, concepts::Alignment T_MemAlignment>
auto alpaka::MdSpan< T_Type, T_Extents, T_Pitches, T_MemAlignment >::getConstMdSpan ( ) const
inlineconstexpr

Definition at line 238 of file MdSpan.hpp.

◆ getExtents()

template<typename T_Type, concepts::Vector T_Extents, concepts::Vector T_Pitches, concepts::Alignment T_MemAlignment>
auto alpaka::MdSpan< T_Type, T_Extents, T_Pitches, T_MemAlignment >::getExtents ( ) const
inlineconstexpr

Definition at line 228 of file MdSpan.hpp.

◆ getPitches()

template<typename T_Type, concepts::Vector T_Extents, concepts::Vector T_Pitches, concepts::Alignment T_MemAlignment>
T_Pitches alpaka::MdSpan< T_Type, T_Extents, T_Pitches, T_MemAlignment >::getPitches ( ) const
inlineconstexpr

Definition at line 233 of file MdSpan.hpp.

◆ operator bool()

template<typename T_Type, concepts::Vector T_Extents, concepts::Vector T_Pitches, concepts::Alignment T_MemAlignment>
alpaka::MdSpan< T_Type, T_Extents, T_Pitches, T_MemAlignment >::operator bool ( ) const
inlineexplicitnodiscardconstexprnoexcept

True if MdSpan is pointing to valid memory.

An MdSpan remains valid even after being moved. The reason for this is that the MdSpan is simply copied. This is more efficient than a real move (e.g., setting the data pointer to nullptr). Implementing a real move is also not possible because MdSpan must be trivially copyable, which requires a default move constructor.

Definition at line 256 of file MdSpan.hpp.

◆ operator*() [1/2]

template<typename T_Type, concepts::Vector T_Extents, concepts::Vector T_Pitches, concepts::Alignment T_MemAlignment>
reference alpaka::MdSpan< T_Type, T_Extents, T_Pitches, T_MemAlignment >::operator* ( )
inlineconstexpr

Definition at line 95 of file MdSpan.hpp.

◆ operator*() [2/2]

template<typename T_Type, concepts::Vector T_Extents, concepts::Vector T_Pitches, concepts::Alignment T_MemAlignment>
const_reference alpaka::MdSpan< T_Type, T_Extents, T_Pitches, T_MemAlignment >::operator* ( ) const
inlineconstexpr

return value the origin pointer is pointing to

Returns
value at the current location

Definition at line 90 of file MdSpan.hpp.

◆ operator=() [1/2]

template<typename T_Type, concepts::Vector T_Extents, concepts::Vector T_Pitches, concepts::Alignment T_MemAlignment>
MdSpan & alpaka::MdSpan< T_Type, T_Extents, T_Pitches, T_MemAlignment >::operator= ( MdSpan< T_Type, T_Extents, T_Pitches, T_MemAlignment > && )
constexprdefault

◆ operator=() [2/2]

template<typename T_Type, concepts::Vector T_Extents, concepts::Vector T_Pitches, concepts::Alignment T_MemAlignment>
MdSpan & alpaka::MdSpan< T_Type, T_Extents, T_Pitches, T_MemAlignment >::operator= ( MdSpan< T_Type, T_Extents, T_Pitches, T_MemAlignment > const & )
constexprdefault

Assignment operator keeping const-ness.

Attention
the assign operator is not removing inner const-ness because the type signature is not changed.

◆ operator[]() [1/4]

template<typename T_Type, concepts::Vector T_Extents, concepts::Vector T_Pitches, concepts::Alignment T_MemAlignment>
reference alpaka::MdSpan< T_Type, T_Extents, T_Pitches, T_MemAlignment >::operator[] ( concepts::IndexVec< index_type, alpaka::trait::GetDim< T_Extents >::value > auto const & idx)
inlineconstexpr

Definition at line 211 of file MdSpan.hpp.

◆ operator[]() [2/4]

template<typename T_Type, concepts::Vector T_Extents, concepts::Vector T_Pitches, concepts::Alignment T_MemAlignment>
const_reference alpaka::MdSpan< T_Type, T_Extents, T_Pitches, T_MemAlignment >::operator[] ( concepts::IndexVec< index_type, alpaka::trait::GetDim< T_Extents >::value > auto const & idx) const
inlineconstexpr

get value at the given index

Parameters
idxn-dimensional offset, relative to the origin pointer
Returns
reference to the value

Definition at line 204 of file MdSpan.hpp.

◆ operator[]() [3/4]

template<typename T_Type, concepts::Vector T_Extents, concepts::Vector T_Pitches, concepts::Alignment T_MemAlignment>
reference alpaka::MdSpan< T_Type, T_Extents, T_Pitches, T_MemAlignment >::operator[] ( std::integral auto const & idx)
inlineconstexpr

Definition at line 223 of file MdSpan.hpp.

◆ operator[]() [4/4]

template<typename T_Type, concepts::Vector T_Extents, concepts::Vector T_Pitches, concepts::Alignment T_MemAlignment>
const_reference alpaka::MdSpan< T_Type, T_Extents, T_Pitches, T_MemAlignment >::operator[] ( std::integral auto const & idx) const
inlineconstexpr

Definition at line 218 of file MdSpan.hpp.

◆ ptr() [1/3]

template<typename T_Type, concepts::Vector T_Extents, concepts::Vector T_Pitches, concepts::Alignment T_MemAlignment>
pointer alpaka::MdSpan< T_Type, T_Extents, T_Pitches, T_MemAlignment >::ptr ( concepts::Vector auto const & idx)
inlineconstexprprotected

Definition at line 289 of file MdSpan.hpp.

◆ ptr() [2/3]

template<typename T_Type, concepts::Vector T_Extents, concepts::Vector T_Pitches, concepts::Alignment T_MemAlignment>
const_pointer alpaka::MdSpan< T_Type, T_Extents, T_Pitches, T_MemAlignment >::ptr ( concepts::Vector auto const & idx) const
inlineconstexprprotected

Definition at line 284 of file MdSpan.hpp.

◆ ptr() [3/3]

template<typename T_Type, concepts::Vector T_Extents, concepts::Vector T_Pitches, concepts::Alignment T_MemAlignment>
auto alpaka::MdSpan< T_Type, T_Extents, T_Pitches, T_MemAlignment >::ptr ( concepts::Vector auto const & idx) const
inlineconstexprprotected

get the pointer of the value relative to the origin pointer m_ptr

Parameters
idxn-dimensional offset
Returns
pointer to value

offset in bytes

We calculate the complete offset in bytes even if it would be possible to change the x-dimension with the native value_types pointer, this is reducing the register footprint.

Definition at line 267 of file MdSpan.hpp.


The documentation for this struct was generated from the following file: