AXOM
Axom provides a robust, flexible software infrastructure for the development of multi-physics applications and computational tools.
|
Provides a generic multidimensional array container. More...
#include </home/docs/checkouts/readthedocs.org/user_builds/axom/checkouts/feature-whitlock-mir_update/src/axom/core/Array.hpp>
Public Types | |
using | value_type = T |
using | ArrayIterator = ArrayIteratorBase< Array< T, DIM, SPACE >, T > |
using | ConstArrayIterator = ArrayIteratorBase< const Array< T, DIM, SPACE >, const T > |
using | ArrayViewType = ArrayView< T, DIM, SPACE > |
using | ConstArrayViewType = ArrayView< const T, DIM, SPACE > |
using | RealConstT = typename std::conditional< is_array_view, T, const T >::type |
using | SliceType = typename std::conditional< DIM==IdxDim, T &, typename detail::SubsliceProxy< T, DIM - IdxDim, Array< T, 1, MemorySpace::Dynamic > >::type >::type |
using | ConstSliceType = typename std::conditional< DIM==IdxDim, RealConstT &, typename detail::SubsliceProxy< T, DIM - IdxDim, const Array< T, 1, MemorySpace::Dynamic > >::type >::type |
Public Member Functions | |
virtual | ~Array () |
template<int LENGTH1D, typename TT = T, int TDIM = DIM> | |
AXOM_HOST_DEVICE std::enable_if< TDIM==1, axom::StackArray< TT, LENGTH1D > >::type | to_stack_array () const |
Convert 1D Array into a StackArray. More... | |
template<typename... Args> | |
AXOM_HOST_DEVICE void | emplace_back_device (Args &&... args) |
Inserts new element at the end of the Array. More... | |
template<typename... Args> | |
Array< T, DIM, SPACE >::ArrayIterator | emplace (Array< T, DIM, SPACE >::ArrayIterator pos, Args &&... args) |
AXOM_HOST_DEVICE SliceType< sizeof...(Args)> | operator() (Args... args) |
Dimension-aware accessor; with N=DIM indices, returns a reference to the given value at that index. Otherwise, returns a sub-array pointed to by the given sub-index. More... | |
AXOM_HOST_DEVICE ConstSliceType< sizeof...(Args)> | operator() (Args... args) const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More... | |
AXOM_HOST_DEVICE SliceType< 1 > | operator[] (const IndexType idx) |
Scalar accessor; returns a sub-array referenced by the given sub- index, beginning at array(idx, 0...) More... | |
AXOM_HOST_DEVICE ConstSliceType< 1 > | operator[] (const IndexType idx) const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More... | |
AXOM_HOST_DEVICE SliceType< UDim > | operator[] (const StackArray< IndexType, UDim > &idx) |
Dimension-aware accessor; with UDim=DIM indices, returns a reference to the given value at that index. Otherwise, returns a sub-array pointed to by the given sub-index. More... | |
AXOM_HOST_DEVICE ConstSliceType< UDim > | operator[] (const StackArray< IndexType, UDim > &idx) const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More... | |
void | swap (ArrayBase &other) |
Swaps two ArrayBases. More... | |
AXOM_HOST_DEVICE const StackArray< IndexType, DIM > & | shape () const |
Returns the dimensions of the Array. More... | |
AXOM_HOST_DEVICE const MDMapping< DIM > & | mapping () const |
Returns the multidimensional mapping for the Array. More... | |
AXOM_HOST_DEVICE const StackArray< IndexType, DIM > & | strides () const |
Returns the memory strides of the Array. More... | |
AXOM_HOST_DEVICE IndexType | minStride () const |
Returns the minimum stride between adjacent items. More... | |
Native Storage Array Constructors | |
Array () | |
Default constructor. Constructs an Array instance with no elements and default allocator ID. More... | |
template<IndexType SFINAE_DIM = DIM, MemorySpace SFINAE_SPACE = SPACE, typename std::enable_if< SFINAE_DIM==1 >::type * = nullptr> | |
Array (IndexType num_elements, IndexType capacity=0, int allocator_id=axom::detail::getAllocatorID< SPACE >()) | |
Constructs a 1D Array instance with the given number of elements. More... | |
template<IndexType SFINAE_DIM = DIM, MemorySpace SFINAE_SPACE = SPACE, typename std::enable_if< SFINAE_DIM==1 >::type * = nullptr> | |
Array (ArrayOptions::Uninitialized, IndexType num_elements, IndexType capacity=0, int allocator_id=axom::detail::getAllocatorID< SPACE >()) | |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More... | |
Array (const axom::StackArray< axom::IndexType, DIM > &shape, int allocator_id=axom::detail::getAllocatorID< SPACE >()) | |
Array (const axom::StackArray< axom::IndexType, DIM > &shape, axom::ArrayStrideOrder rowOrColumn, int allocator_id=axom::detail::getAllocatorID< SPACE >()) | |
Construct Array with row- or column-major data ordering. More... | |
template<typename DirType = axom::IndexType> | |
Array (const axom::StackArray< axom::IndexType, DIM > &shape, const axom::StackArray< DirType, DIM > &slowestDirs, int allocator_id=axom::detail::getAllocatorID< SPACE >()) | |
Construct Array with data ordering specifications. More... | |
template<typename... Args, typename Enable = typename std::enable_if< sizeof...(Args) == DIM && detail::all_types_are_integral<Args...>::value>::type> | |
Array (Args... args) | |
Generic constructor for an Array of arbitrary dimension. More... | |
template<typename... Args, typename Enable = typename std::enable_if< sizeof...(Args) == DIM && detail::all_types_are_integral<Args...>::value>::type> | |
Array (ArrayOptions::Uninitialized, Args... args) | |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More... | |
template<int UDIM = DIM, typename Enable = typename std::enable_if<UDIM == 1>::type> | |
Array (std::initializer_list< T > elems, int allocator_id=axom::detail::getAllocatorID< SPACE >()) | |
Initializer list constructor for a one-dimensional Array. More... | |
AXOM_HOST_DEVICE | Array (const Array &other) |
Copy constructor for an Array instance. More... | |
Array (Array &&other) noexcept | |
Move constructor for an Array instance. More... | |
template<typename OtherArrayType > | |
Array (const ArrayBase< T, DIM, OtherArrayType > &other) | |
Constructor for transferring between memory spaces. More... | |
template<typename OtherArrayType > | |
Array (const ArrayBase< const T, DIM, OtherArrayType > &other) | |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More... | |
template<typename OtherArrayType > | |
Array (const ArrayBase< T, DIM, OtherArrayType > &other, int allocator_id) | |
Constructor for transferring between memory spaces, with a user- specified allocator. More... | |
template<typename OtherArrayType > | |
Array (const ArrayBase< const T, DIM, OtherArrayType > &other, int allocator_id) | |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More... | |
Array copy and move operators | |
Array & | operator= (const Array &other) |
Copy assignment operator for Array. More... | |
Array & | operator= (Array &&other) noexcept |
Move assignment operator for Array. More... | |
template<int UDIM = DIM, typename Enable = typename std::enable_if<UDIM == 1>::type> | |
Array & | operator= (std::initializer_list< T > elems) |
Initializer list assignment operator for Array. More... | |
Array element access operators | |
AXOM_HOST_DEVICE T * | data () |
Return a pointer to the array of data. More... | |
AXOM_HOST_DEVICE const T * | data () const |
Array methods to modify the data. | |
void | fill (const T &value) |
Set all the values of the array. More... | |
void | fill (const T &value, IndexType n, IndexType pos) |
Set a range of elements to a given value. More... | |
void | set (const T *elements, IndexType n, IndexType pos) |
Modify the values of existing elements. More... | |
void | clear () |
Clears the contents of the array. More... | |
void | insert (IndexType pos, const T &value) |
Insert an element into the array at the given position. More... | |
ArrayIterator | insert (ArrayIterator pos, const T &value) |
Insert an element into the array at the value before pos. More... | |
void | insert (IndexType pos, IndexType n, const T *values) |
Insert elements into the array at the given position. More... | |
ArrayIterator | insert (ArrayIterator pos, IndexType n, const T *values) |
Insert elements into the array at the value before pos. More... | |
void | insert (IndexType pos, IndexType n, const T &value) |
Insert n copies of element into the array at the given position. More... | |
ArrayIterator | insert (ArrayIterator pos, IndexType n, const T &value) |
Insert n copies of element into the array at the value before pos. More... | |
template<MemorySpace OtherSpace> | |
void | insert (IndexType pos, ArrayView< const T, DIM, OtherSpace > other) |
Inserts an Array to the end of the calling object. More... | |
template<MemorySpace OtherSpace> | |
void | insert (IndexType pos, ArrayView< T, DIM, OtherSpace > other) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More... | |
template<MemorySpace OtherSpace> | |
void | append (ArrayView< const T, DIM, OtherSpace > other) |
Appends an Array to the end of the calling object. More... | |
template<MemorySpace OtherSpace> | |
void | append (ArrayView< T, DIM, OtherSpace > other) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More... | |
ArrayIterator | erase (ArrayIterator pos) |
Erases an element from the Array. More... | |
ArrayIterator | erase (ArrayIterator first, ArrayIterator last) |
Erases elements in the range [first, last) from the Array. More... | |
template<typename... Args> | |
void | emplace (IndexType pos, Args &&... args) |
Inserts new element into Array at the given position. More... | |
template<typename... Args> | |
ArrayIterator | emplace (ArrayIterator pos, Args &&... args) |
Inserts new element into Array before pos. More... | |
void | push_back (const T &value) |
Push a value to the back of the array. More... | |
void | push_back (T &&value) |
Push a value to the back of the array. More... | |
template<typename... Args> | |
void | emplace_back (Args &&... args) |
Inserts new element at the end of the Array. More... | |
AXOM_HOST_DEVICE void | push_back_device (const T &value) |
Push a value to the back of the array. More... | |
AXOM_HOST_DEVICE void | push_back_device (T &&value) |
Array methods to query and set attributes | |
IndexType | capacity () const |
Return the number of elements allocated for the data array. More... | |
void | reserve (IndexType capacity) |
Increase the capacity. Does nothing if the new capacity is less than the current capacity. More... | |
ArrayIterator | begin () |
Returns an ArrayIterator to the first element of the Array. More... | |
ConstArrayIterator | begin () const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More... | |
ArrayIterator | end () |
Returns an ArrayIterator to the element following the last element of the Array. More... | |
ConstArrayIterator | end () const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More... | |
T & | front () |
Returns a reference to the first element in the Array. More... | |
const T & | front () const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More... | |
T & | back () |
Returns a reference to the last element in the Array. More... | |
const T & | back () const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More... | |
void | shrink () |
Shrink the capacity to be equal to the size. More... | |
AXOM_HOST_DEVICE bool | empty () const |
Returns true iff the Array stores no elements. More... | |
AXOM_HOST_DEVICE IndexType | size () const |
Return the number of elements stored in the data array. More... | |
template<typename... Args, typename Enable = typename std::enable_if< sizeof...(Args) == DIM && detail::all_types_are_integral<Args...>::value>::type> | |
void | resize (Args... args) |
Update the number of elements stored in the data array. More... | |
template<typename... Args, typename Enable = typename std::enable_if< sizeof...(Args) == DIM && detail::all_types_are_integral<Args...>::value>::type> | |
void | resize (ArrayOptions::Uninitialized, Args... args) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More... | |
template<int Dims = DIM, typename Enable = std::enable_if_t<Dims == 1>> | |
void | resize (IndexType size, const T &value) |
void | resize (const StackArray< IndexType, DIM > &size, const T &value) |
void | swap (Array< T, DIM, SPACE > &other) |
Exchanges the contents of this Array with the other. More... | |
double | getResizeRatio () const |
Get the ratio by which the capacity increases upon dynamic resize. More... | |
void | setResizeRatio (double ratio) |
Set the ratio by which the capacity increases upon dynamic resize. More... | |
AXOM_HOST_DEVICE int | getAllocatorID () const |
Get the ID for the umpire allocator. More... | |
void | setDevicePreference (bool on_device) |
Sets the preferred space where operations on this array should be performed. More... | |
ArrayViewType | view () |
Returns a view of the array. More... | |
ConstArrayViewType | view () const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More... | |
AXOM_HOST_DEVICE T & | flatIndex (const IndexType idx) |
Accessor, returns a reference to the given value. For multidimensional arrays, indexes into the (flat) raw data. More... | |
AXOM_HOST_DEVICE RealConstT & | flatIndex (const IndexType idx) const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More... | |
Static Public Attributes | |
static constexpr double | DEFAULT_RESIZE_RATIO = 2.0 |
static constexpr IndexType | MIN_DEFAULT_CAPACITY = 32 |
static constexpr MemorySpace | space = SPACE |
constexpr static int | Dims |
Protected Member Functions | |
void | initialize (IndexType num_elements, IndexType capacity, bool should_default_construct=true) |
Initialize an Array instance with the given number of elements. More... | |
void | initialize_from_other (const T *data, IndexType num_elements, MemorySpace data_space, bool user_provided_allocator) |
Helper function for initializing an Array instance with an existing range of elements. More... | |
void | resizeImpl (const StackArray< IndexType, DIM > &dims, bool construct_with_values, const T *value=nullptr) |
Updates the number of elements stored in the data array. More... | |
T * | reserveForInsert (IndexType n, IndexType pos) |
Make space for a subsequent insertion into the array. More... | |
AXOM_DEVICE IndexType | reserveForDeviceInsert (IndexType n) |
Make space for a subsequent insertion into the array. More... | |
virtual void | updateNumElements (IndexType new_num_elements) |
Update the number of elements. More... | |
virtual void | setCapacity (IndexType new_capacity) |
Set the number of elements allocated for the data array. More... | |
virtual void | dynamicRealloc (IndexType new_num_elements) |
Reallocates the data array when the size exceeds the capacity. More... | |
AXOM_HOST_DEVICE void | setShape (const StackArray< IndexType, DIM > &shape_) |
Set the shape. More... | |
AXOM_SUPPRESS_HD_WARN AXOM_HOST_DEVICE void | setShapeAndStride (const StackArray< IndexType, DIM > &shape, const StackArray< IndexType, DIM > &stride) |
Set the shape and stride. More... | |
IndexType | blockSize () const |
Returns the minimum "chunk size" that should be allocated For example, 2 would be the chunk size of a 2D array whose second dimension is of size 2. This is used when resizing/reallocating; it wouldn't make sense to have a capacity of 3 in the array described above. More... | |
AXOM_HOST_DEVICE void | updateStrides (int min_stride=1) |
Updates the internal striding information to a row-major format Intended to be called after shape is updated. More... | |
void | updateShapeOnInsert (const StackArray< IndexType, DIM > &range_shape) |
Updates the internal dimensions and striding based on the insertion of a range of elements. Intended to be called after the insertion of a multidimensional subslice. More... | |
Protected Attributes | |
T * | m_data = nullptr |
IndexType | m_num_elements = 0 |
The full number of elements in the array i.e., 3 for a 1D Array of size 3, 9 for a 3x3 2D array, etc. More... | |
IndexType | m_capacity = 0 |
double | m_resize_ratio = DEFAULT_RESIZE_RATIO |
int | m_allocator_id = INVALID_ALLOCATOR_ID |
bool | m_executeOnGPU = false |
StackArray< IndexType, DIM > | m_shape |
The extent in each direction. More... | |
MDMapping< DIM > | m_mapping |
For converting between multidim indices and offset. More... | |
IndexType | m_minStride |
Cached value for optimization. More... | |
Provides a generic multidimensional array container.
The Array class provides a generic multidimensional array container with dynamic reallocation and insertion. The dimensionality of the array must be known at compile time but the extents in each dimension are dynamic and can be changed at runtime. Array elements are stored contiguously.
The Array class mirrors std::vector, with future support for GPUs in-development. The class's multidimensional array functionality roughly mirrors the multidimensional array support provided by numpy's ndarray.
Some interfaces accomodate data ordering specifications. Unless otherwise specified, data storage defaults to row-major.
This class is meant to be a drop-in replacement for std::vector. However, it differs in its memory management and construction semantics. Specifically, we do not require axom::Array to initialize/construct its memory at allocation time and we use axom's memory_management and allocator ID abstractions rather than std::allocator.
Array always retains exclusive ownership of its data and is responsible for freeing its memory.
T | the type of the values to hold. |
DIM | The dimension of the array. |
SPACE | The memory space of the array. |
using axom::Array< T, DIM, SPACE >::value_type = T |
using axom::Array< T, DIM, SPACE >::ArrayIterator = ArrayIteratorBase<Array<T, DIM, SPACE>, T> |
using axom::Array< T, DIM, SPACE >::ConstArrayIterator = ArrayIteratorBase<const Array<T, DIM, SPACE>, const T> |
using axom::Array< T, DIM, SPACE >::ArrayViewType = ArrayView<T, DIM, SPACE> |
using axom::Array< T, DIM, SPACE >::ConstArrayViewType = ArrayView<const T, DIM, SPACE> |
|
inherited |
|
inherited |
|
inherited |
axom::Array< T, DIM, SPACE >::Array |
Default constructor. Constructs an Array instance with no elements and default allocator ID.
axom::Array< T, DIM, SPACE >::Array | ( | IndexType | num_elements, |
IndexType | capacity = 0 , |
||
int | allocator_id = axom::detail::getAllocatorID<SPACE>() |
||
) |
Constructs a 1D Array instance with the given number of elements.
[in] | num_elements | the number of elements the Array holds. |
[in] | capacity | the number of elements to allocate space for. |
[in] | allocator_id | the ID of the allocator to use (optional) |
ArrayOptions::Uninitialized
first parameter. These are intended for cases where the array data should not be initialized when memory is allocated, e.g. if the code is known to initialize the dataReferences axom::Array< T, DIM, SPACE >::capacity(), axom::Dynamic, axom::detail::getAllocatorSpace(), axom::Array< T, DIM, SPACE >::initialize(), and axom::Array< T, DIM, SPACE >::m_allocator_id.
axom::Array< T, DIM, SPACE >::Array | ( | ArrayOptions::Uninitialized | , |
IndexType | num_elements, | ||
IndexType | capacity = 0 , |
||
int | allocator_id = axom::detail::getAllocatorID<SPACE>() |
||
) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
References axom::Array< T, DIM, SPACE >::capacity(), axom::Dynamic, axom::detail::getAllocatorSpace(), axom::Array< T, DIM, SPACE >::initialize(), and axom::Array< T, DIM, SPACE >::m_allocator_id.
axom::Array< T, DIM, SPACE >::Array | ( | const axom::StackArray< axom::IndexType, DIM > & | shape, |
int | allocator_id = axom::detail::getAllocatorID<SPACE>() |
||
) |
axom::Array< T, DIM, SPACE >::Array | ( | const axom::StackArray< axom::IndexType, DIM > & | shape, |
axom::ArrayStrideOrder | rowOrColumn, | ||
int | allocator_id = axom::detail::getAllocatorID<SPACE>() |
||
) |
Construct Array with row- or column-major data ordering.
References axom::ArrayBase< T, 1, Array< T, 1, MemorySpace::Dynamic > >::shape().
axom::Array< T, DIM, SPACE >::Array | ( | const axom::StackArray< axom::IndexType, DIM > & | shape, |
const axom::StackArray< DirType, DIM > & | slowestDirs, | ||
int | allocator_id = axom::detail::getAllocatorID<SPACE>() |
||
) |
Construct Array with data ordering specifications.
Example of 3D Array where j is slowest and i is fastest: Array<3, int> ar( shape, axom::StackArray<axom::IndexType, DIM>{2, 0, 1});
References axom::ArrayBase< T, 1, Array< T, 1, MemorySpace::Dynamic > >::shape().
axom::Array< T, DIM, SPACE >::Array | ( | Args... | args | ) |
Generic constructor for an Array of arbitrary dimension.
[in] | args | The parameter pack containing the "shape" of the Array |
axom::Array< T, DIM, SPACE >::Array | ( | ArrayOptions::Uninitialized | , |
Args... | args | ||
) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
axom::Array< T, DIM, SPACE >::Array | ( | std::initializer_list< T > | elems, |
int | allocator_id = axom::detail::getAllocatorID<SPACE>() |
||
) |
Initializer list constructor for a one-dimensional Array.
[in] | elems | The elements to initialize the array with |
[in] | allocator_id | the ID of the allocator to use (optional) |
References axom::Dynamic, and axom::Array< T, DIM, SPACE >::initialize_from_other().
AXOM_HOST_DEVICE axom::Array< T, DIM, SPACE >::Array | ( | const Array< T, DIM, SPACE > & | other | ) |
Copy constructor for an Array instance.
References axom::Array< T, DIM, SPACE >::capacity(), axom::Array< T, DIM, SPACE >::data(), axom::Dynamic, axom::detail::getAllocatorSpace(), axom::isDeviceAllocator(), axom::Array< T, DIM, SPACE >::m_allocator_id, axom::Array< T, DIM, SPACE >::m_data, axom::Array< T, DIM, SPACE >::m_executeOnGPU, axom::Array< T, DIM, SPACE >::setCapacity(), axom::Array< T, DIM, SPACE >::size(), and axom::Array< T, DIM, SPACE >::updateNumElements().
|
noexcept |
Move constructor for an Array instance.
References axom::INVALID_ALLOCATOR_ID, and axom::isDeviceAllocator().
axom::Array< T, DIM, SPACE >::Array | ( | const ArrayBase< T, DIM, OtherArrayType > & | other | ) |
Constructor for transferring between memory spaces.
[in] | other | The array in a different memory space to copy from |
An Array specified with the default Dynamic memory space will always propagate the allocator ID from the source array.
References axom::Array< T, DIM, SPACE >::data(), axom::detail::getAllocatorSpace(), axom::Array< T, DIM, SPACE >::initialize_from_other(), axom::Array< T, DIM, SPACE >::m_allocator_id, and axom::Array< T, DIM, SPACE >::size().
axom::Array< T, DIM, SPACE >::Array | ( | const ArrayBase< const T, DIM, OtherArrayType > & | other | ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
References axom::Array< T, DIM, SPACE >::data(), axom::detail::getAllocatorSpace(), axom::Array< T, DIM, SPACE >::initialize_from_other(), axom::Array< T, DIM, SPACE >::m_allocator_id, and axom::Array< T, DIM, SPACE >::size().
axom::Array< T, DIM, SPACE >::Array | ( | const ArrayBase< T, DIM, OtherArrayType > & | other, |
int | allocator_id | ||
) |
Constructor for transferring between memory spaces, with a user- specified allocator.
[in] | other | The array in a different memory space to copy from |
[in] | allocator_id | the ID of the allocator to use |
References axom::Array< T, DIM, SPACE >::data(), axom::Array< T, DIM, SPACE >::getAllocatorID(), axom::detail::getAllocatorSpace(), axom::Array< T, DIM, SPACE >::initialize_from_other(), and axom::Array< T, DIM, SPACE >::size().
axom::Array< T, DIM, SPACE >::Array | ( | const ArrayBase< const T, DIM, OtherArrayType > & | other, |
int | allocator_id | ||
) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
References axom::Array< T, DIM, SPACE >::data(), axom::Array< T, DIM, SPACE >::getAllocatorID(), axom::detail::getAllocatorSpace(), axom::Array< T, DIM, SPACE >::initialize_from_other(), and axom::Array< T, DIM, SPACE >::size().
|
virtual |
Destructor. Frees the associated buffer.
Reimplemented in axom::sidre::Array< T, DIM >.
References axom::deallocate().
|
inline |
Copy assignment operator for Array.
References axom::Array< T, DIM, SPACE >::capacity(), axom::Array< T, DIM, SPACE >::clear(), axom::Array< T, DIM, SPACE >::data(), axom::Dynamic, axom::detail::getAllocatorSpace(), axom::isDeviceAllocator(), axom::Array< T, DIM, SPACE >::m_allocator_id, axom::Array< T, DIM, SPACE >::m_data, axom::Array< T, DIM, SPACE >::m_executeOnGPU, axom::Array< T, DIM, SPACE >::m_resize_ratio, axom::Array< T, DIM, SPACE >::setCapacity(), axom::Array< T, DIM, SPACE >::size(), and axom::Array< T, DIM, SPACE >::updateNumElements().
|
inlinenoexcept |
Move assignment operator for Array.
References axom::Array< T, DIM, SPACE >::clear(), axom::deallocate(), axom::Array< T, DIM, SPACE >::DEFAULT_RESIZE_RATIO, axom::INVALID_ALLOCATOR_ID, axom::isDeviceAllocator(), axom::Array< T, DIM, SPACE >::m_allocator_id, axom::Array< T, DIM, SPACE >::m_capacity, axom::Array< T, DIM, SPACE >::m_data, axom::Array< T, DIM, SPACE >::m_executeOnGPU, axom::Array< T, DIM, SPACE >::m_num_elements, and axom::Array< T, DIM, SPACE >::m_resize_ratio.
|
inline |
Initializer list assignment operator for Array.
[in] | elems | the elements to set the array to. |
References axom::Array< T, DIM, SPACE >::clear(), and axom::Array< T, DIM, SPACE >::insert().
|
inline |
Return a pointer to the array of data.
References axom::Array< T, DIM, SPACE >::m_data.
|
inline |
References axom::Array< T, DIM, SPACE >::m_data.
|
inline |
Convert 1D Array into a StackArray.
References axom::Array< T, DIM, SPACE >::m_data, and axom::Array< T, DIM, SPACE >::m_num_elements.
|
inline |
Set all the values of the array.
[in] | value | the value to set to. |
|
inline |
Set a range of elements to a given value.
[in] | value | the value to set to. |
[in] | n | the number of elements to write. |
[in] | pos | the position at which to begin writing. |
|
inline |
Modify the values of existing elements.
[in] | elements | the new elements to write. |
[in] | n | the number of elements to write. |
[in] | pos | the position at which to begin writing. |
References axom::Dynamic.
|
inline |
Clears the contents of the array.
|
inline |
Insert an element into the array at the given position.
[in] | pos | the position at which to insert. |
[in] | value | the element value to insert. |
ArrayIterator axom::Array< T, DIM, SPACE >::insert | ( | ArrayIterator | pos, |
const T & | value | ||
) |
Insert an element into the array at the value before pos.
[in] | pos | the ArrayIterator before which value will be inserted. |
[in] | value | the element value to insert. |
|
inline |
Insert elements into the array at the given position.
[in] | pos | the position at which to begin the insertion. |
[in] | n | the number of elements to insert. |
[in] | values | the element values to insert. |
References axom::Dynamic.
ArrayIterator axom::Array< T, DIM, SPACE >::insert | ( | ArrayIterator | pos, |
IndexType | n, | ||
const T * | values | ||
) |
Insert elements into the array at the value before pos.
[in] | pos | the ArrayIterator before which value will be inserted. |
[in] | n | the number of elements to insert. |
[in] | values | the element values to insert. |
|
inline |
Insert n copies of element into the array at the given position.
[in] | pos | the position at which to begin the insertion. |
[in] | n | the number of elements to insert. |
[in] | value | the element value to insert. |
ArrayIterator axom::Array< T, DIM, SPACE >::insert | ( | ArrayIterator | pos, |
IndexType | n, | ||
const T & | value | ||
) |
Insert n copies of element into the array at the value before pos.
[in] | pos | the ArrayIterator before which value will be inserted. |
[in] | n | the number of elements to insert. |
[in] | value | the element value to insert. |
|
inline |
Inserts an Array to the end of the calling object.
[in] | other | The Array to append |
References axom::ArrayView< T, DIM, SPACE >::data(), axom::ArrayBase< T, DIM, ArrayType >::shape(), and axom::ArrayView< T, DIM, SPACE >::size().
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
References axom::Array< T, DIM, SPACE >::insert().
|
inline |
Appends an Array to the end of the calling object.
[in] | other | The Array to append |
OtherArrayType | The underlying type of the other array |
References axom::Array< T, DIM, SPACE >::insert(), and axom::Array< T, DIM, SPACE >::size().
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
References axom::Array< T, DIM, SPACE >::insert(), and axom::Array< T, DIM, SPACE >::size().
ArrayIterator axom::Array< T, DIM, SPACE >::erase | ( | ArrayIterator | pos | ) |
ArrayIterator axom::Array< T, DIM, SPACE >::erase | ( | ArrayIterator | first, |
ArrayIterator | last | ||
) |
Erases elements in the range [first, last) from the Array.
[in] | first | the ArrayIterator to the beginning of the range. |
[in] | last | the ArrayIterator to end of range. |
|
inline |
Inserts new element into Array at the given position.
[in] | pos | the position to insert element at. |
[in] | args | the arguments to forward to constructor of the element. |
ArrayIterator axom::Array< T, DIM, SPACE >::emplace | ( | ArrayIterator | pos, |
Args &&... | args | ||
) |
Inserts new element into Array before pos.
[in] | pos | the ArrayIterator to insert element before. |
[in] | args | the arguments to forward to constructor of the element. |
|
inline |
Push a value to the back of the array.
[in] | value | the value to be added to the back. |
|
inline |
Push a value to the back of the array.
[in] | value | the value to move to the back. |
|
inline |
Inserts new element at the end of the Array.
[in] | args | the arguments to forward to constructor of the element. |
|
inline |
Push a value to the back of the array.
[in] | value | the value to move to the back. |
|
inline |
|
inline |
Inserts new element at the end of the Array.
[in] | args | the arguments to forward to constructor of the element. |
|
inline |
Return the number of elements allocated for the data array.
References axom::Array< T, DIM, SPACE >::m_capacity.
|
inline |
Increase the capacity. Does nothing if the new capacity is less than the current capacity.
[in] | capacity | the new number of elements to allocate. |
References axom::Array< T, DIM, SPACE >::capacity(), axom::Array< T, DIM, SPACE >::m_capacity, and axom::Array< T, DIM, SPACE >::setCapacity().
|
inline |
Returns an ArrayIterator to the first element of the Array.
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
inline |
Returns an ArrayIterator to the element following the last element of the Array.
References axom::Array< T, DIM, SPACE >::size().
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
References axom::Array< T, DIM, SPACE >::size().
|
inline |
Returns a reference to the first element in the Array.
References axom::Array< T, DIM, SPACE >::begin(), and axom::Array< T, DIM, SPACE >::empty().
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
References axom::Array< T, DIM, SPACE >::begin(), and axom::Array< T, DIM, SPACE >::empty().
|
inline |
Returns a reference to the last element in the Array.
References axom::Array< T, DIM, SPACE >::empty(), and axom::Array< T, DIM, SPACE >::end().
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
References axom::Array< T, DIM, SPACE >::empty(), and axom::Array< T, DIM, SPACE >::end().
|
inline |
Shrink the capacity to be equal to the size.
References axom::Array< T, DIM, SPACE >::m_num_elements, and axom::Array< T, DIM, SPACE >::setCapacity().
|
inline |
Returns true iff the Array stores no elements.
References axom::Array< T, DIM, SPACE >::m_num_elements.
|
inline |
Return the number of elements stored in the data array.
References axom::Array< T, DIM, SPACE >::m_num_elements.
|
inline |
Update the number of elements stored in the data array.
References axom::Array< T, DIM, SPACE >::resizeImpl().
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
References axom::Array< T, DIM, SPACE >::resizeImpl().
|
inline |
|
inline |
|
inline |
Exchanges the contents of this Array with the other.
References axom::Array< T, DIM, SPACE >::m_allocator_id, axom::Array< T, DIM, SPACE >::m_capacity, axom::Array< T, DIM, SPACE >::m_data, axom::Array< T, DIM, SPACE >::m_num_elements, axom::Array< T, DIM, SPACE >::m_resize_ratio, and axom::utilities::swap().
|
inline |
Get the ratio by which the capacity increases upon dynamic resize.
References axom::Array< T, DIM, SPACE >::m_resize_ratio.
|
inline |
Set the ratio by which the capacity increases upon dynamic resize.
[in] | ratio | the new resize ratio. |
References axom::Array< T, DIM, SPACE >::m_resize_ratio.
|
inline |
Get the ID for the umpire allocator.
References axom::Array< T, DIM, SPACE >::m_allocator_id.
|
inline |
Sets the preferred space where operations on this array should be performed.
This option only has an effect for memory which is both accessible on the CPU and the GPU. For CUDA this is the Unified and Pinned memory spaces, while for HIP this is the Unified, Pinned, and Device memory spaces.
References axom::Array< T, DIM, SPACE >::m_executeOnGPU.
|
inline |
Returns a view of the array.
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
inlineprotected |
Initialize an Array instance with the given number of elements.
[in] | num_elements | the number of elements the Array holds. |
[in] | capacity | the number of elements to allocate space for. |
[in] | should_default_construct | whether to create default-constructed objects in the region [0, num_elements). Defaults to true. |
References axom::isDeviceAllocator().
|
inlineprotected |
Helper function for initializing an Array instance with an existing range of elements.
[in] | data | pointer to the existing array of elements |
[in] | num_elements | the number of elements in the existing array |
[in] | data_space | the memory space in which data has been allocated |
[in] | user_provided_allocator | true if the Array's allocator ID was provided by the user |
References axom::Dynamic, axom::detail::getAllocatorSpace(), and axom::isDeviceAllocator().
|
inlineprotected |
Updates the number of elements stored in the data array.
[in] | dims | the number of elements to allocate in each dimension |
[in] | construct_with_values | if true, sets new elements in the array to a specified value |
[in] | value | pointer to the value to fill new elements in the array with. If null, will default-construct elements in place. |
References axom::detail::allNonNegative(), axom::StackArray< T, N >::m_data, and axom::detail::packProduct().
|
inlineprotected |
Make space for a subsequent insertion into the array.
[in] | n | the number of elements to insert. |
[in] | pos | the position at which to begin the insertion. |
|
inlineprotected |
Make space for a subsequent insertion into the array.
[in] | n | the number of elements to insert. |
References axom::slic::abort(), and AXOM_UNUSED_VAR.
|
inlineprotectedvirtual |
Update the number of elements.
[in] | new_num_elements | the new number of elements. |
Reimplemented in axom::sidre::Array< T, DIM >.
|
inlineprotectedvirtual |
Set the number of elements allocated for the data array.
[in] | capacity | the new number of elements to allocate. |
Reimplemented in axom::sidre::Array< T, DIM >, and axom::mint::ExternalArray< T, DIM >.
References axom::deallocate().
|
inlineprotectedvirtual |
Reallocates the data array when the size exceeds the capacity.
[in] | new_num_elements | the number of elements which exceeds the current capacity. |
Reimplemented in axom::sidre::Array< T, DIM >, and axom::mint::ExternalArray< T, DIM >.
References axom::utilities::processAbort().
|
inline |
References axom::utilities::annotations::begin(), and axom::utilities::annotations::end().
|
inlineinherited |
Dimension-aware accessor; with N=DIM indices, returns a reference to the given value at that index. Otherwise, returns a sub-array pointed to by the given sub-index.
[in] | args | the parameter pack of indices in each dimension. |
|
inlineinherited |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
inlineinherited |
Scalar accessor; returns a sub-array referenced by the given sub- index, beginning at array(idx, 0...)
[in] | idx | the index of the first dimension. |
|
inlineinherited |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
inlineinherited |
Dimension-aware accessor; with UDim=DIM indices, returns a reference to the given value at that index. Otherwise, returns a sub-array pointed to by the given sub-index.
[in] | args | a stack array of indices in each dimension. |
|
inlineinherited |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
inlineinherited |
Accessor, returns a reference to the given value. For multidimensional arrays, indexes into the (flat) raw data.
[in] | idx | the position of the value to return. |
|
inlineinherited |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
inlineinherited |
Swaps two ArrayBases.
|
inlineinherited |
Returns the dimensions of the Array.
|
inlineinherited |
Returns the multidimensional mapping for the Array.
|
inlineinherited |
Returns the memory strides of the Array.
|
inlineinherited |
Returns the minimum stride between adjacent items.
|
inlineprotectedinherited |
Set the shape.
|
inlineprotectedinherited |
Set the shape and stride.
|
inlineprotectedinherited |
Returns the minimum "chunk size" that should be allocated For example, 2 would be the chunk size of a 2D array whose second dimension is of size 2. This is used when resizing/reallocating; it wouldn't make sense to have a capacity of 3 in the array described above.
|
inlineprotectedinherited |
Updates the internal striding information to a row-major format Intended to be called after shape is updated.
|
inlineprotectedinherited |
Updates the internal dimensions and striding based on the insertion of a range of elements. Intended to be called after the insertion of a multidimensional subslice.
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
protected |
|
protected |
The full number of elements in the array i.e., 3 for a 1D Array of size 3, 9 for a 3x3 2D array, etc.
|
protected |
|
protected |
|
protected |
|
protected |
|
staticconstexprinherited |
|
protectedinherited |
The extent in each direction.
|
protectedinherited |
For converting between multidim indices and offset.
|
protectedinherited |
Cached value for optimization.
For some reason, computing min stride in minStride() slows down flatIndex() for CUDA and HIP, even though it doesn't seem tricky to optimize. As a work around, we cache the value in m_minStrides and update it when m_mapping changes. BTNG, March 2024.