From 4a32b65ba2f2e27ad407418ecf3e5a7bef38528e Mon Sep 17 00:00:00 2001 From: George Bosilca Date: Wed, 20 Oct 2021 16:29:05 -0400 Subject: [PATCH] Const persistent requests A sketch of how not to change the user-facing request for persistent requests upon start. Signed-off-by: George Bosilca --- ompi/mca/pml/ob1/pml_ob1_sendreq.h | 35 ++++++++++++++------- ompi/mca/pml/ob1/pml_ob1_start.c | 50 +++++++++--------------------- ompi/request/request.h | 2 +- 3 files changed, 39 insertions(+), 48 deletions(-) diff --git a/ompi/mca/pml/ob1/pml_ob1_sendreq.h b/ompi/mca/pml/ob1/pml_ob1_sendreq.h index 80a4ae2f6b4..9a768b0e51e 100644 --- a/ompi/mca/pml/ob1/pml_ob1_sendreq.h +++ b/ompi/mca/pml/ob1/pml_ob1_sendreq.h @@ -46,6 +46,7 @@ typedef enum { struct mca_pml_ob1_send_request_t { mca_pml_base_send_request_t req_send; mca_bml_base_endpoint_t* req_endpoint; + mca_pml_base_request_t* req_parent; opal_ptr_t req_recv; opal_atomic_int32_t req_state; opal_atomic_int32_t req_lock; @@ -155,6 +156,7 @@ get_request_from_send_pending(mca_pml_ob1_send_pending_t *type) sendmode, \ persistent, \ 0); /* convertor_flags */ \ + (sendreq)->req_parent = NULL; \ (sendreq)->req_recv.pval = NULL; \ } @@ -198,18 +200,27 @@ static inline void mca_pml_ob1_free_rdma_resources (mca_pml_ob1_send_request_t* * Mark a send request as completed at the MPI level. */ -#define MCA_PML_OB1_SEND_REQUEST_MPI_COMPLETE(sendreq, with_signal) \ -do { \ - (sendreq)->req_send.req_base.req_ompi.req_status.MPI_SOURCE = \ - (sendreq)->req_send.req_base.req_comm->c_my_rank; \ - (sendreq)->req_send.req_base.req_ompi.req_status.MPI_TAG = \ - (sendreq)->req_send.req_base.req_tag; \ - (sendreq)->req_send.req_base.req_ompi.req_status._ucount = \ - (sendreq)->req_send.req_bytes_packed; \ - PERUSE_TRACE_COMM_EVENT( PERUSE_COMM_REQ_COMPLETE, \ - &(sendreq->req_send.req_base), PERUSE_SEND); \ - \ - ompi_request_complete( &((sendreq)->req_send.req_base.req_ompi), (with_signal) ); \ +#define MCA_PML_OB1_SEND_REQUEST_MPI_COMPLETE(sendreq, with_signal) \ +do { \ + (sendreq)->req_send.req_base.req_ompi.req_status.MPI_SOURCE = \ + (sendreq)->req_send.req_base.req_comm->c_my_rank; \ + (sendreq)->req_send.req_base.req_ompi.req_status.MPI_TAG = \ + (sendreq)->req_send.req_base.req_tag; \ + (sendreq)->req_send.req_base.req_ompi.req_status._ucount = \ + (sendreq)->req_send.req_bytes_packed; \ + if(NULL != (sendreq)->req_parent) { \ + PERUSE_TRACE_COMM_EVENT( PERUSE_COMM_REQ_COMPLETE, \ + &(sendreq->req_parent->req_base), PERUSE_SEND); \ + \ + ompi_request_complete( &(sendreq)->req_parent->req_ompi, (with_signal) ); \ + ompi_request_complete( &((sendreq)->req_send.req_base.req_ompi), false ); \ + (sendreq)->req_parent = NULL; /* dissociate from parent */ \ + } else { \ + PERUSE_TRACE_COMM_EVENT( PERUSE_COMM_REQ_COMPLETE, \ + &(sendreq->req_send.req_base), PERUSE_SEND); \ + \ + ompi_request_complete( &((sendreq)->req_send.req_base.req_ompi), (with_signal) ); \ + } \ } while(0) static inline void mca_pml_ob1_send_request_fini (mca_pml_ob1_send_request_t *sendreq) diff --git a/ompi/mca/pml/ob1/pml_ob1_start.c b/ompi/mca/pml/ob1/pml_ob1_start.c index 41795e007e5..eb9ce451ce7 100644 --- a/ompi/mca/pml/ob1/pml_ob1_start.c +++ b/ompi/mca/pml/ob1/pml_ob1_start.c @@ -50,51 +50,31 @@ int mca_pml_ob1_start(size_t count, ompi_request_t** requests) switch(pml_request->req_type) { case MCA_PML_REQUEST_SEND: { - mca_pml_ob1_send_request_t* sendreq = (mca_pml_ob1_send_request_t*)pml_request; + mca_pml_ob1_send_request_t* parentreq = (mca_pml_ob1_send_request_t*)pml_request; + mca_pml_ob1_send_request_t* sendreq = NULL; MEMCHECKER( memchecker_call(&opal_memchecker_base_isdefined, pml_request->req_addr, pml_request->req_count, pml_request->req_datatype); ); - if (!pml_request->req_pml_complete) { - ompi_request_t *request; - - /* buffered sends can be mpi complete and pml incomplete. to support this - * case we need to allocate a new request. */ - rc = mca_pml_ob1_isend_init (pml_request->req_addr, - pml_request->req_count, - pml_request->req_datatype, - pml_request->req_peer, - pml_request->req_tag, - sendreq->req_send.req_send_mode, - pml_request->req_comm, - &request); - if (OPAL_UNLIKELY(OMPI_SUCCESS != rc)) { - return rc; - } - - /* copy the callback and callback data to the new requests */ - request->req_complete_cb = pml_request->req_ompi.req_complete_cb; - request->req_complete_cb_data = pml_request->req_ompi.req_complete_cb_data; - - /* ensure the old request gets released */ - pml_request->req_free_called = true; - - sendreq = (mca_pml_ob1_send_request_t *) request; - requests[i] = request; - } else if (sendreq->req_send.req_bytes_packed != 0) { - size_t offset = 0; - /** - * Reset the convertor in case we're dealing with the original - * request, which when completed do not reset the convertor. - */ - opal_convertor_set_position (&sendreq->req_send.req_base.req_convertor, - &offset); + /* buffered sends can be mpi complete and pml incomplete. to support this + * case we need to allocate a new request. */ + rc = mca_pml_ob1_isend_init (pml_request->req_addr, + pml_request->req_count, + pml_request->req_datatype, + pml_request->req_peer, + pml_request->req_tag, + parentreq->req_send.req_send_mode, + pml_request->req_comm, + (ompi_request_t**)&(sendreq)); + if (OPAL_UNLIKELY(OMPI_SUCCESS != rc)) { + return rc; } /* reset the completion flag */ pml_request->req_pml_complete = false; + sendreq->req_parent = pml_request; MCA_PML_OB1_SEND_REQUEST_START(sendreq, rc); if(rc != OMPI_SUCCESS) diff --git a/ompi/request/request.h b/ompi/request/request.h index 0e6fb80cbf7..72e4321095f 100644 --- a/ompi/request/request.h +++ b/ompi/request/request.h @@ -129,7 +129,7 @@ struct ompi_request_t { ompi_status_public_t req_status; /**< Completion status */ volatile void *req_complete; /**< Flag indicating wether request has completed */ volatile ompi_request_state_t req_state; /**< enum indicate state of the request */ - bool req_persistent; /**< flag indicating if the this is a persistent request */ + bool req_persistent; /**< flag indicating if this is a persistent request */ int req_f_to_c_index; /**< Index in Fortran <-> C translation array */ ompi_request_start_fn_t req_start; /**< Called by MPI_START and MPI_STARTALL */ ompi_request_free_fn_t req_free; /**< Called by free */