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

Malcolm Cohen malcolm at nag-j.co.jp
Sun Nov 20 22:28:26 CST 2022


Hi Jeff,

 

No, my_function is not compatible with MPI_User_function_f18 as it has different characteristics.

 

It is also unlikely to work in practice despite the Intel acceptance at compile time, as an assumed-rank descriptor is unlikely to be exactly the same as a Fortran-90 assumed-shapee array descriptor.

 

Also REAL is not compatible with TYPE(*) so it fails on that front too.

 

On a more philosophical note, I don’t quite see what purpose LEN is meant to achieve. Surely you just pass it the array slice you want to be reduced, no need to tell it the size separately, no?

 

Cheers,

-- 

..............Malcolm Cohen, NAG Oxford/Tokyo.

 

From: mpiwg-fortran <mpiwg-fortran-bounces at lists.mpi-forum.org> On Behalf Of Jeff Hammond via mpiwg-fortran
Sent: Monday, November 21, 2022 12:09 AM
To: MPI Forum <mpiwg-fortran at lists.mpi-forum.org>
Cc: Jeff Hammond <jeff.science at gmail.com>
Subject: [MPIWG Fortran] Fwd: proper modern Fortran support for user-defined reductions

 

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> 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 <mailto: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/20221121/d23260d4/attachment.html>


More information about the mpiwg-fortran mailing list