(j3.2006) MPI usage problems in Fortran
Aleksandar Donev
donev1
Wed Mar 19 13:02:20 EDT 2008
Craig,
You are mixing two things up: Either your buffer is an regular (typed) Fortran
array and has the ASYNC attribute, *or* it is a "TYPE(C_PTR), VALUE". Don't
mix the two as it makes no sense. The pointer itself is neither volatile nor
asynchronous, it is the target of the pointer that is.
> 1. VALUE and ASYNCHRONOUS lead to a compile error (is this correct?)
Yes it is correct, but don't ask me why.
> 2. buf doesn't have the TARGET attribute
Definitely a bad idea---you are taking and retaining a pointer to it. It must
have TARGET.
> 3. How long is buf tainted as Bill suggests?
Ask Bill :-) The standard says nothing that I can understand...
Here is what it should look like:
--------------
interface
? ? ?function MPI_Isend(buf, count, datatype, &
? ? ? ? ? ? ? ? ? ? ? ? dest, tag, comm, request)
BIND(C, ?name="MPI_Isend") result(err)
? ? ? ?use, intrinsic :: ISO_C_BINDING
? ? ? ?import :: MPI_HANDLE
? ? ? ?implicit none
? ? ? ?type(C_PTR), value :: buf
...
? ? ?end function MPI_Isend
end interface
use, intrinsic :: ISO_C_BINDING
use MPI3
type(MPI_HANDLE) :: request
integer, volatile, target :: buf(10)
integer(C_INT) :: err
err = MPI_Isend(C_LOC(buf), 10, MPI_INTEGER, 1, 1, MPI_COMM_WORLD, ?
request)
----------------
Note that buf is volatile and target. Maybe asynchronous and target would also
work, but I think the standard reserves asynchronous for internal Fortran I/O
use and not for things outside of the standard. I don't think it will make
any difference---don't compilers treat the two identically?
This will kill optimization of anything done with buf in any program unit
where it has both the volatile and the target attribute.
Bill and the misguided Note in the standard suggest that maybe this was some
intended use of asynchronous:
--------------
interface
function MPI_Isend(buf, count, datatype, &
dest, tag, comm, request)
BIND(C, name="MPI_Isend") result(err)
use, intrinsic :: ISO_C_BINDING
import :: MPI_HANDLE
implicit none
real(c_double), dimension(*), asynchronous :: buf ! An array
...
end function MPI_Isend
end interface
use, intrinsic :: ISO_C_BINDING
use MPI3
type(MPI_HANDLE) :: request
integer, target :: buf(10) ! Should/must this have ASYNC attribute???
integer(C_INT) :: err
err = MPI_Isend(buf, ..., request)
----------------
but again I don't think the standard holds water in making this actually make
sense, yet alone work.
Best,
Aleks
More information about the J3
mailing list