Description
Problem
When calling MPI_Test
on a null request, what should the value of the MPI_ERROR
field of the status struct be set to? For example consider the following:
#include <mpi.h>
#include <stdio.h>
int main(int argc, char** argv) {
MPI_Init(NULL, NULL);
MPI_Request request;
int flag;
MPI_Status status;
request = MPI_REQUEST_NULL;
// poison the MPI_ERROR value
status.MPI_ERROR = 1;
MPI_Test(&request, &flag, &status);
printf("status.MPI_ERROR == MPI_SUCCESS: %d\n", status.MPI_ERROR == MPI_SUCCESS);
MPI_Finalize();
}
The standard has 2 conflicting statements:
Section 3.2.5 (Return Status) states that
In general, message-passing calls do not modify the value of the error code field of
status variables. This field may be updated only by the functions in Section 3.7.5 which
return multiple statuses. The field is updated if and only if such function returns with an
error code of MPI_ERR_IN_STATUS.Rationale. The error field in status is not needed for calls that return only one status,
such as MPI_WAIT, since that would only duplicate the information returned by the
function itself. The current design avoids the additional overhead of setting it, in such
cases. The field is needed for calls that return multiple statuses, since each request
may have had a different failure. (End of rationale.)
suggests that MPI_ERROR
should be unmodified by MPI_Test
in the above code.
On the other hand, section 3.7.3 (Communication Completion) states that
An empty status is a status which is set to
return tag = MPI_ANY_TAG, source = MPI_ANY_SOURCE, error = MPI_SUCCESS, and is
also internally configured so that calls to MPI_GET_COUNT, MPI_GET_ELEMENTS, and
MPI_GET_ELEMENTS_X return count = 0 and MPI_TEST_CANCELLED returns false.
and
One is allowed to call MPI_TEST with a null or inactive request argument. In such a
case the procedure returns with flag = true and empty status.
suggests that MPI_ERROR
should be set to MPI_SUCCESS
.
As you might guess, MPICH does the former, and Open MPI does the latter.
Proposal
Either:
a) being an "empty status" should not depend on the value of MPI_ERROR,
b) MPI_Test
(and MPI_Wait
) should modify MPI_ERROR when the request is null or inactive.
c) both (a) and allow (b)
d) require the field to be initialized as MPI_SUCCESS
Changes to the Text
Under option a), section 3.7.3 becomes:
An empty status is a status which is set to
return tag = MPI_ANY_TAG, source = MPI_ANY_SOURCE,error = MPI_SUCCESS,and is
also internally configured so that calls to MPI_GET_COUNT, MPI_GET_ELEMENTS, and
MPI_GET_ELEMENTS_X return count = 0 and MPI_TEST_CANCELLED returns false.
under option b), section 3.2.5 would need to be modified to allow functions to modify the value of the error field. I'm not sure the exact wording, but something like the following
In general, message-passing calls may or may not modify the value of the error code field of
status variables. This field may be updated by the functions in Section 3.7.5 which
return multiple statuses. The field is updated if such function returns with an
error code of MPI_ERR_IN_STATUS.
though this doesn't sound quite right.
I'm not sure how option d) would be worded.
Impact on Implementations
a) would require changes to Open MPI
b) would require changes to MPICH
c) would require no changes.
d) would require no changes.
Impact on Users
a) would change how users check if a status is empty
b) would require no changes
c) same as (a)
d) would require user to initialize status
objects before use or reuse.
References and Pull Requests
Metadata
Metadata
Assignees
Labels
Type
Projects
Status