[MPI3 Fortran] Fortran extra_state argument to MPIattributefunctions
Jim Xia
jimxia at ca.ibm.com
Thu May 28 09:16:38 CDT 2009
mpi3-fortran-bounces at lists.mpi-forum.org wrote on 05/28/2009 09:55:20 AM:
> #2. Look at this example program, which uses Cray pointers and LOC to
deal
> with issue #1:
>
> include 'mpif.h'
>
> implicit none
> external copyfunc, delfunc
>
> integer err, kvh, comm
> real extra(10)
>
> call mpi_init(err)
>
> extra(2:10) = 6
> extra(1) = 5
> call mpi_comm_create_keyval(copyfunc, delfunc, kvh, loc(extra),
> + err)
> call mpi_comm_set_attr(mpi_comm_world, kvh, 1, err)
> call mpi_comm_dup(mpi_comm_world, comm, err)
> extra = 7
> call mpi_comm_free(comm, err)
>
> call mpi_finalize(err)
>
> end
>
> subroutine copyfunc(oldcomm, kv, extra, val_in, val_out, flag,
> + ierror)
>
> include 'mpif.h'
>
> implicit none
> integer oldcomm, kv, ierror
> integer(kind=mpi_address_kind) val_in, val_out
> real extra_val(10)
> pointer (extra, extra_val)
> logical flag
>
> print *, extra_val
> flag = 1
> val_out = val_in
> ierror = mpi_success
> end subroutine
>
> subroutine delfunc(oldcomm, kv, val, extra, ierror)
>
> include 'mpif.h'
>
> implicit none
> integer oldcomm, kv, ierror
> integer(kind=mpi_address_kind) val
> real extra_val(10)
> pointer (extra, extra_val)
>
> print *, extra_val
> ierror = mpi_success
> end subroutine
>
> Now copyfunc is called from the MPI library during evaluation of the
> call to mpi_comm_dup, while delfunc is called during the evaluation
> of the call to mpi_comm_free. Those routines are accessing extra, which
> is a local variable in the main program. The program has passed the
> address of extra to mpi_comm_create_keyval, but not to mpi_comm_dup
> or mpi_comm_free.
>
> A compiler may choose to delete "extra = 7" as dead code, or to move
> the assignment before the call to mpi_comm_dup or after the call to
> mpi_comm_free. Or the compiler may decide that use of "loc(extra)"
> means that extra may be accessed or modified by any call, and thus
> be conservative about its optimizations. The standard doesn't provide
> any guidance, since LOC and Cray pointers are outside the standard.
>
> Is there a standard-conformant way to indicate that extra may be
accessed
> or modified during the calls to mpi_comm_dup and mpi_comm_free?
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.
Cheers,
Jim Xia
XL Fortran Compiler Test
IBM Toronto Lab at 8200 Warden Ave, Markham, On, L6G 1C7
Phone (905) 413-3444 Tie-line 313-3444
email: jimxia at ca.ibm.com
D2/YF7/8200 /MKM
http://www.ibm.com/software/awdtools/fortran/xlfortran
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mpi-forum.org/pipermail/mpiwg-fortran/attachments/20090528/8eab22fc/attachment-0001.html>
More information about the mpiwg-fortran
mailing list