[MPIWG Fortran] An implementation problem of F08 binding

Bill Long longb at cray.com
Thu May 1 15:09:11 CDT 2014


On May 1, 2014, at 2:54 PM, Junchao Zhang <jczhang at mcs.anl.gov> wrote:

> If I am correct, Bill Long wants to inline the wrapper.

1) The probability of inlining is certainly increased, since the compiler knows where the referenced routine comes from.  

2) If the wrappers are in the module, there is only one interface to maintain, rather than having to ensure that the separate interfaces in mpi_f08 actually match the ones in the actual wrapper routines in a separate file. 

3) The issue of more meaningful error messages is already mentioned before.

4) It is clearer to both the user and compiler if the routine being called by a user MPI_Send is actually called MPI_Send.  If it is in the module, then the name is not visible outside and hence does not pollute the name space. 

5) Compiling the interfaces and wrappers always has to happen together (since the are in the same module) which prevents compilation mismatches.  This simplifies maintenance and reduces possible errors.   

Much of this is restating that a main motivation of modules in the first place was encapsulation of libraries.  MPI is such a library.

Item (1) helps performance.  With alternatives to MPI increasingly available, good performance is important.

Item (3) improves the usability of the library.

Items (2, 4, 5) improve maintainability and reduce implementation errors.


I’ll send out examples when I get out of the symposium I’m currently attending.


Cheers,
Bill


> 
> --Junchao Zhang
> 
> 
> On Thu, May 1, 2014 at 2:51 PM, Jeff Squyres (jsquyres) <jsquyres at cisco.com> wrote:
> On May 1, 2014, at 2:34 PM, Junchao Zhang <jczhang at mcs.anl.gov> wrote:
> 
> > Hello,
> >    I met a problem when implementing F08 binding in MPICH.  I have a file mpi_f08.F90, which contains all interfaces
> >
> > module mpi_f08
> > ..
> > interface MPI_Send
> >     subroutine MPI_Send_f08ts(buf, count, datatype, dest, tag, comm, ierror)
> >         use :: mpi_f08_types, only : MPI_Datatype, MPI_Comm
> >         implicit none
> >         type(*), dimension(..), intent(in) :: buf
> >         integer, intent(in) :: count, dest, tag
> >         type(MPI_Datatype), intent(in) :: datatype
> >         type(MPI_Comm), intent(in) :: comm
> >         integer, optional, intent(out) :: ierror
> >     end subroutine MPI_Send_f08ts
> > end interface MPI_Send
> > ..
> > end module mpi_f08
> >
> > Then for each subroutine, I create a separate file which implement the wrapper function in Fortran.  For example, send_f08ts.F90 has
> >
> > subroutine MPI_Send_f08ts(buf, count, datatype, dest, tag, comm, ierror)
> >     use :: mpi_f08, only : MPI_Datatype, MPI_Comm
> >     use, intrinsic :: iso_c_binding, only : c_int
> >     use :: mpi_c_interface, only : c_Datatype, c_Comm
> >     use :: mpi_c_interface, only : MPIR_Send_cdesc
> >
> >     implicit none
> >     ..
> > end subroutine MPI_Send_f08ts
> >
> > Bill Long pointed out problems of the implementation. 1) When users supply a bad argument to MPI_Send(), the compiler complains "No specific match can be found for the generic subprogram call MPI_SEND", instead of pointing out the offending arg.
> 
> Maybe Tobias, CC'ed, can shed light on why this is...
> 
> > 2) The wrapper is not in a module, which eliminates many of the advantages of using modern Fortran.
> 
> Can you explain what you mean by this?  There's still lots of advantages for using modern Fortran...
> 
> --
> Jeff Squyres
> jsquyres at cisco.com
> For corporate legal information go to: http://www.cisco.com/web/about/doing_business/legal/cri/
> 
> _______________________________________________
> mpiwg-fortran mailing list
> mpiwg-fortran at lists.mpi-forum.org
> http://lists.mpi-forum.org/mailman/listinfo.cgi/mpiwg-fortran
> 
> _______________________________________________
> mpiwg-fortran mailing list
> mpiwg-fortran at lists.mpi-forum.org
> http://lists.mpi-forum.org/mailman/listinfo.cgi/mpiwg-fortran

Bill Long                                                                       longb at cray.com
Fortran Technical Suport  &                                  voice:  651-605-9024
Bioinformatics Software Development                     fax:  651-605-9142
Cray Inc./ Cray Plaza, Suite 210/ 380 Jackson St./ St. Paul, MN 55101





More information about the mpiwg-fortran mailing list