(j3.2006) MPI usage problems in Fortran
Bill Long
longb
Tue Mar 18 14:35:57 EDT 2008
Craig Rasmussen wrote:
> A problem was described to me at the MPI Forum meeting last week.
> Using split-phase communication (asynchronous) the user can call send
> on a buffer, do computation, then call wait before reusing the
> buffer. The sequence is:
>
>
> A = 3
> call MPI_Isend(A, ...., request, ...)
> ! do computation not involving A
> call MPI_Wait(request, ...)
>
> The problem is that the way the interfaces are currently defined, the
> compiler can't know that MPI_Isend has retained a pointer to A that
> it doesn't release until after the MPI_Wait call.
Most of the time that is not really a problem. If the "not involving A"
claim is correct, then you only have to worry about A being deallocated
by the compiler. This brings up the real problem with these routines.
If A is an array section that is not contiguous, for example, the
compiler will make a local copy, pass the address of the copy, and then
possibly delete the copy (which is associated with the pointer inside
Isend) before the asynchronous Isend routine is done with the data.
Thus, the real concern is to make sure the compiler does not generate
copy-in/copy-out code for the buffer argument. Apart from that, bad
things should not happen.
Cheers,
Bill
> So a common hack
> is to add
>
> call MPI_Get_address(A, ...)
>
> after the MPI_Wait. I assume the correct way to fix this is to add
> the target attribute to the first dummy argument in MPI_Isend. Is
> there a better way? This is especially a problem for codes using the
> implicit MPI interfaces.
>
> However, when I try the following:
>
> implicit none
> interface
> subroutine send(A)
> real, target :: A(*)
> end subroutine send
> end interface
>
> real :: buf(10)
>
> call send(buf)
>
> end program
>
> I get no error message. Is this a legal program? Shouldn't the
> target attribute be required for the actual argument? Section 5.3.17
> doesn't say.
>
> Thanks,
> Craig
>
>
>
> _______________________________________________
> J3 mailing list
> J3 at j3-fortran.org
> http://j3-fortran.org/mailman/listinfo/j3
>
--
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 J3
mailing list