Template Numerical Library version\ main:bb09b17
|
Distributed N-dimensional array view. More...
#include <TNL/Containers/DistributedNDArrayView.h>
Public Types | |
using | ConstLocalViewType = typename NDArrayView::ConstViewType |
Compatible constant NDArrayView of the local array. | |
using | ConstViewType = DistributedNDArrayView< typename NDArrayView::ConstViewType > |
Compatible constant DistributedNDArrayView type. | |
using | DeviceType = typename NDArrayView::DeviceType |
Type of the device used for running operations on the array. | |
using | IndexType = typename NDArrayView::IndexType |
Type of indices used for addressing the array elements. | |
using | LocalBeginsType = LocalBeginsHolder< typename NDArrayView::SizesHolderType > |
Type which represents the position of the first local element in the global N-dimensional array. It has all static sizes set to 0. | |
using | LocalRangeType = Subrange< IndexType > |
Type which represents an integer range [a, b) . | |
using | LocalViewType = NDArrayView |
Compatible NDArrayView of the local array. | |
using | OverlapsType = typename NDArrayView::OverlapsType |
Sequence of integers representing the overlaps in each dimension of a distributed N-dimensional array. | |
using | PermutationType = typename NDArrayView::PermutationType |
Permutation that is applied to indices when accessing the array elements. | |
using | SizesHolderType = typename NDArrayView::SizesHolderType |
Type of the underlying object which represents the sizes of the N-dimensional array. | |
using | ValueType = typename NDArrayView::ValueType |
Type of the values stored in the array. | |
using | ViewType = DistributedNDArrayView< NDArrayView > |
Compatible DistributedNDArrayView type. | |
Public Member Functions | |
DistributedNDArrayView ()=default | |
Constructs an empty array view with zero size. | |
DistributedNDArrayView (const DistributedNDArrayView &)=default | |
A shallow-copy copy-constructor. | |
DistributedNDArrayView (DistributedNDArrayView &&) noexcept=default | |
Move constructor for initialization from rvalues. | |
DistributedNDArrayView (NDArrayView localView, SizesHolderType globalSizes, LocalBeginsType localBegins, SizesHolderType localEnds, MPI::Comm communicator) | |
Constructs an array view initialized by local array view, global sizes, local begins and ends, and MPI communicator. | |
void | bind (DistributedNDArrayView view) |
Re-binds (re-initializes) the array view to a different view. | |
void | bind (ValueType *data) |
Re-binds (re-initializes) the array view to the given raw pointer and preserves the current indexer. | |
void | bind (ValueType *data, typename LocalViewType::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. | |
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 outside the given [skipBegins, skipEnds) range specified by global indices. | |
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. | |
template<typename Device2 = DeviceType, typename Func > | |
void | forGhosts (Func f, const typename Device2::LaunchConfiguration &launch_configuration=typename Device2::LaunchConfiguration{}) const |
Evaluates the function f in parallel for all elements in the ghost region. | |
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 inside the given [begins, ends) range specified by global indices. | |
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. | |
template<typename Device2 = DeviceType, typename Func > | |
void | forLocalBoundary (Func f, const typename Device2::LaunchConfiguration &launch_configuration=typename Device2::LaunchConfiguration{}) const |
Evaluates the function f in parallel for all local-boundary elements of the array. | |
template<typename Device2 = DeviceType, typename Func > | |
void | forLocalInterior (Func f, const typename Device2::LaunchConfiguration &launch_configuration=typename Device2::LaunchConfiguration{}) const |
Evaluates the function f in parallel for all local-internal elements of the array. | |
const MPI::Comm & | getCommunicator () const |
Returns the MPI communicator associated with the array. | |
ConstLocalViewType | getConstLocalView () const |
Returns a non-modifiable view of the local array. | |
ConstViewType | getConstView () const |
Returns a non-modifiable view of the array. | |
ValueType * | getData () |
Returns a raw pointer to the local data. | |
std::add_const_t< ValueType > * | getData () const |
Returns a const-qualified raw pointer to the local data. | |
LocalBeginsType | getLocalBegins () const |
Returns the beginning position of the local array in the global N-dimensional array. | |
SizesHolderType | getLocalEnds () const |
Returns the ending position of the local array in the global N-dimensional array. | |
template<std::size_t level> | |
LocalRangeType | getLocalRange () const |
Returns a specific [begin, end) subrange of the local array in the global N-dimensional array. | |
IndexType | getLocalStorageSize () const |
Returns the size (number of elements) needed to store the local N-dimensional array. | |
LocalViewType | getLocalView () |
Returns a modifiable view of the local array. | |
template<std::size_t level> | |
__cuda_callable__ IndexType | getOverlap () const |
Returns the overlap of a distributed N-dimensional array along the specified axis. | |
__cuda_callable__ OverlapsType & | getOverlaps () |
Returns the N-dimensional overlaps holder instance. | |
__cuda_callable__ const OverlapsType & | getOverlaps () const |
Returns the N-dimensional overlaps holder instance. | |
template<std::size_t level> | |
IndexType | getSize () const |
Returns a specific component of the N-dimensional global sizes. | |
const SizesHolderType & | getSizes () const |
Returns the N-dimensional sizes of the global array. | |
template<typename... IndexTypes> | |
IndexType | getStorageIndex (IndexTypes &&... indices) const |
Returns the local storage index for given global indices. | |
ViewType | getView () |
Returns a modifiable view of the array. | |
bool | operator!= (const DistributedNDArrayView &other) const |
Compares the array with another distributed N-dimensional array. | |
template<typename... IndexTypes> | |
ValueType & | operator() (IndexTypes &&... indices) |
Accesses an element of the array. | |
template<typename... IndexTypes> | |
const ValueType & | operator() (IndexTypes &&... indices) const |
Accesses an element of the array. | |
DistributedNDArrayView & | operator= (const DistributedNDArrayView &other)=default |
Copy-assignment operator for deep-copying data from another array. | |
template<typename OtherArray > | |
DistributedNDArrayView & | operator= (const OtherArray &other) |
Templated copy-assignment operator for deep-copying data from another array. | |
bool | operator== (const DistributedNDArrayView &other) const |
Compares the array with another distributed N-dimensional array. | |
ValueType & | operator[] (IndexType index) |
Accesses an element in a one-dimensional array. | |
const ValueType & | operator[] (IndexType index) const |
Accesses an element in a one-dimensional array. | |
void | reset () |
Resets the array view to the empty state. | |
Static Public Member Functions | |
static constexpr std::size_t | getDimension () |
Returns the dimension of the N-dimensional array, i.e. N. | |
Protected Attributes | |
MPI::Comm | communicator = MPI_COMM_NULL |
MPI communicator associated with the array. | |
SizesHolderType | globalSizes |
Global sizes of the whole distributed N-dimensional array. | |
LocalBeginsType | localBegins |
Global indices of the first local element in the whole N-dimensional array. | |
SizesHolderType | localEnds |
Global indices of the end-of-range element, [localBegins, localEnds) . | |
NDArrayView | localView |
View of the N-dimensional array containing the local elements and overlaps. | |
Distributed N-dimensional array view.
NDArrayView | Type of the N-dimensional array view which is used to access the local elements. It must be an instance of the NDArrayView template. |
|
inline |
Evaluates the function f
in parallel for all elements of the array.
Each MPI rank iterates over all of its local elements.
See NDArrayView::forAll for the requirements on the function f
.
|
inline |
Evaluates the function f
in parallel for all elements outside the given [skipBegins, skipEnds)
range specified by global indices.
Each MPI rank iterates over its local elements outside the range.
See NDArrayView::forAll for the requirements on the function f
.
|
inline |
Evaluates the function f
in parallel for all boundary elements of the array.
Each MPI rank iterates over its local elements which are neighbours of global boundaries.
See NDArrayView::forAll for the requirements on the function f
.
|
inline |
Evaluates the function f
in parallel for all elements in the ghost region.
Each MPI rank iterates over elements which are in the overlapping region (i.e., owned by a different MPI rank). If all overlaps are 0, it has no effect.
See NDArrayView::forAll for the requirements on the function f
.
|
inline |
Evaluates the function f
in parallel for all elements inside the given [begins, ends)
range specified by global indices.
Each MPI rank iterates over its local elements from the range.
See NDArrayView::forAll for the requirements on the function f
.
|
inline |
Evaluates the function f
in parallel for all internal elements of the array.
Each MPI rank iterates over its local elements which are not neighbours of global boundaries.
See NDArrayView::forAll for the requirements on the function f
.
|
inline |
Evaluates the function f
in parallel for all local-boundary elements of the array.
Each MPI rank iterates over its local elements which are neighbours of overlaps. If all overlaps are 0, it has no effect.
See NDArrayView::forAll for the requirements on the function f
.
|
inline |
Evaluates the function f
in parallel for all local-internal elements of the array.
Each MPI rank iterates over its local elements which are not neighbours of overlaps. If all overlaps are 0, it is equivalent to forAll.
See NDArrayView::forAll for the requirements on the function f
.
|
inlinenodiscard |
Returns a specific [begin, end)
subrange of the local array in the global N-dimensional array.
level | Integer specifying the component of the sizes to be returned. |
|
inlinenodiscard |
Returns the overlap of a distributed N-dimensional array along the specified axis.
level | Integer specifying the axis of the array. |
|
inlinenodiscard |
Returns a specific component of the N-dimensional global sizes.
level | Integer specifying the component of the sizes to be returned. |
|
inlinenodiscard |
Returns the local storage index for given global indices.
indices | Global 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.
Only local elements or elements in the overlapping region can be accessed.
indices | Global 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.
Only local elements or elements in the overlapping region can be accessed.
indices | Global indices of the element in the N-dimensional array. The number of indices supplied must be equal to N, i.e. getDimension(). |
|
default |
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.
Only local elements or elements in the overlapping region can be accessed.
index | Global index of the element in the one-dimensional array. |
|
inlinenodiscard |
Accesses an element in a one-dimensional array.
Only local elements or elements in the overlapping region can be accessed.
index | Global index of the element in the one-dimensional array. |
|
protected |
Global indices of the first local element in the whole N-dimensional array.
Note that localBegins
and localEnds have different static sizes (and hence different C++ type): localBegins
is always 0, localEnds
has always the full static size.