[MPI3 Fortran] Proposing changes to Fortran 2008

Craig Rasmussen crasmussen at lanl.gov
Tue Mar 18 10:02:35 CDT 2008


On Mar 18, 2008, at 8:17 AM, Jeff Squyres wrote:

> On Mar 18, 2008, at 10:08 AM, Craig Rasmussen wrote:
>
>>> I admit that I know so little about Fortran that much of your mail
>>> went over my head.  :-(  But a question about the above: is it
>>> possible to allow non-contiguous datatypes to be passed through
>>> without having the compiler copy them into contiguous areas?  It may
>>> be possible, for example, for the MPI datatype to accurately  
>>> describe
>>> the non-contiguousness of the data, and MPI is well-equipped to
>>> handle
>>> such situations.
>>
>> I'm not sure I understand MPI datatypes to respond coherently, but
>> that's never stopped me before :-)
>>
>> I think you really want contiguous"ness", otherwise you wouldn't know
>> how to stride through the data with constant offsets.  Right?
>
>
> No.

Yes!  (sorry, couldn't resist Jeff :-)

What you say below is as I expected.  If you have an array of foo,  
then foo must be contiguous in order for you to be able to stride  
though it to get at each (noncontiguous) char c.  I don't think we  
disagree here.  In Fortran, you can take a slice of an array so that  
the sliced elements aren't contiguous anymore.  The compiler handles  
this by modifying the array meta-data (stride information), or if  
necessary when going to C, make a copy.  So in Fortran we have to be  
a little more careful what we mean by contiguous (and I'm sure I  
don't fully understand it yet).

Cheers,
Craig

>
> MPI datatypes are a rich abstraction that allow the description of a
> variety of different layouts in memory (such as constant strides,
> etc.).  Specifically: in C, there is no requirement for a contiguous
> buffer.  As long as the accompanying MPI datatype accurately describes
> the buffer, you're good to go.
>
> This is one of the reasons that MPI requires a datatype argument --
> because even though modern languages such as C++ and Fortran can
> derive a type from the buffer argument, what if the actual memory
> layout differs from that of the buffer argument type?  For example:
>
> struct foo {
>    char c;
>    double d;
> }
>
> struct foo instance;
> MPI_Send(&instance->c, ...);
>
> What is passed is a pointer to a character.  But what you really want
> to send is the whole struct (which likely has a big hole in its memory
> map).  Likewise, the type in the following call doesn't tell anything
> to MPI, and an explicit datatype is required:
>
> MPI_Send(&instance, ...)
>
> And note that &instance == &instance->c.
>
> -- 
> Jeff Squyres
> Cisco Systems
>
> _______________________________________________
> mpi3-fortran mailing list
> mpi3-fortran at lists.mpi-forum.org
> http://lists.mpi-forum.org/mailman/listinfo.cgi/mpi3-fortran




More information about the mpiwg-fortran mailing list