The specialization of the Kokkos array class for each dimension. More...
#include <KokkosArray.h>
Public Member Functions | |
Array ()=default | |
Default constructor. More... | |
Array (const Array< T, 1 > &array) | |
Copy constructor. More... | |
auto & | operator= (const Array< T, 1 > &array) |
Shallow copy another Kokkos array. More... | |
Array (dof_id_type n0) | |
Constructor Initialize and allocate array with given dimensions This allocates both host and device data. More... | |
Array (const std::vector< T > &vector) | |
Constructor Initialize and allocate array by copying a standard vector variable This allocates and copies to both host and device data. More... | |
void | init (dof_id_type n0) |
Initialize array with given dimensions but do not allocate. More... | |
void | create (dof_id_type n0) |
Initialize and allocate array with given dimensions on host and device. More... | |
void | createHost (dof_id_type n0) |
Initialize and allocate array with given dimensions on host only. More... | |
void | createDevice (dof_id_type n0) |
Initialize and allocate array with given dimensions on device only. More... | |
void | offset (dof_id_signed_type d0) |
Set starting index offsets. More... | |
template<bool host, bool device> | |
void | copyVector (const std::vector< T > &vector) |
Copy a standard vector variable This re-initializes and re-allocates array with the size of the vector. More... | |
template<bool host, bool device> | |
void | copySet (const std::set< T > &set) |
Copy a standard set variable This re-initializes and re-allocates array with the size of the set. More... | |
auto & | operator= (const std::vector< T > &vector) |
Copy a standard vector variable This allocates and copies to both host and device data. More... | |
auto & | operator= (const std::set< T > &set) |
Copy a standard set variable This allocates and copies to both host and device data. More... | |
KOKKOS_FUNCTION T & | operator() (dof_id_signed_type i0) const |
Get an array entry. 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... | |
KOKKOS_FUNCTION iterator | begin () const |
Get the beginning iterator. More... | |
KOKKOS_FUNCTION iterator | end () const |
Get the end iterator. More... | |
Protected Member Functions | |
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... | |
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] |
Size of each dimension. More... | |
dof_id_type | _s [dimension] |
Stride of each dimension. More... | |
dof_id_signed_type | _d [dimension] |
Offset of each dimension. More... | |
Private Member Functions | |
usingKokkosArrayBaseMembers (T, 1) | |
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.
Definition at line 1010 of file KokkosArray.h.
|
default |
Default constructor.
|
inline |
|
inline |
Constructor Initialize and allocate array with given dimensions This allocates both host and device data.
n0 | The first dimension size |
Definition at line 1043 of file KokkosArray.h.
|
inline |
Constructor Initialize and allocate array by copying a standard vector variable This allocates and copies to both host and device data.
vector | The standard vector variable to copy |
Definition at line 1050 of file KokkosArray.h.
|
inherited |
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.
|
inherited |
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.
|
inlineinherited |
Get the beginning iterator.
Definition at line 332 of file KokkosArray.h.
|
inherited |
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.
|
protectedinherited |
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.
|
inherited |
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.
|
inline |
Copy a standard set variable This re-initializes and re-allocates array with the size of the set.
host | Whether to allocate and copy to the host data |
device | Whether to allocate and copy to the device data |
set | The standard set variable to copy |
Definition at line 1105 of file KokkosArray.h.
|
inherited |
Copy data from host to device.
Definition at line 657 of file KokkosArray.h.
|
inherited |
Copy all the nested Kokkos arrays including self from host to device.
Definition at line 814 of file KokkosArray.h.
|
inherited |
Copy data from device to host.
Definition at line 681 of file KokkosArray.h.
|
inline |
Copy a standard vector variable This re-initializes and re-allocates array with the size of the vector.
host | Whether to allocate and copy to the host data |
device | Whether to allocate and copy to the device data |
vector | The standard vector variable to copy |
Definition at line 1086 of file KokkosArray.h.
|
inlineinherited |
Allocate array on host and device.
n | The vector containing the size of each dimension |
Definition at line 228 of file KokkosArray.h.
|
inline |
Initialize and allocate array with given dimensions on host and device.
n0 | The first dimension size |
Definition at line 1061 of file KokkosArray.h.
|
inlineinherited |
Allocate array on device only.
n | The vector containing the size of each dimension |
Definition at line 238 of file KokkosArray.h.
|
inline |
Initialize and allocate array with given dimensions on device only.
n0 | The first dimension size |
Definition at line 1071 of file KokkosArray.h.
|
inlineinherited |
Allocate array on host only.
n | The vector containing the size of each dimension |
Definition at line 233 of file KokkosArray.h.
|
inline |
Initialize and allocate array with given dimensions on host only.
n0 | The first dimension size |
Definition at line 1066 of file KokkosArray.h.
|
protectedinherited |
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.
|
protectedinherited |
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.
|
inlineinherited |
Get the data pointer.
Definition at line 171 of file KokkosArray.h.
|
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.
array | The Kokkos array to be deep copied |
Definition at line 824 of file KokkosArray.h.
|
inherited |
Free all data and reset.
Definition at line 444 of file KokkosArray.h.
|
inlineinherited |
Get the device data pointer.
Definition at line 223 of file KokkosArray.h.
|
inlineinherited |
Get the end iterator.
Definition at line 342 of file KokkosArray.h.
|
inlineinherited |
Get the first element.
Definition at line 182 of file KokkosArray.h.
|
inlineinherited |
Get the host data pointer.
Definition at line 218 of file KokkosArray.h.
|
inline |
Initialize array with given dimensions but do not allocate.
n0 | The first dimension size |
Definition at line 1056 of file KokkosArray.h.
|
inlineinherited |
Get whether the array was allocated either on host or device.
Definition at line 134 of file KokkosArray.h.
|
inlineinherited |
Get whether the device array was aliased.
Definition at line 154 of file KokkosArray.h.
|
inlineinherited |
Get whether the array was allocated on device.
Definition at line 144 of file KokkosArray.h.
|
inlineinherited |
Get whether the host array was aliased.
Definition at line 149 of file KokkosArray.h.
|
inlineinherited |
Get whether the array was allocated on host.
Definition at line 139 of file KokkosArray.h.
|
inlineinherited |
Get the last element.
Definition at line 193 of file KokkosArray.h.
|
inlineinherited |
Get the size of a dimension.
dim | The dimension index |
Definition at line 165 of file KokkosArray.h.
|
inherited |
Apply starting index offsets to each dimension.
d | The vector containing the offset of each dimension |
Definition at line 642 of file KokkosArray.h.
|
inline |
Set starting index offsets.
d0 | The first dimension offset |
Definition at line 1076 of file KokkosArray.h.
|
inline |
Get an array entry.
i0 | The first dimension index |
Definition at line 1141 of file KokkosArray.h.
|
inline |
Shallow copy another Kokkos array.
array | The Kokkos array to be shallow copied |
Definition at line 1029 of file KokkosArray.h.
|
inline |
Copy a standard vector variable This allocates and copies to both host and device data.
vector | The standard vector variable to copy |
Definition at line 1117 of file KokkosArray.h.
|
inline |
Copy a standard set variable This allocates and copies to both host and device data.
set | The standard set variable to copy |
Definition at line 1128 of file KokkosArray.h.
|
inlineinherited |
Get an array entry.
i | The dimensionless index |
Definition at line 205 of file KokkosArray.h.
|
inherited |
Shallow copy another Kokkos array.
array | The Kokkos array to be shallow copied |
Definition at line 495 of file KokkosArray.h.
|
inlineinherited |
|
inherited |
Swap with another Kokkos array.
array | The Kokkos array to be swapped |
Definition at line 859 of file KokkosArray.h.
|
inlineinherited |
Get the reference count.
Definition at line 127 of file KokkosArray.h.
|
private |
|
protectedinherited |
Offset of each dimension.
Definition at line 362 of file KokkosArray.h.
|
protectedinherited |
Size of each dimension.
Definition at line 354 of file KokkosArray.h.
|
protectedinherited |
Stride of each dimension.
Definition at line 358 of file KokkosArray.h.