Skip to content
This repository was archived by the owner on Sep 30, 2022. It is now read-only.

Commit 9753665

Browse files
bosilcahjelmn
authored andcommitted
Make the request lock recursive.
If during the request completion callback we post another request that completes right away (such a small send or a match for an unexpected short message) we will try to complete the second request while holding the lock for the completion of the first. For performance reasons (mainly to avoid unlocking and locking the request mutex several times) we have made the request lock recursive. (cherry picked from commit open-mpi/ompi@bf19067) Signed-off-by: Nathan Hjelm <[email protected]>
1 parent b7f4c24 commit 9753665

File tree

4 files changed

+16
-16
lines changed

4 files changed

+16
-16
lines changed

ompi/mca/pml/ob1/pml_ob1_recvreq.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@ do { \
123123
*/
124124
#define MCA_PML_OB1_RECV_REQUEST_MPI_COMPLETE( recvreq ) \
125125
do { \
126-
PERUSE_TRACE_COMM_EVENT( PERUSE_COMM_REQ_COMPLETE, \
127-
&(recvreq->req_recv.req_base), PERUSE_RECV ); \
126+
PERUSE_TRACE_COMM_EVENT( PERUSE_COMM_REQ_COMPLETE, \
127+
&(recvreq->req_recv.req_base), PERUSE_RECV ); \
128128
ompi_request_complete( &(recvreq->req_recv.req_base.req_ompi), true ); \
129129
} while (0)
130130

ompi/mca/pml/ob1/pml_ob1_sendreq.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,10 +209,10 @@ do {
209209
(sendreq)->req_send.req_base.req_ompi.req_status.MPI_ERROR = OMPI_SUCCESS; \
210210
(sendreq)->req_send.req_base.req_ompi.req_status._ucount = \
211211
(sendreq)->req_send.req_bytes_packed; \
212-
ompi_request_complete( &((sendreq)->req_send.req_base.req_ompi), (with_signal) ); \
213-
\
214212
PERUSE_TRACE_COMM_EVENT( PERUSE_COMM_REQ_COMPLETE, \
215213
&(sendreq->req_send.req_base), PERUSE_SEND); \
214+
\
215+
ompi_request_complete( &((sendreq)->req_send.req_base.req_ompi), (with_signal) ); \
216216
} while(0)
217217

218218
static inline void mca_pml_ob1_send_request_fini (mca_pml_ob1_send_request_t *sendreq)

ompi/request/request.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ opal_pointer_array_t ompi_request_f_to_c_table = {{0}};
3636
size_t ompi_request_waiting = 0;
3737
size_t ompi_request_completed = 0;
3838
size_t ompi_request_failed = 0;
39-
opal_mutex_t ompi_request_lock = {{0}};
39+
opal_recursive_mutex_t ompi_request_lock = {{0}};
4040
opal_condition_t ompi_request_cond = {{0}};
4141
ompi_predefined_request_t ompi_request_null = {{{{{0}}}}};
4242
ompi_predefined_request_t *ompi_request_null_addr = &ompi_request_null;
@@ -109,7 +109,7 @@ OBJ_CLASS_INSTANCE(
109109

110110
int ompi_request_init(void)
111111
{
112-
OBJ_CONSTRUCT(&ompi_request_lock, opal_mutex_t);
112+
OBJ_CONSTRUCT(&ompi_request_lock, opal_recursive_mutex_t);
113113
OBJ_CONSTRUCT(&ompi_request_cond, opal_condition_t);
114114

115115
OBJ_CONSTRUCT(&ompi_request_null, ompi_request_t);

ompi/request/request.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -306,18 +306,18 @@ typedef struct ompi_request_fns_t {
306306
/**
307307
* Globals used for tracking requests and request completion.
308308
*/
309-
OMPI_DECLSPEC extern opal_pointer_array_t ompi_request_f_to_c_table;
310-
OMPI_DECLSPEC extern size_t ompi_request_waiting;
311-
OMPI_DECLSPEC extern size_t ompi_request_completed;
312-
OMPI_DECLSPEC extern size_t ompi_request_failed;
313-
OMPI_DECLSPEC extern int32_t ompi_request_poll;
314-
OMPI_DECLSPEC extern opal_mutex_t ompi_request_lock;
315-
OMPI_DECLSPEC extern opal_condition_t ompi_request_cond;
309+
OMPI_DECLSPEC extern opal_pointer_array_t ompi_request_f_to_c_table;
310+
OMPI_DECLSPEC extern size_t ompi_request_waiting;
311+
OMPI_DECLSPEC extern size_t ompi_request_completed;
312+
OMPI_DECLSPEC extern size_t ompi_request_failed;
313+
OMPI_DECLSPEC extern int32_t ompi_request_poll;
314+
OMPI_DECLSPEC extern opal_recursive_mutex_t ompi_request_lock;
315+
OMPI_DECLSPEC extern opal_condition_t ompi_request_cond;
316316
OMPI_DECLSPEC extern ompi_predefined_request_t ompi_request_null;
317317
OMPI_DECLSPEC extern ompi_predefined_request_t *ompi_request_null_addr;
318-
OMPI_DECLSPEC extern ompi_request_t ompi_request_empty;
319-
OMPI_DECLSPEC extern ompi_status_public_t ompi_status_empty;
320-
OMPI_DECLSPEC extern ompi_request_fns_t ompi_request_functions;
318+
OMPI_DECLSPEC extern ompi_request_t ompi_request_empty;
319+
OMPI_DECLSPEC extern ompi_status_public_t ompi_status_empty;
320+
OMPI_DECLSPEC extern ompi_request_fns_t ompi_request_functions;
321321

322322
/**
323323
* Initialize the MPI_Request subsystem; invoked during MPI_INIT.

0 commit comments

Comments
 (0)