12 #ifdef MOOSE_KOKKOS_SCOPE 19 #define usingKokkosArrayBaseMembers(T, dimension, index_type) \ 21 using ArrayBase<T, dimension, index_type>::_n; \ 22 using ArrayBase<T, dimension, index_type>::_s; \ 23 using ArrayBase<T, dimension, index_type>::_d; \ 24 using ArrayBase<T, dimension, index_type>::_is_offset; \ 27 using typename ArrayBase<T, dimension, index_type>::signed_index_type; \ 28 using ArrayBase<T, dimension, index_type>::operator= 35 void free(
void * ptr);
61 unsigned int dimension = 1,
62 typename index_type = MOOSE_KOKKOS_INDEX_TYPE,
75 template <
typename T,
unsigned int dimension,
typename index_type, LayoutType layout>
92 static constexpr
bool value =
false;
95 template <
typename T,
unsigned int dimension,
typename index_type, LayoutType layout>
105 template <
typename T,
unsigned int dimension,
typename index_type>
108 static_assert(std::is_integral_v<index_type>,
"Kokkos array index type must be an integral type");
109 static_assert(std::is_unsigned_v<index_type>,
"Kokkos array index type must be unsigned");
110 static_assert(!std::is_same_v<bool, index_type>,
"Kokkos array index type must not be bool");
122 #ifdef MOOSE_KOKKOS_SCOPE 130 template <
typename... size_type>
142 #ifndef MOOSE_KOKKOS_SCOPE 144 "Kokkos array cannot be deep copied outside the Kokkos compilation scope");
175 #ifdef MOOSE_KOKKOS_SCOPE 205 KOKKOS_FUNCTION index_type
size()
const {
return _size; }
211 KOKKOS_FUNCTION index_type
n(
unsigned int dim)
const {
return _n[
dim]; }
217 KOKKOS_FUNCTION T *
data()
const 239 KOKKOS_FUNCTION T &
last()
const 253 KOKKOS_ASSERT(i <
_size);
276 return ::Kokkos::View<T *, ::Kokkos::HostSpace, ::Kokkos::MemoryTraits<::Kokkos::Unmanaged>>(
285 return ::Kokkos::View<T *, MemSpace, ::Kokkos::MemoryTraits<::Kokkos::Unmanaged>>(
_device_data,
292 template <
typename... size_type>
295 createInternal<false, false, false>(
n...);
302 template <
bool initialize = true>
303 void create(
const std::vector<index_type> &
n)
305 createInternal<true, true, initialize>(
n);
312 template <
bool initialize =
true,
typename... size_type>
315 createInternal<true, true, initialize>(
n...);
322 template <
bool initialize = true>
325 createInternal<true, false, initialize>(
n);
332 template <
bool initialize =
true,
typename... size_type>
335 createInternal<true, false, initialize>(
n...);
341 void createDevice(
const std::vector<index_type> &
n) { createInternal<false, true, false>(
n); }
346 template <
typename... size_type>
349 createInternal<false, true, false>(
n...);
365 void offset(
const std::vector<signed_index_type> & d);
370 template <
typename... offset_type>
371 void offset(offset_type... d);
413 void moveToHost(
bool should_free_device =
true);
479 KOKKOS_FUNCTION iterator
begin()
const 481 KOKKOS_IF_ON_HOST(
return iterator(
_host_data);)
489 KOKKOS_FUNCTION iterator
end()
const 501 index_type
_n[dimension] = {0};
505 index_type
_s[dimension] = {0};
519 #ifdef MOOSE_KOKKOS_SCOPE 527 template <
bool host,
bool device,
bool initialize,
typename... size_type>
536 template <
bool host,
bool device,
bool initialize>
545 template <
bool initialize>
546 void createInternal(
const std::vector<index_type> &
n,
bool host,
bool device);
555 template <
typename TargetSpace,
typename SourceSpace>
556 void copyInternal(T * target,
const T * source, index_type
n);
560 #ifdef MOOSE_KOKKOS_SCOPE 565 template <
bool initialize>
623 template <
typename T,
unsigned int dimension,
typename index_type>
632 _host_data =
nullptr;
633 _is_host_alias =
false;
643 for (index_type i = 0; i < _size; ++i)
650 _is_host_alloc =
false;
654 template <
typename T,
unsigned int dimension,
typename index_type>
658 if (!_is_device_alloc)
661 if (_is_device_alias)
663 _device_data =
nullptr;
664 _is_device_alias =
false;
669 _is_device_alloc =
false;
672 template <
typename T,
unsigned int dimension,
typename index_type>
679 if (_counter.use_count() > 1)
681 _host_data =
nullptr;
682 _device_data =
nullptr;
684 else if (_counter.use_count() == 1)
692 for (
unsigned int i = 0; i < dimension; ++i)
702 _is_host_alloc =
false;
703 _is_device_alloc =
false;
704 _is_host_alias =
false;
705 _is_device_alias =
false;
710 template <
typename T,
unsigned int dimension,
typename index_type>
715 mooseError(
"Kokkos array error: cannot shallow copy arrays with different layouts.");
723 for (
unsigned int i = 0; i < dimension; ++i)
742 #ifdef MOOSE_KOKKOS_SCOPE 743 template <
typename T,
unsigned int dimension,
typename index_type>
748 mooseError(
"Kokkos array error: attempted to alias host data before array initialization.");
750 if (_is_host_alloc && !_is_host_alias)
751 mooseError(
"Kokkos array error: cannot alias host data because host data was not aliased.");
754 _is_host_alloc =
true;
755 _is_host_alias =
true;
758 template <
typename T,
unsigned int dimension,
typename index_type>
763 mooseError(
"Kokkos array error: attempted to alias device data before array initialization.");
765 if (_is_device_alloc && !_is_device_alias)
766 mooseError(
"Kokkos array error: cannot alias device data because device data was not aliased.");
769 _is_device_alloc =
true;
770 _is_device_alias =
true;
773 template <
typename T,
unsigned int dimension,
typename index_type>
774 template <
bool initialize>
784 std::is_default_constructible<T>::value,
785 "Data type is not default-constructible. Initialization argument should be set to false.");
787 _host_data =
new T[_size];
790 _host_data =
static_cast<T *
>(std::malloc(_size *
sizeof(T)));
792 _is_host_alloc =
true;
796 template <
typename T,
unsigned int dimension,
typename index_type>
800 if (_is_device_alloc)
804 static_cast<T *
>(::Kokkos::kokkos_malloc<ExecSpace::memory_space>(_size *
sizeof(T)));
806 _is_device_alloc =
true;
809 template <
typename T,
unsigned int dimension,
typename index_type>
810 template <
bool host,
bool device,
bool initialize>
814 if (n.size() != dimension)
815 mooseError(
"Kokkos array error: the number of dimensions provided (",
817 ") must match the array dimension (",
824 _counter = std::make_shared<unsigned int>();
826 uint64_t overflow_checker = 1;
833 overflow_checker *= n[i];
840 mooseError(
"Kokkos array error: the dimensions provided (",
842 ") has the total size of ",
844 " which exceeds the limit of ",
845 MooseUtils::prettyCppType<index_type>(),
852 for (
unsigned int i = 1; i < dimension; ++i)
853 _s[i] = _s[i - 1] * _n[i - 1];
857 _s[dimension - 1] = 1;
859 for (
int i = dimension - 2; i >= 0; --i)
860 _s[i] = _s[i + 1] * _n[i + 1];
864 allocHost<initialize>();
866 if constexpr (device)
872 template <
typename T,
unsigned int dimension,
typename index_type>
873 template <
bool initialize>
880 createInternal<true, true, initialize>(n);
881 else if (host && !device)
882 createInternal<true, false, initialize>(n);
883 else if (!host && device)
884 createInternal<false, true, initialize>(n);
886 createInternal<false, false, initialize>(n);
889 template <
typename T,
unsigned int dimension,
typename index_type>
890 template <
bool host,
bool device,
bool initialize,
typename... size_type>
894 static_assert((std::is_convertible<size_type, index_type>::value && ...),
895 "All arguments must be convertible to index_type");
896 static_assert(
sizeof...(n) == dimension,
"Number of arguments should match array dimension");
898 std::vector<index_type> dims;
899 (dims.push_back(n), ...);
901 createInternal<host, device, initialize>(dims);
904 template <
typename T,
unsigned int dimension,
typename index_type>
905 template <
typename TargetSpace,
typename SourceSpace>
909 ::Kokkos::Impl::DeepCopy<TargetSpace, SourceSpace>(target, source, n *
sizeof(T));
913 template <
typename T,
unsigned int dimension,
typename index_type>
917 if (d.size() > dimension)
918 mooseError(
"Kokkos array error: the number of offsets provided (",
920 ") cannot be larger than the array dimension (",
930 template <
typename T,
unsigned int dimension,
typename index_type>
931 template <
typename... offset_type>
935 static_assert((std::is_convertible<offset_type, signed_index_type>::value && ...),
936 "All arguments must be convertible to signed_index_type");
937 static_assert(
sizeof...(d) == dimension,
"Number of arguments should match array dimension");
939 std::vector<signed_index_type> offsets;
940 (offsets.push_back(d), ...);
945 template <
typename T,
unsigned int dimension,
typename index_type>
954 if (!_is_device_alloc)
956 if (_counter.use_count() == 1)
961 mooseError(
"Kokkos array error: cannot copy from host to device because device memory " 962 "was not allocated. Cannot allocate device memory for copy because the array is " 967 copyInternal<MemSpace, ::Kokkos::HostSpace>(_device_data, _host_data, _size);
970 template <
typename T,
unsigned int dimension,
typename index_type>
975 if (!_is_device_alloc)
981 if (_counter.use_count() == 1)
986 mooseError(
"Kokkos array error: cannot copy from device to host because host memory " 987 "was not allocated. Cannot allocate host memory for copy because the array is " 992 copyInternal<::Kokkos::HostSpace, MemSpace>(_host_data, _device_data, _size);
995 template <
typename T,
unsigned int dimension,
typename index_type>
1000 "moveToDevice() not allowed for a nested array whose data type is another array.");
1002 if (should_free_host && _counter.use_count() > 1)
1003 mooseError(
"Kokkos array error: cannot move array from host to device because there is at " 1004 "least one shallow copy of this array still alive.");
1008 if (_counter.use_count() == 1)
1012 template <
typename T,
unsigned int dimension,
typename index_type>
1016 if (should_free_device && _counter.use_count() > 1)
1017 mooseError(
"Kokkos array error: cannot move array from device to host because there is at " 1018 "least one shallow copy of this array still alive.");
1022 if (_counter.use_count() == 1)
1026 template <
typename T,
unsigned int dimension,
typename index_type>
1034 mooseError(
"Kokkos array error: cannot copy in data larger than the array size.");
1037 mooseError(
"Kokkos array error: offset cannot be larger than the array size.");
1042 if (!_is_host_alloc)
1044 "Kokkos array error: cannot copy in to the array because host memory was not allocated.");
1047 copyInternal<::Kokkos::HostSpace, ::Kokkos::HostSpace>(_host_data + offset, ptr, n);
1052 if (!_is_device_alloc)
1053 mooseError(
"Kokkos array error: cannot copy in to the array because device memory was not " 1057 copyInternal<MemSpace, ::Kokkos::HostSpace>(_device_data + offset, ptr, n);
1062 if (!_is_host_alloc)
1064 "Kokkos array error: cannot copy in to the array because host memory was not allocated.");
1067 copyInternal<::Kokkos::HostSpace, MemSpace>(_host_data + offset, ptr, n);
1072 if (!_is_device_alloc)
1073 mooseError(
"Kokkos array error: cannot copy in to the array because device memory was not " 1077 copyInternal<MemSpace, MemSpace>(_device_data + offset, ptr, n);
1081 template <
typename T,
unsigned int dimension,
typename index_type>
1089 mooseError(
"Kokkos array error: cannot copy out data larger than the array size.");
1092 mooseError(
"Kokkos array error: offset cannot be larger than the array size.");
1097 if (!_is_host_alloc)
1098 mooseError(
"Kokkos array error: cannot copy out from the array because host memory was not " 1102 copyInternal<::Kokkos::HostSpace, ::Kokkos::HostSpace>(ptr, _host_data + offset, n);
1107 if (!_is_host_alloc)
1108 mooseError(
"Kokkos array error: cannot copy out from the array because host memory was not " 1112 copyInternal<MemSpace, ::Kokkos::HostSpace>(ptr, _host_data + offset, n);
1117 if (!_is_device_alloc)
1118 mooseError(
"Kokkos array error: cannot copy out from the array because device memory was not " 1122 copyInternal<::Kokkos::HostSpace, MemSpace>(ptr, _device_data + offset, n);
1127 if (!_is_device_alloc)
1128 mooseError(
"Kokkos array error: cannot copy out from the array because device memory was not " 1132 copyInternal<MemSpace, MemSpace>(ptr, _device_data + offset, n);
1136 template <
typename T>
1142 template <
typename T,
unsigned int dimension,
typename index_type, LayoutType layout>
1149 template <
typename T,
unsigned int dimension,
typename index_type>
1153 for (index_type i = 0; i < _size; ++i)
1159 template <
typename T,
unsigned int dimension,
typename index_type>
1164 mooseError(
"Kokkos array error: cannot deep copy arrays with different layouts.");
1168 "Kokkos array error: cannot deep copy using constructor from array without host data.");
1170 std::vector<index_type> n(std::begin(array.
_n), std::end(array.
_n));
1176 for (index_type i = 0; i < _size; ++i)
1184 std::memcpy(_host_data, array.
_host_data, _size *
sizeof(T));
1186 if (_is_device_alloc)
1187 copyInternal<MemSpace, MemSpace>(_device_data, array.
_device_data, _size);
1190 for (
unsigned int i = 0; i < dimension; ++i)
1192 _d[i] = array.
_d[i];
1193 _s[i] = array.
_s[i];
1199 template <
typename T,
unsigned int dimension,
typename index_type>
1206 this->shallowCopy(array);
1210 template <
typename T,
unsigned int dimension,
typename index_type>
1215 std::fill_n(_host_data, _size, scalar);
1217 if (_is_device_alloc)
1218 ::Kokkos::Experimental::fill_n(ExecSpace(), deviceView(), _size, scalar);
1223 template <
typename T,
unsigned int dimension,
typename index_type, LayoutType layout>
1229 bool is_alloc = array.
isAlloc();
1235 std::string type =
typeid(T).
name();
1238 unsigned int dim = dimension;
1241 for (
unsigned int dim = 0;
dim < dimension; ++
dim)
1243 auto n = array.
n(
dim);
1253 T * data =
static_cast<T *
>(std::malloc(array.
size() *
sizeof(T)));
1257 for (index_type i = 0; i < array.
size(); ++i)
1263 for (
auto &
value : array)
1267 template <
typename T,
unsigned int dimension,
typename index_type, LayoutType layout>
1274 dataLoad(stream, is_alloc,
nullptr);
1279 std::string from_type_name;
1280 dataLoad(stream, from_type_name,
nullptr);
1282 if (from_type_name !=
typeid(T).
name())
1283 mooseError(
"Kokkos array error: cannot load array because the stored array is of type '",
1285 "' but the loading array is of type '",
1289 unsigned int from_dimension;
1290 dataLoad(stream, from_dimension,
nullptr);
1292 if (from_dimension != dimension)
1293 mooseError(
"Kokkos array error: cannot load array because the stored array is ",
1295 "D but the loading array is ",
1299 std::vector<index_type> from_n(dimension);
1300 std::vector<index_type> n(dimension);
1302 for (
unsigned int dim = 0;
dim < dimension; ++
dim)
1309 mooseError(
"Kokkos array error: cannot load array because the stored array has dimensions (",
1311 ") but the loading array has dimensions (",
1317 for (
auto &
value : array)
1320 if (array.isDeviceAlloc())
1321 array.copyToDevice();
1325 std::vector<T> data(array.
size());
1327 for (
auto &
value : data)
1350 template <
typename T,
unsigned int dimension,
typename index_type, LayoutType layout>
1352 class Array :
public ArrayBase<T, dimension, index_type>
1354 #ifdef MOOSE_KOKKOS_SCOPE 1367 :
ArrayBase<T, dimension, index_type>(array)
1370 #ifdef MOOSE_KOKKOS_SCOPE 1377 template <
typename... size_type>
1394 #ifdef MOOSE_KOKKOS_SCOPE 1401 template <
typename... indices>
1402 KOKKOS_FUNCTION T &
operator()(indices... i)
const;
1416 #ifdef MOOSE_KOKKOS_SCOPE 1420 template <
unsigned int... i>
1422 std::integer_sequence<unsigned int, i...>)
const 1429 #ifdef MOOSE_KOKKOS_SCOPE 1430 template <
typename T,
unsigned int dimension,
typename index_type, LayoutType layout>
1431 template <
typename... indices>
1435 static_assert((std::is_convertible<indices, signed_index_type>::value && ...),
1436 "All arguments must be convertible to signed_index_type");
1437 static_assert(
sizeof...(i) == dimension,
"Number of arguments should match array dimension");
1443 for (
unsigned int d = 0; d <
sizeof...(i); ++d)
1444 KOKKOS_ASSERT(
idx[d] - _d[d] >= 0 && static_cast<index_type>(
idx[d] - _d[d]) < _n[d]);
1455 : (static_cast<signed_index_type>(i) - _d[d]) * _s[d])),
1459 (((
idx += (d == dimension - 1 ? static_cast<signed_index_type>(i) - _d[d]
1468 (d == 0 ?
static_cast<signed_index_type>(i) : static_cast<signed_index_type>(i) * _s[d])),
1472 (((
idx += (d == dimension - 1 ? static_cast<signed_index_type>(i)
1478 return this->operator[](
idx);
1482 template <
typename T,
typename index_type>
1485 #ifdef MOOSE_KOKKOS_SCOPE 1501 #ifdef MOOSE_KOKKOS_SCOPE 1532 #ifdef MOOSE_KOKKOS_SCOPE 1540 template <
bool host,
bool device>
1543 this->
template createInternal<host, device, false>({
static_cast<index_type
>(vector.size())});
1546 std::memcpy(this->
hostData(), vector.data(), this->
size() *
sizeof(T));
1549 this->
template copyInternal<MemSpace, ::Kokkos::HostSpace>(
1559 template <
bool host,
bool device>
1562 std::vector<T> vector(
set.
begin(),
set.
end());
1564 copyVector<host, device>(vector);
1574 copyVector<true, true>(vector);
1585 copySet<true, true>(
set);
1597 KOKKOS_ASSERT(i -
_d[0] >= 0 && static_cast<index_type>(i -
_d[0]) <
_n[0]);
1612 void axby(
const T a,
1617 const bool accumulate =
false);
1625 void scal(
const T a);
1639 template <
typename T,
typename index_type = MOOSE_KOKKOS_INDEX_TYPE>
1641 template <
typename T,
1642 typename index_type = MOOSE_KOKKOS_INDEX_TYPE,
1645 template <
typename T,
1646 typename index_type = MOOSE_KOKKOS_INDEX_TYPE,
1649 template <
typename T,
1650 typename index_type = MOOSE_KOKKOS_INDEX_TYPE,
1653 template <
typename T,
1654 typename index_type = MOOSE_KOKKOS_INDEX_TYPE,
std::string name(const ElemQuality q)
typename std::make_signed< index_type >::type signed_index_type
T * deviceData() const
Get the device data pointer.
MemcpyType
The enumerator that dictates the memory copy direction.
KOKKOS_FUNCTION index_type n(unsigned int dim) const
Get the size of a dimension.
KOKKOS_FUNCTION iterator(T *p)
auto & operator=(const Array< T, dimension, index_type, layout > &array)
Shallow copy another Kokkos array.
void moveToHost(bool should_free_device=true)
Copy data from device to host and deallocate device.
KOKKOS_FUNCTION pointer operator &() const
KOKKOS_FUNCTION T & last() const
Get the last element.
Array(const Array< T, dimension, index_type, layout > &array)
Copy constructor.
signed_index_type _d[dimension]
Offset of each dimension.
LayoutType
The enumerator that dictates the memory layout.
void copyVector(const std::vector< T > &vector)
Copy a standard vector variable This re-initializes and re-allocates array with the size of the vecto...
KOKKOS_FUNCTION iterator operator++(int)
Array()
Default constructor.
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
KOKKOS_FUNCTION bool isDeviceAlloc() const
Get whether the array was allocated on device.
void dataLoad(std::istream &stream, Array< T, dimension, index_type, layout > &array, void *context)
Array()
Default constructor.
void createHost(size_type... n)
Allocate array on host only.
KOKKOS_FUNCTION T & operator[](index_type i) const
Get an array entry.
KOKKOS_FUNCTION T & operator()(signed_index_type i) const
Get an array entry.
KOKKOS_FUNCTION iterator end() const
Get the end iterator.
bool _is_offset
Flag whether the array indices are offset.
void moveToDevice(bool should_free_host=true)
Copy data from host to device and deallocate host.
KOKKOS_FUNCTION T & first() const
Get the first element.
void shallowCopy(const ArrayBase< T, dimension, index_type > &array)
Shallow copy another Kokkos array.
static constexpr std::size_t dim
This is the dimension of all vector and tensor datastructures used in MOOSE.
The type trait that determines if a template type is Kokkos array.
void allocDevice()
Allocate device data for an initialized array that has not allocated device data. ...
bool _is_device_alloc
Flag whether device data was allocated.
bool _is_malloc
Flag whether host data was allocated using malloc.
Array(size_type... n)
Constructor Initialize and allocate array with given dimensions This allocates both host and device d...
void copyOut(T *ptr, MemcpyType dir, index_type n, index_type offset=0)
Copy data to an external data from this array.
index_type _s[dimension]
Stride of each dimension.
void swap(ArrayBase< T, dimension, index_type > &array)
Swap with another Kokkos array.
void allocHost()
Allocate host data for an initialized array that has not allocated host data.
void createInternal(size_type... n)
The internal method to initialize and allocate this array.
void initialize(EquationSystems &es, const std::string &system_name)
KOKKOS_FUNCTION T & operator()(indices... i) const
Get an array entry.
bool _is_host_alloc
Flag whether host data was allocated.
auto max(const L &left, const R &right)
void aliasDevice(T *ptr)
Point the device data to an external data instead of allocating it.
Array(const Array< T, 1, index_type, LayoutType::LEFT > &array)
Copy constructor.
auto hostView() const
Get the host unmanaged view.
KOKKOS_FUNCTION bool isHostAlloc() const
Get whether the array was allocated on host.
auto deviceView() const
Get the device unmanaged view.
void freeDevice()
Free device data.
KOKKOS_FUNCTION bool isDeviceAlias() const
Get whether the device array was aliased.
KOKKOS_FUNCTION bool isAlloc() const
Get whether the array was allocated either on host or 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...
index_type _size
Total size.
const LayoutType _layout
Memory layout type.
KOKKOS_FUNCTION pointer operator->() const
std::ptrdiff_t difference_type
bool _is_device_alias
Flag whether the device data points to an external data.
KOKKOS_FUNCTION friend bool operator==(const iterator &a, const iterator &b)
Real value(unsigned n, unsigned alpha, unsigned beta, Real x)
KOKKOS_FUNCTION T & operatorInternal(const signed_index_type(&idx)[dimension], std::integer_sequence< unsigned int, i... >) const
Internal method for calling operator() with array indices.
void copyToDeviceInner(T &)
unsigned int useCount() const
Get the reference count.
Array(const std::vector< T > &vector)
Constructor Initialize and allocate array by copying a standard vector variable This allocates and co...
void create(const std::vector< index_type > &n)
Allocate array on host and device.
KOKKOS_FUNCTION T * data() const
Get the data pointer.
void aliasHost(T *ptr)
Point the host data to an external data instead of allocating it.
The base class for Kokkos arrays.
void copyToDevice()
Copy data from host to device.
KOKKOS_FUNCTION index_type size() const
Get the total array size.
void dataStore(std::ostream &stream, Array< T, dimension, index_type, layout > &array, void *context)
void create(size_type... n)
Allocate array on host and device.
void copyIn(const T *ptr, MemcpyType dir, index_type n, index_type offset=0)
Copy data from an external data to this array.
void destroy()
Free all data and reset.
std::string stringify(const T &t)
conversion to string
ArrayBase(const ArrayBase< T, dimension, index_type > &array)
Copy constructor.
std::string demangle(const char *name)
std::shared_ptr< unsigned int > _counter
Reference counter.
KOKKOS_FUNCTION iterator & operator++()
KOKKOS_FUNCTION friend bool operator!=(const iterator &a, const iterator &b)
ArrayBase(const LayoutType layout)
Constructor.
The type trait that determines the default behavior of copy constructor and deepCopy() If this type t...
bool _is_host_alias
Flag whether the host data points to an external data.
KOKKOS_FUNCTION T & operator()(const signed_index_type(&idx)[dimension]) const
Get an array entry using indices stored in an array.
auto & operator=(const T &scalar)
Assign a scalar value uniformly.
void createDevice(const std::vector< index_type > &n)
Allocate array on device only.
KOKKOS_FUNCTION reference operator*() const
KOKKOS_FUNCTION iterator begin() const
Get the beginning iterator.
void copyInternal(T *target, const T *source, index_type n)
The internal method to perform a memory copy.
std::forward_iterator_tag iterator_category
IntRange< T > make_range(T beg, T end)
auto & operator=(const Array< T, 1, index_type, LayoutType::LEFT > &array)
Shallow copy another Kokkos array.
void init(size_type... n)
Initialize array with given dimensions but do not allocate.
index_type unsigned_index_type
T * hostData() const
Get the host data pointer.
T * _device_data
Device data.
auto & operator=(const std::set< T > &set)
Copy a standard set variable This allocates and copies to both host and device data.
Array(index_type n)
Constructor Initialize and allocate array with given size This allocates both host and device data...
void copyToDeviceNested()
Copy all the nested Kokkos arrays including self from host to device.
void destroy(triangulateio &t, IO_Type)
auto & operator=(const std::vector< T > &vector)
Copy a standard vector variable This allocates and copies to both host and device data...
void createDevice(size_type... n)
Allocate array on device only.
bool _is_init
Flag whether array was initialized.
void copyToHost()
Copy data from device to host.
void createHost(const std::vector< index_type > &n)
Allocate array on host only.
ArrayBase(const LayoutType layout, size_type... n)
Constructor Initialize and allocate array with given dimensions This allocates both host and device d...
void freeHost()
Free host data.
KOKKOS_FUNCTION bool isHostAlias() const
Get whether the host array was aliased.
auto index_range(const T &sizable)
static constexpr bool value
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 ...
std::string prettyCppType(const std::string &cpp_type)
index_type _n[dimension]
Size of each dimension.
usingKokkosArrayBaseMembers(T, dimension, index_type)
void offset(const std::vector< signed_index_type > &d)
Apply starting index offsets to each dimension.
KOKKOS_FUNCTION iterator()