Loading...
Searching...
No Matches
Dune::VariableSizeCommunicator< Allocator > Class Template Reference
Common » Parallel Communication » Parallel Computing based on Indexsets

A buffered communicator where the amount of data sent does not have to be known a priori. More...

`#include <dune/common/parallel/variablesizecommunicator.hh>`

## Public Types

typedef std::map< int, std::pair< InterfaceInformation, InterfaceInformation >, std::less< int >, typename std::allocator_traits< Allocator >::template rebind_alloc< std::pair< const int, std::pair< InterfaceInformation, InterfaceInformation > > > > | InterfaceMap
| The type of the map from process number to InterfaceInformation for sending and receiving to and from it.

## Public Member Functions

| VariableSizeCommunicator (MPI_Comm comm, const InterfaceMap &inf)
| Creates a communicator with the default maximum buffer size.
| VariableSizeCommunicator (const Interface &inf)
| Creates a communicator with the default maximum buffer size.
| VariableSizeCommunicator (MPI_Comm comm, const InterfaceMap &inf, std::size_t max_buffer_size)
| Creates a communicator with a specific maximum buffer size.
| VariableSizeCommunicator (const Interface &inf, std::size_t max_buffer_size)
| Creates a communicator with a specific maximum buffer size.
| ~VariableSizeCommunicator ()
| VariableSizeCommunicator (const VariableSizeCommunicator &other)
| Copy-constructs a communicator.
VariableSizeCommunicator & | operator= (const VariableSizeCommunicator &other)
| Copy-assignes a communicator.
template<class DataHandle>
void | forward (DataHandle &handle)
| Communicate forward.
template<class DataHandle>
void | backward (DataHandle &handle)
| Communicate backwards.

## Detailed Description

template<class Allocator = std::allocator<std::pair<InterfaceInformation,InterfaceInformation> >>
class Dune::VariableSizeCommunicator< Allocator >

A buffered communicator where the amount of data sent does not have to be known a priori.

In contrast to BufferedCommunicator the amount of data is determined by the container whose entries are sent and not known at the receiving side a priori.

Note that there is no global index-space, only local index-spaces on each rank. Note also that each rank has two index-spaces, one used for gathering/sending, and one used for scattering/receiving. These may be the identical, but they do not have to be.

For data send from rank A to rank B, the order that rank A inserts its indices into its send-interface for rank B has to be the same order that rank B inserts its matching indices into its receive interface for rank A. (This is because the VariableSizeCommunicator has no concept of a global index-space, so the order used to insert the indices into the interfaces is the only clue it has to know which source index should be communicated to which target index.)

It is permissible for a rank to communicate with itself, i.e. it can define send- and receive-interfaces to itself. These interfaces do not need to contain the same indices, as the local send index-space can be different from the local receive index-space. This is useful for repartitioning or for aggregating in AMG.

Do not assume that gathering to an index happens before scattering to the same index in the same communication, as VariableSizeCommunicator assumes they are from different index-spaces. This is a pitfall if you want do communicate a vector in-place, e.g. to sum up partial results from different ranks. Instead, have separate source and target vectors and copy the source vector to the target vector before communicating.

## Member Typedef Documentation

## InterfaceMap

template<class Allocator = std::allocator<std::pair<InterfaceInformation,InterfaceInformation> >>

typedef std::map<int,std::pair<InterfaceInformation,InterfaceInformation>, std::less<int>, typename std::allocator_traits<Allocator>::template rebind_alloc< std::pair<const int,std::pair<InterfaceInformation,InterfaceInformation> > > > Dune::VariableSizeCommunicator< Allocator >::InterfaceMap

The type of the map from process number to InterfaceInformation for sending and receiving to and from it.

## Constructor & Destructor Documentation

## VariableSizeCommunicator() [1/5]

template<class Allocator = std::allocator<std::pair<InterfaceInformation,InterfaceInformation> >>

Dune::VariableSizeCommunicator< Allocator >::VariableSizeCommunicator | ( | MPI_Comm | comm,
|  | const InterfaceMap & | inf )

inline

Creates a communicator with the default maximum buffer size.

The default size is either what the macro DUNE_MAX_COMMUNICATION_BUFFER_SIZE is set to, or 32768 if it is not set.

## VariableSizeCommunicator() [2/5]

template<class Allocator = std::allocator<std::pair<InterfaceInformation,InterfaceInformation> >>

Dune::VariableSizeCommunicator< Allocator >::VariableSizeCommunicator | ( | const Interface & | inf | ) |

inline

Creates a communicator with the default maximum buffer size.

Parameters

  inf | The communication interface.

## VariableSizeCommunicator() [3/5]

template<class Allocator = std::allocator<std::pair<InterfaceInformation,InterfaceInformation> >>

Dune::VariableSizeCommunicator< Allocator >::VariableSizeCommunicator | ( | MPI_Comm | comm,
|  | const InterfaceMap & | inf,
|  | std::size_t | max_buffer_size )

inline

Creates a communicator with a specific maximum buffer size.

Parameters

  comm | The MPI communicator to use.
  inf | The communication interface.
  max_buffer_size | The maximum buffer size allowed.

## VariableSizeCommunicator() [4/5]

template<class Allocator = std::allocator<std::pair<InterfaceInformation,InterfaceInformation> >>

Dune::VariableSizeCommunicator< Allocator >::VariableSizeCommunicator | ( | const Interface & | inf,
|  | std::size_t | max_buffer_size )

inline

Creates a communicator with a specific maximum buffer size.

Parameters

  inf | The communication interface.
  max_buffer_size | The maximum buffer size allowed.

## ~VariableSizeCommunicator()

template<class Allocator = std::allocator<std::pair<InterfaceInformation,InterfaceInformation> >>

Dune::VariableSizeCommunicator< Allocator >::~VariableSizeCommunicator | ( |  | ) |

inline

## VariableSizeCommunicator() [5/5]

template<class Allocator = std::allocator<std::pair<InterfaceInformation,InterfaceInformation> >>

Dune::VariableSizeCommunicator< Allocator >::VariableSizeCommunicator | ( | const VariableSizeCommunicator< Allocator > & | other | ) |

inline

Copy-constructs a communicator.

Parameters

  other | VariableSizeCommunicator that is copied.

## Member Function Documentation

## backward()

template<class Allocator = std::allocator<std::pair<InterfaceInformation,InterfaceInformation> >>
template<class DataHandle>

void Dune::VariableSizeCommunicator< Allocator >::backward | ( | DataHandle & | handle | ) |

inline

Communicate backwards.

Template Parameters

  DataHandle

  The type of the handle describing the data. This type has to adhere to the following interface:
  // returns whether the number of data items per entry is fixed
  bool fixedsize();
  // get the number of data items for an entry with index i
  std::size_t size(std::size_t i);
  // gather the data at index i
  template<class MessageBuffer>
  void gather(MessageBuffer& buf, std::size_t i);
  // scatter the n data items to index i
  template<class MessageBuffer>
  void scatter(MessageBuffer& buf, std::size_t i, std::size_t n);
  Dune::size
  constexpr std::integral_constant< std::size_t, sizeof...(II)> size(std::integer_sequence< T, II... >)
  Return the size of the sequence.
  Definition integersequence.hh:75

Parameters

  handle | A handle responsible for describing the data, gathering, and scattering it.

## forward()

template<class Allocator = std::allocator<std::pair<InterfaceInformation,InterfaceInformation> >>
template<class DataHandle>

void Dune::VariableSizeCommunicator< Allocator >::forward | ( | DataHandle & | handle | ) |

inline

Communicate forward.

Template Parameters

  DataHandle

  The type of the handle describing the data. This type has to adhere to the following interface:
  // returns whether the number of data items per entry is fixed
  bool fixedsize();
  // get the number of data items for an entry with index i
  std::size_t size(std::size_t i);
  // gather the data at index i
  template<class MessageBuffer>
  void gather(MessageBuffer& buf, std::size_t i);
  // scatter the n data items to index i
  template<class MessageBuffer>
  void scatter(MessageBuffer& buf, std::size_t i, std::size_t n);

Parameters

  handle | A handle responsible for describing the data, gathering, and scattering it.

## operator=()

template<class Allocator = std::allocator<std::pair<InterfaceInformation,InterfaceInformation> >>

VariableSizeCommunicator & Dune::VariableSizeCommunicator< Allocator >::operator= | ( | const VariableSizeCommunicator< Allocator > & | other | ) |

inline

Copy-assignes a communicator.

Parameters

  other | VariableSizeCommunicator that is copied.

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

- variablesizecommunicator.hh