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

Non owning view to data. More...

#include <View.hpp>

Inheritance diagram for alpaka::View< T_Api, T_Type, T_Extents, T_MemAlignment >:

Public Member Functions

template<alpaka::concepts::HasApi T_Any, alpaka::concepts::Vector T_UserExtents, alpaka::concepts::Vector T_UserPitches>
constexpr View (T_Any const &any, T_Type *data, T_UserExtents const &extents, T_UserPitches const &pitches, T_MemAlignment const memAlignment=T_MemAlignment{})
 Creates a view.
constexpr View (View &&)=default
constexpr View (View const &)=default
template<typename T_Type_Other>
constexpr View (View< T_Api, T_Type_Other, T_Extents, T_MemAlignment > &&other)
template<typename T_Type_Other>
constexpr View (View< T_Api, T_Type_Other, T_Extents, T_MemAlignment > const &other)
constexpr auto getConstView () const
 create a read only view
constexpr alpaka::concepts::IMdSpan auto getMdSpan ()
constexpr alpaka::concepts::IMdSpan auto getMdSpan () const
template<alpaka::concepts::Vector LowHaloVecType, alpaka::concepts::Vector UpHaloVecType>
constexpr auto getSubView (alpaka::BoundaryDirection< View::dim(), LowHaloVecType, UpHaloVecType > boundaryDir) const
constexpr Viewoperator= (View &&)=default
constexpr Viewoperator= (View const &)=default
 Assignment operator keeping const-ness.
constexpr auto getSubView (alpaka::concepts::VectorOrScalar auto const &extents) const
 Creates a sub view to a part of the memory.
constexpr auto getSubView (alpaka::concepts::VectorOrScalar auto const &extents)
 Creates a sub view to a part of the memory.
constexpr auto getSubView (alpaka::concepts::VectorOrScalar auto const &offset, alpaka::concepts::VectorOrScalar auto const &extents) const
 Creates a sub view to a part of the memory.
constexpr auto getSubView (alpaka::concepts::VectorOrScalar auto const &offset, alpaka::concepts::VectorOrScalar auto const &extents)
 Creates a sub view to a part of the memory.
Public Member Functions inherited from alpaka::MdSpan< T_Type, T_Extents::UniVec, T_Extents::UniVec, T_MemAlignment >
constexpr MdSpan ()=default
constexpr auto begin () const
constexpr auto cbegin () const
constexpr auto cend () const
constexpr const_pointer data () const
 get origin pointer
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 const_reference operator* () const
 return value the origin pointer is pointing to
constexpr MdSpanoperator= (MdSpan const &)=default
 Assignment operator keeping const-ness.
constexpr const_reference operator[] (concepts::IndexVec< index_type, alpaka::trait::GetDim< T_Extents >::value > auto const &idx) const
 get value at the given index

Static Public Member Functions

static consteval T_Api getApi ()
Static Public Member Functions inherited from alpaka::MdSpan< T_Type, T_Extents::UniVec, T_Extents::UniVec, T_MemAlignment >
static consteval uint32_t dim ()
static constexpr auto getAlignment ()

Private Types

using BaseMdSpan = MdSpan<T_Type, typename T_Extents::UniVec, typename T_Extents::UniVec, T_MemAlignment>

Additional Inherited Members

Public Types inherited from alpaka::MdSpan< T_Type, T_Extents::UniVec, T_Extents::UniVec, T_MemAlignment >
using const_pointer
using const_reference
using ConstThis
using index_type
using pointer
using reference
using value_type
Protected Member Functions inherited from alpaka::MdSpan< T_Type, T_Extents::UniVec, T_Extents::UniVec, T_MemAlignment >
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<alpaka::concepts::Api T_Api, typename T_Type, alpaka::concepts::Vector T_Extents, alpaka::concepts::Alignment T_MemAlignment>
struct alpaka::View< T_Api, T_Type, T_Extents, T_MemAlignment >

Non owning view to data.

This view is only holding a pointer to real data, copying the view is cheap. Const-ness of the view instance is propagated to the data region.

This satisfies the alpaka::concepts::IView concept and, therefore, also the alpaka::concepts::IMdSpan concept.

Definition at line 74 of file View.hpp.

Member Typedef Documentation

◆ BaseMdSpan

template<alpaka::concepts::Api T_Api, typename T_Type, alpaka::concepts::Vector T_Extents, alpaka::concepts::Alignment T_MemAlignment>
using alpaka::View< T_Api, T_Type, T_Extents, T_MemAlignment >::BaseMdSpan = MdSpan<T_Type, typename T_Extents::UniVec, typename T_Extents::UniVec, T_MemAlignment>
private

Definition at line 77 of file View.hpp.

Constructor & Destructor Documentation

◆ View() [1/5]

template<alpaka::concepts::Api T_Api, typename T_Type, alpaka::concepts::Vector T_Extents, alpaka::concepts::Alignment T_MemAlignment>
template<alpaka::concepts::HasApi T_Any, alpaka::concepts::Vector T_UserExtents, alpaka::concepts::Vector T_UserPitches>
alpaka::View< T_Api, T_Type, T_Extents, T_MemAlignment >::View ( T_Any const & any,
T_Type * data,
T_UserExtents const & extents,
T_UserPitches const & pitches,
T_MemAlignment const memAlignment = T_MemAlignment{} )
inlineconstexpr

Creates a view.

Parameters
datahandle to the physical data
extentsn-dimensional extents in elements of the view. Must satisfy n <= number_of_elements in the data handle.

Definition at line 90 of file View.hpp.

◆ View() [2/5]

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

Definition at line 110 of file View.hpp.

◆ View() [3/5]

template<alpaka::concepts::Api T_Api, typename T_Type, alpaka::concepts::Vector T_Extents, alpaka::concepts::Alignment T_MemAlignment>
alpaka::View< T_Api, T_Type, T_Extents, T_MemAlignment >::View ( View< T_Api, T_Type, T_Extents, T_MemAlignment > const & )
constexprdefault

◆ View() [4/5]

template<alpaka::concepts::Api T_Api, typename T_Type, alpaka::concepts::Vector T_Extents, alpaka::concepts::Alignment T_MemAlignment>
template<typename T_Type_Other>
alpaka::View< T_Api, T_Type, T_Extents, T_MemAlignment >::View ( View< T_Api, T_Type_Other, T_Extents, T_MemAlignment > && other)
inlineconstexpr

Definition at line 119 of file View.hpp.

◆ View() [5/5]

template<alpaka::concepts::Api T_Api, typename T_Type, alpaka::concepts::Vector T_Extents, alpaka::concepts::Alignment T_MemAlignment>
alpaka::View< T_Api, T_Type, T_Extents, T_MemAlignment >::View ( View< T_Api, T_Type, T_Extents, T_MemAlignment > && )
constexprdefault

Member Function Documentation

◆ getApi()

template<alpaka::concepts::Api T_Api, typename T_Type, alpaka::concepts::Vector T_Extents, alpaka::concepts::Alignment T_MemAlignment>
consteval T_Api alpaka::View< T_Api, T_Type, T_Extents, T_MemAlignment >::getApi ( )
inlinestaticconsteval

Definition at line 134 of file View.hpp.

◆ getConstView()

template<alpaka::concepts::Api T_Api, typename T_Type, alpaka::concepts::Vector T_Extents, alpaka::concepts::Alignment T_MemAlignment>
auto alpaka::View< T_Api, T_Type, T_Extents, T_MemAlignment >::getConstView ( ) const
inlineconstexpr

create a read only view

Definition at line 150 of file View.hpp.

◆ getMdSpan() [1/2]

template<alpaka::concepts::Api T_Api, typename T_Type, alpaka::concepts::Vector T_Extents, alpaka::concepts::Alignment T_MemAlignment>
alpaka::concepts::IMdSpan auto alpaka::View< T_Api, T_Type, T_Extents, T_MemAlignment >::getMdSpan ( )
inlineconstexpr

Definition at line 144 of file View.hpp.

◆ getMdSpan() [2/2]

template<alpaka::concepts::Api T_Api, typename T_Type, alpaka::concepts::Vector T_Extents, alpaka::concepts::Alignment T_MemAlignment>
alpaka::concepts::IMdSpan auto alpaka::View< T_Api, T_Type, T_Extents, T_MemAlignment >::getMdSpan ( ) const
inlineconstexpr

Definition at line 139 of file View.hpp.

◆ getSubView() [1/5]

template<alpaka::concepts::Api T_Api, typename T_Type, alpaka::concepts::Vector T_Extents, alpaka::concepts::Alignment T_MemAlignment>
template<alpaka::concepts::Vector LowHaloVecType, alpaka::concepts::Vector UpHaloVecType>
auto alpaka::View< T_Api, T_Type, T_Extents, T_MemAlignment >::getSubView ( alpaka::BoundaryDirection< View< T_Api, T_Type, T_Extents, T_MemAlignment >::dim(), LowHaloVecType, UpHaloVecType > boundaryDir) const
inlineconstexpr

Definition at line 233 of file View.hpp.

◆ getSubView() [2/5]

template<alpaka::concepts::Api T_Api, typename T_Type, alpaka::concepts::Vector T_Extents, alpaka::concepts::Alignment T_MemAlignment>
auto alpaka::View< T_Api, T_Type, T_Extents, T_MemAlignment >::getSubView ( alpaka::concepts::VectorOrScalar auto const & extents)
inlineconstexpr

Creates a sub view to a part of the memory.

The sub view has the same dimension as the original.

Parameters
extentsNumber of elements for each dimension. Each number must be less than or equal to the number of elements in the original dimension.
Returns
View which is pointing only to a part of the original view.

Definition at line 179 of file View.hpp.

◆ getSubView() [3/5]

template<alpaka::concepts::Api T_Api, typename T_Type, alpaka::concepts::Vector T_Extents, alpaka::concepts::Alignment T_MemAlignment>
auto alpaka::View< T_Api, T_Type, T_Extents, T_MemAlignment >::getSubView ( alpaka::concepts::VectorOrScalar auto const & extents) const
inlineconstexpr

Creates a sub view to a part of the memory.

The sub view has the same dimension as the original.

Parameters
extentsNumber of elements for each dimension. Each number must be less than or equal to the number of elements in the original dimension.
Returns
View which is pointing only to a part of the original view.

Definition at line 171 of file View.hpp.

◆ getSubView() [4/5]

template<alpaka::concepts::Api T_Api, typename T_Type, alpaka::concepts::Vector T_Extents, alpaka::concepts::Alignment T_MemAlignment>
auto alpaka::View< T_Api, T_Type, T_Extents, T_MemAlignment >::getSubView ( alpaka::concepts::VectorOrScalar auto const & offset,
alpaka::concepts::VectorOrScalar auto const & extents )
inlineconstexpr

Creates a sub view to a part of the memory.

The sub view has the same dimension as the original. The offset defines the first coordinate of each dimension. The offset + extents - 1 defines the last element for each dimension in the original view. Offset plus extents should not exceed the extents of the original view.

Parameters
offsetoffset in elements to the original view
extentsnumber of elements for each dimension
Returns
View which is pointing only to a part of the original view with a shifted origin pointer. The alignment of the sub view is reduced to the element alignment.

Definition at line 216 of file View.hpp.

◆ getSubView() [5/5]

template<alpaka::concepts::Api T_Api, typename T_Type, alpaka::concepts::Vector T_Extents, alpaka::concepts::Alignment T_MemAlignment>
auto alpaka::View< T_Api, T_Type, T_Extents, T_MemAlignment >::getSubView ( alpaka::concepts::VectorOrScalar auto const & offset,
alpaka::concepts::VectorOrScalar auto const & extents ) const
inlineconstexpr

Creates a sub view to a part of the memory.

The sub view has the same dimension as the original. The offset defines the first coordinate of each dimension. The offset + extents - 1 defines the last element for each dimension in the original view. Offset plus extents should not exceed the extents of the original view.

Parameters
offsetoffset in elements to the original view
extentsnumber of elements for each dimension
Returns
View which is pointing only to a part of the original view with a shifted origin pointer. The alignment of the sub view is reduced to the element alignment.

Definition at line 202 of file View.hpp.

◆ operator=() [1/2]

template<alpaka::concepts::Api T_Api, typename T_Type, alpaka::concepts::Vector T_Extents, alpaka::concepts::Alignment T_MemAlignment>
View & alpaka::View< T_Api, T_Type, T_Extents, T_MemAlignment >::operator= ( View< T_Api, T_Type, T_Extents, T_MemAlignment > && )
constexprdefault

◆ operator=() [2/2]

template<alpaka::concepts::Api T_Api, typename T_Type, alpaka::concepts::Vector T_Extents, alpaka::concepts::Alignment T_MemAlignment>
View & alpaka::View< T_Api, T_Type, T_Extents, T_MemAlignment >::operator= ( View< T_Api, T_Type, T_Extents, 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.

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