The base class for Kokkos arrays. More...
#include <KokkosArray.h>
Classes | |
| class | iterator |
| Array iterator. More... | |
Public Member Functions | |
| ArrayBase ()=default | |
| Default constructor. More... | |
| ArrayBase (const ArrayBase< T, dimension > &array) | |
| Copy constructor. More... | |
| ~ArrayBase () | |
| Destructor. More... | |
| void | destroy () |
| Free all data and reset. More... | |
| void | shallowCopy (const ArrayBase< T, dimension > &array) |
| Shallow copy another Kokkos array. More... | |
| unsigned int | useCount () const |
| Get the reference count. 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 dof_id_type | size () const |
| Get the total array size. More... | |
| KOKKOS_FUNCTION dof_id_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[] (dof_id_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... | |
| void | create (const std::vector< dof_id_type > &n) |
| Allocate array on host and device. More... | |
| void | createHost (const std::vector< dof_id_type > &n) |
| Allocate array on host only. More... | |
| void | createDevice (const std::vector< dof_id_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< dof_id_signed_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, MemcpyKind dir, dof_id_type n, dof_id_type offset=0) |
| Copy data from an external data to this array. More... | |
| void | copyOut (T *ptr, MemcpyKind dir, dof_id_type n, dof_id_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 | deepCopy (const ArrayBase< T, dimension > &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 > &array) |
| Swap with another Kokkos array. More... | |
| auto & | operator= (const T &scalar) |
| Assign a scalar value uniformly. 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> | |
| void | createInternal (const std::vector< dof_id_type > &n) |
| The internal method to initialize and allocate this array. More... | |
| void | createInternal (const std::vector< dof_id_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, dof_id_type n) |
| The internal method to perform a memory copy. More... | |
Protected Attributes | |
| dof_id_type | _n [dimension] = {0} |
| Size of each dimension. More... | |
| dof_id_type | _s [dimension] = {0} |
| Stride of each dimension. More... | |
| dof_id_signed_type | _d [dimension] = {0} |
| Offset of each dimension. More... | |
Private Member Functions | |
| void | allocHost () |
| Allocate host data for an initialized array that has not allocated host data. More... | |
| void | allocDevice () |
| Allocate device data for an initialized array that has not allocated device data. More... | |
Private Attributes | |
| std::shared_ptr< unsigned int > | _counter |
| Reference counter. More... | |
| bool | _is_init = false |
| Flag whether array was initialized. More... | |
| bool | _is_host_alloc = false |
| Flag whether host data was allocated. More... | |
| bool | _is_device_alloc = false |
| Flag whether device data was allocated. More... | |
| bool | _is_host_alias = false |
| Flag whether the host data points to an external data. More... | |
| bool | _is_device_alias = false |
| Flag whether the device data points to an external data. More... | |
| T * | _host_data = nullptr |
| Host data. More... | |
| T * | _device_data = nullptr |
| Device data. More... | |
| dof_id_type | _size = 0 |
| Total size. More... | |
The base class for Kokkos arrays.
Definition at line 83 of file KokkosArray.h.
|
default |
Default constructor.
|
inline |
Copy constructor.
Definition at line 94 of file KokkosArray.h.
|
inline |
Destructor.
Definition at line 110 of file KokkosArray.h.
| void Moose::Kokkos::ArrayBase< T, dimension >::aliasDevice | ( | T * | ptr | ) |
Point the device data to an external data instead of allocating it.
| ptr | The pointer to the external device data |
Definition at line 538 of file KokkosArray.h.
| void Moose::Kokkos::ArrayBase< T, dimension >::aliasHost | ( | T * | ptr | ) |
Point the host data to an external data instead of allocating it.
| ptr | The pointer to the external host data |
Definition at line 523 of file KokkosArray.h.
|
private |
Allocate device data for an initialized array that has not allocated device data.
Definition at line 568 of file KokkosArray.h.
|
private |
Allocate host data for an initialized array that has not allocated host data.
Definition at line 553 of file KokkosArray.h.
|
inline |
Get the beginning iterator.
Definition at line 332 of file KokkosArray.h.
| void Moose::Kokkos::ArrayBase< T, dimension >::copyIn | ( | const T * | ptr, |
| MemcpyKind | dir, | ||
| dof_id_type | n, | ||
| dof_id_type | offset = 0 |
||
| ) |
Copy data from an external data to this array.
| ptr | The pointer to the external data |
| dir | The copy direction |
| n | The number of entries to copy |
| offset | The starting offset of this array |
Definition at line 705 of file KokkosArray.h.
|
protected |
The internal method to perform a memory copy.
| TargetSpace | The Kokkos memory space of target data |
| Sourcespace | The Kokkos memory space of source data |
| target | The pointer to the target data |
| source | The pointer to the source data |
| n | The number of entries to copy |
Definition at line 634 of file KokkosArray.h.
| void Moose::Kokkos::ArrayBase< T, dimension >::copyOut | ( | T * | ptr, |
| MemcpyKind | dir, | ||
| dof_id_type | n, | ||
| dof_id_type | offset = 0 |
||
| ) |
Copy data to an external data from this array.
| ptr | The pointer to the external data |
| dir | The copy direction |
| n | The number of entries to copy |
| offset | The starting offset of this array |
Definition at line 753 of file KokkosArray.h.
| void Moose::Kokkos::ArrayBase< T, dimension >::copyToDevice | ( | ) |
Copy data from host to device.
Definition at line 657 of file KokkosArray.h.
| void Moose::Kokkos::ArrayBase< T, dimension >::copyToDeviceNested | ( | ) |
Copy all the nested Kokkos arrays including self from host to device.
Definition at line 814 of file KokkosArray.h.
| void Moose::Kokkos::ArrayBase< T, dimension >::copyToHost | ( | ) |
Copy data from device to host.
Definition at line 681 of file KokkosArray.h.
|
inline |
Allocate array on host and device.
| n | The vector containing the size of each dimension |
Definition at line 228 of file KokkosArray.h.
|
inline |
Allocate array on device only.
| n | The vector containing the size of each dimension |
Definition at line 238 of file KokkosArray.h.
|
inline |
Allocate array on host only.
| n | The vector containing the size of each dimension |
Definition at line 233 of file KokkosArray.h.
|
protected |
The internal method to initialize and allocate this array.
| host | Whether host data will be allocated |
| device | Whether device data will be allocated |
| n | The vector containing the size of each dimension |
Definition at line 582 of file KokkosArray.h.
|
protected |
The internal method to initialize and allocate this array.
| n | The vector containing the size of each dimension |
| host | The flag whether host data will be allocated |
| device | The flag whether device data will be allocated |
Definition at line 619 of file KokkosArray.h.
|
inline |
Get the data pointer.
Definition at line 171 of file KokkosArray.h.
| void Moose::Kokkos::ArrayBase< T, dimension >::deepCopy | ( | const ArrayBase< T, dimension > & | 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.
| array | The Kokkos array to be deep copied |
Definition at line 824 of file KokkosArray.h.
Referenced by Moose::Kokkos::ArrayBase< T, 4 >::ArrayBase().
| void Moose::Kokkos::ArrayBase< T, dimension >::destroy | ( | ) |
Free all data and reset.
Definition at line 444 of file KokkosArray.h.
Referenced by Moose::Kokkos::ArrayBase< T, 4 >::~ArrayBase().
|
inline |
Get the device data pointer.
Definition at line 223 of file KokkosArray.h.
|
inline |
|
inline |
Get the first element.
Definition at line 182 of file KokkosArray.h.
|
inline |
Get the host data pointer.
Definition at line 218 of file KokkosArray.h.
|
inline |
Get whether the array was allocated either on host or device.
Definition at line 134 of file KokkosArray.h.
|
inline |
Get whether the device array was aliased.
Definition at line 154 of file KokkosArray.h.
|
inline |
Get whether the array was allocated on device.
Definition at line 144 of file KokkosArray.h.
|
inline |
Get whether the host array was aliased.
Definition at line 149 of file KokkosArray.h.
|
inline |
Get whether the array was allocated on host.
Definition at line 139 of file KokkosArray.h.
|
inline |
Get the last element.
Definition at line 193 of file KokkosArray.h.
|
inline |
Get the size of a dimension.
| dim | The dimension index |
Definition at line 165 of file KokkosArray.h.
Referenced by Moose::Kokkos::ArrayBase< T, 4 >::create(), Moose::Kokkos::ArrayBase< T, 4 >::createDevice(), and Moose::Kokkos::ArrayBase< T, 4 >::createHost().
| void Moose::Kokkos::ArrayBase< T, dimension >::offset | ( | const std::vector< dof_id_signed_type > & | d | ) |
Apply starting index offsets to each dimension.
| d | The vector containing the offset of each dimension |
Definition at line 642 of file KokkosArray.h.
Referenced by Moose::Kokkos::Array< T, 1 >::offset(), Moose::Kokkos::Array< T, 2 >::offset(), Moose::Kokkos::Array< T, 3 >::offset(), Moose::Kokkos::Array< T, 4 >::offset(), and Moose::Kokkos::Array< T, 5 >::offset().
| auto & Moose::Kokkos::ArrayBase< T, dimension >::operator= | ( | const T & | scalar | ) |
Assign a scalar value uniformly.
| scalar | The scalar value to be assigned |
Definition at line 870 of file KokkosArray.h.
|
inline |
Get an array entry.
| i | The dimensionless index |
Definition at line 205 of file KokkosArray.h.
| void Moose::Kokkos::ArrayBase< T, dimension >::shallowCopy | ( | const ArrayBase< T, dimension > & | array | ) |
Shallow copy another Kokkos array.
| array | The Kokkos array to be shallow copied |
Definition at line 495 of file KokkosArray.h.
Referenced by Moose::Kokkos::ArrayBase< T, 4 >::ArrayBase(), and Moose::Kokkos::ArrayBase< T, 4 >::swap().
|
inline |
| void Moose::Kokkos::ArrayBase< T, dimension >::swap | ( | ArrayBase< T, dimension > & | array | ) |
Swap with another Kokkos array.
| array | The Kokkos array to be swapped |
Definition at line 859 of file KokkosArray.h.
|
inline |
Get the reference count.
Definition at line 127 of file KokkosArray.h.
|
private |
Reference counter.
Definition at line 407 of file KokkosArray.h.
Referenced by Moose::Kokkos::ArrayBase< T, 4 >::shallowCopy(), and Moose::Kokkos::ArrayBase< T, 4 >::useCount().
|
protected |
Offset of each dimension.
Definition at line 362 of file KokkosArray.h.
Referenced by Moose::Kokkos::ArrayBase< T, 4 >::deepCopy(), and Moose::Kokkos::ArrayBase< T, 4 >::shallowCopy().
|
private |
Device data.
Definition at line 435 of file KokkosArray.h.
Referenced by Moose::Kokkos::ArrayBase< T, 4 >::begin(), Moose::Kokkos::ArrayBase< T, 4 >::data(), Moose::Kokkos::ArrayBase< T, 4 >::deepCopy(), Moose::Kokkos::ArrayBase< T, 4 >::deviceData(), Moose::Kokkos::ArrayBase< T, 4 >::end(), Moose::Kokkos::ArrayBase< T, 4 >::first(), Moose::Kokkos::ArrayBase< T, 4 >::last(), Moose::Kokkos::ArrayBase< T, 4 >::operator[](), and Moose::Kokkos::ArrayBase< T, 4 >::shallowCopy().
|
private |
Host data.
Definition at line 431 of file KokkosArray.h.
Referenced by Moose::Kokkos::ArrayBase< T, 4 >::begin(), Moose::Kokkos::ArrayBase< T, 4 >::data(), Moose::Kokkos::ArrayBase< T, 4 >::deepCopy(), Moose::Kokkos::ArrayBase< T, 4 >::end(), Moose::Kokkos::ArrayBase< T, 4 >::first(), Moose::Kokkos::ArrayBase< T, 4 >::hostData(), Moose::Kokkos::ArrayBase< T, 4 >::last(), Moose::Kokkos::ArrayBase< T, 4 >::operator[](), and Moose::Kokkos::ArrayBase< T, 4 >::shallowCopy().
|
private |
Flag whether the device data points to an external data.
Definition at line 427 of file KokkosArray.h.
Referenced by Moose::Kokkos::ArrayBase< T, 4 >::isDeviceAlias(), and Moose::Kokkos::ArrayBase< T, 4 >::shallowCopy().
|
private |
Flag whether device data was allocated.
Definition at line 419 of file KokkosArray.h.
Referenced by Moose::Kokkos::ArrayBase< T, 4 >::deepCopy(), Moose::Kokkos::ArrayBase< T, 4 >::isAlloc(), Moose::Kokkos::ArrayBase< T, 4 >::isDeviceAlloc(), and Moose::Kokkos::ArrayBase< T, 4 >::shallowCopy().
|
private |
Flag whether the host data points to an external data.
Definition at line 423 of file KokkosArray.h.
Referenced by Moose::Kokkos::ArrayBase< T, 4 >::isHostAlias(), and Moose::Kokkos::ArrayBase< T, 4 >::shallowCopy().
|
private |
Flag whether host data was allocated.
Definition at line 415 of file KokkosArray.h.
Referenced by Moose::Kokkos::ArrayBase< T, 4 >::deepCopy(), Moose::Kokkos::ArrayBase< T, 4 >::isAlloc(), Moose::Kokkos::ArrayBase< T, 4 >::isHostAlloc(), and Moose::Kokkos::ArrayBase< T, 4 >::shallowCopy().
|
private |
Flag whether array was initialized.
Definition at line 411 of file KokkosArray.h.
Referenced by Moose::Kokkos::ArrayBase< T, 4 >::shallowCopy().
|
protected |
Size of each dimension.
Definition at line 354 of file KokkosArray.h.
Referenced by Moose::Kokkos::ArrayBase< T, 4 >::deepCopy(), Moose::Kokkos::ArrayBase< T, 4 >::n(), and Moose::Kokkos::ArrayBase< T, 4 >::shallowCopy().
|
protected |
Stride of each dimension.
Definition at line 358 of file KokkosArray.h.
Referenced by Moose::Kokkos::ArrayBase< T, 4 >::deepCopy(), and Moose::Kokkos::ArrayBase< T, 4 >::shallowCopy().
|
private |
Total size.
Definition at line 439 of file KokkosArray.h.
Referenced by Moose::Kokkos::ArrayBase< T, 4 >::end(), Moose::Kokkos::ArrayBase< T, 4 >::last(), Moose::Kokkos::ArrayBase< T, 4 >::operator[](), Moose::Kokkos::ArrayBase< T, 4 >::shallowCopy(), and Moose::Kokkos::ArrayBase< T, 4 >::size().
1.8.14