The Kokkos jagged array class. More...
#include <KokkosJaggedArray.h>
Public Member Functions | |
| JaggedArray ()=default | |
| Default constructor. More... | |
| template<typename... size_type> | |
| JaggedArray (size_type... n) | |
| Constructor. More... | |
| void | create (const std::vector< index_type > &n) |
| Allocate outer array. More... | |
| template<typename... size_type> | |
| void | create (size_type... n) |
| Allocate outer array. More... | |
| void | reserve (const std::array< uint64_t, outer > &index, const std::array< uint64_t, inner > &dimension) |
| Reserve inner array for an outer array entry. More... | |
| void | finalize () |
| Setup array structure. More... | |
| void | copyToDevice () |
| Copy data from host to device. More... | |
| void | copyToHost () |
| Copy data from device to host. More... | |
| void | moveToDevice () |
| Copy data from host to device and deallocate host. More... | |
| void | moveToHost () |
| Copy data from device to host and deallocate device. More... | |
| auto & | array () |
| Get the underlying data array. More... | |
| KOKKOS_FUNCTION bool | isFinalized () const |
| Get whether the array is finalized. More... | |
| KOKKOS_FUNCTION bool | isHostAlloc () const |
| Get whether the array was allocated on host. More... | |
| KOKKOS_FUNCTION bool | isDeviceAlloc () const |
| Get whether the array was allocated on device. More... | |
| KOKKOS_FUNCTION index_type | size () const |
| Get the total data array size. More... | |
| KOKKOS_FUNCTION index_type | n () const |
| Get the total outer array size. More... | |
| KOKKOS_FUNCTION index_type | n (unsigned int dim) const |
| Get the size of a dimension of the outer array. More... | |
| KOKKOS_FUNCTION auto | operator[] (index_type i) const |
| Get an inner array. More... | |
| template<typename... indices> | |
| KOKKOS_FUNCTION auto | operator() (indices... i) const |
| Get an inner array. More... | |
Protected Attributes | |
| Array1D< T, index_type > | _data |
| Sequential data array. More... | |
| Array< JaggedArrayInnerDim< inner >, outer, index_type > | _dims |
| Dimension information of each inner array. More... | |
| Array< index_type, outer, index_type > | _offsets |
| Starting offset of each inner array into the sequential data array. More... | |
| bool | _finalized = false |
| Whether the array was finalized. More... | |
The Kokkos jagged array class.
A Kokkos jagged array aids in treating jagged arrays conveniently and efficiently by using a sequential data storage and providing multi-dimensional indexing using internal dope vectors. A jagged array is divided into the inner and outer arrays. The outer array is the regular part of a jagged array. Each entry of the outer array can hold an inner array, whose size can vary with each other. Calling create() will allocate the outer array, and inner arrays should be reserved one-by-one through reserve(). Once the array structure is set, finalize() should be called. A finalized array cannot be restructured unless it is reset completely by calling create() again. The inner array returned by operator() or operator[] using the outer array index is held in a temporary wrapper object. To avoid the overhead of temporary object creation, it is recommended to store the object locally.
| T | The data type |
| inner | The inner array dimension size |
| outer | The outer array dimension size |
| index_type | The array index type |
| layout | The memory layout type |
Definition at line 164 of file KokkosJaggedArray.h.
|
default |
Default constructor.
|
inline |
Constructor.
Definition at line 177 of file KokkosJaggedArray.h.
|
inline |
Get the underlying data array.
Definition at line 248 of file KokkosJaggedArray.h.
|
inline |
Copy data from host to device.
Definition at line 207 of file KokkosJaggedArray.h.
|
inline |
Copy data from device to host.
Definition at line 216 of file KokkosJaggedArray.h.
| void Moose::Kokkos::JaggedArray< T, inner, outer, index_type, layout >::create | ( | const std::vector< index_type > & | n | ) |
Allocate outer array.
| n | The vector containing the size of each dimension for the outer array |
Definition at line 322 of file KokkosJaggedArray.h.
Referenced by Moose::Kokkos::JaggedArray< T, inner, outer, index_type, layout >::JaggedArray().
| void Moose::Kokkos::JaggedArray< T, inner, outer, index_type, layout >::create | ( | size_type... | n | ) |
Allocate outer array.
| n | The size of each dimension for the outer array |
Definition at line 338 of file KokkosJaggedArray.h.
| void Moose::Kokkos::JaggedArray< T, inner, outer, index_type, layout >::finalize | ( | ) |
Setup array structure.
Definition at line 394 of file KokkosJaggedArray.h.
|
inline |
Get whether the array was allocated on device.
Definition at line 264 of file KokkosJaggedArray.h.
|
inline |
Get whether the array is finalized.
Definition at line 254 of file KokkosJaggedArray.h.
|
inline |
Get whether the array was allocated on host.
Definition at line 259 of file KokkosJaggedArray.h.
|
inline |
Copy data from host to device and deallocate host.
Definition at line 225 of file KokkosJaggedArray.h.
|
inline |
Copy data from device to host and deallocate device.
Definition at line 236 of file KokkosJaggedArray.h.
|
inline |
Get the total outer array size.
Definition at line 274 of file KokkosJaggedArray.h.
Referenced by Moose::Kokkos::JaggedArray< T, inner, outer, index_type, layout >::JaggedArray().
|
inline |
Get the size of a dimension of the outer array.
| dim | The dimension index |
Definition at line 280 of file KokkosJaggedArray.h.
| KOKKOS_FUNCTION auto Moose::Kokkos::JaggedArray< T, inner, outer, index_type, layout >::operator() | ( | indices... | i | ) | const |
Get an inner array.
| i | The index of each dimension |
Definition at line 443 of file KokkosJaggedArray.h.
| KOKKOS_FUNCTION auto Moose::Kokkos::JaggedArray< T, inner, outer, index_type, layout >::operator[] | ( | index_type | i | ) | const |
Get an inner array.
| i | The dimensionless outer array index |
Definition at line 428 of file KokkosJaggedArray.h.
| void Moose::Kokkos::JaggedArray< T, inner, outer, index_type, layout >::reserve | ( | const std::array< uint64_t, outer > & | index, |
| const std::array< uint64_t, inner > & | dimension | ||
| ) |
Reserve inner array for an outer array entry.
| index | The array containing the index for the outer array |
| dimension | The array containing the size of each dimension for the inner array |
Definition at line 353 of file KokkosJaggedArray.h.
|
inline |
Get the total data array size.
Definition at line 269 of file KokkosJaggedArray.h.
|
protected |
Sequential data array.
Definition at line 300 of file KokkosJaggedArray.h.
Referenced by Moose::Kokkos::JaggedArray< T, inner, outer, index_type, layout >::array(), Moose::Kokkos::JaggedArray< T, inner, outer, index_type, layout >::copyToDevice(), Moose::Kokkos::JaggedArray< T, inner, outer, index_type, layout >::copyToHost(), Moose::Kokkos::JaggedArray< T, inner, outer, index_type, layout >::isDeviceAlloc(), Moose::Kokkos::JaggedArray< T, inner, outer, index_type, layout >::isHostAlloc(), Moose::Kokkos::JaggedArray< T, inner, outer, index_type, layout >::moveToDevice(), Moose::Kokkos::JaggedArray< T, inner, outer, index_type, layout >::moveToHost(), and Moose::Kokkos::JaggedArray< T, inner, outer, index_type, layout >::size().
|
protected |
Dimension information of each inner array.
Definition at line 304 of file KokkosJaggedArray.h.
Referenced by Moose::Kokkos::JaggedArray< T, inner, outer, index_type, layout >::moveToDevice(), and Moose::Kokkos::JaggedArray< T, inner, outer, index_type, layout >::moveToHost().
|
protected |
Whether the array was finalized.
Definition at line 312 of file KokkosJaggedArray.h.
Referenced by Moose::Kokkos::JaggedArray< T, inner, outer, index_type, layout >::copyToDevice(), Moose::Kokkos::JaggedArray< T, inner, outer, index_type, layout >::copyToHost(), Moose::Kokkos::JaggedArray< T, inner, outer, index_type, layout >::isFinalized(), Moose::Kokkos::JaggedArray< T, inner, outer, index_type, layout >::moveToDevice(), and Moose::Kokkos::JaggedArray< T, inner, outer, index_type, layout >::moveToHost().
|
protected |
Starting offset of each inner array into the sequential data array.
Definition at line 308 of file KokkosJaggedArray.h.
Referenced by Moose::Kokkos::JaggedArray< T, inner, outer, index_type, layout >::moveToDevice(), Moose::Kokkos::JaggedArray< T, inner, outer, index_type, layout >::moveToHost(), and Moose::Kokkos::JaggedArray< T, inner, outer, index_type, layout >::n().
1.8.14