Ginkgo  Generated from pipelines/3035309441 branch based on develop. Ginkgo version 2.0.0
A numerical linear algebra library targeting many-core architectures
Public Member Functions | Static Public Member Functions | Friends | List of all members
gko::experimental::distributed::RowScatterer< LocalIndexType > Class Template Reference

The distributed::RowScatterer scatters local values to their owning processes and accumulates received contributions into a local target. More...

#include <ginkgo/core/distributed/row_scatterer.hpp>

Inheritance diagram for gko::experimental::distributed::RowScatterer< LocalIndexType >:
[legend]
Collaboration diagram for gko::experimental::distributed::RowScatterer< LocalIndexType >:
[legend]

Public Member Functions

void apply_async (ptr_param< const LinOp > local_values) const
 Start scattering local values to their owning ranks. More...
 
void wait_and_accumulate (ptr_param< LinOp > distributed_target) const
 Wait for the scatter communication to complete and accumulate received values into the target: target += received_contributions. More...
 
dim< 2 > get_size () const
 Returns the size of the row scatterer.
 
std::shared_ptr< const mpi::CollectiveCommunicator > get_collective_communicator () const
 Get the used collective communicator.
 
const LocalIndexType * get_const_recv_idxs () const
 Read access to the (local) row indices into which the received values are accumulated.
 
size_type get_num_recv_idxs () const
 Returns the number of (local) row indices.
 
 RowScatterer (const RowScatterer &o)
 
 RowScatterer (RowScatterer &&o)
 
RowScatterer & operator= (const RowScatterer &o)
 
RowScatterer & operator= (RowScatterer &&o)
 
- Public Member Functions inherited from gko::PolymorphicObject
virtual void validate_data () const
 Throws gko::InvalidData exception if we found the data inside the object does not fulfill certain property up to our knowledge.
 
PolymorphicObject & operator= (const PolymorphicObject &)
 
std::shared_ptr< const Executor > get_executor () const noexcept
 Returns the Executor of the object. More...
 
- Public Member Functions inherited from gko::log::EnableLogging< PolymorphicObject >
void add_logger (std::shared_ptr< const Logger > logger) override
 
void remove_logger (const Logger *logger) override
 
void remove_logger (ptr_param< const Logger > logger)
 
const std::vector< std::shared_ptr< const Logger > > & get_loggers () const override
 
void clear_loggers () override
 
- Public Member Functions inherited from gko::log::Loggable
void remove_logger (ptr_param< const Logger > logger)
 
- Public Member Functions inherited from gko::EnableCloneable< RowScatterer< LocalIndexType > >
std::unique_ptr< RowScatterer< LocalIndexType > > clone (std::shared_ptr< const Executor > exec) const
 Creates a clone of the object. More...
 
std::unique_ptr< RowScatterer< LocalIndexType > > clone () const
 Creates a clone of the object. More...
 
void convert_to (result_type *result) const override
 Converts the implementer to an object of type result_type. More...
 
void move_to (result_type *result) override
 Converts the implementer to an object of type result_type by moving data from this object. More...
 
std::unique_ptr< RowScatterer< LocalIndexType > > create_default () const
 
std::unique_ptr< RowScatterer< LocalIndexType > > create_default (std::shared_ptr< const Executor > exec) const
 
- Public Member Functions inherited from gko::ConvertibleTo< ResultType >
void convert_to (ptr_param< result_type > result) const
 
void move_to (ptr_param< result_type > result)
 
- Public Member Functions inherited from gko::Cloneable
std::unique_ptr< Cloneable > clone (std::shared_ptr< const Executor > exec) const
 
std::unique_ptr< Cloneable > clone () const
 
Cloneable * copy_from (ptr_param< const Cloneable > other)
 
Cloneable * move_from (ptr_param< Cloneable > other)
 
std::unique_ptr< Cloneable > create_default (std::shared_ptr< const Executor > exec) const
 
std::unique_ptr< Cloneable > create_default () const
 
- Public Member Functions inherited from gko::experimental::distributed::DistributedBase
 DistributedBase (const DistributedBase &other)=default
 
 DistributedBase (DistributedBase &&other)=default
 
DistributedBase & operator= (const DistributedBase &)
 Copy assignment that doesn't change the used mpi::communicator. More...
 
DistributedBase & operator= (DistributedBase &&) noexcept
 Move assignment that doesn't change the used mpi::communicator. More...
 
mpi::communicator get_communicator () const
 Access the used mpi::communicator. More...
 

Static Public Member Functions

template<typename GlobalIndexType = int64, typename = std::enable_if_t<sizeof(GlobalIndexType) >= sizeof(LocalIndexType)>
static std::unique_ptr< RowScatterer > create (std::shared_ptr< const Executor > exec, std::shared_ptr< const mpi::CollectiveCommunicator > coll_comm, const index_map< LocalIndexType, GlobalIndexType > &imap)
 Creates a distributed::RowScatterer from a given collective communicator and index map. More...
 
static std::unique_ptr< RowScatterer > create_from_gatherer (std::shared_ptr< const Executor > exec, ptr_param< const RowGatherer< LocalIndexType >> gatherer)
 Creates a distributed::RowScatterer from an existing RowGatherer. More...
 
static std::unique_ptr< RowScatterer > create (std::shared_ptr< const Executor > exec, mpi::communicator comm)
 Create method for an empty RowScatterer.
 

Friends

class EnableCloneable< RowScatterer >
 

Additional Inherited Members

- Public Types inherited from gko::EnableCloneable< RowScatterer< LocalIndexType > >
using result_type = RowScatterer< LocalIndexType >
 
- Public Types inherited from gko::ConvertibleTo< ResultType >
using result_type = ResultType
 

Detailed Description

template<typename LocalIndexType = int32>
class gko::experimental::distributed::RowScatterer< LocalIndexType >

The distributed::RowScatterer scatters local values to their owning processes and accumulates received contributions into a local target.

This is the transpose of the RowGatherer operation:

The operation is split into two phases to allow overlapping computation with communication:

  1. apply_async packs the send buffer and initiates the MPI communication.
  2. wait_and_accumulate waits for the communication to complete, then accumulates the received values into the target vector.

The scatterer keeps track of the in-flight communication, so only one scatter can be active at any given time.

Example usage:

{c++}
rs->apply_async(local_vals);
// ... overlap other work while communication is in flight ...
rs->wait_and_accumulate(target);
// target now has accumulated the scattered values
Template Parameters
LocalIndexTypethe index type for the stored indices

Member Function Documentation

◆ apply_async()

template<typename LocalIndexType = int32>
void gko::experimental::distributed::RowScatterer< LocalIndexType >::apply_async ( ptr_param< const LinOp >  local_values) const

Start scattering local values to their owning ranks.

Packs the local values into a send buffer and initiates the MPI communication. The scatter is finished by calling wait_and_accumulate.

Parameters
local_valuesthe local values to scatter (distributed::Vector). Its local vector must have as many rows as this process sends. It might not be modified before wait_and_accumulate is called.
Exceptions
InvalidStateErrorif a previous scatter has not been finished by wait_and_accumulate.

◆ create()

template<typename LocalIndexType = int32>
template<typename GlobalIndexType = int64, typename = std::enable_if_t<sizeof(GlobalIndexType) >= sizeof(LocalIndexType)>
static std::unique_ptr<RowScatterer> gko::experimental::distributed::RowScatterer< LocalIndexType >::create ( std::shared_ptr< const Executor >  exec,
std::shared_ptr< const mpi::CollectiveCommunicator >  coll_comm,
const index_map< LocalIndexType, GlobalIndexType > &  imap 
)
inlinestatic

Creates a distributed::RowScatterer from a given collective communicator and index map.

Template Parameters
GlobalIndexTypethe global index type of the index map
Parameters
execthe executor
coll_commthe collective communicator in the gather direction, i.e. the one that would be used to create the corresponding RowGatherer. It receives the non-local rows of imap. The scatterer uses its inverse.
imapthe index map defining the scatter pattern
Returns
a unique_ptr to the created distributed::RowScatterer

◆ create_from_gatherer()

template<typename LocalIndexType = int32>
static std::unique_ptr<RowScatterer> gko::experimental::distributed::RowScatterer< LocalIndexType >::create_from_gatherer ( std::shared_ptr< const Executor >  exec,
ptr_param< const RowGatherer< LocalIndexType >>  gatherer 
)
static

Creates a distributed::RowScatterer from an existing RowGatherer.

The scatterer is the transpose of the gatherer: it inverts the communication pattern and accumulates received values at the positions from which the gatherer originally sent.

Parameters
execthe executor
gathererthe RowGatherer to create the inverse from
Returns
a unique_ptr to the created distributed::RowScatterer

◆ wait_and_accumulate()

template<typename LocalIndexType = int32>
void gko::experimental::distributed::RowScatterer< LocalIndexType >::wait_and_accumulate ( ptr_param< LinOp >  distributed_target) const

Wait for the scatter communication to complete and accumulate received values into the target: target += received_contributions.

Parameters
distributed_targetthe target vector to accumulate into. It must have the same value type and number of columns as the local_values of apply_async.
Exceptions
InvalidStateErrorif there is no scatter started by apply_async.

The documentation for this class was generated from the following files:
gko::experimental::distributed::RowScatterer::create_from_gatherer
static std::unique_ptr< RowScatterer > create_from_gatherer(std::shared_ptr< const Executor > exec, ptr_param< const RowGatherer< LocalIndexType >> gatherer)
Creates a distributed::RowScatterer from an existing RowGatherer.