(j3.2006) Paper on copyless argument passing
Aleksandar Donev
donev1
Thu Apr 24 16:31:54 EDT 2008
Hello,
Comments please.
This is following some discussions with the MPI Forum and the needs to avoid
copy in/out. Ultimately, it seems that they would like a similar guarantee
against copy in/out to be added for the case when the dummy and actual both
have the ASYNCHRONOUS attribute, without necessarily having the TARGET
attribute. We say that in a note (that I proposed yesterday we change). I
don't know how to word it in standardese, since I cannot use pointer
association (no targets!) as a way to basically say there won't be any
copying...
Thanks,
Aleks
-------------- next part --------------
To: J3
Subject: Guaranteed no copy in/out and TARGET
From: Aleksandar Donev
The current draft has not made any changes to the way copy in/out
interacts with the TARGET attribute on the dummy and/or actual
arguments, even though the important concepts of a contiguous and
simply contiguous object were introduced. I believe this is an
integration omission and we need to update some of the rules in
clause 12.5.2.4.
Guaranteed copy-less argument passing is useful when pointers are
involved. This is especially true with C Interop, where many routines
may take and keep a pointer to the actual. The only way to propagate
pointer association accross procedure calls in the current standard
is to have the TARGET attribute on both the dummy and the actual,
and to make the dummy an assumed-shape array or a pointer. This last
restriction makes this feature hard to use when updating old codes or
existing widely-used interfaces (example, MPI), or with C Interop. It
was there in previous revisions of Fortran in order to avoid having
the user rely on, and compilers to implement, run-time checks for
contiguity of the actual when the dummy expects a contiguous array
(assumed-size, explicit shape, and in F2008, assumed-shape with the
CONTIGUOUS attribute). The restriction is no longer needed in F2008,
since users need to understand and compilers have to implement at
least the basic compile-time test for simply contiguous objects.
Therefore, in F2008, we should guarantee no copy in/out when the dummy
is a TARGET and is explicit shape, assumed size, or assumed shape
with the CONTIGUOUS attribute, and the actual is a simply contiguous
TARGET. This is in addition to the existing guarantee when the dummy
is assumed-shape.
This change is analogous to what we already did in C1238 for
ASYNCHRONOUS dummies: The intention there was that when the actual is
simply contiguous we know there won't be any copy in/out. We should
provide this implicit guarantee explicitly to programmers.
Edits are provided to make this integration change.
Edits against 08-007r1:
-------------
[290] 12.5.2.3 Argument association, para. 9
Replace the sentence before the bullet item list with:
"If the dummy argument has the TARGET attribute, does not have the
VALUE attribute, and:
1) The dummy argument is a scalar, an assumed-shape array that does
not have the CONTIGUOUS attribute, and the effective argument has the
TARGET attribute but is not a coindexed object or an array section
with a vector subscript, or
1) The dummy argument is an explicit-shape array, an assumed-shape
array with the CONTIGUOUS attribute, or an assumed-size array, and the
effective argument is simply contiguous and has the TARGET attribute
but is not a coindexed object
then:"
-------
[290] 12.5.2.3 Argument association, para. 10
Replace the sentence before the bullet item list with:
"If the dummy argument has the TARGET attribute and is an
explicit-shape array, an assumed-shape array with the CONTIGUOUS
attribute, or an assumed-size array, and the effective argument is
not simply contiguous and has the TARGET attribute but is not an
array section with a vector subscript then"
More information about the J3
mailing list