[MPICH] About extent and size of datatype?
William Gropp
gropp at mcs.anl.gov
Tue Dec 11 08:35:38 CST 2007
The extent can be thought of as a stride, and only describes how
successive copies of a datatype are laid out in memory. In terms of
what data is moved, in MPI, only the data elements are sent, so,
roughly speaking, count*MPI_Type_size(datatype) is sent (however, an
MPI implementation is permitted to use lossless compression, for
example, and there have been examples that do that). When the
datatype is not contiguous, it tells the send how to gather the data
to send and the receive how to scatter the data. So your
understanding is correct.
Bill
On Dec 11, 2007, at 12:52 AM, Ruini Xue wrote:
> hello,
>
> I am a little confused by the extent and size of derived datatypes.
> In my opinion, `extent' includes the additional `padding spaces'
> introduced by non-continuous displacements of blocks in the
> datatype, while `size' only counts the `useful' bytes which do not
> include the padding spaces. Generally, the `extent' of a datatype
> is not smaller then its `size'. As far as I know, some blocks in
> derived datatypes have negative displacements, thus their `
> extents' might be smaller than their `sizes'.
>
> So the questions are "how many bytes does MPI_Send() really send
> out if the datatype has a bigger extent than its size?" and " how
> does the corresponding MPI_Recv() place the received data?" I goes
> through the MPICH2 code, and got a blur big picture. It seems that
> MPI_Send() sends the datetype in compacted format, in other word,
> only MPI_Type_size(datatype) * count bytes are sent, but not
> MPI_Type_extent(datatype) * count. Accordingly, MPI_Recv() only
> receives MPI_Type_size(datatype) * count bytes from the sender, and
> these bytes are unpacked to the receive buffer according to the
> definition of the datatype. In other words, padding spaces are
> inserted in the receive buffer if necessary while unpacking the
> received data. This optimization is reasonable: to reduce the
> amount of transfer data, while holding the semantics of derived types.
>
> To conclude, only useful bytes are transfered, while both the send
> and receive buff should be big enough to hold the 'whole datatype'.
>
> Is my understanding right? Please let me know any mistake I made.
>
> Thanks in advance!
>
> Best
>
> Andrew
William Gropp
Paul and Cynthia Saylor Professor of Computer Science
University of Illinois Urbana-Champaign
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/mpich-discuss/attachments/20071211/8d0a01a8/attachment.htm>
More information about the mpich-discuss
mailing list