https://mooseframework.inl.gov
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | List of all members
Moose::Kokkos::Array< T, dimension, index_type, layout > Class Template Reference

The Kokkos array class. More...

#include <KokkosArray.h>

Inheritance diagram for Moose::Kokkos::Array< T, dimension, index_type, layout >:
[legend]

Public Types

using unsigned_index_type = index_type
 
using signed_index_type = typename std::make_signed< index_type >::type
 

Public Member Functions

 Array ()
 Default constructor. More...
 
 Array (const Array< T, dimension, index_type, layout > &array)
 Copy constructor. More...
 
template<typename... size_type>
 Array (size_type... n)
 Constructor Initialize and allocate array with given dimensions This allocates both host and device data. More...
 
auto & operator= (const Array< T, dimension, index_type, layout > &array)
 Shallow copy another Kokkos array. More...
 
template<typename... indices>
KOKKOS_FUNCTION T & operator() (indices... i) const
 Get an array entry. More...
 
KOKKOS_FUNCTION T & operator() (const signed_index_type(&idx)[dimension]) const
 Get an array entry using indices stored in an array. More...
 
void destroy ()
 Free all data and reset. More...
 
void shallowCopy (const ArrayBase< T, dimension, index_type > &array)
 Shallow copy another Kokkos array. More...
 
unsigned int useCount () const
 Get the reference count. More...
 
bool isSlotConstructed (index_type i) const
 Get whether slot i is tracked as constructed. More...
 
constructed_entry_range< false > constructedEntries ()
 Get host-side range over entries tracked as constructed. More...
 
constructed_entry_range< true > constructedEntries () const
 Get host-side range over entries tracked as constructed. More...
 
KOKKOS_FUNCTION bool isAlloc () const
 Get whether the array was allocated either on host or device. 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 bool isHostAlias () const
 Get whether the host array was aliased. More...
 
KOKKOS_FUNCTION bool isDeviceAlias () const
 Get whether the device array was aliased. More...
 
KOKKOS_FUNCTION index_type size () const
 Get the total array size. More...
 
KOKKOS_FUNCTION index_type n (unsigned int dim) const
 Get the size of a dimension. More...
 
KOKKOS_FUNCTION T * data () const
 Get the data pointer. More...
 
KOKKOS_FUNCTION T & first () const
 Get the first element. More...
 
KOKKOS_FUNCTION T & last () const
 Get the last element. More...
 
KOKKOS_FUNCTION T & operator[] (index_type i) const
 Get an array entry. More...
 
T * hostData () const
 Get the host data pointer. More...
 
T * deviceData () const
 Get the device data pointer. More...
 
auto hostView () const
 Get the host unmanaged view. More...
 
auto deviceView () const
 Get the device unmanaged view. More...
 
template<typename... size_type>
void init (size_type... n)
 Initialize array with given dimensions but do not allocate. More...
 
template<bool initialize = true>
void create (const std::vector< index_type > &n)
 Allocate array on host and device. More...
 
template<bool initialize = true, typename... size_type>
void create (size_type... n)
 Allocate array on host and device. More...
 
template<bool initialize = true>
void createHost (const std::vector< index_type > &n)
 Allocate array on host only. More...
 
template<bool initialize = true, typename... size_type>
void createHost (size_type... n)
 Allocate array on host only. More...
 
void createDevice (const std::vector< index_type > &n)
 Allocate array on device only. More...
 
template<typename... size_type>
void createDevice (size_type... n)
 Allocate array on device only. More...
 
void aliasHost (T *ptr)
 Point the host data to an external data instead of allocating it. More...
 
void aliasDevice (T *ptr)
 Point the device data to an external data instead of allocating it. More...
 
void offset (const std::vector< signed_index_type > &d)
 Apply starting index offsets to each dimension. More...
 
template<typename... offset_type>
void offset (offset_type... d)
 Apply starting index offsets to each dimension. More...
 
void copyToDevice ()
 Copy data from host to device. More...
 
void copyToHost ()
 Copy data from device to host. More...
 
void copyIn (const T *ptr, MemcpyType dir, index_type n, index_type offset=0)
 Copy data from an external data to this array. More...
 
void copyOut (T *ptr, MemcpyType dir, index_type n, index_type offset=0)
 Copy data to an external data from this array. More...
 
void copyToDeviceNested ()
 Copy all the nested Kokkos arrays including self from host to device. More...
 
void moveToDevice (bool should_free_host=true)
 Copy data from host to device and deallocate host. More...
 
void moveToHost (bool should_free_device=true)
 Copy data from device to host and deallocate device. More...
 
void deepCopy (const ArrayBase< T, dimension, index_type > &array)
 Deep copy another Kokkos array If ArrayDeepCopy<T>::value is true, it will copy-construct each entry If ArrayDeepCopy<T>::value is false, it will do a memory copy. More...
 
void swap (ArrayBase< T, dimension, index_type > &array)
 Swap with another Kokkos array. More...
 
KOKKOS_FUNCTION iterator begin () const
 Get the beginning iterator. More...
 
KOKKOS_FUNCTION iterator end () const
 Get the end iterator. More...
 

Protected Member Functions

template<bool host, bool device, bool initialize, typename... size_type>
void createInternal (size_type... n)
 The internal method to initialize and allocate this array. More...
 
template<bool host, bool device, bool initialize>
void createInternal (const std::vector< index_type > &n)
 The internal method to initialize and allocate this array. More...
 
template<bool initialize>
void createInternal (const std::vector< index_type > &n, bool host, bool device)
 The internal method to initialize and allocate this array. More...
 
template<typename TargetSpace , typename SourceSpace >
void copyInternal (T *target, const T *source, index_type n)
 The internal method to perform a memory copy. More...
 
template<typename... Args>
T & emplaceAt (index_type i, Args &&... args)
 Placement-new construct slot i from args, recording initialization. More...
 

Protected Attributes

index_type _n [dimension] = {0}
 Size of each dimension. More...
 
index_type _s [dimension] = {0}
 Stride of each dimension. More...
 
signed_index_type _d [dimension] = {0}
 Offset of each dimension. More...
 

Private Member Functions

 usingKokkosArrayBaseMembers (T, dimension, index_type)
 
template<typename indices >
KOKKOS_FUNCTION index_type linearIndex (const indices(&idx)[dimension]) const
 Get the dimensionless index for indices stored in an array. More...
 
template<typename indices , unsigned int... i>
KOKKOS_FUNCTION index_type linearIndexHelper (const indices(&idx)[dimension], std::integer_sequence< unsigned int, i... >) const
 
template<typename... indices>
KOKKOS_FUNCTION index_type linearIndex (indices... i) const
 Get the dimensionless index for a multi-dimensional index. More...
 
template<typename indices , typename... Args>
T & emplace (const indices(&idx)[dimension], Args &&... args)
 Placement-new construct an entry from args, recording initialization. More...
 

Detailed Description

template<typename T, unsigned int dimension, typename index_type, LayoutType layout>
class Moose::Kokkos::Array< T, dimension, index_type, layout >

The Kokkos array class.

The specialization of the Kokkos array class for each dimension.

All array data that needs to be accessed on device in Kokkos objects should use this class. If the array is populated on host and is to be accessed on device, make sure to call copyToDevice() after populating data. For a nested Kokkos array, either copyToDeviceNested() should be called for the outermost array or copyToDevice() should be called for each instance of Kokkos array from the innermost to the outermost. Do not store this object as reference in your Kokkos object if it is used on device, because the reference refers to a host object and therefore is not accessible on device. If storing it as a reference is required, see ReferenceWrapper.

Template Parameters
TThe data type
dimensionThe array dimension size
index_typeThe array index type
layoutThe memory layout type

Definition at line 65 of file KokkosArray.h.

Member Typedef Documentation

◆ signed_index_type

template<typename T, unsigned int dimension, typename index_type>
using Moose::Kokkos::ArrayBase< T, dimension, index_type >::signed_index_type = typename std::make_signed<index_type>::type
inherited

Definition at line 115 of file KokkosArray.h.

◆ unsigned_index_type

template<typename T, unsigned int dimension, typename index_type>
using Moose::Kokkos::ArrayBase< T, dimension, index_type >::unsigned_index_type = index_type
inherited

Definition at line 114 of file KokkosArray.h.

Constructor & Destructor Documentation

◆ Array() [1/3]

template<typename T, unsigned int dimension, typename index_type, LayoutType layout>
Moose::Kokkos::Array< T, dimension, index_type, layout >::Array ( )
inline

Default constructor.

Definition at line 1574 of file KokkosArray.h.

1574 : ArrayBase<T, dimension, index_type>(layout) {}

◆ Array() [2/3]

template<typename T, unsigned int dimension, typename index_type, LayoutType layout>
Moose::Kokkos::Array< T, dimension, index_type, layout >::Array ( const Array< T, dimension, index_type, layout > &  array)
inline

Copy constructor.

Definition at line 1578 of file KokkosArray.h.

1579  : ArrayBase<T, dimension, index_type>(array)
1580  {
1581  }

◆ Array() [3/3]

template<typename T, unsigned int dimension, typename index_type, LayoutType layout>
template<typename... size_type>
Moose::Kokkos::Array< T, dimension, index_type, layout >::Array ( size_type...  n)
inline

Constructor Initialize and allocate array with given dimensions This allocates both host and device data.

Parameters
nThe size of each dimension

Definition at line 1590 of file KokkosArray.h.

1590  : ArrayBase<T, dimension, index_type>(layout, n...)
1591  {
1592  }
KOKKOS_FUNCTION index_type n(unsigned int dim) const
Get the size of a dimension.
Definition: KokkosArray.h:300

Member Function Documentation

◆ aliasDevice()

template<typename T, unsigned int dimension, typename index_type >
void Moose::Kokkos::ArrayBase< T, dimension, index_type >::aliasDevice ( T *  ptr)
inherited

Point the device data to an external data instead of allocating it.

Parameters
ptrThe pointer to the external device data

Definition at line 980 of file KokkosArray.h.

981 {
982  if (!_is_init)
983  mooseError("Kokkos array error: attempted to alias device data before array initialization.");
984 
986  mooseError("Kokkos array error: cannot alias device data because device data was not aliased.");
987 
988  _device_data = ptr;
989  _is_device_alloc = true;
990  _is_device_alias = true;
991 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:311
bool _is_device_alloc
Flag whether device data was allocated.
Definition: KokkosArray.h:689
bool _is_device_alias
Flag whether the device data points to an external data.
Definition: KokkosArray.h:697
T * _device_data
Device data.
Definition: KokkosArray.h:705
bool _is_init
Flag whether array was initialized.
Definition: KokkosArray.h:681

◆ aliasHost()

template<typename T, unsigned int dimension, typename index_type >
void Moose::Kokkos::ArrayBase< T, dimension, index_type >::aliasHost ( T *  ptr)
inherited

Point the host data to an external data instead of allocating it.

Parameters
ptrThe pointer to the external host data

Definition at line 965 of file KokkosArray.h.

966 {
967  if (!_is_init)
968  mooseError("Kokkos array error: attempted to alias host data before array initialization.");
969 
971  mooseError("Kokkos array error: cannot alias host data because host data was not aliased.");
972 
973  _host_data = ptr;
974  _is_host_alloc = true;
975  _is_host_alias = true;
976 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:311
T * _host_data
Host data.
Definition: KokkosArray.h:701
bool _is_host_alloc
Flag whether host data was allocated.
Definition: KokkosArray.h:685
bool _is_host_alias
Flag whether the host data points to an external data.
Definition: KokkosArray.h:693
bool _is_init
Flag whether array was initialized.
Definition: KokkosArray.h:681

◆ begin()

template<typename T, unsigned int dimension, typename index_type>
KOKKOS_FUNCTION iterator Moose::Kokkos::ArrayBase< T, dimension, index_type >::begin ( ) const
inlineinherited

Get the beginning iterator.

Returns
The beginning iterator

Definition at line 568 of file KokkosArray.h.

Referenced by Moose::Kokkos::Array< T, 1, index_type, LayoutType::LEFT >::copySet(), and Moose::Kokkos::Array< T, 1, index_type, LayoutType::LEFT >::copyVector().

569  {
570  KOKKOS_IF_ON_HOST(return iterator(_host_data);)
571 
572  return iterator(_device_data);
573  }
T * _host_data
Host data.
Definition: KokkosArray.h:701
T * _device_data
Device data.
Definition: KokkosArray.h:705

◆ constructedEntries() [1/2]

template<typename T , unsigned int dimension, typename index_type >
ArrayBase< T, dimension, index_type >::template constructed_entry_range< false > Moose::Kokkos::ArrayBase< T, dimension, index_type >::constructedEntries ( )
inherited

Get host-side range over entries tracked as constructed.

Returns
Range that skips slots for which isSlotConstructed() is false

Definition at line 802 of file KokkosArray.h.

803 {
804  return constructed_entry_range<false>(*this);
805 }

◆ constructedEntries() [2/2]

template<typename T , unsigned int dimension, typename index_type >
ArrayBase< T, dimension, index_type >::template constructed_entry_range< true > Moose::Kokkos::ArrayBase< T, dimension, index_type >::constructedEntries ( ) const
inherited

Get host-side range over entries tracked as constructed.

Returns
Range that skips slots for which isSlotConstructed() is false

Definition at line 809 of file KokkosArray.h.

810 {
811  return constructed_entry_range<true>(*this);
812 }

◆ copyIn()

template<typename T, unsigned int dimension, typename index_type>
void Moose::Kokkos::ArrayBase< T, dimension, index_type >::copyIn ( const T *  ptr,
MemcpyType  dir,
index_type  n,
index_type  offset = 0 
)
inherited

Copy data from an external data to this array.

Parameters
ptrThe pointer to the external data
dirThe copy direction
nThe number of entries to copy
offsetThe starting offset of this array

Definition at line 1248 of file KokkosArray.h.

Referenced by Moose::Kokkos::dataLoad().

1252 {
1253  if (n > _size)
1254  mooseError("Kokkos array error: cannot copy in data larger than the array size.");
1255 
1256  if (offset > _size)
1257  mooseError("Kokkos array error: offset cannot be larger than the array size.");
1258 
1259  if (dir == MemcpyType::HOST_TO_HOST)
1260  {
1261  // If host side memory is not allocated, print error
1262  if (!_is_host_alloc)
1263  mooseError(
1264  "Kokkos array error: cannot copy in to the array because host memory was not allocated.");
1265 
1266  // Copy from host to host
1267  copyInternal<::Kokkos::HostSpace, ::Kokkos::HostSpace>(_host_data + offset, ptr, n);
1268  }
1269  else if (dir == MemcpyType::HOST_TO_DEVICE)
1270  {
1271  // If device side memory is not allocated, print error
1272  if (!_is_device_alloc)
1273  mooseError("Kokkos array error: cannot copy in to the array because device memory was not "
1274  "allocated.");
1275 
1276  // Copy from host to device
1277  copyInternal<MemSpace, ::Kokkos::HostSpace>(_device_data + offset, ptr, n);
1278  }
1279  else if (dir == MemcpyType::DEVICE_TO_HOST)
1280  {
1281  // If host side memory is not allocated, print error
1282  if (!_is_host_alloc)
1283  mooseError(
1284  "Kokkos array error: cannot copy in to the array because host memory was not allocated.");
1285 
1286  // Copy from device to host
1287  copyInternal<::Kokkos::HostSpace, MemSpace>(_host_data + offset, ptr, n);
1288  }
1289  else if (dir == MemcpyType::DEVICE_TO_DEVICE)
1290  {
1291  // If device side memory is not allocated, print error
1292  if (!_is_device_alloc)
1293  mooseError("Kokkos array error: cannot copy in to the array because device memory was not "
1294  "allocated.");
1295 
1296  // Copy from device to device
1297  copyInternal<MemSpace, MemSpace>(_device_data + offset, ptr, n);
1298  }
1299 }
KOKKOS_FUNCTION index_type n(unsigned int dim) const
Get the size of a dimension.
Definition: KokkosArray.h:300
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:311
bool _is_device_alloc
Flag whether device data was allocated.
Definition: KokkosArray.h:689
T * _host_data
Host data.
Definition: KokkosArray.h:701
bool _is_host_alloc
Flag whether host data was allocated.
Definition: KokkosArray.h:685
index_type _size
Total size.
Definition: KokkosArray.h:709
T * _device_data
Device data.
Definition: KokkosArray.h:705
void offset(const std::vector< signed_index_type > &d)
Apply starting index offsets to each dimension.
Definition: KokkosArray.h:1137

◆ copyInternal()

template<typename T, unsigned int dimension, typename index_type>
template<typename TargetSpace , typename SourceSpace >
void Moose::Kokkos::ArrayBase< T, dimension, index_type >::copyInternal ( T *  target,
const T *  source,
index_type  n 
)
protectedinherited

The internal method to perform a memory copy.

Template Parameters
TargetSpaceThe Kokkos memory space of target data
SourcespaceThe Kokkos memory space of source data
Parameters
targetThe pointer to the target data
sourceThe pointer to the source data
nThe number of entries to copy

Definition at line 1129 of file KokkosArray.h.

1130 {
1131  ::Kokkos::Impl::DeepCopy<TargetSpace, SourceSpace>(target, source, n * sizeof(T));
1132  ::Kokkos::fence();
1133 }
KOKKOS_FUNCTION index_type n(unsigned int dim) const
Get the size of a dimension.
Definition: KokkosArray.h:300

◆ copyOut()

template<typename T, unsigned int dimension, typename index_type>
void Moose::Kokkos::ArrayBase< T, dimension, index_type >::copyOut ( T *  ptr,
MemcpyType  dir,
index_type  n,
index_type  offset = 0 
)
inherited

Copy data to an external data from this array.

Parameters
ptrThe pointer to the external data
dirThe copy direction
nThe number of entries to copy
offsetThe starting offset of this array

Definition at line 1303 of file KokkosArray.h.

Referenced by Moose::Kokkos::dataStore().

1307 {
1308  if (n > _size)
1309  mooseError("Kokkos array error: cannot copy out data larger than the array size.");
1310 
1311  if (offset > _size)
1312  mooseError("Kokkos array error: offset cannot be larger than the array size.");
1313 
1314  if (dir == MemcpyType::HOST_TO_HOST)
1315  {
1316  // If host side memory is not allocated, print error
1317  if (!_is_host_alloc)
1318  mooseError("Kokkos array error: cannot copy out from the array because host memory was not "
1319  "allocated.");
1320 
1321  // Copy from host to host
1322  copyInternal<::Kokkos::HostSpace, ::Kokkos::HostSpace>(ptr, _host_data + offset, n);
1323  }
1324  else if (dir == MemcpyType::HOST_TO_DEVICE)
1325  {
1326  // If host side memory is not allocated, print error
1327  if (!_is_host_alloc)
1328  mooseError("Kokkos array error: cannot copy out from the array because host memory was not "
1329  "allocated.");
1330 
1331  // Copy from host to device
1332  copyInternal<MemSpace, ::Kokkos::HostSpace>(ptr, _host_data + offset, n);
1333  }
1334  else if (dir == MemcpyType::DEVICE_TO_HOST)
1335  {
1336  // If device side memory is not allocated, print error
1337  if (!_is_device_alloc)
1338  mooseError("Kokkos array error: cannot copy out from the array because device memory was not "
1339  "allocated.");
1340 
1341  // Copy from device to host
1342  copyInternal<::Kokkos::HostSpace, MemSpace>(ptr, _device_data + offset, n);
1343  }
1344  else if (dir == MemcpyType::DEVICE_TO_DEVICE)
1345  {
1346  // If device side memory is not allocated, print error
1347  if (!_is_device_alloc)
1348  mooseError("Kokkos array error: cannot copy out from the array because device memory was not "
1349  "allocated.");
1350 
1351  // Copy from device to device
1352  copyInternal<MemSpace, MemSpace>(ptr, _device_data + offset, n);
1353  }
1354 }
KOKKOS_FUNCTION index_type n(unsigned int dim) const
Get the size of a dimension.
Definition: KokkosArray.h:300
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:311
bool _is_device_alloc
Flag whether device data was allocated.
Definition: KokkosArray.h:689
T * _host_data
Host data.
Definition: KokkosArray.h:701
bool _is_host_alloc
Flag whether host data was allocated.
Definition: KokkosArray.h:685
index_type _size
Total size.
Definition: KokkosArray.h:709
T * _device_data
Device data.
Definition: KokkosArray.h:705
void offset(const std::vector< signed_index_type > &d)
Apply starting index offsets to each dimension.
Definition: KokkosArray.h:1137

◆ copyToDevice()

template<typename T , unsigned int dimension, typename index_type >
void Moose::Kokkos::ArrayBase< T, dimension, index_type >::copyToDevice ( )
inherited

Copy data from host to device.

Definition at line 1167 of file KokkosArray.h.

Referenced by Moose::Kokkos::ArrayBase< Moose::Kokkos::Array< Moose::Kokkos::Array< Moose::Kokkos::Real33 > >, dimension, index_type >::copyToDeviceNested(), Moose::Kokkos::ArrayBase< Moose::Kokkos::Array< Moose::Kokkos::Array< Moose::Kokkos::Real33 > >, dimension, index_type >::deepCopy(), Moose::Kokkos::ArrayBase< Moose::Kokkos::Array< Moose::Kokkos::Array< Moose::Kokkos::Real33 > >, dimension, index_type >::moveToDevice(), Moose::Kokkos::VariableGradientTempl< is_ad >::VariableGradientTempl(), and Moose::Kokkos::VariableValueTempl< is_ad >::VariableValueTempl().

1168 {
1169  // If host side memory is not allocated, do nothing
1170  if (!_is_host_alloc)
1171  return;
1172 
1173  // If device side memory is not allocated,
1174  if (!_is_device_alloc)
1175  {
1176  if (_counter.use_count() == 1)
1177  // allocate memory if this array is not shared with other arrays
1178  allocDevice();
1179  else
1180  // print error if this array is shared with other arrays
1181  mooseError("Kokkos array error: cannot copy from host to device because device memory "
1182  "was not allocated. Cannot allocate device memory for copy because the array is "
1183  "being shared.");
1184  }
1185 
1186  // Copy from host to device
1187  copyInternal<MemSpace, ::Kokkos::HostSpace>(_device_data, _host_data, _size);
1188 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:311
void allocDevice()
Allocate device data for an initialized array that has not allocated device data. ...
Definition: KokkosArray.h:1020
bool _is_device_alloc
Flag whether device data was allocated.
Definition: KokkosArray.h:689
T * _host_data
Host data.
Definition: KokkosArray.h:701
bool _is_host_alloc
Flag whether host data was allocated.
Definition: KokkosArray.h:685
index_type _size
Total size.
Definition: KokkosArray.h:709
std::shared_ptr< unsigned int > _counter
Reference counter.
Definition: KokkosArray.h:673
T * _device_data
Device data.
Definition: KokkosArray.h:705

◆ copyToDeviceNested()

template<typename T , unsigned int dimension, typename index_type >
void Moose::Kokkos::ArrayBase< T, dimension, index_type >::copyToDeviceNested ( )
inherited

Copy all the nested Kokkos arrays including self from host to device.

Definition at line 1371 of file KokkosArray.h.

1372 {
1373  for (const auto i : make_range(_size))
1375 
1376  copyToDevice();
1377 }
T * _host_data
Host data.
Definition: KokkosArray.h:701
index_type _size
Total size.
Definition: KokkosArray.h:709
void copyToDeviceInner(T &)
Definition: KokkosArray.h:1358
void copyToDevice()
Copy data from host to device.
Definition: KokkosArray.h:1167
IntRange< T > make_range(T beg, T end)

◆ copyToHost()

template<typename T , unsigned int dimension, typename index_type >
void Moose::Kokkos::ArrayBase< T, dimension, index_type >::copyToHost ( )
inherited

Copy data from device to host.

Definition at line 1192 of file KokkosArray.h.

Referenced by Moose::Kokkos::ArrayBase< Moose::Kokkos::Array< Moose::Kokkos::Array< Moose::Kokkos::Real33 > >, dimension, index_type >::moveToHost().

1193 {
1194  // If device side memory is not allocated, do nothing
1195  if (!_is_device_alloc)
1196  return;
1197 
1198  // If host side memory is not allocated,
1199  if (!_is_host_alloc)
1200  {
1201  if (_counter.use_count() == 1)
1202  // allocate memory if this array is not shared with other arrays
1203  allocHost<false>();
1204  else
1205  // print error if this array is shared with other arrays
1206  mooseError("Kokkos array error: cannot copy from device to host because host memory "
1207  "was not allocated. Cannot allocate host memory for copy because the array is "
1208  "being shared.");
1209  }
1210 
1211  // Copy from device to host
1212  copyInternal<::Kokkos::HostSpace, MemSpace>(_host_data, _device_data, _size);
1213 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:311
bool _is_device_alloc
Flag whether device data was allocated.
Definition: KokkosArray.h:689
T * _host_data
Host data.
Definition: KokkosArray.h:701
bool _is_host_alloc
Flag whether host data was allocated.
Definition: KokkosArray.h:685
index_type _size
Total size.
Definition: KokkosArray.h:709
std::shared_ptr< unsigned int > _counter
Reference counter.
Definition: KokkosArray.h:673
T * _device_data
Device data.
Definition: KokkosArray.h:705

◆ create() [1/2]

template<typename T, unsigned int dimension, typename index_type>
template<bool initialize = true>
void Moose::Kokkos::ArrayBase< T, dimension, index_type >::create ( const std::vector< index_type > &  n)
inlineinherited

Allocate array on host and device.

Template Parameters
initializeWhether to initialize host data (calls default constructor)
Parameters
nThe vector containing the size of each dimension

Definition at line 392 of file KokkosArray.h.

Referenced by Moose::Kokkos::ArrayBase< Moose::Kokkos::Array< Moose::Kokkos::Array< Moose::Kokkos::Real33 > >, dimension, index_type >::ArrayBase(), Moose::Kokkos::VariableGradientTempl< is_ad >::VariableGradientTempl(), and Moose::Kokkos::VariableValueTempl< is_ad >::VariableValueTempl().

393  {
394  createInternal<true, true, initialize>(n);
395  }
KOKKOS_FUNCTION index_type n(unsigned int dim) const
Get the size of a dimension.
Definition: KokkosArray.h:300

◆ create() [2/2]

template<typename T, unsigned int dimension, typename index_type>
template<bool initialize = true, typename... size_type>
void Moose::Kokkos::ArrayBase< T, dimension, index_type >::create ( size_type...  n)
inlineinherited

Allocate array on host and device.

Template Parameters
initializeWhether to initialize host data (calls default constructor)
Parameters
nThe size of each dimension

Definition at line 402 of file KokkosArray.h.

403  {
404  createInternal<true, true, initialize>(n...);
405  }
KOKKOS_FUNCTION index_type n(unsigned int dim) const
Get the size of a dimension.
Definition: KokkosArray.h:300

◆ createDevice() [1/2]

template<typename T, unsigned int dimension, typename index_type>
void Moose::Kokkos::ArrayBase< T, dimension, index_type >::createDevice ( const std::vector< index_type > &  n)
inlineinherited

Allocate array on device only.

Parameters
nThe vector containing the size of each dimension

Definition at line 430 of file KokkosArray.h.

430 { createInternal<false, true, false>(n); }
KOKKOS_FUNCTION index_type n(unsigned int dim) const
Get the size of a dimension.
Definition: KokkosArray.h:300

◆ createDevice() [2/2]

template<typename T, unsigned int dimension, typename index_type>
template<typename... size_type>
void Moose::Kokkos::ArrayBase< T, dimension, index_type >::createDevice ( size_type...  n)
inlineinherited

Allocate array on device only.

Parameters
nThe size of each dimension

Definition at line 436 of file KokkosArray.h.

437  {
438  createInternal<false, true, false>(n...);
439  }
KOKKOS_FUNCTION index_type n(unsigned int dim) const
Get the size of a dimension.
Definition: KokkosArray.h:300

◆ createHost() [1/2]

template<typename T, unsigned int dimension, typename index_type>
template<bool initialize = true>
void Moose::Kokkos::ArrayBase< T, dimension, index_type >::createHost ( const std::vector< index_type > &  n)
inlineinherited

Allocate array on host only.

Template Parameters
initializeWhether to initialize host data (calls default constructor)
Parameters
nThe vector containing the size of each dimension

Definition at line 412 of file KokkosArray.h.

413  {
414  createInternal<true, false, initialize>(n);
415  }
KOKKOS_FUNCTION index_type n(unsigned int dim) const
Get the size of a dimension.
Definition: KokkosArray.h:300

◆ createHost() [2/2]

template<typename T, unsigned int dimension, typename index_type>
template<bool initialize = true, typename... size_type>
void Moose::Kokkos::ArrayBase< T, dimension, index_type >::createHost ( size_type...  n)
inlineinherited

Allocate array on host only.

Template Parameters
initializeWhether to initialize host data (calls default constructor)
Parameters
nThe size of each dimension

Definition at line 422 of file KokkosArray.h.

423  {
424  createInternal<true, false, initialize>(n...);
425  }
KOKKOS_FUNCTION index_type n(unsigned int dim) const
Get the size of a dimension.
Definition: KokkosArray.h:300

◆ createInternal() [1/3]

template<typename T , unsigned int dimension, typename index_type >
template<bool host, bool device, bool initialize, typename... size_type>
void Moose::Kokkos::ArrayBase< T, dimension, index_type >::createInternal ( size_type...  n)
protectedinherited

The internal method to initialize and allocate this array.

Template Parameters
hostWhether host data will be allocated
deviceWhether device data will be allocated
initializeWhether to initialize host data (calls default constructor)
Parameters
nThe size of each dimension

Definition at line 1114 of file KokkosArray.h.

1115 {
1116  static_assert((std::is_convertible<size_type, index_type>::value && ...),
1117  "All arguments must be convertible to index_type");
1118  static_assert(sizeof...(n) == dimension, "Number of arguments should match array dimension");
1119 
1120  std::vector<index_type> dims;
1121  (dims.push_back(n), ...);
1122 
1123  createInternal<host, device, initialize>(dims);
1124 }
KOKKOS_FUNCTION index_type n(unsigned int dim) const
Get the size of a dimension.
Definition: KokkosArray.h:300

◆ createInternal() [2/3]

template<typename T , unsigned int dimension, typename index_type>
template<bool host, bool device, bool initialize>
void Moose::Kokkos::ArrayBase< T, dimension, index_type >::createInternal ( const std::vector< index_type > &  n)
protectedinherited

The internal method to initialize and allocate this array.

Template Parameters
hostWhether host data will be allocated
deviceWhether device data will be allocated
initializeWhether to initialize host data (calls default constructor)
Parameters
nThe vector containing the size of each dimension

Definition at line 1034 of file KokkosArray.h.

1035 {
1036  if (n.size() != dimension)
1037  mooseError("Kokkos array error: the number of dimensions provided (",
1038  n.size(),
1039  ") must match the array dimension (",
1040  dimension,
1041  ").");
1042 
1043  if (_counter)
1044  destroy();
1045 
1046  _counter = std::make_shared<unsigned int>();
1047 
1048  uint64_t overflow_checker = 1;
1049 
1050  _size = 1;
1051  _s[0] = 1;
1052 
1053  for (const auto i : make_range(dimension))
1054  {
1055  overflow_checker *= n[i];
1056 
1057  _n[i] = n[i];
1058  _size *= n[i];
1059  }
1060 
1061  if (overflow_checker > std::numeric_limits<index_type>::max())
1062  mooseError("Kokkos array error: the dimensions provided (",
1064  ") has the total size of ",
1065  overflow_checker,
1066  " which exceeds the limit of ",
1067  MooseUtils::prettyCppType<index_type>(),
1068  ".");
1069 
1070  if (_layout == LayoutType::LEFT)
1071  {
1072  _s[0] = 1;
1073 
1074  for (const auto i : make_range(1u, dimension))
1075  _s[i] = _s[i - 1] * _n[i - 1];
1076  }
1077  else
1078  {
1079  _s[dimension - 1] = 1;
1080 
1081  for (int i = dimension - 2; i >= 0; --i)
1082  _s[i] = _s[i + 1] * _n[i + 1];
1083  }
1084 
1085  if constexpr (host)
1086  allocHost<initialize>();
1087 
1088  if constexpr (device)
1089  allocDevice();
1090 
1091  _is_init = true;
1092 }
KOKKOS_FUNCTION index_type n(unsigned int dim) const
Get the size of a dimension.
Definition: KokkosArray.h:300
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:311
void allocDevice()
Allocate device data for an initialized array that has not allocated device data. ...
Definition: KokkosArray.h:1020
index_type _s[dimension]
Stride of each dimension.
Definition: KokkosArray.h:594
auto max(const L &left, const R &right)
index_type _size
Total size.
Definition: KokkosArray.h:709
const LayoutType _layout
Memory layout type.
Definition: KokkosArray.h:713
void destroy()
Free all data and reset.
Definition: KokkosArray.h:896
std::string stringify(const T &t)
conversion to string
Definition: Conversion.h:64
std::shared_ptr< unsigned int > _counter
Reference counter.
Definition: KokkosArray.h:673
IntRange< T > make_range(T beg, T end)
bool _is_init
Flag whether array was initialized.
Definition: KokkosArray.h:681
index_type _n[dimension]
Size of each dimension.
Definition: KokkosArray.h:590

◆ createInternal() [3/3]

template<typename T , unsigned int dimension, typename index_type>
template<bool initialize>
void Moose::Kokkos::ArrayBase< T, dimension, index_type >::createInternal ( const std::vector< index_type > &  n,
bool  host,
bool  device 
)
protectedinherited

The internal method to initialize and allocate this array.

Template Parameters
initializeWhether to initialize host data (calls default constructor)
Parameters
nThe vector containing the size of each dimension
hostThe flag whether host data will be allocated
deviceThe flag whether device data will be allocated

Definition at line 1097 of file KokkosArray.h.

1100 {
1101  if (host && device)
1102  createInternal<true, true, initialize>(n);
1103  else if (host && !device)
1104  createInternal<true, false, initialize>(n);
1105  else if (!host && device)
1106  createInternal<false, true, initialize>(n);
1107  else
1108  createInternal<false, false, initialize>(n);
1109 }
KOKKOS_FUNCTION index_type n(unsigned int dim) const
Get the size of a dimension.
Definition: KokkosArray.h:300

◆ data()

template<typename T, unsigned int dimension, typename index_type>
KOKKOS_FUNCTION T* Moose::Kokkos::ArrayBase< T, dimension, index_type >::data ( ) const
inlineinherited

Get the data pointer.

Returns
The pointer to the underlying data depending on the architecture this function is being called on

Definition at line 306 of file KokkosArray.h.

Referenced by Moose::Kokkos::copyToDeviceInner(), Moose::Kokkos::dataLoad(), Moose::Kokkos::dataStore(), and Moose::Kokkos::Matrix::find().

307  {
308  KOKKOS_IF_ON_HOST(return _host_data;)
309 
310  return _device_data;
311  }
T * _host_data
Host data.
Definition: KokkosArray.h:701
T * _device_data
Device data.
Definition: KokkosArray.h:705

◆ deepCopy()

template<typename T, unsigned int dimension, typename index_type>
void Moose::Kokkos::ArrayBase< T, dimension, index_type >::deepCopy ( const ArrayBase< T, dimension, index_type > &  array)
inherited

Deep copy another Kokkos array If ArrayDeepCopy<T>::value is true, it will copy-construct each entry If ArrayDeepCopy<T>::value is false, it will do a memory copy.

Parameters
arrayThe Kokkos array to be deep copied

Definition at line 1381 of file KokkosArray.h.

Referenced by Moose::Kokkos::ArrayBase< Moose::Kokkos::Array< Moose::Kokkos::Array< Moose::Kokkos::Real33 > >, dimension, index_type >::ArrayBase().

1382 {
1383  if (_layout != array._layout)
1384  mooseError("Kokkos array error: cannot deep copy arrays with different layouts.");
1385 
1386  if (ArrayDeepCopy<T>::value && !array._is_host_alloc)
1387  mooseError(
1388  "Kokkos array error: cannot deep copy using constructor from array without host data.");
1389 
1390  std::vector<index_type> n(std::begin(array._n), std::end(array._n));
1391 
1392  createInternal<false>(n, array._is_host_alloc, array._is_device_alloc);
1393 
1394  if (_is_host_alloc)
1395  for (const auto i : make_range(_size))
1396  if (array.isSlotConstructed(i))
1397  emplaceAt(i, array._host_data[i]);
1398 
1400  copyToDevice();
1401  else if (_is_device_alloc)
1402  copyInternal<MemSpace, MemSpace>(_device_data, array._device_data, _size);
1403 
1404  for (const auto i : make_range(dimension))
1405  {
1406  _d[i] = array._d[i];
1407  _s[i] = array._s[i];
1408  }
1409 }
KOKKOS_FUNCTION index_type n(unsigned int dim) const
Get the size of a dimension.
Definition: KokkosArray.h:300
signed_index_type _d[dimension]
Offset of each dimension.
Definition: KokkosArray.h:598
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:311
bool _is_device_alloc
Flag whether device data was allocated.
Definition: KokkosArray.h:689
index_type _s[dimension]
Stride of each dimension.
Definition: KokkosArray.h:594
bool _is_host_alloc
Flag whether host data was allocated.
Definition: KokkosArray.h:685
index_type _size
Total size.
Definition: KokkosArray.h:709
const LayoutType _layout
Memory layout type.
Definition: KokkosArray.h:713
T & emplaceAt(index_type i, Args &&... args)
Placement-new construct slot i from args, recording initialization.
Definition: KokkosArray.h:830
void copyToDevice()
Copy data from host to device.
Definition: KokkosArray.h:1167
IntRange< T > make_range(T beg, T end)
T * _device_data
Device data.
Definition: KokkosArray.h:705
static constexpr bool value
Definition: KokkosArray.h:93

◆ destroy()

template<typename T , unsigned int dimension, typename index_type >
void Moose::Kokkos::ArrayBase< T, dimension, index_type >::destroy ( )
inherited

Free all data and reset.

Definition at line 896 of file KokkosArray.h.

Referenced by Moose::Kokkos::System::clearActiveMatrixTags(), Moose::Kokkos::System::clearActiveResidualTags(), Moose::Kokkos::System::clearActiveSolutionTags(), Moose::Kokkos::System::clearActiveVariables(), Moose::Kokkos::ArrayBase< Moose::Kokkos::Array< Moose::Kokkos::Array< Moose::Kokkos::Real33 > >, dimension, index_type >::createInternal(), Moose::Kokkos::ArrayBase< Moose::Kokkos::Array< Moose::Kokkos::Array< Moose::Kokkos::Real33 > >, dimension, index_type >::shallowCopy(), and Moose::Kokkos::ArrayBase< Moose::Kokkos::Array< Moose::Kokkos::Array< Moose::Kokkos::Real33 > >, dimension, index_type >::~ArrayBase().

897 {
898  if (!_counter)
899  return;
900 
901  if (_counter.use_count() > 1)
902  {
903  _host_data = nullptr;
904  _device_data = nullptr;
905  }
906  else if (_counter.use_count() == 1)
907  {
908  freeHost();
909  freeDevice();
910  }
911 
912  _size = 0;
913 
914  for (const auto i : make_range(dimension))
915  {
916  _n[i] = 0;
917  _s[i] = 0;
918  _d[i] = 0;
919  }
920 
921  _is_init = false;
922  _is_host_alloc = false;
923  _is_device_alloc = false;
924  _is_host_alias = false;
925  _is_device_alias = false;
926 
927  _counter.reset();
928  _slots_constructed.reset();
929 }
signed_index_type _d[dimension]
Offset of each dimension.
Definition: KokkosArray.h:598
bool _is_device_alloc
Flag whether device data was allocated.
Definition: KokkosArray.h:689
T * _host_data
Host data.
Definition: KokkosArray.h:701
index_type _s[dimension]
Stride of each dimension.
Definition: KokkosArray.h:594
bool _is_host_alloc
Flag whether host data was allocated.
Definition: KokkosArray.h:685
void freeDevice()
Free device data.
Definition: KokkosArray.h:878
index_type _size
Total size.
Definition: KokkosArray.h:709
bool _is_device_alias
Flag whether the device data points to an external data.
Definition: KokkosArray.h:697
std::shared_ptr< unsigned int > _counter
Reference counter.
Definition: KokkosArray.h:673
bool _is_host_alias
Flag whether the host data points to an external data.
Definition: KokkosArray.h:693
std::shared_ptr< std::vector< bool > > _slots_constructed
Non-null only for malloc-allocated arrays; tracks which slots have been emplace-constructed.
Definition: KokkosArray.h:677
IntRange< T > make_range(T beg, T end)
T * _device_data
Device data.
Definition: KokkosArray.h:705
bool _is_init
Flag whether array was initialized.
Definition: KokkosArray.h:681
void freeHost()
Free host data.
Definition: KokkosArray.h:845
index_type _n[dimension]
Size of each dimension.
Definition: KokkosArray.h:590

◆ deviceData()

template<typename T, unsigned int dimension, typename index_type>
T* Moose::Kokkos::ArrayBase< T, dimension, index_type >::deviceData ( ) const
inlineinherited

Get the device data pointer.

Returns
The pointer to the underlying device data

Definition at line 358 of file KokkosArray.h.

Referenced by Moose::Kokkos::Array< T, 1, index_type, LayoutType::LEFT >::copyVector().

358 { return _device_data; }
T * _device_data
Device data.
Definition: KokkosArray.h:705

◆ deviceView()

template<typename T, unsigned int dimension, typename index_type>
auto Moose::Kokkos::ArrayBase< T, dimension, index_type >::deviceView ( ) const
inlineinherited

Get the device unmanaged view.

Returns
The device unmanaged view

Definition at line 372 of file KokkosArray.h.

Referenced by Moose::Kokkos::ArrayBase< Moose::Kokkos::Array< Moose::Kokkos::Array< Moose::Kokkos::Real33 > >, dimension, index_type >::operator=().

373  {
374  return ::Kokkos::View<T *, MemSpace, ::Kokkos::MemoryTraits<::Kokkos::Unmanaged>>(_device_data,
375  _size);
376  }
index_type _size
Total size.
Definition: KokkosArray.h:709
T * _device_data
Device data.
Definition: KokkosArray.h:705

◆ emplace()

template<typename T , unsigned int dimension, typename index_type , LayoutType layout>
template<typename indices , typename... Args>
T & Moose::Kokkos::Array< T, dimension, index_type, layout >::emplace ( const indices(&)  idx[dimension],
Args &&...  args 
)

Placement-new construct an entry from args, recording initialization.

Parameters
idxThe array storing the indices
argsArguments forwarded to T's constructor
Returns
Reference to the constructed element

Definition at line 1668 of file KokkosArray.h.

1669 {
1670  return this->emplaceAt(linearIndex(idx), std::forward<Args>(args)...);
1671 }
KOKKOS_FUNCTION index_type linearIndex(indices... i) const
Get the dimensionless index for a multi-dimensional index.
Definition: KokkosArray.h:1676
T & emplaceAt(index_type i, Args &&... args)
Placement-new construct slot i from args, recording initialization.
Definition: KokkosArray.h:830

◆ emplaceAt()

template<typename T , unsigned int dimension, typename index_type>
template<typename... Args>
T & Moose::Kokkos::ArrayBase< T, dimension, index_type >::emplaceAt ( index_type  i,
Args &&...  args 
)
protectedinherited

Placement-new construct slot i from args, recording initialization.

Parameters
iThe dimensionless slot index
argsArguments forwarded to T's constructor
Returns
Reference to the constructed element

Definition at line 830 of file KokkosArray.h.

Referenced by Moose::Kokkos::ArrayBase< Moose::Kokkos::Array< Moose::Kokkos::Array< Moose::Kokkos::Real33 > >, dimension, index_type >::deepCopy(), Moose::Kokkos::Array< ContiguousElementID >::emplace(), and Moose::Kokkos::Array< T, 1, index_type, LayoutType::LEFT >::emplace().

831 {
832  mooseAssert(_is_host_alloc && _slots_constructed,
833  "emplaceAt requires a malloc-allocated array (create<false>)");
834  mooseAssert(i < _size, "emplaceAt index out of bounds");
835 
836  new (_host_data + i) T(std::forward<Args>(args)...);
837  (*_slots_constructed)[i] = true;
838 
839  return _host_data[i];
840 }
T * _host_data
Host data.
Definition: KokkosArray.h:701
bool _is_host_alloc
Flag whether host data was allocated.
Definition: KokkosArray.h:685
index_type _size
Total size.
Definition: KokkosArray.h:709
std::shared_ptr< std::vector< bool > > _slots_constructed
Non-null only for malloc-allocated arrays; tracks which slots have been emplace-constructed.
Definition: KokkosArray.h:677

◆ end()

template<typename T, unsigned int dimension, typename index_type>
KOKKOS_FUNCTION iterator Moose::Kokkos::ArrayBase< T, dimension, index_type >::end ( ) const
inlineinherited

Get the end iterator.

Returns
The end iterator

Definition at line 578 of file KokkosArray.h.

Referenced by Moose::Kokkos::Array< T, 1, index_type, LayoutType::LEFT >::copySet().

579  {
580  KOKKOS_IF_ON_HOST(return iterator(_host_data + _size);)
581 
582  return iterator(_device_data + _size);
583  }
T * _host_data
Host data.
Definition: KokkosArray.h:701
index_type _size
Total size.
Definition: KokkosArray.h:709
T * _device_data
Device data.
Definition: KokkosArray.h:705

◆ first()

template<typename T, unsigned int dimension, typename index_type>
KOKKOS_FUNCTION T& Moose::Kokkos::ArrayBase< T, dimension, index_type >::first ( ) const
inlineinherited

Get the first element.

Returns
The reference of the first element depending on the architecture this function is being called on

Definition at line 317 of file KokkosArray.h.

Referenced by Moose::Kokkos::RPNEvaluator::eval().

318  {
319  KOKKOS_IF_ON_HOST(return _host_data[0];)
320 
321  return _device_data[0];
322  }
T * _host_data
Host data.
Definition: KokkosArray.h:701
T * _device_data
Device data.
Definition: KokkosArray.h:705

◆ hostData()

template<typename T, unsigned int dimension, typename index_type>
T* Moose::Kokkos::ArrayBase< T, dimension, index_type >::hostData ( ) const
inlineinherited

Get the host data pointer.

Returns
The pointer to the underlying host data

Definition at line 353 of file KokkosArray.h.

Referenced by Moose::Kokkos::Array< T, 1, index_type, LayoutType::LEFT >::copyVector().

353 { return _host_data; }
T * _host_data
Host data.
Definition: KokkosArray.h:701

◆ hostView()

template<typename T, unsigned int dimension, typename index_type>
auto Moose::Kokkos::ArrayBase< T, dimension, index_type >::hostView ( ) const
inlineinherited

Get the host unmanaged view.

Returns
The host unmanaged view

Definition at line 363 of file KokkosArray.h.

364  {
365  return ::Kokkos::View<T *, ::Kokkos::HostSpace, ::Kokkos::MemoryTraits<::Kokkos::Unmanaged>>(
366  _host_data, _size);
367  }
T * _host_data
Host data.
Definition: KokkosArray.h:701
index_type _size
Total size.
Definition: KokkosArray.h:709

◆ init()

template<typename T, unsigned int dimension, typename index_type>
template<typename... size_type>
void Moose::Kokkos::ArrayBase< T, dimension, index_type >::init ( size_type...  n)
inlineinherited

Initialize array with given dimensions but do not allocate.

Parameters
nThe size of each dimension

Definition at line 382 of file KokkosArray.h.

383  {
384  createInternal<false, false, false>(n...);
385  }
KOKKOS_FUNCTION index_type n(unsigned int dim) const
Get the size of a dimension.
Definition: KokkosArray.h:300

◆ isAlloc()

template<typename T, unsigned int dimension, typename index_type>
KOKKOS_FUNCTION bool Moose::Kokkos::ArrayBase< T, dimension, index_type >::isAlloc ( ) const
inlineinherited

Get whether the array was allocated either on host or device.

Returns
Whether the array was allocated either on host or device

Definition at line 269 of file KokkosArray.h.

Referenced by Moose::Kokkos::dataStore(), Moose::Kokkos::VariableGradientTempl< is_ad >::VariableGradientTempl(), and Moose::Kokkos::VariableValueTempl< is_ad >::VariableValueTempl().

269 { return _is_host_alloc || _is_device_alloc; }
bool _is_device_alloc
Flag whether device data was allocated.
Definition: KokkosArray.h:689
bool _is_host_alloc
Flag whether host data was allocated.
Definition: KokkosArray.h:685

◆ isDeviceAlias()

template<typename T, unsigned int dimension, typename index_type>
KOKKOS_FUNCTION bool Moose::Kokkos::ArrayBase< T, dimension, index_type >::isDeviceAlias ( ) const
inlineinherited

Get whether the device array was aliased.

Returns
Whether the device array was aliased

Definition at line 289 of file KokkosArray.h.

289 { return _is_device_alias; }
bool _is_device_alias
Flag whether the device data points to an external data.
Definition: KokkosArray.h:697

◆ isDeviceAlloc()

template<typename T, unsigned int dimension, typename index_type>
KOKKOS_FUNCTION bool Moose::Kokkos::ArrayBase< T, dimension, index_type >::isDeviceAlloc ( ) const
inlineinherited

Get whether the array was allocated on device.

Returns
Whether the array was allocated on device

Definition at line 279 of file KokkosArray.h.

Referenced by Moose::Kokkos::dataStore().

279 { return _is_device_alloc; }
bool _is_device_alloc
Flag whether device data was allocated.
Definition: KokkosArray.h:689

◆ isHostAlias()

template<typename T, unsigned int dimension, typename index_type>
KOKKOS_FUNCTION bool Moose::Kokkos::ArrayBase< T, dimension, index_type >::isHostAlias ( ) const
inlineinherited

Get whether the host array was aliased.

Returns
Whether the host array was aliased

Definition at line 284 of file KokkosArray.h.

284 { return _is_host_alias; }
bool _is_host_alias
Flag whether the host data points to an external data.
Definition: KokkosArray.h:693

◆ isHostAlloc()

template<typename T, unsigned int dimension, typename index_type>
KOKKOS_FUNCTION bool Moose::Kokkos::ArrayBase< T, dimension, index_type >::isHostAlloc ( ) const
inlineinherited

Get whether the array was allocated on host.

Returns
Whether the array was allocated on host

Definition at line 274 of file KokkosArray.h.

Referenced by Moose::Kokkos::dataLoad().

274 { return _is_host_alloc; }
bool _is_host_alloc
Flag whether host data was allocated.
Definition: KokkosArray.h:685

◆ isSlotConstructed()

template<typename T , unsigned int dimension, typename index_type>
bool Moose::Kokkos::ArrayBase< T, dimension, index_type >::isSlotConstructed ( index_type  i) const
inherited

Get whether slot i is tracked as constructed.

For an array created with initialization (initialize = true) every slot is default-constructed at allocation, so all slots are reported as constructed. For an array created without initialization (initialize = false) only slots constructed through emplace() are tracked; placement-new directly into the storage is not recorded here, so such a slot is reported as not constructed and its destructor is skipped on free (a leak for types that own resources).

Parameters
iThe slot index
Returns
true if the slot is tracked as constructed

Definition at line 816 of file KokkosArray.h.

Referenced by Moose::Kokkos::ArrayBase< Moose::Kokkos::Array< Moose::Kokkos::Array< Moose::Kokkos::Real33 > >, dimension, index_type >::deepCopy(), and Moose::Kokkos::ArrayBase< Moose::Kokkos::Array< Moose::Kokkos::Array< Moose::Kokkos::Real33 > >, dimension, index_type >::freeHost().

817 {
818  mooseAssert(i < _size, "isSlotConstructed index out of bounds");
819 
820  if (!_slots_constructed)
821  return _is_host_alloc;
822 
823  return (*_slots_constructed)[i];
824 }
bool _is_host_alloc
Flag whether host data was allocated.
Definition: KokkosArray.h:685
index_type _size
Total size.
Definition: KokkosArray.h:709
std::shared_ptr< std::vector< bool > > _slots_constructed
Non-null only for malloc-allocated arrays; tracks which slots have been emplace-constructed.
Definition: KokkosArray.h:677

◆ last()

template<typename T, unsigned int dimension, typename index_type>
KOKKOS_FUNCTION T& Moose::Kokkos::ArrayBase< T, dimension, index_type >::last ( ) const
inlineinherited

Get the last element.

Returns
The reference of the last element depending on the architecture this function is being called on

Definition at line 328 of file KokkosArray.h.

329  {
330  KOKKOS_IF_ON_HOST(return _host_data[_size - 1];)
331 
332  return _device_data[_size - 1];
333  }
T * _host_data
Host data.
Definition: KokkosArray.h:701
index_type _size
Total size.
Definition: KokkosArray.h:709
T * _device_data
Device data.
Definition: KokkosArray.h:705

◆ linearIndex() [1/2]

template<typename T , unsigned int dimension, typename index_type , LayoutType layout>
template<typename... indices>
KOKKOS_FUNCTION index_type Moose::Kokkos::Array< T, dimension, index_type, layout >::linearIndex ( indices...  i) const
private

Get the dimensionless index for a multi-dimensional index.

Definition at line 1676 of file KokkosArray.h.

1677 {
1678  static_assert((std::is_convertible<indices, signed_index_type>::value && ...),
1679  "All arguments must be convertible to signed_index_type");
1680  static_assert(sizeof...(i) == dimension, "Number of arguments should match array dimension");
1681 
1682 #ifndef NDEBUG
1683  {
1684  signed_index_type idx[dimension] = {static_cast<signed_index_type>(i)...};
1685 
1686  for (unsigned int d = 0; d < sizeof...(i); ++d)
1687  KOKKOS_ASSERT(idx[d] - _d[d] >= 0 && static_cast<index_type>(idx[d] - _d[d]) < _n[d]);
1688  }
1689 #endif
1690 
1691  index_type idx = 0;
1692  unsigned int d = 0;
1693 
1694  if constexpr (layout == LayoutType::LEFT)
1695  (((idx += (d == 0 ? static_cast<signed_index_type>(i) - _d[d]
1696  : (static_cast<signed_index_type>(i) - _d[d]) * _s[d])),
1697  ++d),
1698  ...);
1699  else
1700  (((idx += (d == dimension - 1 ? static_cast<signed_index_type>(i) - _d[d]
1701  : (static_cast<signed_index_type>(i) - _d[d]) * _s[d])),
1702  ++d),
1703  ...);
1704 
1705  return idx;
1706 }
typename std::make_signed< index_type >::type signed_index_type
Definition: KokkosArray.h:115
signed_index_type _d[dimension]
Offset of each dimension.
Definition: KokkosArray.h:598
index_type _s[dimension]
Stride of each dimension.
Definition: KokkosArray.h:594
unsigned int idx(const ElemType type, const unsigned int nx, const unsigned int i, const unsigned int j)
index_type _n[dimension]
Size of each dimension.
Definition: KokkosArray.h:590

◆ linearIndex() [2/2]

template<typename T, unsigned int dimension, typename index_type, LayoutType layout>
template<typename indices >
KOKKOS_FUNCTION index_type Moose::Kokkos::Array< T, dimension, index_type, layout >::linearIndex ( const indices(&)  idx[dimension]) const
inlineprivate

Get the dimensionless index for indices stored in an array.

Definition at line 1650 of file KokkosArray.h.

1651  {
1652  return linearIndexHelper(idx, std::make_integer_sequence<unsigned int, dimension>{});
1653  }
KOKKOS_FUNCTION index_type linearIndexHelper(const indices(&idx)[dimension], std::integer_sequence< unsigned int, i... >) const
Definition: KokkosArray.h:1655

◆ linearIndexHelper()

template<typename T, unsigned int dimension, typename index_type, LayoutType layout>
template<typename indices , unsigned int... i>
KOKKOS_FUNCTION index_type Moose::Kokkos::Array< T, dimension, index_type, layout >::linearIndexHelper ( const indices(&)  idx[dimension],
std::integer_sequence< unsigned int, i... >   
) const
inlineprivate

Definition at line 1655 of file KokkosArray.h.

1657  {
1658  return linearIndex(idx[i]...);
1659  }
KOKKOS_FUNCTION index_type linearIndex(indices... i) const
Get the dimensionless index for a multi-dimensional index.
Definition: KokkosArray.h:1676

◆ moveToDevice()

template<typename T , unsigned int dimension, typename index_type >
void Moose::Kokkos::ArrayBase< T, dimension, index_type >::moveToDevice ( bool  should_free_host = true)
inherited

Copy data from host to device and deallocate host.

Parameters
should_free_hostWhether the host memory should be freed. Host memory cannot be freed when there are shallow copies of this array that are still alive. If should_free_host is true, and we cannot free for above reason, it will error.

Definition at line 1217 of file KokkosArray.h.

Referenced by Moose::Kokkos::JaggedArray< T, inner, outer, index_type, layout >::moveToDevice().

1218 {
1219  static_assert(!is_kokkos_array<T>::value,
1220  "moveToDevice() not allowed for a nested array whose data type is another array.");
1221 
1222  if (should_free_host && _counter.use_count() > 1)
1223  mooseError("Kokkos array error: cannot move array from host to device because there is at "
1224  "least one shallow copy of this array still alive.");
1225 
1226  copyToDevice();
1227 
1228  if (_counter.use_count() == 1)
1229  freeHost();
1230 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:311
void copyToDevice()
Copy data from host to device.
Definition: KokkosArray.h:1167
std::shared_ptr< unsigned int > _counter
Reference counter.
Definition: KokkosArray.h:673
void freeHost()
Free host data.
Definition: KokkosArray.h:845

◆ moveToHost()

template<typename T , unsigned int dimension, typename index_type >
void Moose::Kokkos::ArrayBase< T, dimension, index_type >::moveToHost ( bool  should_free_device = true)
inherited

Copy data from device to host and deallocate device.

Parameters
should_free_deviceWhether the device memory should be freed. Device memory cannot be freed when there are shallow copies of this array that are still alive. If should_free_device is true, and we cannot free for above reason, it will error.

Definition at line 1234 of file KokkosArray.h.

Referenced by Moose::Kokkos::JaggedArray< T, inner, outer, index_type, layout >::moveToHost().

1235 {
1236  if (should_free_device && _counter.use_count() > 1)
1237  mooseError("Kokkos array error: cannot move array from device to host because there is at "
1238  "least one shallow copy of this array still alive.");
1239 
1240  copyToHost();
1241 
1242  if (_counter.use_count() == 1)
1243  freeDevice();
1244 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:311
void freeDevice()
Free device data.
Definition: KokkosArray.h:878
std::shared_ptr< unsigned int > _counter
Reference counter.
Definition: KokkosArray.h:673
void copyToHost()
Copy data from device to host.
Definition: KokkosArray.h:1192

◆ n()

template<typename T, unsigned int dimension, typename index_type>
KOKKOS_FUNCTION index_type Moose::Kokkos::ArrayBase< T, dimension, index_type >::n ( unsigned int  dim) const
inlineinherited

Get the size of a dimension.

Parameters
dimThe dimension index
Returns
The size of the dimension

Definition at line 300 of file KokkosArray.h.

Referenced by Moose::Kokkos::ArrayBase< Moose::Kokkos::Array< Moose::Kokkos::Array< Moose::Kokkos::Real33 > >, dimension, index_type >::ArrayBase(), Moose::Kokkos::ArrayBase< Moose::Kokkos::Array< Moose::Kokkos::Array< Moose::Kokkos::Real33 > >, dimension, index_type >::copyIn(), Moose::Kokkos::ArrayBase< Moose::Kokkos::Array< Moose::Kokkos::Array< Moose::Kokkos::Real33 > >, dimension, index_type >::copyInternal(), Moose::Kokkos::ArrayBase< Moose::Kokkos::Array< Moose::Kokkos::Array< Moose::Kokkos::Real33 > >, dimension, index_type >::copyOut(), Moose::Kokkos::ArrayBase< Moose::Kokkos::Array< Moose::Kokkos::Array< Moose::Kokkos::Real33 > >, dimension, index_type >::create(), Moose::Kokkos::ArrayBase< Moose::Kokkos::Array< Moose::Kokkos::Array< Moose::Kokkos::Real33 > >, dimension, index_type >::createDevice(), Moose::Kokkos::ArrayBase< Moose::Kokkos::Array< Moose::Kokkos::Array< Moose::Kokkos::Real33 > >, dimension, index_type >::createHost(), Moose::Kokkos::ArrayBase< Moose::Kokkos::Array< Moose::Kokkos::Array< Moose::Kokkos::Real33 > >, dimension, index_type >::createInternal(), Moose::Kokkos::dataLoad(), Moose::Kokkos::dataStore(), Moose::Kokkos::ArrayBase< Moose::Kokkos::Array< Moose::Kokkos::Array< Moose::Kokkos::Real33 > >, dimension, index_type >::deepCopy(), Moose::Kokkos::ArrayBase< Moose::Kokkos::Array< Moose::Kokkos::Array< Moose::Kokkos::Real33 > >, dimension, index_type >::init(), Moose::Kokkos::MaterialPropertyValueBase< T, 0 >::n(), and Moose::Kokkos::JaggedArray< T, inner, outer, index_type, layout >::n().

300 { return _n[dim]; }
static constexpr std::size_t dim
This is the dimension of all vector and tensor datastructures used in MOOSE.
Definition: Moose.h:165
index_type _n[dimension]
Size of each dimension.
Definition: KokkosArray.h:590

◆ offset() [1/2]

template<typename T , unsigned int dimension, typename index_type >
void Moose::Kokkos::ArrayBase< T, dimension, index_type >::offset ( const std::vector< signed_index_type > &  d)
inherited

Apply starting index offsets to each dimension.

Parameters
dThe vector containing the offset of each dimension

Definition at line 1137 of file KokkosArray.h.

Referenced by Moose::Kokkos::ArrayBase< Moose::Kokkos::Array< Moose::Kokkos::Array< Moose::Kokkos::Real33 > >, dimension, index_type >::copyIn(), Moose::Kokkos::ArrayBase< Moose::Kokkos::Array< Moose::Kokkos::Array< Moose::Kokkos::Real33 > >, dimension, index_type >::copyOut(), and Moose::Kokkos::ArrayBase< Moose::Kokkos::Array< Moose::Kokkos::Array< Moose::Kokkos::Real33 > >, dimension, index_type >::offset().

1138 {
1139  if (d.size() > dimension)
1140  mooseError("Kokkos array error: the number of offsets provided (",
1141  d.size(),
1142  ") cannot be larger than the array dimension (",
1143  dimension,
1144  ").");
1145 
1146  for (const auto i : index_range(d))
1147  _d[i] = d[i];
1148 }
signed_index_type _d[dimension]
Offset of each dimension.
Definition: KokkosArray.h:598
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:311
auto index_range(const T &sizable)

◆ offset() [2/2]

template<typename T , unsigned int dimension, typename index_type >
template<typename... offset_type>
void Moose::Kokkos::ArrayBase< T, dimension, index_type >::offset ( offset_type...  d)
inherited

Apply starting index offsets to each dimension.

Parameters
dThe offset of each dimension

Definition at line 1153 of file KokkosArray.h.

1154 {
1155  static_assert((std::is_convertible<offset_type, signed_index_type>::value && ...),
1156  "All arguments must be convertible to signed_index_type");
1157  static_assert(sizeof...(d) == dimension, "Number of arguments should match array dimension");
1158 
1159  std::vector<signed_index_type> offsets;
1160  (offsets.push_back(d), ...);
1161 
1162  offset(offsets);
1163 }
void offset(const std::vector< signed_index_type > &d)
Apply starting index offsets to each dimension.
Definition: KokkosArray.h:1137

◆ operator()() [1/2]

template<typename T, unsigned int dimension, typename index_type, LayoutType layout>
template<typename... indices>
KOKKOS_FUNCTION T& Moose::Kokkos::Array< T, dimension, index_type, layout >::operator() ( indices...  i) const
inline

Get an array entry.

Parameters
iThe index of each dimension
Returns
The reference of the entry depending on the architecture this function is being called on

Definition at line 1614 of file KokkosArray.h.

1615  {
1616  return this->operator[](linearIndex(i...));
1617  }
KOKKOS_FUNCTION index_type linearIndex(indices... i) const
Get the dimensionless index for a multi-dimensional index.
Definition: KokkosArray.h:1676
KOKKOS_FUNCTION T & operator[](index_type i) const
Get an array entry.
Definition: KokkosArray.h:340

◆ operator()() [2/2]

template<typename T, unsigned int dimension, typename index_type, LayoutType layout>
KOKKOS_FUNCTION T& Moose::Kokkos::Array< T, dimension, index_type, layout >::operator() ( const signed_index_type(&)  idx[dimension]) const
inline

Get an array entry using indices stored in an array.

Parameters
idxThe array storing the indices
Returns
The reference of the entry depending on the architecture this function is being called on

Definition at line 1624 of file KokkosArray.h.

1625  {
1626  return this->operator[](linearIndex(idx));
1627  }
KOKKOS_FUNCTION index_type linearIndex(indices... i) const
Get the dimensionless index for a multi-dimensional index.
Definition: KokkosArray.h:1676
KOKKOS_FUNCTION T & operator[](index_type i) const
Get an array entry.
Definition: KokkosArray.h:340

◆ operator=()

template<typename T, unsigned int dimension, typename index_type, LayoutType layout>
auto& Moose::Kokkos::Array< T, dimension, index_type, layout >::operator= ( const Array< T, dimension, index_type, layout > &  array)
inline

Shallow copy another Kokkos array.

Parameters
arrayThe Kokkos array to be shallow copied

Definition at line 1599 of file KokkosArray.h.

1600  {
1601  this->shallowCopy(array);
1602 
1603  return *this;
1604  }
void shallowCopy(const ArrayBase< T, dimension, index_type > &array)
Shallow copy another Kokkos array.
Definition: KokkosArray.h:933

◆ operator[]()

template<typename T, unsigned int dimension, typename index_type>
KOKKOS_FUNCTION T& Moose::Kokkos::ArrayBase< T, dimension, index_type >::operator[] ( index_type  i) const
inlineinherited

Get an array entry.

Parameters
iThe dimensionless index
Returns
The reference of the entry depending on the architecture this function is being called on

Definition at line 340 of file KokkosArray.h.

Referenced by Moose::Kokkos::Array< ContiguousElementID >::operator()(), and Moose::Kokkos::Array< T, 1, index_type, LayoutType::LEFT >::operator()().

341  {
342  KOKKOS_ASSERT(i < _size);
343 
344  KOKKOS_IF_ON_HOST(return _host_data[i];)
345 
346  return _device_data[i];
347  }
T * _host_data
Host data.
Definition: KokkosArray.h:701
index_type _size
Total size.
Definition: KokkosArray.h:709
T * _device_data
Device data.
Definition: KokkosArray.h:705

◆ shallowCopy()

template<typename T, unsigned int dimension, typename index_type>
void Moose::Kokkos::ArrayBase< T, dimension, index_type >::shallowCopy ( const ArrayBase< T, dimension, index_type > &  array)
inherited

Shallow copy another Kokkos array.

Parameters
arrayThe Kokkos array to be shallow copied

Definition at line 933 of file KokkosArray.h.

Referenced by Moose::Kokkos::ArrayBase< Moose::Kokkos::Array< Moose::Kokkos::Array< Moose::Kokkos::Real33 > >, dimension, index_type >::ArrayBase(), Moose::Kokkos::Array< ContiguousElementID >::operator=(), Moose::Kokkos::Array< T, 1, index_type, LayoutType::LEFT >::operator=(), and Moose::Kokkos::ArrayBase< Moose::Kokkos::Array< Moose::Kokkos::Array< Moose::Kokkos::Real33 > >, dimension, index_type >::swap().

934 {
935  if (_layout != array._layout)
936  mooseError("Kokkos array error: cannot shallow copy arrays with different layouts.");
937 
938  destroy();
939 
940  _counter = array._counter;
941  _slots_constructed = array._slots_constructed;
942 
943  _size = array._size;
944 
945  for (const auto i : make_range(dimension))
946  {
947  _n[i] = array._n[i];
948  _s[i] = array._s[i];
949  _d[i] = array._d[i];
950  }
951 
952  _is_init = array._is_init;
953  _is_host_alloc = array._is_host_alloc;
954  _is_device_alloc = array._is_device_alloc;
955  _is_host_alias = array._is_host_alias;
956  _is_device_alias = array._is_device_alias;
957 
958  _host_data = array._host_data;
959  _device_data = array._device_data;
960 }
signed_index_type _d[dimension]
Offset of each dimension.
Definition: KokkosArray.h:598
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:311
bool _is_device_alloc
Flag whether device data was allocated.
Definition: KokkosArray.h:689
T * _host_data
Host data.
Definition: KokkosArray.h:701
index_type _s[dimension]
Stride of each dimension.
Definition: KokkosArray.h:594
bool _is_host_alloc
Flag whether host data was allocated.
Definition: KokkosArray.h:685
index_type _size
Total size.
Definition: KokkosArray.h:709
const LayoutType _layout
Memory layout type.
Definition: KokkosArray.h:713
bool _is_device_alias
Flag whether the device data points to an external data.
Definition: KokkosArray.h:697
void destroy()
Free all data and reset.
Definition: KokkosArray.h:896
std::shared_ptr< unsigned int > _counter
Reference counter.
Definition: KokkosArray.h:673
bool _is_host_alias
Flag whether the host data points to an external data.
Definition: KokkosArray.h:693
std::shared_ptr< std::vector< bool > > _slots_constructed
Non-null only for malloc-allocated arrays; tracks which slots have been emplace-constructed.
Definition: KokkosArray.h:677
IntRange< T > make_range(T beg, T end)
T * _device_data
Device data.
Definition: KokkosArray.h:705
bool _is_init
Flag whether array was initialized.
Definition: KokkosArray.h:681
index_type _n[dimension]
Size of each dimension.
Definition: KokkosArray.h:590

◆ size()

template<typename T, unsigned int dimension, typename index_type>
KOKKOS_FUNCTION index_type Moose::Kokkos::ArrayBase< T, dimension, index_type >::size ( ) const
inlineinherited

Get the total array size.

Returns
The total array size

Definition at line 294 of file KokkosArray.h.

Referenced by Moose::Kokkos::ResidualObject::accumulateTaggedElementalMatrix(), Moose::Kokkos::ResidualObject::accumulateTaggedElementalResidual(), Moose::Kokkos::LinearSystemContributionObject::accumulateTaggedMatrix(), Moose::Kokkos::ResidualObject::accumulateTaggedNodalMatrix(), Moose::Kokkos::ResidualObject::accumulateTaggedNodalResidual(), Moose::Kokkos::LinearSystemContributionObject::accumulateTaggedVector(), Moose::Kokkos::ResidualObject::accumulateTaggedVectorNodalMatrix(), Moose::Kokkos::ResidualObject::accumulateTaggedVectorNodalResidual(), Moose::Kokkos::Array< T, 1, index_type, LayoutType::LEFT >::copyVector(), Moose::Kokkos::dataLoad(), Moose::Kokkos::dataStore(), KokkosPiecewiseBase::functionSize(), Moose::Kokkos::Mesh::getElementVolume(), Moose::Kokkos::Variable::mooseVar(), Moose::Kokkos::JaggedArray< T, inner, outer, index_type, layout >::n(), BlockRestrictable::numKokkosBlockElements(), BlockRestrictable::numKokkosBlockNodes(), BlockRestrictable::numKokkosBlockSides(), BoundaryRestrictable::numKokkosBoundaryNodes(), BoundaryRestrictable::numKokkosBoundarySides(), Moose::Kokkos::MaterialBase::numKokkosElements(), Moose::Kokkos::MaterialBase::numKokkosElementSides(), Moose::Kokkos::Vector::operator()(), Moose::Kokkos::Vector::operator[](), Moose::Kokkos::MapBase< unsigned int, unsigned int >::size(), and KokkosBoundNodalKernel::skipOnBoundary().

294 { return _size; }
index_type _size
Total size.
Definition: KokkosArray.h:709

◆ swap()

template<typename T, unsigned int dimension, typename index_type>
void Moose::Kokkos::ArrayBase< T, dimension, index_type >::swap ( ArrayBase< T, dimension, index_type > &  array)
inherited

Swap with another Kokkos array.

Parameters
arrayThe Kokkos array to be swapped

Definition at line 1413 of file KokkosArray.h.

1414 {
1415  ArrayBase<T, dimension, index_type> clone(_layout);
1416 
1417  clone.shallowCopy(*this);
1418  this->shallowCopy(array);
1419  array.shallowCopy(clone);
1420 }
void shallowCopy(const ArrayBase< T, dimension, index_type > &array)
Shallow copy another Kokkos array.
Definition: KokkosArray.h:933
const LayoutType _layout
Memory layout type.
Definition: KokkosArray.h:713

◆ useCount()

template<typename T, unsigned int dimension, typename index_type>
unsigned int Moose::Kokkos::ArrayBase< T, dimension, index_type >::useCount ( ) const
inlineinherited

Get the reference count.

Returns
The reference count

Definition at line 174 of file KokkosArray.h.

174 { return _counter.use_count(); }
std::shared_ptr< unsigned int > _counter
Reference counter.
Definition: KokkosArray.h:673

◆ usingKokkosArrayBaseMembers()

template<typename T, unsigned int dimension, typename index_type, LayoutType layout>
Moose::Kokkos::Array< T, dimension, index_type, layout >::usingKokkosArrayBaseMembers ( ,
dimension  ,
index_type   
)
private

Member Data Documentation

◆ _d

template<typename T, unsigned int dimension, typename index_type>
signed_index_type Moose::Kokkos::ArrayBase< T, dimension, index_type >::_d[dimension] = {0}
protectedinherited

◆ _n

template<typename T, unsigned int dimension, typename index_type>
index_type Moose::Kokkos::ArrayBase< T, dimension, index_type >::_n[dimension] = {0}
protectedinherited

◆ _s

template<typename T, unsigned int dimension, typename index_type>
index_type Moose::Kokkos::ArrayBase< T, dimension, index_type >::_s[dimension] = {0}
protectedinherited

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