(j3.2006) MPI usage problems in Fortran
Craig Rasmussen
crasmussen
Thu Mar 20 12:00:39 EDT 2008
On Mar 19, 2008, at 11:02 AM, Aleksandar Donev wrote:
> 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.
>
Sure. But what I wanted to do was specify that the target of the
pointer is asynchronous in the interface. I don't have a clear way
to do this. If the interface can somehow specify that the target of
the variable in involved in an asynchronous transaction then the
compiler can know this without the programmer being required to add
it as an attribute on the actual (and they will forget to do this).
It is the role of an interface to specify how a variable will be used.
However, after carefully reading section 12.5.2.4 (and loosing
several million brain cells in the process) I think maybe
asynchronous is not the way to proceed.
Since we are considering using type(C_PTR) to interoperate with a C
void* argument, I don't think copy-in/copy-out semantics applies, so
no need for NOTE 12.27. Also, as I read paragraph 11 pg. 290, "If
the dummy argument has the TARGET attribute and the effective
argument does not have the TARGET attribute...", then declaring a
dummy argument with the TARGET attribute (and then calling MPI
routines), doesn't require that TARGET be applied to the effective
argument of the dummy (so the performance of an entire code is
compromised).
> 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.
>
So are either asynchronous or target sufficient to guarantee that buf
is tainted within the scope of the procedure so that statement
reordering won't collide with the MPI semantics of the MPI_Wait
call. As Bill says, this is very much like asynchronous I/O in
Fortran and should be treated similarly. Perhaps it would be helpful
to have the ASYNCHRONOUS attribute apply to procedures, i.e.,
ASYNCHRONOUS FUNCTION MPI_Isend(...)
ASYNCHRONOUS FUNCTION MPI_Wait(...)
This way the compiler can have a clue about the behavior of
asynchronous procedures beyond intrinsic I/O.
Regards,
Craig
More information about the J3
mailing list