Skip to content

Commit efbf926

Browse files
committed
ompi/request: Fix a persistent request creation bug
According to the MPI-3.1 p.52 and p.53 (cited below), a request created by `MPI_*_INIT` but not yet started by `MPI_START` or `MPI_STARTALL` is inactive therefore `MPI_WAIT` or its friends must return immediately if such a request is passed. The current implementation hangs in `MPI_WAIT` and its friends in such case because a persistent request is initialized as `req_complete = REQUEST_PENDING`. This commit fixes the initialization. Also, this commit fixes internal requests used in `MPI_PROBE` and `MPI_IPROBE` which was marked wrongly as persistent. MPI-3.1 p.52: We shall use the following terminology: A null handle is a handle with value MPI_REQUEST_NULL. A persistent request and the handle to it are inactive if the request is not associated with any ongoing communication (see Section 3.9). A handle is active if it is neither null nor inactive. 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. We set a status variable to empty when the value returned by it is not significant. Status is set in this way so as to prevent errors due to accesses of stale information. MPI-3.1 p.53: One is allowed to call MPI_WAIT with a null or inactive request argument. In this case the operation returns immediately with empty status. Signed-off-by: KAWASHIMA Takahiro <[email protected]> (back-ported from commit 6510800)
1 parent d0b97d7 commit efbf926

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

ompi/mca/pml/ob1/pml_ob1_iprobe.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ int mca_pml_ob1_iprobe(int src,
3636
recvreq.req_recv.req_base.req_ompi.req_type = OMPI_REQUEST_PML;
3737
recvreq.req_recv.req_base.req_type = MCA_PML_REQUEST_IPROBE;
3838

39-
MCA_PML_OB1_RECV_REQUEST_INIT(&recvreq, NULL, 0, &ompi_mpi_char.dt, src, tag, comm, true);
39+
MCA_PML_OB1_RECV_REQUEST_INIT(&recvreq, NULL, 0, &ompi_mpi_char.dt, src, tag, comm, false);
4040
MCA_PML_OB1_RECV_REQUEST_START(&recvreq);
4141

4242
if( REQUEST_COMPLETE( &(recvreq.req_recv.req_base.req_ompi)) ) {
@@ -66,7 +66,7 @@ int mca_pml_ob1_probe(int src,
6666
recvreq.req_recv.req_base.req_ompi.req_type = OMPI_REQUEST_PML;
6767
recvreq.req_recv.req_base.req_type = MCA_PML_REQUEST_PROBE;
6868

69-
MCA_PML_OB1_RECV_REQUEST_INIT(&recvreq, NULL, 0, &ompi_mpi_char.dt, src, tag, comm, true);
69+
MCA_PML_OB1_RECV_REQUEST_INIT(&recvreq, NULL, 0, &ompi_mpi_char.dt, src, tag, comm, false);
7070
MCA_PML_OB1_RECV_REQUEST_START(&recvreq);
7171

7272
ompi_request_wait_completion(&recvreq.req_recv.req_base.req_ompi);

ompi/request/request.h

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -142,13 +142,14 @@ typedef struct ompi_predefined_request_t ompi_predefined_request_t;
142142
* performance path (since requests may be re-used, it is possible
143143
* that we will have to initialize a request multiple times).
144144
*/
145-
#define OMPI_REQUEST_INIT(request, persistent) \
146-
do { \
147-
(request)->req_complete = REQUEST_PENDING; \
148-
(request)->req_state = OMPI_REQUEST_INACTIVE; \
149-
(request)->req_persistent = (persistent); \
150-
(request)->req_complete_cb = NULL; \
151-
(request)->req_complete_cb_data = NULL; \
145+
#define OMPI_REQUEST_INIT(request, persistent) \
146+
do { \
147+
(request)->req_complete = \
148+
(persistent) ? REQUEST_COMPLETED : REQUEST_PENDING; \
149+
(request)->req_state = OMPI_REQUEST_INACTIVE; \
150+
(request)->req_persistent = (persistent); \
151+
(request)->req_complete_cb = NULL; \
152+
(request)->req_complete_cb_data = NULL; \
152153
} while (0);
153154

154155

0 commit comments

Comments
 (0)