Template Numerical Library version\ main:bb09b17
Loading...
Searching...
No Matches
TNL::Containers::DistributedArrayView< Value, Device, Index > Class Template Reference

Distributed array view. More...

#include <TNL/Containers/DistributedArrayView.h>

Collaboration diagram for TNL::Containers::DistributedArrayView< Value, Device, Index >:

Public Types

using ConstLocalViewType = Containers::ArrayView< std::add_const_t< Value >, Device, Index >
 
using ConstViewType = DistributedArrayView< std::add_const_t< Value >, Device, Index >
 
using DeviceType = Device
 
using IndexType = Index
 
using LocalRangeType = Subrange< Index >
 
using LocalViewType = Containers::ArrayView< Value, Device, Index >
 
template<typename _Value , typename _Device = Device, typename _Index = Index>
using Self = DistributedArrayView< _Value, _Device, _Index >
 A template which allows to quickly obtain a DistributedArrayView type with changed template parameters.
 
using SynchronizerType = ByteArraySynchronizer< DeviceType, IndexType >
 
using ValueType = Value
 
using ViewType = DistributedArrayView< Value, Device, Index >
 

Public Member Functions

 DistributedArrayView (const DistributedArrayView &)=default
 
template<typename Value_ >
 DistributedArrayView (const DistributedArrayView< Value_, Device, Index > &)
 
 DistributedArrayView (const LocalRangeType &localRange, IndexType ghosts, IndexType globalSize, MPI::Comm communicator, LocalViewType localData)
 
 DistributedArrayView (DistributedArrayView &&) noexcept=default
 
void bind (const LocalRangeType &localRange, IndexType ghosts, IndexType globalSize, const MPI::Comm &communicator, LocalViewType localData)
 
void bind (DistributedArrayView view)
 
template<typename Value_ >
void bind (Value_ *data, IndexType localSize)
 
void copyFromGlobal (ConstLocalViewType globalArray)
 
bool empty () const
 
template<typename Function >
void forElements (IndexType begin, IndexType end, Function &&f)
 Process the lambda function f for each array element in interval [ begin, end).
 
template<typename Function >
void forElements (IndexType begin, IndexType end, Function &&f) const
 Process the lambda function f for each array element in interval [ begin, end) for constant instances of the array.
 
const MPI::CommgetCommunicator () const
 
ConstLocalViewType getConstLocalView () const
 
ConstLocalViewType getConstLocalViewWithGhosts () const
 
ConstViewType getConstView () const
 Returns a non-modifiable view of the array view.
 
ValueType getElement (IndexType i) const
 
IndexType getGhosts () const
 
const LocalRangeTypegetLocalRange () const
 
LocalViewType getLocalView ()
 
LocalViewType getLocalViewWithGhosts ()
 
IndexType getSize () const
 
std::shared_ptr< SynchronizerTypegetSynchronizer () const
 
int getValuesPerElement () const
 
ViewType getView ()
 Returns a modifiable view of the array view.
 
void loadFromGlobalFile (const String &fileName, bool allowCasting=false)
 
void loadFromGlobalFile (File &file, bool allowCasting=false)
 
template<typename Array >
bool operator!= (const Array &array) const
 
template<typename Array , typename... , typename = std::enable_if_t< HasSubscriptOperator< Array >::value >>
DistributedArrayViewoperator= (const Array &array)
 
template<typename Array , typename... , typename >
DistributedArrayView< Value, Device, Index > & operator= (const Array &array)
 
DistributedArrayViewoperator= (const DistributedArrayView &view)
 
DistributedArrayViewoperator= (DistributedArrayView &&) noexcept=default
 
template<typename Array >
bool operator== (const Array &array) const
 
__cuda_callable__ ValueType & operator[] (IndexType i)
 
__cuda_callable__ const ValueType & operator[] (IndexType i) const
 
void reset ()
 
void setElement (IndexType i, ValueType value)
 
void setSynchronizer (std::shared_ptr< SynchronizerType > synchronizer, int valuesPerElement=1)
 
void setValue (ValueType value)
 
void startSynchronization ()
 
void waitForSynchronization () const
 

Protected Attributes

MPI::Comm communicator = MPI_COMM_NULL
 
IndexType ghosts = 0
 
IndexType globalSize = 0
 
LocalViewType localData
 
LocalRangeType localRange
 
std::shared_ptr< SynchronizerTypesynchronizer = nullptr
 
int valuesPerElement = 1
 

Detailed Description

template<typename Value, typename Device = Devices::Host, typename Index = int>
class TNL::Containers::DistributedArrayView< Value, Device, Index >

Distributed array view.

Member Function Documentation

◆ forElements() [1/2]

template<typename Value , typename Device , typename Index >
template<typename Function >
void TNL::Containers::DistributedArrayView< Value, Device, Index >::forElements ( IndexType begin,
IndexType end,
Function && f )

Process the lambda function f for each array element in interval [ begin, end).

The lambda function is supposed to be declared as

f( IndexType elementIdx, ValueType& elementValue )

where

  • elementIdx is an index of the array element being currently processed
  • elementValue is a value of the array element being currently processed

This is performed at the same place where the array is allocated, i.e. it is efficient even on GPU.

Parameters
beginThe beginning of the array elements interval.
endThe end of the array elements interval.
fThe lambda function to be processed.

◆ forElements() [2/2]

template<typename Value , typename Device , typename Index >
template<typename Function >
void TNL::Containers::DistributedArrayView< Value, Device, Index >::forElements ( IndexType begin,
IndexType end,
Function && f ) const

Process the lambda function f for each array element in interval [ begin, end) for constant instances of the array.

The lambda function is supposed to be declared as

f( IndexType elementIdx, const ValueType& elementValue )

where

  • elementIdx is an index of the array element being currently processed
  • elementValue is a value of the array element being currently processed

This is performed at the same place where the array is allocated, i.e. it is efficient even on GPU.

Parameters
beginThe beginning of the array elements interval.
endThe end of the array elements interval.
fThe lambda function to be processed.

The documentation for this class was generated from the following files: