-
Notifications
You must be signed in to change notification settings - Fork 936
Description
The current F77 MPI_BUFFER_DETACH implementation does not return the detached buffer pointer to the caller -- it simply does not make sense to do this in F77 because a) you can't get it, b) pointer implementations between compilers seem to differ, and c) even among the F77 compilers that do support pointers, you can't compare or use the pointer in a meaningful way. There are two precedents that support this interpretation: LAM/MPI and CT6 both do not return the pointer to F77 callers.
Oh, and users of buffered sends should be punished, anyway. :-)
However, this is a problem for the F90 bindings, which are [mostly] layered on top of the F77 bindings. In F90, you can manage memory much like C, so it does make sense to return the detached buffer though the F90 API. Hence, we need to override the default MPI F90 interface for MPI_DETATCH_BUFFER and have a specific implementation that returns the buffer pointer to the caller.
Here's some nuggets of information that may be helpful from an e-mail exchange from us and a Fortran expert at Sun (Ian B.):
Terry's e-mail to Ian:
In MPI there is a function pair to called MPI_Buffer_attach and MPI_Buffer_detach. These are used by the application program to give the MPI library some buffer space to use for the buffered communications functions.
When you call MPI_Buffer_attach you pass it a pointer to a buffer that you want MPI to use. In C when you call MPI_Buffer_detach you pass it a pointer to a pointer in which the MPI library returns to you the pointer to the buffer you passed it via the MPI_Buffer_attach. For C I can see this being used if you don't keep around the pointer to the buffer and you want to free the buffer returned by MPI_Buffer_detach.
My question is the above applicable to Fortran programs at all? Could do something similar with Fortran (90-03) pointers?
Ian's response:
Yes, one could do that with f90 pointers. You would need an interface for the MPI_Buffer_* routines, or else the pointer arguments won't be passed correctly. Something like
interface
subroutine MPI_Buffer_attach(p)
integer, pointer, intent(in) :: p(:)
end subroutine
end interface
interface
subroutine MPI_Buffer_detach(p)
integer, pointer, intent(out) :: p(:)
end subroutine
end interface
(I haven't actually tried compiling that, so caveat emptor.)