[MPI3 Fortran] MPI buffer arguments - void and call-by-reference
Bill Long
longb at cray.com
Mon Feb 16 11:54:04 CST 2009
N.M. Maclaren wrote:
>> The only one of those that ABSOLUTELY blocks copy-in/copy-out and the
>> more-or-less equivalent optimisations is VOLATILE. ASYNCHRONOUS does
>> the least blocking, and is therefore the most efficient.
>
> Ugh. I have thought of a case where even VOLATILE doesn't block
> copy-in/copy-out, but it's irrelevant to this debate.
That it is irrelevant is reassuring, although it would be interesting to
see the case. If it were relevant, then ASYNCHRONOUS would be
ineffective as well. Copy-in/copy-out is blocked by two constraints in
the standard (C1232 and C1233) in which VOLATILE and ASYNCHRONOUS are
interchangeable. In regards to how they affect copy-in/copy-out, these
two attributes are identical.
In the cases relevant to the MPI discussion, there is essentially no
difference between VOLATILE and ASYNCHRONOUS is regards to code motion
across a call site. The caller cannot tell if the callee contains a
WAIT statement, and even if it could, would be hard pressed to determine
if that particular WAIT statement had anything to do with a particular
asynchronous variable. Effectively, all motion of code involving a
variable with either the volatile or asynchronous attributes across a
call site is suppressed by the optimizer. The difference is that a
variable can get the ASYNCHRONOUS attribute implicitly, whereas VOLATILE
must be explicitly specified.
On the surface, the main area of difference between VOLATILE and
ASYNCHRONOUS is that a standard-conforming program is not allowed to
improperly reference or define an asynchronous variable in a part of the
code where it is subject to asynchronous activity. The program can
reference or define variables declared VOLATILE with many fewer
restrictions. Of course, if you do not have any references or
definitions of the variable in a particular region of the code, then it
does not matter which way it was declared.
The definitions and references of volatile variables that the are
exceptional (compared to nonvolatile variables) are, by their nature,
asynchronous. The core difference between VOLATILE and ASYNCHRONOUS is
that the compiler knows exactly where the asynchronous activity is
coming from - the Fortran I/O system. Since the I/O system is part of
the processor, it might be able to narrow the scope of optimization
suppression compared to the volatile case. But, as noted above, for a
standard-conforming program, the cases where this makes an actual
difference are slim. It is a reasonable and conforming implementation
to just make ASYNCHRONOUS a synonym for VOLATILE. If we want to extend
ASYNCHRONOUS to apply outside the Fortran I/O environment (such as for
MPI non-blocking transfers), then that main distinction is lost. This
is, among others, a reason for opposition to this approach.
Cheers,
Bill
>
> I am also pretty sure that I can construct an example where TARGET
> isn't enough to make MPI non-blocking transfers safe, but would need
> to check that with the standard very carefully.
>
>
> Regards,
> Nick Maclaren,
> University of Cambridge Computing Service,
> New Museums Site, Pembroke Street, Cambridge CB2 3QH, England.
> Email: nmm1 at cam.ac.uk
> Tel.: +44 1223 334761 Fax: +44 1223 334679
>
--
Bill Long longb at cray.com
Fortran Technical Support & voice: 651-605-9024
Bioinformatics Software Development fax: 651-605-9142
Cray Inc., 1340 Mendota Heights Rd., Mendota Heights, MN, 55120
More information about the mpiwg-fortran
mailing list