[mpich-discuss] Wrapping routines with choice buffers from Fortran

Zhou, Hui zhouh at anl.gov
Mon Feb 24 15:41:54 CST 2025


Hi Gregor,

Thanks for bring up the Fortran profiling interface issue. Admittedly, we have not discussed such issues thoroughly yet. I believe the truth lies in the consensus and you are the first real user I hear from 😉 .

Yes, it appears that the Fortran PMPI_ should call C PMPI_ functions to avoid double profiling. Opinions?

--
Hui
________________________________
From: Gregor Corbin via discuss <discuss at mpich.org>
Sent: Thursday, February 20, 2025 9:56 AM
To: discuss at mpich.org <discuss at mpich.org>
Cc: Gregor Corbin <g.corbin at fz-juelich.de>
Subject: [mpich-discuss] Wrapping routines with choice buffers from Fortran

Hi everyone,

I am developing a set of wrappers for the C and Fortran 2008 ('use
mpi_f08') bindings. The F08 wrappers are intercepting the Fortran
routines, for instance

     subroutine mpi_send_f08ts_(buf, count, datatype, dest, tag, comm,
ierror)
         use :: mpi_f08, only: MPI_Comm, MPI_Datatype, PMPI_Send
         implicit none
         ! argument declarations ...
         ! wrapper code ...
         call PMPI_Send(buf, count, datatype, dest, tag, comm, ierror)
     end subroutine


In MPICH, the call to PMPI_Send is forwarded to MPIR_Send_cdesc which
then calls MPI_Send internally. Since I also wrap MPI_Send in C, calls
from Fortran go through both wrappers, which is not intended. This only
happens for routines with choice buffers, though. Routines without
buffers call into the PMPI interface (e.g. mpi_wait_f08_ calls
MPIR_Wait_c which binds directly to PMPI_Wait). I attached a small
example that demonstrates the issue.

Is this behavior intended? How can I correctly wrap these choice buffer
routines?

Best,

Gregor Corbin



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mpich.org/pipermail/discuss/attachments/20250224/b9a8e58b/attachment.html>


More information about the discuss mailing list