[MPI3 Fortran] [Mpi-comments] MPI 3.0: Fortran 2008 interface - issue with the LOGICAL kind
Rolf Rabenseifner
rabenseifner at hlrs.de
Tue Mar 5 10:18:00 CST 2013
I fully agree with Jeff.
We have to clearly distinguish:
- (A) LOGICAL in normal MPI routines (e.g. MPI_Test)
- (B) LOGICAL in callbacks, and here
- (B1) the callback routines written by users
based on the ABSTRACT INTERFACEs,
- (B2) the predefined callback routines in the MPI lib,
- (B3) The MPI routines with callback PROCEDURE dummy arguments.
For (A), it would be an absolute no-go to change the
application's actual arguments, which may be an array of LOGICALs.
We did this for the handles and that should be enough of surprise.
We should first discuss (A) before we try to solve (B).
For (B), the minumum change should be done for the MPI-1 interface,
i.e., for MPI_OP_CREATE.
The proposal in #364 is mainly driven by the goal, that the user
do not see further changes for (A).
Additionally no surprises if the user uses (B3) in combination
with (B2).
Rolf
----- Original Message -----
> From: "Jeff Squyres (jsquyres)" <jsquyres at cisco.com>
> To: "MPI-3 Fortran working group" <mpi3-fortran at lists.mpi-forum.org>
> Cc: "Martin Schulz" <schulzm at llnl.gov>
> Sent: Tuesday, March 5, 2013 3:09:27 PM
> Subject: Re: [MPI3 Fortran] [Mpi-comments] MPI 3.0: Fortran 2008 interface - issue with the LOGICAL kind
> The problems I have with changing to any flavor of INTEGER are
> twofold:
>
> 1. Backwards incompatibility. Yes, mpi_f08 is new, but there's now
> nonzero number of codes out there that use it, and are therefore using
> default LOGICAL.
>
> 2. Violates the Law of Least Astonishment. For 15+ years, Fortran devs
> have been using default LOGICAL for MPI's boolean flags, and testing
> with .true. and .false.. Changing that to INTEGER (any flavor) would
> be downright weird.
>
>
> On Mar 4, 2013, at 7:57 PM, Craig Rasmussen <rasmus at cas.uoregon.edu>
> wrote:
>
> > I talked with Bill briefly on the phone and he suggested something
> > close to what we already do, namely use overloading to get around
> > the problem (see Bill's earlier comment on two levels of wrappers).
> >
> > We could switch to LOGICAL(C_BOOL) dummy arguments in all procedures
> > with BIND(C) interfaces. Then in addition we could overload these
> > functions (like MPI_Test) with thin wrappers that are required to
> > call the regular BIND(C) version so that the tools folks are happy.
> > Regular users would never know the difference. I suppose we could
> > actually use INTEGER(C_INT) in these interfaces rather than
> > LOGICAL(C_BOOL) as there is less chance of confusion and
> > INTEGER(C_INT) and LOGICAL can always different. Whereas
> > LOGICAL(C_BOOL) and LOGICAL may be the same type.
> >
> > Bill also suggested that replacing LOGICAL dummy arguments with
> > INTEGER(C_INT) in the callback routines would a safer way to go.
> >
> > Craig Rasmussen
> > CAS Scientific Programmer
> > rasmus at cas.uoregon.edu
> >
> >
> >
> >
> > On Mar 4, 2013, at 12:19 PM, Bill Long wrote:
> >
> >>
> >>
> >> On 3/4/13 1:26 PM, Tobias Burnus wrote:
> >>> Bill Long wrote:
> >>>>>
> >>>>> There isn't any difficulty about a Fortran wrapper using
> >>>>> integers (as
> >>>>> C does), and converting them to LOGICAL, but it can't be
> >>>>> BIND(C).
> >>>>
> >>>> There is also no difficulty in having the wrapper arguments being
> >>>> LOGICAL.
> >>>>
> >>>> subroutine sub (x) bind(c, name="MPI_xxx_f")
> >>>> logical :: x
> >>>> integer(int) :: cx
> >>>>
> >>>> cx = merge(1, 0, x)
> >>>
> >>> Well, except that compilers might simply reject a default-kind
> >>> LOGICAL
> >>> with BIND(C), in line with the Fortran standard.
> >>
> >> Ug. I tried 5 compilers. Three (Cray, Intel, PGI) just let it pass.
> >> One gave an error, and one gave a warning. What a mess. I'm more
> >> convinced now that before that the only practical solution here is
> >> to get rid of the LOGICAL arguments, replacing them with INTEGER
> >> arguments, which is what the C functions expect anyway.
> >> (Alternatively, the problem goes away if support for mpif.h is
> >> removed, which I would highly recommend anyway.)
> >>
> >> I'm trying to work out how to use two layers of wrapper functions
> >> to get around the error from that one compiler. Unattractive, to
> >> say the least.
> >>
> >> Cheers,
> >> Bill
> >>
> >>
> >>>
> >>> Your code above assumes that a Fortran compiler allows passing a
> >>> default-kind LOGICAL to a Bind(C) procedure and that it then can
> >>> handle
> >>> that LOGICAL. I think no one really doubts the second part. But
> >>> the
> >>> first part is not really covered by the Fortran standard and
> >>> standard-conforming compilers do exist, which reject default-kind
> >>> LOGICALs.
> >>>
> >>> J3/WG5 could change the standard such that it supports other
> >>> LOGICAL
> >>> kinds besides C_Bool, including kind(.true.). However, if
> >>> LOGICAL(kind=kind(.true.) / C_INT) exists, users will assume that
> >>> it
> >>> acts like C's "int", which will lead to problems. So far, I
> >>> haven't seen
> >>> a convincing proposal how to solve this.
> >>>
> >>> Tobias
> >>> _______________________________________________
> >>> mpi3-fortran mailing list
> >>> mpi3-fortran at lists.mpi-forum.org
> >>> http://lists.mpi-forum.org/mailman/listinfo.cgi/mpi3-fortran
> >>
> >> --
> >> Bill Long longb at cray.com
> >> Fortran Technical Support & voice: 651-605-9024
> >> Bioinformatics Software Development fax: 651-605-9142
> >> Cray Inc./Cray Plaza, Suite 210/380 Jackson St./St. Paul, MN 55101
> >>
> >>
> >> _______________________________________________
> >> mpi3-fortran mailing list
> >> mpi3-fortran at lists.mpi-forum.org
> >> http://lists.mpi-forum.org/mailman/listinfo.cgi/mpi3-fortran
> >
> > _______________________________________________
> > mpi3-fortran mailing list
> > mpi3-fortran at lists.mpi-forum.org
> > http://lists.mpi-forum.org/mailman/listinfo.cgi/mpi3-fortran
>
>
> --
> Jeff Squyres
> jsquyres at cisco.com
> For corporate legal information go to:
> http://www.cisco.com/web/about/doing_business/legal/cri/
>
>
> _______________________________________________
> mpi3-fortran mailing list
> mpi3-fortran at lists.mpi-forum.org
> http://lists.mpi-forum.org/mailman/listinfo.cgi/mpi3-fortran
--
Dr. Rolf Rabenseifner . . . . . . . . . .. email rabenseifner at hlrs.de
High Performance Computing Center (HLRS) . phone ++49(0)711/685-65530
University of Stuttgart . . . . . . . . .. fax ++49(0)711 / 685-65832
Head of Dpmt Parallel Computing . . . www.hlrs.de/people/rabenseifner
Nobelstr. 19, D-70550 Stuttgart, Germany . . . . (Office: Room 1.307)
More information about the mpiwg-fortran
mailing list