[MPI3 Fortran] Proposing changes to Fortran 2008

Craig Rasmussen crasmussen at lanl.gov
Thu Mar 20 10:13:00 CDT 2008


Yes, but the same size hole would exist for the "companion" C struct  
as well.  So however you calculate stride information for C would  
work for an interoperable derived type in Fortran as well.  Suppose  
foo were,

struct foo {
     char a;
     char b;
     int i;
     char c;
     char d;
}

Don't you have to worry about the C compiler reordering the elements  
of foo?

Cheers,
Craig


On Mar 19, 2008, at 6:26 PM, Jeff Squyres wrote:

> Isn't there likely to be a "hole" between c and d?
>
> On Mar 19, 2008, at 12:22 PM, Craig Rasmussen wrote:
>
>> I'm not sure your example is relevant for a Fortran API though.  In
>> Fortran we like to be safer than using NULL as a valid reference
>> point :-).
>>
>> Seriously though, we have been discussing using the Fortran intrinsic
>> C_LOC to obtain the address of a Fortran object to pass to C.  In the
>> description of C_LOC is requires that the variable "shall either be a
>> contiguous variable with interoperable type and type parameters, or
>> be a scalar, ...".
>>
>> I believe your example:
>>
>> struct foo {
>>    char c;
>>    double d;
>> }
>>
>> then passing the address of foo_instance[0].c should work fine in
>> Fortran as well under the following restraints:
>> 1. foo_instance in a contiguous array
>> 2. foo in of interoperable type
>>
>> Cheers,
>> Craig
>>
>>
>> On Mar 18, 2008, at 7:16 PM, Jeff Squyres wrote:
>>
>>> On Mar 18, 2008, at 11:02 AM, Craig Rasmussen wrote:
>>>
>>>>> 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).
>>>
>>>
>>> There is absolutely no requirement for contiguousness of user  
>>> buffers
>>> in the C bindings for MPI.
>>>
>>> Indeed, you can construct an MPI datatype (map) based off an
>>> arbitrary
>>> reference point in memory (e.g., NULL) and use relative memory
>>> offsets
>>> to describe the layout of the data that you want to access.  Hence,
>>> the pointer that you pass to MPI_SEND may actually have a memory map
>>> that spans all over actual memory.
>>>
>>> -- 
>>> 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
>>
>> _______________________________________________
>> mpi3-fortran mailing list
>> mpi3-fortran at lists.mpi-forum.org
>> http://lists.mpi-forum.org/mailman/listinfo.cgi/mpi3-fortran
>
>
> -- 
> 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