Arcane  4.1.12.0
User documentation
Loading...
Searching...
No Matches
Arcane::MDSpan< DataType, Extents, LayoutPolicy > Class Template Reference

Base class for multi-dimensional views. More...

#include <arccore/base/MDSpan.h>

Public Types

using value_type = DataType
using ExtentsType = Extents
using LayoutPolicyType = LayoutPolicy
using MDIndexType = typename Extents::MDIndexType
using LoopIndexType = MDIndexType
using ArrayExtentsWithOffsetType = ArrayExtentsWithOffset<Extents, LayoutPolicy>
using DynamicDimsType = typename Extents::DynamicDimsType
using RemovedFirstExtentsType = typename Extents::RemovedFirstExtentsType
using ArrayBoundsIndexType = typename Extents::MDIndexType
using IndexType = typename Extents::MDIndexType

Public Member Functions

constexpr __host__ __device__ MDSpan (DataType *ptr, ArrayExtentsWithOffsetType extents)
constexpr __host__ __device__ MDSpan (DataType *ptr, const DynamicDimsType &dims)
template<typename X, typename = std::enable_if_t<std::is_same_v<X, UnqualifiedValueType>>>
constexpr __host__ __device__ MDSpan (const MDSpan< X, Extents > &rhs)
constexpr __host__ __device__ MDSpan (SmallSpan< DataType > v)
constexpr __host__ __device__ MDSpan (SmallSpan< const DataType > v)
constexpr __host__ __device__ ThatClass & operator= (SmallSpan< DataType > v)
constexpr __host__ __device__ ThatClass & operator= (SmallSpan< const DataType > v)
constexpr __host__ __device__ DataType * _internalData ()
constexpr __host__ __device__ const DataType * _internalData () const
ArrayExtents< Extents > extents () const
ArrayExtentsWithOffsetType extentsWithOffset () const
constexpr __host__ __device__ Int32 extent0 () const
 Value of the first dimension.
constexpr __host__ __device__ Int32 extent1 () const
 Value of the second dimension.
constexpr __host__ __device__ Int32 extent2 () const
 Value of the third dimension.
constexpr __host__ __device__ Int32 extent3 () const
 Value of the fourth dimension.
constexpr __host__ __device__ Int64 offset (Int32 i, Int32 j, Int32 k, Int32 l) const
 Value for element i,j,k,l.
constexpr __host__ __device__ Int64 offset (Int32 i, Int32 j, Int32 k) const
 Value for element i,j,k.
constexpr __host__ __device__ Int64 offset (Int32 i, Int32 j) const
 Value for element i,j.
constexpr __host__ __device__ Int64 offset (Int32 i) const
 Value for element i.
constexpr __host__ __device__ Int64 offset (MDIndexType idx) const
 Value for element idx.
constexpr __host__ __device__ DataType & operator() (Int32 i, Int32 j, Int32 k, Int32 l) const
 Value for element i,j,k,l.
__host__ __device__ DataType & operator() (Int32 i, Int32 j, Int32 k) const
 Value for element i,j,k.
constexpr __host__ __device__ DataType & operator() (Int32 i, Int32 j) const
 Value for element i,j.
constexpr __host__ __device__ DataType & operator() (Int32 i) const
 Value for element i.
constexpr __host__ __device__ DataType operator[] (Int32 i) const
 Value for element i.
constexpr __host__ __device__ DataType & operator() (MDIndexType idx) const
 Value for element idx.
constexpr __host__ __device__ DataType * ptrAt (Int32 i, Int32 j, Int32 k, Int32 l) const
 Pointer to the value for element i,j,k,l.
__host__ __device__ DataType * ptrAt (Int32 i, Int32 j, Int32 k) const
 Pointer to the value for element i,j,k.
constexpr __host__ __device__ DataType * ptrAt (Int32 i, Int32 j) const
 Pointer to the value for element i,j.
constexpr __host__ __device__ DataType * ptrAt (Int32 i) const
 Pointer to the value for element i.
constexpr __host__ __device__ DataType * ptrAt (MDIndexType idx) const
 Pointer to the value for element i.
__host__ __device__ MDSpan< DataType, RemovedFirstExtentsType, LayoutPolicy > slice (Int32 i) const
 Returns a dimension (N-1) view starting from index element i.
constexpr __host__ __device__ MDSpan< const DataType, Extents, LayoutPolicy > constSpan () const
constexpr __host__ __device__ MDSpan< const DataType, Extents, LayoutPolicy > constMDSpan () const
constexpr __host__ __device__ Span< DataType > to1DSpan () const
constexpr SmallSpan< DataType > to1DSmallSpan ()
constexpr SmallSpan< const DataType > to1DSmallSpan () const
constexpr SmallSpan< const DataType > to1DConstSmallSpan () const

Friends

class NumArray< UnqualifiedValueType, Extents, LayoutPolicy >
class MDSpan< const UnqualifiedValueType, Extents, LayoutPolicy >

Detailed Description

template<typename DataType, typename Extents, typename LayoutPolicy>
class Arcane::MDSpan< DataType, Extents, LayoutPolicy >

Base class for multi-dimensional views.

This class is inspired by the std::mdspan class currently being defined (see http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p0009r12.html)

This class is used to manage views on arrays such as NumArray. The methods of this class are accessible on the accelerator.

For more information, refer to the page Usage of the NumArray class.

Definition at line 43 of file arccore/src/base/arccore/base/MDSpan.h.

Member Typedef Documentation

◆ ArrayBoundsIndexType

template<typename DataType, typename Extents, typename LayoutPolicy>
using Arcane::MDSpan< DataType, Extents, LayoutPolicy >::ArrayBoundsIndexType = typename Extents::MDIndexType

Definition at line 64 of file arccore/src/base/arccore/base/MDSpan.h.

◆ ArrayExtentsWithOffsetType

template<typename DataType, typename Extents, typename LayoutPolicy>
using Arcane::MDSpan< DataType, Extents, LayoutPolicy >::ArrayExtentsWithOffsetType = ArrayExtentsWithOffset<Extents, LayoutPolicy>

Definition at line 59 of file arccore/src/base/arccore/base/MDSpan.h.

◆ DynamicDimsType

template<typename DataType, typename Extents, typename LayoutPolicy>
using Arcane::MDSpan< DataType, Extents, LayoutPolicy >::DynamicDimsType = typename Extents::DynamicDimsType

Definition at line 60 of file arccore/src/base/arccore/base/MDSpan.h.

◆ ExtentsType

template<typename DataType, typename Extents, typename LayoutPolicy>
using Arcane::MDSpan< DataType, Extents, LayoutPolicy >::ExtentsType = Extents

Definition at line 55 of file arccore/src/base/arccore/base/MDSpan.h.

◆ IndexType

template<typename DataType, typename Extents, typename LayoutPolicy>
using Arcane::MDSpan< DataType, Extents, LayoutPolicy >::IndexType = typename Extents::MDIndexType

Definition at line 65 of file arccore/src/base/arccore/base/MDSpan.h.

◆ LayoutPolicyType

template<typename DataType, typename Extents, typename LayoutPolicy>
using Arcane::MDSpan< DataType, Extents, LayoutPolicy >::LayoutPolicyType = LayoutPolicy

Definition at line 56 of file arccore/src/base/arccore/base/MDSpan.h.

◆ LoopIndexType

template<typename DataType, typename Extents, typename LayoutPolicy>
using Arcane::MDSpan< DataType, Extents, LayoutPolicy >::LoopIndexType = MDIndexType

Definition at line 58 of file arccore/src/base/arccore/base/MDSpan.h.

◆ MDIndexType

template<typename DataType, typename Extents, typename LayoutPolicy>
using Arcane::MDSpan< DataType, Extents, LayoutPolicy >::MDIndexType = typename Extents::MDIndexType

Definition at line 57 of file arccore/src/base/arccore/base/MDSpan.h.

◆ RemovedFirstExtentsType

template<typename DataType, typename Extents, typename LayoutPolicy>
using Arcane::MDSpan< DataType, Extents, LayoutPolicy >::RemovedFirstExtentsType = typename Extents::RemovedFirstExtentsType

Definition at line 61 of file arccore/src/base/arccore/base/MDSpan.h.

◆ value_type

template<typename DataType, typename Extents, typename LayoutPolicy>
using Arcane::MDSpan< DataType, Extents, LayoutPolicy >::value_type = DataType

Definition at line 54 of file arccore/src/base/arccore/base/MDSpan.h.

Constructor & Destructor Documentation

◆ MDSpan() [1/5]

template<typename DataType, typename Extents, typename LayoutPolicy>
__host__ __device__ Arcane::MDSpan< DataType, Extents, LayoutPolicy >::MDSpan ( DataType * ptr,
ArrayExtentsWithOffsetType extents )
inlineconstexpr

Definition at line 70 of file arccore/src/base/arccore/base/MDSpan.h.

◆ MDSpan() [2/5]

template<typename DataType, typename Extents, typename LayoutPolicy>
__host__ __device__ Arcane::MDSpan< DataType, Extents, LayoutPolicy >::MDSpan ( DataType * ptr,
const DynamicDimsType & dims )
inlineconstexpr

Definition at line 75 of file arccore/src/base/arccore/base/MDSpan.h.

◆ MDSpan() [3/5]

template<typename DataType, typename Extents, typename LayoutPolicy>
template<typename X, typename = std::enable_if_t<std::is_same_v<X, UnqualifiedValueType>>>
__host__ __device__ Arcane::MDSpan< DataType, Extents, LayoutPolicy >::MDSpan ( const MDSpan< X, Extents > & rhs)
inlineconstexpr

Definition at line 81 of file arccore/src/base/arccore/base/MDSpan.h.

◆ MDSpan() [4/5]

template<typename DataType, typename Extents, typename LayoutPolicy>
__host__ __device__ Arcane::MDSpan< DataType, Extents, LayoutPolicy >::MDSpan ( SmallSpan< DataType > v)
inlineconstexpr

Definition at line 85 of file arccore/src/base/arccore/base/MDSpan.h.

◆ MDSpan() [5/5]

template<typename DataType, typename Extents, typename LayoutPolicy>
__host__ __device__ Arcane::MDSpan< DataType, Extents, LayoutPolicy >::MDSpan ( SmallSpan< const DataType > v)
inlineconstexpr

Definition at line 89 of file arccore/src/base/arccore/base/MDSpan.h.

Member Function Documentation

◆ _internalData() [1/2]

template<typename DataType, typename Extents, typename LayoutPolicy>
__host__ __device__ DataType * Arcane::MDSpan< DataType, Extents, LayoutPolicy >::_internalData ( )
inlineconstexpr

Definition at line 108 of file arccore/src/base/arccore/base/MDSpan.h.

◆ _internalData() [2/2]

template<typename DataType, typename Extents, typename LayoutPolicy>
__host__ __device__ const DataType * Arcane::MDSpan< DataType, Extents, LayoutPolicy >::_internalData ( ) const
inlineconstexpr

Definition at line 109 of file arccore/src/base/arccore/base/MDSpan.h.

◆ constMDSpan()

template<typename DataType, typename Extents, typename LayoutPolicy>
__host__ __device__ MDSpan< const DataType, Extents, LayoutPolicy > Arcane::MDSpan< DataType, Extents, LayoutPolicy >::constMDSpan ( ) const
inlineconstexpr

Definition at line 244 of file arccore/src/base/arccore/base/MDSpan.h.

◆ constSpan()

template<typename DataType, typename Extents, typename LayoutPolicy>
__host__ __device__ MDSpan< const DataType, Extents, LayoutPolicy > Arcane::MDSpan< DataType, Extents, LayoutPolicy >::constSpan ( ) const
inlineconstexpr

Definition at line 239 of file arccore/src/base/arccore/base/MDSpan.h.

◆ extent0()

template<typename DataType, typename Extents, typename LayoutPolicy>
__host__ __device__ Int32 Arcane::MDSpan< DataType, Extents, LayoutPolicy >::extent0 ( ) const
inlineconstexpr

Value of the first dimension.

Definition at line 125 of file arccore/src/base/arccore/base/MDSpan.h.

◆ extent1()

template<typename DataType, typename Extents, typename LayoutPolicy>
__host__ __device__ Int32 Arcane::MDSpan< DataType, Extents, LayoutPolicy >::extent1 ( ) const
inlineconstexpr

Value of the second dimension.

Definition at line 127 of file arccore/src/base/arccore/base/MDSpan.h.

◆ extent2()

template<typename DataType, typename Extents, typename LayoutPolicy>
__host__ __device__ Int32 Arcane::MDSpan< DataType, Extents, LayoutPolicy >::extent2 ( ) const
inlineconstexpr

Value of the third dimension.

Definition at line 129 of file arccore/src/base/arccore/base/MDSpan.h.

◆ extent3()

template<typename DataType, typename Extents, typename LayoutPolicy>
__host__ __device__ Int32 Arcane::MDSpan< DataType, Extents, LayoutPolicy >::extent3 ( ) const
inlineconstexpr

Value of the fourth dimension.

Definition at line 131 of file arccore/src/base/arccore/base/MDSpan.h.

◆ extents()

template<typename DataType, typename Extents, typename LayoutPolicy>
ArrayExtents< Extents > Arcane::MDSpan< DataType, Extents, LayoutPolicy >::extents ( ) const
inline

Definition at line 113 of file arccore/src/base/arccore/base/MDSpan.h.

◆ extentsWithOffset()

template<typename DataType, typename Extents, typename LayoutPolicy>
ArrayExtentsWithOffsetType Arcane::MDSpan< DataType, Extents, LayoutPolicy >::extentsWithOffset ( ) const
inline

Definition at line 117 of file arccore/src/base/arccore/base/MDSpan.h.

◆ offset() [1/5]

template<typename DataType, typename Extents, typename LayoutPolicy>
__host__ __device__ Int64 Arcane::MDSpan< DataType, Extents, LayoutPolicy >::offset ( Int32 i) const
inlineconstexpr

Value for element i.

Definition at line 151 of file arccore/src/base/arccore/base/MDSpan.h.

◆ offset() [2/5]

template<typename DataType, typename Extents, typename LayoutPolicy>
__host__ __device__ Int64 Arcane::MDSpan< DataType, Extents, LayoutPolicy >::offset ( Int32 i,
Int32 j ) const
inlineconstexpr

Value for element i,j.

Definition at line 146 of file arccore/src/base/arccore/base/MDSpan.h.

◆ offset() [3/5]

template<typename DataType, typename Extents, typename LayoutPolicy>
__host__ __device__ Int64 Arcane::MDSpan< DataType, Extents, LayoutPolicy >::offset ( Int32 i,
Int32 j,
Int32 k ) const
inlineconstexpr

Value for element i,j,k.

Definition at line 141 of file arccore/src/base/arccore/base/MDSpan.h.

◆ offset() [4/5]

◆ offset() [5/5]

template<typename DataType, typename Extents, typename LayoutPolicy>
__host__ __device__ Int64 Arcane::MDSpan< DataType, Extents, LayoutPolicy >::offset ( MDIndexType idx) const
inlineconstexpr

Value for element idx.

Definition at line 154 of file arccore/src/base/arccore/base/MDSpan.h.

◆ operator()() [1/5]

template<typename DataType, typename Extents, typename LayoutPolicy>
__host__ __device__ DataType & Arcane::MDSpan< DataType, Extents, LayoutPolicy >::operator() ( Int32 i) const
inlineconstexpr

Value for element i.

Definition at line 177 of file arccore/src/base/arccore/base/MDSpan.h.

◆ operator()() [2/5]

template<typename DataType, typename Extents, typename LayoutPolicy>
__host__ __device__ DataType & Arcane::MDSpan< DataType, Extents, LayoutPolicy >::operator() ( Int32 i,
Int32 j ) const
inlineconstexpr

Value for element i,j.

Definition at line 172 of file arccore/src/base/arccore/base/MDSpan.h.

◆ operator()() [3/5]

template<typename DataType, typename Extents, typename LayoutPolicy>
__host__ __device__ DataType & Arcane::MDSpan< DataType, Extents, LayoutPolicy >::operator() ( Int32 i,
Int32 j,
Int32 k ) const
inline

Value for element i,j,k.

Definition at line 167 of file arccore/src/base/arccore/base/MDSpan.h.

◆ operator()() [4/5]

template<typename DataType, typename Extents, typename LayoutPolicy>
__host__ __device__ DataType & Arcane::MDSpan< DataType, Extents, LayoutPolicy >::operator() ( Int32 i,
Int32 j,
Int32 k,
Int32 l ) const
inlineconstexpr

Value for element i,j,k,l.

Definition at line 162 of file arccore/src/base/arccore/base/MDSpan.h.

◆ operator()() [5/5]

template<typename DataType, typename Extents, typename LayoutPolicy>
__host__ __device__ DataType & Arcane::MDSpan< DataType, Extents, LayoutPolicy >::operator() ( MDIndexType idx) const
inlineconstexpr

Value for element idx.

Definition at line 182 of file arccore/src/base/arccore/base/MDSpan.h.

◆ operator=() [1/2]

template<typename DataType, typename Extents, typename LayoutPolicy>
__host__ __device__ ThatClass & Arcane::MDSpan< DataType, Extents, LayoutPolicy >::operator= ( SmallSpan< const DataType > v)
inlineconstexpr

Definition at line 99 of file arccore/src/base/arccore/base/MDSpan.h.

◆ operator=() [2/2]

template<typename DataType, typename Extents, typename LayoutPolicy>
__host__ __device__ ThatClass & Arcane::MDSpan< DataType, Extents, LayoutPolicy >::operator= ( SmallSpan< DataType > v)
inlineconstexpr

Definition at line 93 of file arccore/src/base/arccore/base/MDSpan.h.

◆ operator[]()

template<typename DataType, typename Extents, typename LayoutPolicy>
__host__ __device__ DataType Arcane::MDSpan< DataType, Extents, LayoutPolicy >::operator[] ( Int32 i) const
inlineconstexpr

Value for element i.

Definition at line 179 of file arccore/src/base/arccore/base/MDSpan.h.

◆ ptrAt() [1/5]

template<typename DataType, typename Extents, typename LayoutPolicy>
__host__ __device__ DataType * Arcane::MDSpan< DataType, Extents, LayoutPolicy >::ptrAt ( Int32 i) const
inlineconstexpr

Pointer to the value for element i.

Definition at line 205 of file arccore/src/base/arccore/base/MDSpan.h.

◆ ptrAt() [2/5]

template<typename DataType, typename Extents, typename LayoutPolicy>
__host__ __device__ DataType * Arcane::MDSpan< DataType, Extents, LayoutPolicy >::ptrAt ( Int32 i,
Int32 j ) const
inlineconstexpr

Pointer to the value for element i,j.

Definition at line 200 of file arccore/src/base/arccore/base/MDSpan.h.

◆ ptrAt() [3/5]

template<typename DataType, typename Extents, typename LayoutPolicy>
__host__ __device__ DataType * Arcane::MDSpan< DataType, Extents, LayoutPolicy >::ptrAt ( Int32 i,
Int32 j,
Int32 k ) const
inline

Pointer to the value for element i,j,k.

Definition at line 195 of file arccore/src/base/arccore/base/MDSpan.h.

◆ ptrAt() [4/5]

template<typename DataType, typename Extents, typename LayoutPolicy>
__host__ __device__ DataType * Arcane::MDSpan< DataType, Extents, LayoutPolicy >::ptrAt ( Int32 i,
Int32 j,
Int32 k,
Int32 l ) const
inlineconstexpr

Pointer to the value for element i,j,k,l.

Definition at line 190 of file arccore/src/base/arccore/base/MDSpan.h.

Referenced by Arcane::MDSpan< DataType, Extents, RightLayout >::slice().

◆ ptrAt() [5/5]

template<typename DataType, typename Extents, typename LayoutPolicy>
__host__ __device__ DataType * Arcane::MDSpan< DataType, Extents, LayoutPolicy >::ptrAt ( MDIndexType idx) const
inlineconstexpr

Pointer to the value for element i.

Definition at line 208 of file arccore/src/base/arccore/base/MDSpan.h.

◆ slice()

template<typename DataType, typename Extents, typename LayoutPolicy>
__host__ __device__ MDSpan< DataType, RemovedFirstExtentsType, LayoutPolicy > Arcane::MDSpan< DataType, Extents, LayoutPolicy >::slice ( Int32 i) const
inline

Returns a dimension (N-1) view starting from index element i.

For example:

MDSpan<Real, MDDim3> span3 = ...;
MDSpan<Real, MDDim2> sliced_span = span3.slice(5);
// sliced_span(i,i) <=> span3(5,i,j);
__host__ __device__ MDSpan< DataType, RemovedFirstExtentsType, LayoutPolicy > slice(Int32 i) const
Returns a dimension (N-1) view starting from index element i.
Warning
This is only valid if LayoutPolicy is RightLayout.

Definition at line 228 of file arccore/src/base/arccore/base/MDSpan.h.

◆ to1DConstSmallSpan()

template<typename DataType, typename Extents, typename LayoutPolicy>
SmallSpan< const DataType > Arcane::MDSpan< DataType, Extents, LayoutPolicy >::to1DConstSmallSpan ( ) const
inlineconstexpr

Definition at line 262 of file arccore/src/base/arccore/base/MDSpan.h.

◆ to1DSmallSpan() [1/2]

template<typename DataType, typename Extents, typename LayoutPolicy>
SmallSpan< DataType > Arcane::MDSpan< DataType, Extents, LayoutPolicy >::to1DSmallSpan ( )
inlineconstexpr

Definition at line 254 of file arccore/src/base/arccore/base/MDSpan.h.

◆ to1DSmallSpan() [2/2]

template<typename DataType, typename Extents, typename LayoutPolicy>
SmallSpan< const DataType > Arcane::MDSpan< DataType, Extents, LayoutPolicy >::to1DSmallSpan ( ) const
inlineconstexpr

Definition at line 258 of file arccore/src/base/arccore/base/MDSpan.h.

◆ to1DSpan()

template<typename DataType, typename Extents, typename LayoutPolicy>
__host__ __device__ Span< DataType > Arcane::MDSpan< DataType, Extents, LayoutPolicy >::to1DSpan ( ) const
inlineconstexpr

Definition at line 249 of file arccore/src/base/arccore/base/MDSpan.h.

◆ MDSpan< const UnqualifiedValueType, Extents, LayoutPolicy >

template<typename DataType, typename Extents, typename LayoutPolicy>
friend class MDSpan< const UnqualifiedValueType, Extents, LayoutPolicy >
friend

Definition at line 1 of file arccore/src/base/arccore/base/MDSpan.h.

◆ NumArray< UnqualifiedValueType, Extents, LayoutPolicy >

template<typename DataType, typename Extents, typename LayoutPolicy>
friend class NumArray< UnqualifiedValueType, Extents, LayoutPolicy >
friend

Definition at line 1 of file arccore/src/base/arccore/base/MDSpan.h.


The documentation for this class was generated from the following files: