[MPI3 Fortran] Proposing changes to Fortran 2008

Hubert Ritzdorf ritzdorf at it.neclab.eu
Mon Mar 31 14:58:16 CDT 2008

Aleksandar Donev wrote:
>> And I have also seen compiler switches for "don't perform copy-in/copy
>> out".
> Can you give an example please and explain what it does exactly?
When I see it correctly, avoiding copy-in/copy-out is somewhat like
optimization for a Fortran compiler. In the beginning of the Fortran 90
compiler developments, many compilers performed a copy-in/copy-out
at places where it really was not necessary. With the improvement of the
compilers, the number of copy-in/copy-out operations decreased.
Nevertheless, if the compiler is not sure that it can perform this
optimization the compiler inserts a copy-in/copy-out.

Such a compiler option turns off copy-in/copy-out for that source
file to be compiled. It works such as an optimization flag.
>> And I see 
>> Fortran codes transferring scalar arguments such as "my_array (1,1)"
>> (nevertheless many
>> data items are transferred)  in order to avoid  copy in/copy out.
> Why not just "my_array"? If this is trying to get around the rank-matching 
> requirement than using my_array(1,1) is in fact perfectly legal and OK---you 
> are relying on sequence association which is exactly what passing the first 
> element of an array does. But in that case your assertion that they do this 
> to avoid copy in/out is wrong---they do it to pass a rank-2 array to a rank-1 
> buffer dummy.
> Formally, nothing in the standard prevents copy in/out when relying on 
> sequence association as in the example above. It is just that no compiler in 
> their sane mind would perform copying when that was completely unnecessary: 
> The actual argument is already contiguous so why copy it?
Since the application programmer cannot be "sure" that copy-in/copy out 
is not
performed.  If you specify my_array(1,1), the compiler will transfer the 
address of
Otherwise,  the compiler could decide to perform a copy-in/copy-out (see 
above, since
the compiler is not sure that it is completely unnecessary). I have for 
example seen that a
compiler decided to make a temporary vector for an array-section of a 
1-dimensional array:
the MPI_Irecv received incorrect data, the application code failed. From 
the Fortran
90 compilers view, it was correct code (possibly not most efficient), 
but this doesn't
help the application programmer. He will look for a "portable" solution 
and transfer
the first array element (I know, it's not guaranteed but it works).

Best regards

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3245 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://lists.mpi-forum.org/pipermail/mpiwg-fortran/attachments/20080331/77484c98/attachment-0001.bin>

More information about the mpiwg-fortran mailing list