https://mooseframework.inl.gov
Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | List of all members
Moose::Kokkos::JaggedArrayInnerData< T, inner, layout > Class Template Reference

The inner array wrapper class. More...

#include <KokkosJaggedArray.h>

Public Member Functions

KOKKOS_FUNCTION JaggedArrayInnerData (T *data, JaggedArrayInnerDim< inner > dim)
 Constructor.
 
KOKKOS_FUNCTION unsigned int size () const
 Get the total inner array size.
 
KOKKOS_FUNCTION unsigned int n (unsigned int dim) const
 Get the size of a dimension of the inner array.
 
KOKKOS_FUNCTION T & operator[] (unsigned int i) const
 Get an array entry.
 
template<typename... indices>
KOKKOS_FUNCTION T & operator() (indices... i) const
 Get an array entry.
 
template<unsigned int dim, typename... indices>
KOKKOS_FUNCTION auto slice (indices... i) const
 Get a one-dimensional view of the inner array along a dimension.
 

Protected Attributes

T * _data
 Pointer to the inner array data.
 
JaggedArrayInnerDim< inner > _dim
 Inner array dimension information.
 

Detailed Description

template<typename T, unsigned int inner, LayoutType layout>
class Moose::Kokkos::JaggedArrayInnerData< T, inner, layout >

The inner array wrapper class.

This object provides access to an inner array with local multi-dimensional indexing and is created as a temporary object by the jagged array class.

Template Parameters
TThe data type
innerThe inner array dimension size
layoutThe memory layout type

Definition at line 52 of file KokkosJaggedArray.h.

Constructor & Destructor Documentation

◆ JaggedArrayInnerData()

template<typename T , unsigned int inner, LayoutType layout>
KOKKOS_FUNCTION Moose::Kokkos::JaggedArrayInnerData< T, inner, layout >::JaggedArrayInnerData ( T *  data,
JaggedArrayInnerDim< inner >  dim 
)
inline

Constructor.

Parameters
dataThe pointer to the inner array data
dimThe inner array dimension information

Definition at line 60 of file KokkosJaggedArray.h.

61 : _data(data), _dim(dim)
62 {
63 }
JaggedArrayInnerDim< inner > _dim
Inner array dimension information.
T * _data
Pointer to the inner array data.
static constexpr std::size_t dim
This is the dimension of all vector and tensor datastructures used in MOOSE.
Definition Moose.h:175

Member Function Documentation

◆ n()

template<typename T , unsigned int inner, LayoutType layout>
KOKKOS_FUNCTION unsigned int Moose::Kokkos::JaggedArrayInnerData< T, inner, layout >::n ( unsigned int  dim) const
inline

Get the size of a dimension of the inner array.

Parameters
dimThe dimension index
Returns
The size of the dimension of the inner array

Definition at line 75 of file KokkosJaggedArray.h.

75{ return _dim[dim]; }

◆ operator()()

template<typename T , unsigned int inner, LayoutType layout>
template<typename... indices>
KOKKOS_FUNCTION T & Moose::Kokkos::JaggedArrayInnerData< T, inner, layout >::operator() ( indices...  i) const

Get an array entry.

Parameters
iThe inner array index of each dimension

Definition at line 115 of file KokkosJaggedArray.h.

116{
117 static_assert((std::is_convertible<indices, unsigned int>::value && ...),
118 "All arguments must be convertible to unsigned int");
119 static_assert(sizeof...(i) == inner, "Number of arguments should match array dimension");
120
121#ifndef NDEBUG
122 {
123 unsigned int idx[inner] = {static_cast<unsigned int>(i)...};
124
125 for (unsigned int d = 0; d < sizeof...(i); ++d)
126 KOKKOS_ASSERT(idx[d] < _dim[d]);
127 }
128#endif
129
130 unsigned int idx = 0;
131 unsigned int d = 0;
132
133 if constexpr (layout == LayoutType::LEFT)
134 (((idx +=
135 (d == 0 ? static_cast<unsigned int>(i) : static_cast<unsigned int>(i) * _dim.stride[d])),
136 ++d),
137 ...);
138 else
139 (((idx += (d == inner - 1 ? static_cast<unsigned int>(i)
140 : static_cast<unsigned int>(i) * _dim.stride[d])),
141 ++d),
142 ...);
143
144 return _data[idx];
145}
unsigned int idx(const ElemType type, const unsigned int nx, const unsigned int i, const unsigned int j)

◆ operator[]()

template<typename T , unsigned int inner, LayoutType layout>
KOKKOS_FUNCTION T & Moose::Kokkos::JaggedArrayInnerData< T, inner, layout >::operator[] ( unsigned int  i) const
inline

Get an array entry.

Parameters
iThe dimensionless inner array index

Definition at line 80 of file KokkosJaggedArray.h.

81 {
82 KOKKOS_ASSERT(i < _dim.stride[inner]);
83
84 return _data[i];
85 }

◆ size()

template<typename T , unsigned int inner, LayoutType layout>
KOKKOS_FUNCTION unsigned int Moose::Kokkos::JaggedArrayInnerData< T, inner, layout >::size ( ) const
inline

Get the total inner array size.

Returns
The total inner array size

Definition at line 69 of file KokkosJaggedArray.h.

69{ return _dim.stride[inner]; }

◆ slice()

template<typename T , unsigned int inner, LayoutType layout>
template<unsigned int dim, typename... indices>
KOKKOS_FUNCTION auto Moose::Kokkos::JaggedArrayInnerData< T, inner, layout >::slice ( indices...  i) const

Get a one-dimensional view of the inner array along a dimension.

Template Parameters
dimThe dimension along which the view runs
Parameters
iThe index of each of the other dimensions, in order
Returns
The JaggedArrayInnerSlice object

Definition at line 202 of file KokkosJaggedArray.h.

203{
204 static_assert(dim < inner, "The sliced dimension should be less than the inner array dimension");
205 static_assert(sizeof...(i) == inner - 1,
206 "Number of arguments should be the inner array dimension minus one");
207
208 const unsigned int fixed[inner - 1] = {static_cast<unsigned int>(i)...};
209
210 // The stride of every dimension is stored by reserve(), including the contiguous one
211 unsigned int offset = 0;
212
213 for (unsigned int d = 0, f = 0; d < inner; ++d)
214 if (d != dim)
215 {
216 KOKKOS_ASSERT(fixed[f] < _dim[d]);
217
218 offset += fixed[f++] * _dim.stride[d];
219 }
220
221 return JaggedArrayInnerSlice<T>(_data + offset, _dim.stride[dim], _dim[dim]);
222}

Member Data Documentation

◆ _data

template<typename T , unsigned int inner, LayoutType layout>
T* Moose::Kokkos::JaggedArrayInnerData< T, inner, layout >::_data
protected

Pointer to the inner array data.

Definition at line 105 of file KokkosJaggedArray.h.

Referenced by Moose::Kokkos::JaggedArrayInnerData< T, inner, layout >::operator[]().

◆ _dim

template<typename T , unsigned int inner, LayoutType layout>
JaggedArrayInnerDim<inner> Moose::Kokkos::JaggedArrayInnerData< T, inner, layout >::_dim
protected

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