mpi-forum / mpi-issues

Tickets for the MPI Forum
http://www.mpi-forum.org/
67 stars 8 forks source link

what is the purpose of MPI_F_STATUS_IGNORE? #837

Closed jeffhammond closed 8 months ago

jeffhammond commented 8 months ago

Problem

@dalcinl and I were looking at this yesterday and trying to figure out why we have a way to test for only these two Fortran buffer sentinels, and no others.

My hypothesis is that these are used to write tools interception of the Fortran interface in C, because tools may look at the status coming back out from the implementation to know how many bytes are written.

Does anyone actually use these? The only references I can find online are to cases where they are broken by compiler optimization.

Two global variables of type MPI_Fint*, MPI_F_STATUS_IGNORE and MPI_F_STATUSES_IGNORE are declared in mpi.h. They can be used to test, in C, whether f_status is the Fortran value of MPI_STATUS_IGNORE or MPI_STATUSES_IGNORE defined in the mpi module or (deprecated) mpif.h. These are global variables, not C constant expressions and cannot be used in places where C requires constant expressions. Their value is defined only between the calls to MPI_INIT and MPI_FINALIZE and should not be changed by user code.

Proposal

There should be rationale/advice about what these are for, because it's not obvious why they exist and why other buffer sentinels are not.

Changes to the Text

TODO

Impact on Implementations

None

Impact on Users

Probably none

References and Pull Requests

ABI

wrwilliams commented 8 months ago

My hypothesis is that these are used to write tools interception of the Fortran interface in C, because tools may look at the status coming back out from the implementation to know how many bytes are written.

This is indeed a tools thing; in Score-P we look at status for all requests--not only the size but the source and tag (for message matching in trace files) and cancellation checking. And, for this reason, a STATUS_IGNORE argument from the user gets replaced with a tool-allocated status/array of statuses which we then will restore on the way back out.

jeffhammond commented 8 months ago

Does Score-P intercept the Fortran API with C code? That is, do you use MPI_F_STATUS_IGNORE?

jprotze commented 8 months ago

MUST handles the value through wrap.py: https://github.com/LLNL/wrap/blob/81ab913690105d6810e4545caf610db1e7596f52/wrap.py#L1253

If the value from Fortran is equal this value, we don't use status_c2f to return the status to Fortran and we pass status ignore to the pmpi call.

I think, having similar values for sentinels like mpi_bottom would make the life much easier :)

wrwilliams commented 8 months ago

Does Score-P intercept the Fortran API with C code? That is, do you use MPI_F_STATUS_IGNORE?

Yes and yes-ish. We have a callback mechanism that grabs the value of MPI_F_STATUS_IGNORE and caches it as a C variable, which is gross but apparently necessary in some cases.

mahermanns commented 8 months ago

@jeffhammond Does this answer your question?