[MPI3 Fortran] Proposing changes to Fortran 2008

Jeff Squyres jsquyres at cisco.com
Wed Mar 19 19:26:39 CDT 2008


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




More information about the mpiwg-fortran mailing list