[MPI3 Fortran] Proposed solution for the volatile buffer problem
Bill Long
longb at cray.com
Tue Dec 30 10:02:03 CST 2008
I've thought about the various proposed solutions to the problem of
protecting a buffer used for a split send/receive - wait pair of calls.
In particular, the need to prevent motion of code involving the buffer
across the wait call. Most of them seem to have at least one defect.
Here is a possible solution (not entirely original) that I think works,
and involves minimal and localized changes in the Fortran spec:
Introduce a new subprogram prefix named VOLATILE.
A VOLATILE subroutine:
1) must also be BIND(C)
2) may modify any variable accessible in the program unit that calls the
subroutine
The VOLATILE prefix is not required to match between an interface and
the actual definition of the subprogram.
Restriction (1) gets around the objection that the concept really makes
no sense in the Fortran-Fortran case. Restriction (2) will require that
variables be reloaded from memory after a call to a volatile subroutine,
and that code motion across the call is effectively blocked.
This scheme can be implemented entirely in a module with interfaces for
the MPI routines, avoiding user code changes. Vendors understand what
"volatile" means for variables, and this usage is a very natural
extension. This should be easy to implement. And avoids adding more
keywords to Fortran.
In practice, the VOLATILE prefix would be added to the interface for the
"wait" subroutine.
There is some concern about the performance hit from register spills
before the CALL, but since you would possibly be waiting for the
subroutine to complete anyway, it might not have an noticeable
performance hit in actual practice.
Cheers,
Bill
--
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