Template Numerical Library version\ main:4e58ea6
|
Distributed array. More...
#include <TNL/Containers/DistributedArray.h>
Public Types | |
using | AllocatorType = Allocator |
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, typename _Allocator = typename Allocators::Default< _Device >::template Allocator< _Value >> | |
using | Self = DistributedArray< _Value, _Device, _Index, _Allocator > |
A template which allows to quickly obtain a DistributedArray type with changed template parameters. | |
using | SynchronizerType = typename ViewType::SynchronizerType |
using | ValueType = Value |
using | ViewType = DistributedArrayView< Value, Device, Index > |
Public Member Functions | |
DistributedArray ()=default | |
Constructs an empty array with zero size. | |
DistributedArray (const AllocatorType &allocator) | |
Constructs an empty array and sets the provided allocator. | |
DistributedArray (const DistributedArray &array) | |
Copy constructor (makes a deep copy). | |
DistributedArray (const DistributedArray &array, const AllocatorType &allocator) | |
Copy constructor with a specific allocator (makes a deep copy). | |
DistributedArray (DistributedArray &&) noexcept=default | |
DistributedArray (LocalRangeType localRange, Index ghosts, Index globalSize, const MPI::Comm &communicator, const AllocatorType &allocator=AllocatorType()) | |
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. | |
AllocatorType | getAllocator () const |
Returns the allocator associated to the array. | |
const MPI::Comm & | getCommunicator () const |
Returns the MPI communicator associated to the array. | |
ConstLocalViewType | getConstLocalView () const |
Returns a non-modifiable view of the local part of the array. | |
ConstLocalViewType | getConstLocalViewWithGhosts () const |
Returns a non-modifiable view of the local part of the array, including ghost values. | |
ConstViewType | getConstView () const |
Returns a non-modifiable view of the array. | |
ValueType | getElement (IndexType i) const |
IndexType | getGhosts () const |
const LocalRangeType & | getLocalRange () const |
Returns the local range of the distributed array. | |
LocalViewType | getLocalView () |
Returns a modifiable view of the local part of the array. | |
LocalViewType | getLocalViewWithGhosts () |
Returns a modifiable view of the local part of the array, including ghost values. | |
IndexType | getSize () const |
std::shared_ptr< SynchronizerType > | getSynchronizer () const |
int | getValuesPerElement () const |
ViewType | getView () |
Returns a modifiable view of the array. | |
void | loadFromGlobalFile (const String &fileName, bool allowCasting=false) |
void | loadFromGlobalFile (File &file, bool allowCasting=false) |
operator ConstViewType () const | |
Conversion operator to a non-modifiable view of the array. | |
operator ViewType () | |
Conversion operator to a modifiable view of the array. | |
template<typename Array > | |
bool | operator!= (const Array &array) const |
template<typename Array , typename... , typename = std::enable_if_t< HasSubscriptOperator< Array >::value >> | |
DistributedArray & | operator= (const Array &array) |
template<typename Array , typename... , typename > | |
DistributedArray< Value, Device, Index, Allocator > & | operator= (const Array &array) |
DistributedArray & | operator= (const DistributedArray &array) |
DistributedArray & | operator= (DistributedArray &&) noexcept(false)=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 | setDistribution (LocalRangeType localRange, Index ghosts, Index globalSize, const MPI::Comm &communicator) |
Set new global size and distribution of the array. | |
void | setElement (IndexType i, ValueType value) |
template<typename Array > | |
void | setLike (const Array &array) |
void | setSynchronizer (std::shared_ptr< SynchronizerType > synchronizer, int valuesPerElement=1) |
void | setValue (ValueType value) |
void | startSynchronization () |
void | waitForSynchronization () const |
Protected Attributes | |
LocalArrayType | localData |
ViewType | view |
Distributed array.
|
explicit |
Constructs an empty array and sets the provided allocator.
allocator | The allocator to be associated with this array. |
|
explicit |
Copy constructor (makes a deep copy).
array | The array to be copied. |
|
explicit |
Copy constructor with a specific allocator (makes a deep copy).
array | The array to be copied. |
allocator | The allocator to be associated with this array. |
void TNL::Containers::DistributedArray< Value, Device, Index, Allocator >::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
where
This is performed at the same place where the array is allocated, i.e. it is efficient even on GPU.
begin | The beginning of the array elements interval. |
end | The end of the array elements interval. |
f | The lambda function to be processed. |
void TNL::Containers::DistributedArray< Value, Device, Index, Allocator >::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
where
This is performed at the same place where the array is allocated, i.e. it is efficient even on GPU.
begin | The beginning of the array elements interval. |
end | The end of the array elements interval. |
f | The lambda function to be processed. |
void TNL::Containers::DistributedArray< Value, Device, Index, Allocator >::setDistribution | ( | LocalRangeType | localRange, |
Index | ghosts, | ||
Index | globalSize, | ||
const MPI::Comm & | communicator ) |
Set new global size and distribution of the array.
localRange | The range of elements in the global array that is owned by this rank. |
ghosts | Number of ghost elements allocated by this rank. |
globalSize | The size of the global array. |
communicator | Reference to the MPI communicator on which the array is distributed. |