<br>
<br><tt><font size=2>mpi3-fortran-bounces@lists.mpi-forum.org wrote on
05/28/2009 09:55:20 AM:<br>
<br>
> #2.  Look at this example program, which uses Cray pointers and
LOC to deal<br>
> with issue #1:<br>
> <br>
>       include 'mpif.h'<br>
> <br>
>       implicit none<br>
>       external copyfunc, delfunc<br>
> <br>
>       integer err, kvh, comm<br>
>       real extra(10)<br>
> <br>
>       call mpi_init(err)<br>
> <br>
>       extra(2:10) = 6<br>
>       extra(1) = 5<br>
>       call mpi_comm_create_keyval(copyfunc, delfunc,
kvh, loc(extra),<br>
>      +     err)<br>
>       call mpi_comm_set_attr(mpi_comm_world, kvh, 1,
err)<br>
>       call mpi_comm_dup(mpi_comm_world, comm, err)<br>
>       extra = 7<br>
>       call mpi_comm_free(comm, err)<br>
> <br>
>       call mpi_finalize(err)<br>
>      <br>
>       end<br>
> <br>
>       subroutine copyfunc(oldcomm, kv, extra, val_in,
val_out, flag,<br>
>      +     ierror)<br>
> <br>
>       include 'mpif.h'<br>
> <br>
>       implicit none<br>
>       integer oldcomm, kv, ierror<br>
>       integer(kind=mpi_address_kind) val_in, val_out<br>
>       real extra_val(10)<br>
>       pointer (extra, extra_val)<br>
>       logical flag<br>
> <br>
>       print *, extra_val<br>
>       flag = 1<br>
>       val_out = val_in<br>
>       ierror = mpi_success<br>
>       end subroutine<br>
> <br>
>       subroutine delfunc(oldcomm, kv, val, extra, ierror)<br>
> <br>
>       include 'mpif.h'<br>
> <br>
>       implicit none<br>
>       integer oldcomm, kv, ierror<br>
>       integer(kind=mpi_address_kind) val<br>
>       real extra_val(10)<br>
>       pointer (extra, extra_val)<br>
> <br>
>       print *, extra_val<br>
>       ierror = mpi_success<br>
>       end subroutine<br>
> <br>
> Now copyfunc is called from the MPI library during evaluation of the<br>
> call to mpi_comm_dup, while delfunc is called during the evaluation<br>
> of the call to mpi_comm_free.  Those routines are accessing extra,
which<br>
> is a local variable in the main program.  The program has passed
the<br>
> address of extra to mpi_comm_create_keyval, but not to mpi_comm_dup<br>
> or mpi_comm_free.<br>
> <br>
> A compiler may choose to delete "extra = 7" as dead code,
or to move<br>
> the assignment before the call to mpi_comm_dup or after the call to<br>
> mpi_comm_free. Or the compiler may decide that use of "loc(extra)"<br>
> means that extra may be accessed or modified by any call, and thus<br>
> be conservative about its optimizations.  The standard doesn't
provide<br>
> any guidance, since LOC and Cray pointers are outside the standard.<br>
> <br>
> Is there a standard-conformant way to indicate that extra may be accessed<br>
> or modified during the calls to mpi_comm_dup and mpi_comm_free?<br>
</font></tt>
<br>
<br><tt><font size=2>Not now.  But I've suggested two options to deal
with this kind of aliasing problems to the standard body: one is to use
aliasing hint statement such as alias_associate (delfunc, extra); the other
is aliasing block (or async block) that automatically generates this kind
of info between variables and procedures.  However neither proposal
is leading to anywhere.  Majority of the committee wanted to expand
the definition of asynchronous attribute to deal with this, which I think
is a wrong idea.</font></tt>
<br>
<br><tt><font size=2>Cheers,</font></tt>
<br>
<br>
<br><font size=2 face="sans-serif">Jim Xia<br>
<br>
XL Fortran Compiler Test<br>
IBM Toronto Lab at 8200 Warden Ave, Markham, On, L6G 1C7<br>
Phone (905) 413-3444  Tie-line 313-3444<br>
email: jimxia@ca.ibm.com<br>
D2/YF7/8200 /MKM<br>
<br>
</font><a href=http://www.ibm.com/software/awdtools/fortran/xlfortran><font size=2 face="sans-serif">http://www.ibm.com/software/awdtools/fortran/xlfortran</font></a>