[Dune] Contribution to CollectiveCommunication

Aleksejs Fomins aleksejs.fomins at lspr.ch
Thu Jan 22 09:50:49 CET 2015


Dear Dune,

Following our discussions on POD communication, I have written a small
utility, which might find its place among CollectiveCommunication
methods if people want it. The motivation is that there are numerous
gather and scatter methods in there, but no wrapper for MPI_Alltoallv,
as far as I can tell.

The interface is as follows

template <typename T>
void communicate(
  const T * in,
  const int * lengthIn,
  T * out,
  int * lengthOut
)

where "in" is an array of data which needs to be sent to each process
(stacked together), and "lengthIn" is an array which defines sizes of
chunks to be sent to each process. Correspondingly, "out" is an array of
data received from all processes (stacked together), and "lengthOut"
defines sizes of blocks received from each process. User needs to
provide "in" and "lengthIn", as well as receive sufficient memory for
"out" and "lengthOut".

For example, if process 1 would like to send
2 elements to process 0
3 elements to process 1 (self)
5 elements to process 2
then "in" would have length 10, and lengthIn={2,3,5} on process 1


I have also written an alternative interface with vectors
template <typename T>
void communicate(
  const std::vector<T> & in,
  const std::vector<int> & lengthIn,
  std::vector<T> & out,
  std::vector<int> & lengthOut
)

where all vectors have the same meaning as above. The advantage of
vector formulation is that user need not care about the output vectors
at all, the correct amount of memory for output storage will be reserved
automatically.


I have attached the implementation and a test for it.


Hope it is of use.

Regards,
Aleksejs
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test-allcommunicate.cc
Type: text/x-c++src
Size: 2730 bytes
Desc: not available
URL: <https://lists.dune-project.org/pipermail/dune/attachments/20150122/96a3601d/attachment.cc>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: allcommunication.hh
Type: text/x-c++hdr
Size: 3193 bytes
Desc: not available
URL: <https://lists.dune-project.org/pipermail/dune/attachments/20150122/96a3601d/attachment.hh>


More information about the Dune mailing list