Re: [MPI3 Fortran] MPI buffer arguments - void and call-by-reference
On Feb 14 2009, Bill Long wrote:
Aleksandar Donev wrote:
On Monday 09 February 2009 14:59, Rolf Rabenseifner wrote:
Fortran compilers are allowed to choose call-by-incopy-and-outcopy instead of call-by-reference.
There are already at least two cases where Fortran compilers are not allowed to choose. These are when both the actual and the dummy have the attribute: TARGET, VOLATILE, and ASYNCHRONOUS. Perhaps adding yet
Just to be clear, the "and" above should be "or". You do not need to specify all of these options - one will do.
Um. While that is true, to a first approximation, it isn't really. The reason is that all three of those have subtly different constraints on when a compiler must not use copy-in/copy-out and other optimisations. For example, consider: SUBROUTINE Fred (array, index) INTEGER, INTENT(INOUT), TARGET :: array(:) INTEGER, INTENT(INOUT), POINTER :: index(:) PRINT *, SUM(array) CALL Joe(index) PRINT *, SUM(array) CONTAINS SUBROUTINE Joe (arg1, arg2) INTEGER, INTENT(INOUT), TARGET :: arg1(:) INTEGER, INTENT(INOUT), POINTER :: arg2(:) arg2 = arg2+arg1 END SUBROUTINE Joe END SUBROUTINE Fred The compiler must recalculate the sum and must not use copy-in/copy-out, in case index points to array. But, if array were ASYNCHRONOUS or a MPI non-blocking transfer buffer (and not TARGET), it could do either or both, because it knows that there is no WAIT statement or external call in Joe, and so array can neither start to be nor cease being a pending affector at any time during the call to Fred. 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.
The ultimate problem comes because a pointer (inside the MPI chambers) has been associated with the buffer and actions on the buffer are being taken through that pointer.
Sorry, NO! You have omitted the word 'asynchronously', and that is critical! The WHOLE point of MPI non-blocking transfers is that they are asynchronous.
The TARGET attribute identifies a variable as being (possibly) the target of a (Fortran) pointer. Given the similarity of the situations, it would be reasonable to require that a buffer have the TARGET attribute if it is used as the memory for a non-blocking MPI data transfer routine.
For the above reasons, it won't help. I really don't understand why there are these objections to ASYNCHRONOUS, and would appreciate it if anyone who does understand could send me clear, explicit statements of what they object to. Regards, Nick Maclaren, University of Cambridge Computing Service, New Museums Site, Pembroke Street, Cambridge CB2 3QH, England. Email: [email protected] Tel.: +44 1223 334761 Fax: +44 1223 334679
participants (1)
-
N.M. Maclaren