[MPIWG Fortran] Fwd: proper modern Fortran support for user-defined reductions

Jeff Hammond jeff.science at gmail.com
Sun Nov 20 09:09:02 CST 2022


Brandon Cook raised an interesting issue w.r.t. user-defined reductions and
Fortran 2008 in https://github.com/mpi-forum/mpi-issues/issues/576.

I looked at this and it appears we can do something better (
https://github.com/mpi-forum/mpi-issues/issues/576#issuecomment-1317157138),
namely:

    abstract interface

    subroutine MPI_User_function_f18(invec, inoutvec, len, datatype)
        use mpi_f08, only : MPI_Datatype
        implicit none
        type(*), dimension(..), target, intent(in) :: invec
        type(*), dimension(..), target, intent(inout) :: inoutvec
        integer, intent(in) :: len
        type(MPI_Datatype), intent(in) :: datatype
    end subroutine

    end interface

which allows the user to create their own reduce functions, e.g.:

    subroutine MY_function(invec, inoutvec, len, datatype)
        use mpi_f08, only : MPI_Datatype
        implicit none
        real, dimension(:), target, intent(in) :: invec
        real, dimension(:), target, intent(inout) :: inoutvec
        integer, intent(in) :: len
        type(MPI_Datatype), intent(in) :: datatype
        inoutvec = inoutvec +  invec
    end subroutine

Do people think this is worth proposing for MPI-5?  It would require a new
MPI_Op_create function, but already did one for large-count.

Also, can a proper Fortran language lawyer like Bill Long confirm that
MY_function is compatible with the abstract interface above?  Intel Fortran
doesn't complain, but I want to be sure.

Thanks!

Jeff

--
Jeff Hammond
jeff.science at gmail.com
http://jeffhammond.github.io/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mpi-forum.org/pipermail/mpiwg-fortran/attachments/20221120/6d164816/attachment.html>


More information about the mpiwg-fortran mailing list