Skip to content

Commit b90c838

Browse files
committed
Refactor the request completion (#1422)
* Remodel the request. Added the wait sync primitive and integrate it into the PML and MTL infrastructure. The multi-threaded requests are now significantly less heavy and less noisy (only the threads associated with completed requests are signaled). * Fix the condition to release the request.
1 parent 1d31104 commit b90c838

32 files changed

+526
-445
lines changed

ompi/communicator/comm_request.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
* reseved.
55
* Copyright (c) 2015 Research Organization for Information Science
66
* and Technology (RIST). All rights reserved.
7+
* Copyright (c) 2004-2016 The University of Tennessee and The University
8+
* of Tennessee Research Foundation. All rights
9+
* reserved.
710
* $COPYRIGHT$
811
*
912
* Additional copyrights may follow
@@ -114,7 +117,7 @@ static int ompi_comm_request_progress (void)
114117
/* don't call ompi_request_test_all as it causes a recursive call into opal_progress */
115118
while (request_item->subreq_count) {
116119
ompi_request_t *subreq = request_item->subreqs[request_item->subreq_count-1];
117-
if (true == subreq->req_complete) {
120+
if( REQUEST_COMPLETE(subreq) ) {
118121
ompi_request_free (&subreq);
119122
request_item->subreq_count--;
120123
} else {
@@ -204,7 +207,7 @@ static int ompi_comm_request_free (struct ompi_request_t **ompi_req)
204207
{
205208
ompi_comm_request_t *request = (ompi_comm_request_t *) *ompi_req;
206209

207-
if (!(*ompi_req)->req_complete) {
210+
if( !REQUEST_COMPLETE(*ompi_req) ) {
208211
return MPI_ERR_REQUEST;
209212
}
210213

ompi/mca/coll/libnbc/coll_libnbc_component.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
44
* University Research and Technology
55
* Corporation. All rights reserved.
6-
* Copyright (c) 2004-2005 The University of Tennessee and The University
6+
* Copyright (c) 2004-2016 The University of Tennessee and The University
77
* of Tennessee Research Foundation. All rights
88
* reserved.
99
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
@@ -300,7 +300,7 @@ request_free(struct ompi_request_t **ompi_req)
300300
ompi_coll_libnbc_request_t *request =
301301
(ompi_coll_libnbc_request_t*) *ompi_req;
302302

303-
if (true != request->super.req_complete) {
303+
if( !REQUEST_COMPLETE(&request->super) ) {
304304
return MPI_ERR_REQUEST;
305305
}
306306

ompi/mca/io/ompio/io_ompio_request.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
44
* University Research and Technology
55
* Corporation. All rights reserved.
6-
* Copyright (c) 2004-2007 The University of Tennessee and The University
6+
* Copyright (c) 2004-2016 The University of Tennessee and The University
77
* of Tennessee Research Foundation. All rights
88
* reserved.
99
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
@@ -29,7 +29,7 @@ static int mca_io_ompio_request_free ( struct ompi_request_t **req)
2929
{
3030
mca_ompio_request_t *ompio_req = ( mca_ompio_request_t *)*req;
3131
if ( NULL != ompio_req->req_free_fn ) {
32-
ompio_req->req_free_fn (ompio_req );
32+
ompio_req->req_free_fn (ompio_req );
3333
}
3434
opal_list_remove_item (&mca_io_ompio_pending_requests, &ompio_req->req_item);
3535

@@ -65,7 +65,7 @@ void mca_io_ompio_request_destruct(mca_ompio_request_t* req)
6565
OMPI_REQUEST_FINI ( &(req->req_ompi));
6666
OBJ_DESTRUCT (&req->req_item);
6767
if ( NULL != req->req_data ) {
68-
free (req->req_data);
68+
free (req->req_data);
6969
}
7070

7171
return;
@@ -79,16 +79,16 @@ int mca_io_ompio_component_progress ( void )
7979

8080
OPAL_LIST_FOREACH(litem, &mca_io_ompio_pending_requests, opal_list_item_t) {
8181
req = GET_OMPIO_REQ_FROM_ITEM(litem);
82-
if ( true == req->req_ompi.req_complete ) {
83-
continue;
84-
}
82+
if( REQUEST_COMPLETE(&req->req_ompi) ) {
83+
continue;
84+
}
8585
if ( NULL != req->req_progress_fn ) {
8686
if ( req->req_progress_fn(req) ) {
8787
completed++;
8888
ompi_request_complete (&req->req_ompi, 1);
8989
/* The fbtl progress function is expected to set the
90-
** status elements
91-
*/
90+
* status elements
91+
*/
9292
}
9393
}
9494

ompi/mca/osc/pt2pt/osc_pt2pt_request.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
* Copyright (c) 2011-2012 Sandia National Laboratories. All rights reserved.
44
* Copyright (c) 2014 Los Alamos National Security, LLC. All rights
55
* reserved.
6+
* Copyright (c) 2016 The University of Tennessee and The University
7+
* of Tennessee Research Foundation. All rights
8+
* reserved.
69
* $COPYRIGHT$
710
*
811
* Additional copyrights may follow
@@ -32,7 +35,7 @@ request_free(struct ompi_request_t **ompi_req)
3235
ompi_osc_pt2pt_request_t *request =
3336
(ompi_osc_pt2pt_request_t*) *ompi_req;
3437

35-
if (true != request->super.req_complete) {
38+
if (REQUEST_COMPLETED != request->super.req_complete) {
3639
return MPI_ERR_REQUEST;
3740
}
3841

ompi/mca/osc/rdma/osc_rdma_request.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
* Copyright (c) 2011-2012 Sandia National Laboratories. All rights reserved.
44
* Copyright (c) 2014-2015 Los Alamos National Security, LLC. All rights
55
* reserved.
6+
* Copyright (c) 2016 The University of Tennessee and The University
7+
* of Tennessee Research Foundation. All rights
8+
* reserved.
69
* $COPYRIGHT$
710
*
811
* Additional copyrights may follow
@@ -30,7 +33,7 @@ static int request_free(struct ompi_request_t **ompi_req)
3033
ompi_osc_rdma_request_t *request =
3134
(ompi_osc_rdma_request_t*) *ompi_req;
3235

33-
if (true != request->super.req_complete) {
36+
if( REQUEST_COMPLETE(&request->super) ) {
3437
return MPI_ERR_REQUEST;
3538
}
3639

ompi/mca/pml/base/pml_base_recvreq.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
33
* University Research and Technology
44
* Corporation. All rights reserved.
5-
* Copyright (c) 2004-2010 The University of Tennessee and The University
5+
* Copyright (c) 2004-2016 The University of Tennessee and The University
66
* of Tennessee Research Foundation. All rights
77
* reserved.
88
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
@@ -78,7 +78,7 @@ OMPI_DECLSPEC OBJ_CLASS_DECLARATION(mca_pml_base_recv_request_t);
7878
(request)->req_base.req_sequence = 0; \
7979
(request)->req_base.req_datatype = datatype; \
8080
/* What about req_type ? */ \
81-
(request)->req_base.req_pml_complete = OPAL_INT_TO_BOOL(persistent); \
81+
(request)->req_base.req_pml_complete = false; \
8282
(request)->req_base.req_free_called = false; \
8383
}
8484
/**
@@ -99,7 +99,7 @@ OMPI_DECLSPEC OBJ_CLASS_DECLARATION(mca_pml_base_recv_request_t);
9999
(request)->req_ompi.req_status._ucount = 0; \
100100
(request)->req_ompi.req_status._cancelled = 0; \
101101
\
102-
(request)->req_ompi.req_complete = false; \
102+
(request)->req_ompi.req_complete = REQUEST_PENDING; \
103103
(request)->req_ompi.req_state = OMPI_REQUEST_ACTIVE; \
104104
} while (0)
105105

ompi/mca/pml/base/pml_base_request.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
44
* University Research and Technology
55
* Corporation. All rights reserved.
6-
* Copyright (c) 2004-2007 The University of Tennessee and The University
6+
* Copyright (c) 2004-2016 The University of Tennessee and The University
77
* of Tennessee Research Foundation. All rights
88
* reserved.
99
* Copyright (c) 2004-2008 High Performance Computing Center Stuttgart,
@@ -62,11 +62,11 @@ struct mca_pml_base_request_t {
6262

6363
/* START: These fields have to match the definition of the mca_pml_cm_request_t */
6464
ompi_request_t req_ompi; /**< base request */
65-
volatile bool req_pml_complete; /**< flag indicating if the pt-2-pt layer is done with this request */
65+
volatile int32_t req_pml_complete; /**< flag indicating if the pt-2-pt layer is done with this request */
66+
volatile int32_t req_free_called; /**< flag indicating if the user has freed this request */
6667
mca_pml_base_request_type_t req_type; /**< MPI request type - used for test */
6768
struct ompi_communicator_t *req_comm; /**< communicator pointer */
6869
struct ompi_datatype_t *req_datatype; /**< pointer to data type */
69-
volatile bool req_free_called; /**< flag indicating if the user has freed this request */
7070
opal_convertor_t req_convertor; /**< always need the convertor */
7171
/* END: These field have to match the definition of the mca_pml_cm_request_t */
7272

ompi/mca/pml/base/pml_base_sendreq.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
33
* University Research and Technology
44
* Corporation. All rights reserved.
5-
* Copyright (c) 2004-2007 The University of Tennessee and The University
5+
* Copyright (c) 2004-2016 The University of Tennessee and The University
66
* of Tennessee Research Foundation. All rights
77
* reserved.
88
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
@@ -88,7 +88,7 @@ OMPI_DECLSPEC OBJ_CLASS_DECLARATION( mca_pml_base_send_request_t );
8888
(request)->req_base.req_tag = (int32_t)tag; \
8989
(request)->req_base.req_comm = comm; \
9090
/* (request)->req_base.req_proc is set on request allocation */ \
91-
(request)->req_base.req_pml_complete = OPAL_INT_TO_BOOL(persistent); \
91+
(request)->req_base.req_pml_complete = false; \
9292
(request)->req_base.req_free_called = false; \
9393
(request)->req_base.req_ompi.req_status._cancelled = 0; \
9494
(request)->req_bytes_packed = 0; \
@@ -119,7 +119,7 @@ OMPI_DECLSPEC OBJ_CLASS_DECLARATION( mca_pml_base_send_request_t );
119119
#define MCA_PML_BASE_SEND_START( request ) \
120120
do { \
121121
(request)->req_pml_complete = false; \
122-
(request)->req_ompi.req_complete = false; \
122+
(request)->req_ompi.req_complete = REQUEST_PENDING; \
123123
(request)->req_ompi.req_state = OMPI_REQUEST_ACTIVE; \
124124
(request)->req_ompi.req_status._cancelled = 0; \
125125
} while (0)

ompi/mca/pml/cm/pml_cm_request.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
33
* University Research and Technology
44
* Corporation. All rights reserved.
5-
* Copyright (c) 2004-2007 The University of Tennessee and The University
5+
* Copyright (c) 2004-2016 The University of Tennessee and The University
66
* of Tennessee Research Foundation. All rights
77
* reserved.
88
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
@@ -42,11 +42,11 @@ struct mca_pml_cm_request_t {
4242

4343
/* START: These fields have to match the definition of the mca_pml_base_request_t */
4444
ompi_request_t req_ompi; /**< base request */
45-
volatile bool req_pml_complete; /**< flag indicating if the pt-2-pt layer is done with this request */
45+
volatile int32_t req_pml_complete; /**< flag indicating if the pt-2-pt layer is done with this request */
46+
volatile int32_t req_free_called; /**< flag indicating if the user has freed this request */
4647
mca_pml_cm_request_type_t req_pml_type;
4748
struct ompi_communicator_t *req_comm; /**< communicator pointer */
4849
struct ompi_datatype_t *req_datatype; /**< pointer to data type */
49-
volatile bool req_free_called; /**< flag indicating if the user has freed this request */
5050
opal_convertor_t req_convertor; /**< convertor that describes the memory layout */
5151
/* END: These fields have to match the definition of the mca_pml_base_request_t */
5252
};

ompi/mca/pml/ob1/pml_ob1_iprobe.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
33
* University Research and Technology
44
* Corporation. All rights reserved.
5-
* Copyright (c) 2004-2013 The University of Tennessee and The University
5+
* Copyright (c) 2004-2016 The University of Tennessee and The University
66
* of Tennessee Research Foundation. All rights
77
* reserved.
88
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
@@ -39,7 +39,7 @@ int mca_pml_ob1_iprobe(int src,
3939
MCA_PML_OB1_RECV_REQUEST_INIT(&recvreq, NULL, 0, &ompi_mpi_char.dt, src, tag, comm, true);
4040
MCA_PML_OB1_RECV_REQUEST_START(&recvreq);
4141

42-
if( recvreq.req_recv.req_base.req_ompi.req_complete == true ) {
42+
if( REQUEST_COMPLETE( &(recvreq.req_recv.req_base.req_ompi)) ) {
4343
if( NULL != status ) {
4444
*status = recvreq.req_recv.req_base.req_ompi.req_status;
4545
}
@@ -106,7 +106,7 @@ mca_pml_ob1_improbe(int src,
106106
src, tag, comm, false);
107107
MCA_PML_OB1_RECV_REQUEST_START(recvreq);
108108

109-
if( recvreq->req_recv.req_base.req_ompi.req_complete == true ) {
109+
if( REQUEST_COMPLETE( &(recvreq->req_recv.req_base.req_ompi)) ) {
110110
if( NULL != status ) {
111111
*status = recvreq->req_recv.req_base.req_ompi.req_status;
112112
}

ompi/mca/pml/ob1/pml_ob1_recvreq.c

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -71,28 +71,26 @@ static int mca_pml_ob1_recv_request_free(struct ompi_request_t** request)
7171
{
7272
mca_pml_ob1_recv_request_t* recvreq = *(mca_pml_ob1_recv_request_t**)request;
7373

74-
assert( false == recvreq->req_recv.req_base.req_free_called );
75-
76-
OPAL_THREAD_LOCK(&ompi_request_lock);
77-
recvreq->req_recv.req_base.req_free_called = true;
78-
79-
PERUSE_TRACE_COMM_EVENT( PERUSE_COMM_REQ_NOTIFY,
80-
&(recvreq->req_recv.req_base), PERUSE_RECV );
81-
82-
if( true == recvreq->req_recv.req_base.req_pml_complete ) {
83-
/* make buffer defined when the request is compeleted,
84-
and before releasing the objects. */
85-
MEMCHECKER(
86-
memchecker_call(&opal_memchecker_base_mem_defined,
87-
recvreq->req_recv.req_base.req_addr,
88-
recvreq->req_recv.req_base.req_count,
89-
recvreq->req_recv.req_base.req_datatype);
90-
);
74+
if(false == recvreq->req_recv.req_base.req_free_called){
75+
76+
recvreq->req_recv.req_base.req_free_called = true;
77+
PERUSE_TRACE_COMM_EVENT( PERUSE_COMM_REQ_NOTIFY,
78+
&(recvreq->req_recv.req_base), PERUSE_RECV );
79+
80+
if( true == recvreq->req_recv.req_base.req_pml_complete ) {
81+
/* make buffer defined when the request is compeleted,
82+
and before releasing the objects. */
83+
MEMCHECKER(
84+
memchecker_call(&opal_memchecker_base_mem_defined,
85+
recvreq->req_recv.req_base.req_addr,
86+
recvreq->req_recv.req_base.req_count,
87+
recvreq->req_recv.req_base.req_datatype);
88+
);
89+
90+
MCA_PML_OB1_RECV_REQUEST_RETURN( recvreq );
91+
}
9192

92-
MCA_PML_OB1_RECV_REQUEST_RETURN( recvreq );
9393
}
94-
95-
OPAL_THREAD_UNLOCK(&ompi_request_lock);
9694
*request = MPI_REQUEST_NULL;
9795
return OMPI_SUCCESS;
9896
}
@@ -126,14 +124,12 @@ static int mca_pml_ob1_recv_request_cancel(struct ompi_request_t* ompi_request,
126124
request->req_recv.req_base.req_pml_complete = true;
127125
OB1_MATCHING_UNLOCK(&ob1_comm->matching_lock);
128126

129-
OPAL_THREAD_LOCK(&ompi_request_lock);
130127
ompi_request->req_status._cancelled = true;
131128
/* This macro will set the req_complete to true so the MPI Test/Wait* functions
132129
* on this request will be able to complete. As the status is marked as
133130
* cancelled the cancel state will be detected.
134131
*/
135132
MCA_PML_OB1_RECV_REQUEST_MPI_COMPLETE(request);
136-
OPAL_THREAD_UNLOCK(&ompi_request_lock);
137133
/*
138134
* Receive request cancelled, make user buffer accessible.
139135
*/

0 commit comments

Comments
 (0)