[Dune] A question on CollectiveCommunication

Jö Fahlke jorrit at jorrit.de
Mon Jan 19 12:35:35 CET 2015


Am Mon, 19. Jan 2015, 11:51:10 +0100 schrieb Aleksejs Fomins:
> I am trying to understand the paradigm of the communication used in Dune
> 
> The question concerns the following
> Dune::CommDataHandleIF< DataHandleImp, DataTypeImp >

This is an abstraction to communicate on top of a grid (i.e. sending data from
an interior entity on one rank to the corresponding overlap entities on other
ranks).

> int Dune::CollectiveCommunication< C >::gather( T * in, T * out, int
> len, int root) const

This is a lower level an abstraction directly on top of MPI, it does not know
anything about grids (but it may be used by grids to implement communication).

> In both cases we define a template parameter which defines the data
> type to be communicated. As I understood from discussions with Marcus
> and Peter, internally the communication is performed using MPI_BYTE
> communication, i.e. sending size_of(T) data from a given address to a
> given address.
> 
> It looks to me that this should not work for T = some stl object, because:
> 1) If T has variable size, and we are passing a pointer to the array
> of T's in gather, then gather has no information on the length of each
> individual T
> 2) If I would like to communicate T = std::vector<int>, would not the
> internal implementation of vector contain a pointer to an array for
> the current processor?
> 
> That said, the question is as follows:
> 
> Is dune communication interface intended to handle standard stl types?
> If no, which DataTypes are expected/allowed to be communicated?

No, the interface isn't designed for that.  stl containers usually contain
pointers to the real data, and that won't be communicated correctly if used
directly.  It works for fundamental types and probably for aggregates
(i.e. types that don't have user-defined constructors).  That should include
std::complex and std::array, but none of the more complex containers.

However, communicating a std::vector is easy, since the standard guarantees
that the data of the vector is layed-out contiguously.  Just pass &v[0] (or
v.data() in C++11) as the adress of the array.  You need to make sure that the
receiving vector has a sufficient size before the call, though; in the worst
case you have to do a seperate communication just to communicate the size.

Regards,
Jö.

-- 
Jorrit (Jö) Fahlke, Institute for Computational und Applied Mathematics,
University of Münster, Orleans-Ring 10, D-48149 Münster
Tel: +49 251 83 35146 Fax: +49 251 83 32729

Der Horizont vieler Menschen ist ein Kreis mit Radius Null - und das
nennen sie ihren Standpunkt.
-- A. Einstein
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 828 bytes
Desc: Digital signature
URL: <https://lists.dune-project.org/pipermail/dune/attachments/20150119/24eac3b5/attachment.sig>


More information about the Dune mailing list