Template Numerical Library version\ main:be918e6f
|
Simple data structure which provides a non-owning encapsulation of N-dimensional array data. More...
#include <TNL/Containers/NDArrayView.h>
Public Types | |
using | ConstViewType = NDArrayView< std::add_const_t< ValueType >, DeviceType, IndexerType > |
Compatible constant NDArrayView type. | |
using | DeviceType = Device |
Type of the device used for running operations on the array. | |
using | IndexerType = Indexer |
Type of the N-dimensional indexer, NDArrayIndexer. | |
using | IndexType = typename Indexer::IndexType |
Type of indices used for addressing the array elements. | |
using | OverlapsType = typename Indexer::OverlapsType |
Sequence of integers representing the overlaps in each dimension of a distributed N-dimensional array. | |
using | PermutationType = typename Indexer::PermutationType |
Permutation that is applied to indices when accessing the array elements. | |
using | SizesHolderType = typename Indexer::SizesHolderType |
Type of the underlying object which represents the sizes of the N-dimensional array. | |
using | StridesHolderType = typename Indexer::StridesHolderType |
Type of the base class which represents the strides of the N-dimensional array. | |
using | ValueType = Value |
Type of the values stored in the array. | |
using | ViewType = NDArrayView< ValueType, DeviceType, IndexerType > |
Compatible NDArrayView type. | |
Public Member Functions | |
__cuda_callable__ | NDArrayView ()=default |
Constructs an array view with zero size. | |
__cuda_callable__ | NDArrayView (const NDArrayView &)=default |
A shallow-copy copy-constructor. | |
__cuda_callable__ | NDArrayView (NDArrayView &&) noexcept=default |
Move constructor for initialization from rvalues. | |
__cuda_callable__ | NDArrayView (Value *data, IndexerType indexer) |
Constructs an array view initialized by a raw data pointer and an indexer. | |
__cuda_callable__ | NDArrayView (Value *data, SizesHolderType sizes, StridesHolderType strides=StridesHolderType{}, OverlapsType overlaps=OverlapsType{}) |
Constructs an array view initialized by a raw data pointer, sizes, strides and overlaps. | |
__cuda_callable__ void | bind (NDArrayView view) |
Re-binds (re-initializes) the array view to a different view. | |
__cuda_callable__ void | bind (Value *data) |
Re-binds (re-initializes) the array view to the given raw pointer and preserves the current indexer. | |
__cuda_callable__ void | bind (Value *data, IndexerType indexer) |
Re-binds (re-initializes) the array view to the given raw pointer and changes the indexer. | |
template<typename Device2 = DeviceType, typename Func> | |
void | forAll (Func f, const typename Device2::LaunchConfiguration &launch_configuration=typename Device2::LaunchConfiguration{}) const |
Evaluates the function f in parallel for all elements of the array view. | |
template<typename Device2 = DeviceType, typename SkipBegins, typename SkipEnds, typename Func> | |
void | forBoundary (const SkipBegins &skipBegins, const SkipEnds &skipEnds, Func f, const typename Device2::LaunchConfiguration &launch_configuration=typename Device2::LaunchConfiguration{}) const |
Evaluates the function f in parallel for all elements of the array view outside the N-dimensional interval [skipBegins, skipEnds) . | |
template<typename Device2 = DeviceType, typename Func> | |
void | forBoundary (Func f, const typename Device2::LaunchConfiguration &launch_configuration=typename Device2::LaunchConfiguration{}) const |
Evaluates the function f in parallel for all boundary elements of the array view. | |
template<typename Device2 = DeviceType, typename Begins, typename Ends, typename Func> | |
void | forInterior (const Begins &begins, const Ends &ends, Func f, const typename Device2::LaunchConfiguration &launch_configuration=typename Device2::LaunchConfiguration{}) const |
Evaluates the function f in parallel for all elements of the array view inside the N-dimensional interval [begins, ends) . | |
template<typename Device2 = DeviceType, typename Func> | |
void | forInterior (Func f, const typename Device2::LaunchConfiguration &launch_configuration=typename Device2::LaunchConfiguration{}) const |
Evaluates the function f in parallel for all internal elements of the array view. | |
__cuda_callable__ ConstViewType | getConstView () const |
Returns a non-modifiable view of the array. | |
__cuda_callable__ ValueType * | getData () |
Returns a raw pointer to the data. | |
__cuda_callable__ std::add_const_t< ValueType > * | getData () const |
Returns a const-qualified raw pointer to the data. | |
__cuda_callable__ const IndexerType & | getIndexer () const |
Returns a const-qualified reference to the underlying indexer. | |
template<std::size_t... Dimensions, typename... IndexTypes> | |
__cuda_callable__ auto | getSubarrayView (IndexTypes &&... indices) |
Returns a modifiable view of a subarray. | |
__cuda_callable__ ViewType | getView () |
Returns a modifiable view of the array. | |
TNL_NVCC_HD_WARNING_DISABLE __cuda_callable__ bool | operator!= (const NDArrayView &other) const |
Compares the array view with another N-dimensional array view. | |
template<typename... IndexTypes> | |
__cuda_callable__ ValueType & | operator() (IndexTypes &&... indices) |
Accesses an element of the array. | |
template<typename... IndexTypes> | |
__cuda_callable__ const ValueType & | operator() (IndexTypes &&... indices) const |
Accesses an element of the array. | |
TNL_NVCC_HD_WARNING_DISABLE __cuda_callable__ NDArrayView & | operator= (const NDArrayView &other) |
Copy-assignment operator for deep-copying data from another array. | |
template<typename OtherView> | |
TNL_NVCC_HD_WARNING_DISABLE __cuda_callable__ NDArrayView & | operator= (const OtherView &other) |
Templated copy-assignment operator for deep-copying data from another array. | |
TNL_NVCC_HD_WARNING_DISABLE __cuda_callable__ bool | operator== (const NDArrayView &other) const |
Compares the array view with another N-dimensional array view. | |
__cuda_callable__ ValueType & | operator[] (IndexType &&index) |
Accesses an element in a one-dimensional array. | |
__cuda_callable__ const ValueType & | operator[] (IndexType index) const |
Accesses an element in a one-dimensional array. | |
__cuda_callable__ void | reset () |
Resets the array view to the empty state. | |
Protected Attributes | |
Value * | array = nullptr |
Pointer to the first element of the bound N-dimensional array. | |
IndexerType | indexer |
Object which transforms the multi-dimensional indices to a one-dimensional index. | |
Simple data structure which provides a non-owning encapsulation of N-dimensional array data.
Value | Type of the values stored in the array. |
Device | Type of the device that will be used for running operations on the array. |
Type | of the N-dimensional indexer, NDArrayIndexer. |
|
default |
A shallow-copy copy-constructor.
This allows views to be passed-by-value into CUDA kernels and be captured-by-value in cuda_callable lambda functions.
|
inline |
Evaluates the function f
in parallel for all elements of the array view.
The function f
is called as f(indices...)
, where indices...
are substituted by the actual indices of all array elements. For example, given a 3D array view a
with int
as IndexType, the function can be defined and used as follows:
|
inline |
Evaluates the function f
in parallel for all elements of the array view outside the N-dimensional interval [skipBegins, skipEnds)
.
The function f
is called as f(indices...)
, where indices...
are substituted by the actual indices of all array view elements.
|
inline |
Evaluates the function f
in parallel for all boundary elements of the array view.
The function f
is called as f(indices...)
, where indices...
are substituted by the actual indices of all array view elements. For example, given a 3D array view a
with int
as IndexType, the function can be defined and used as follows:
|
inline |
Evaluates the function f
in parallel for all elements of the array view inside the N-dimensional interval [begins, ends)
.
The function f
is called as f(indices...)
, where indices...
are substituted by the actual indices of all array view elements.
|
inline |
Evaluates the function f
in parallel for all internal elements of the array view.
The function f
is called as f(indices...)
, where indices...
are substituted by the actual indices of all array elements. For example, given a 3D array view a
with int
as IndexType, the function can be defined and used as follows:
|
inlinenodiscard |
Returns a modifiable view of a subarray.
Dimensions | Sequence of integers representing the dimensions of the array which selects the subset of dimensions to appear in the subarray. |
indices | Indices of the origin of the subarray in the whole array. The number of indices supplied must be equal to N, i.e. getDimension(). |
|
inlinenodiscard |
Accesses an element of the array.
indices | Indices of the element in the N-dimensional array. The number of indices supplied must be equal to N, i.e. getDimension(). |
|
inlinenodiscard |
Accesses an element of the array.
indices | Indices of the element in the N-dimensional array. The number of indices supplied must be equal to N, i.e. getDimension(). |
|
inline |
Copy-assignment operator for deep-copying data from another array.
This is just like the operator on a regular array, but the sizes must match (i.e. copy-assignment cannot resize).
Note that there is no move-assignment operator, so expressions like a = b.getView()
are resolved as copy-assignment.
|
inlinenodiscard |
Accesses an element in a one-dimensional array.
index | Index of the element in the one-dimensional array. |
|
inlinenodiscard |
Accesses an element in a one-dimensional array.
index | Index of the element in the one-dimensional array. |