From 0425a7a7d89a4a26e13f6cdb71a123a63b5df371 Mon Sep 17 00:00:00 2001 From: George Bosilca Date: Wed, 8 Jan 2020 16:07:36 -0500 Subject: [PATCH] Consistent return from all progress functions. This fix ensures that all progress functions return the number of completed events. Signed-off-by: George Bosilca (cherry picked from commit 72501f8f9c37b8db8dd08b274abd9774687a60cb) --- ompi/communicator/comm_request.c | 4 +++- ompi/mca/mtl/psm2/mtl_psm2.c | 2 +- ompi/request/grequest.c | 19 ++++++++++--------- ompi/request/grequestx.c | 4 +--- oshmem/mca/spml/ucx/spml_ucx_component.c | 11 ++++++----- 5 files changed, 21 insertions(+), 19 deletions(-) diff --git a/ompi/communicator/comm_request.c b/ompi/communicator/comm_request.c index 272fc33600..1ca5679ae0 100644 --- a/ompi/communicator/comm_request.c +++ b/ompi/communicator/comm_request.c @@ -100,6 +100,7 @@ static int ompi_comm_request_progress (void) { ompi_comm_request_t *request, *next; static int32_t progressing = 0; + int completed = 0; /* don't allow re-entry */ if (opal_atomic_swap_32 (&progressing, 1)) { @@ -121,6 +122,7 @@ static int ompi_comm_request_progress (void) if( REQUEST_COMPLETE(subreq) ) { ompi_request_free (&subreq); request_item->subreq_count--; + completed++; } else { item_complete = false; break; @@ -156,7 +158,7 @@ static int ompi_comm_request_progress (void) opal_mutex_unlock (&ompi_comm_request_mutex); progressing = 0; - return 1; + return completed; } void ompi_comm_request_start (ompi_comm_request_t *request) diff --git a/ompi/mca/mtl/psm2/mtl_psm2.c b/ompi/mca/mtl/psm2/mtl_psm2.c index 50f0d96fbc..086d824451 100644 --- a/ompi/mca/mtl/psm2/mtl_psm2.c +++ b/ompi/mca/mtl/psm2/mtl_psm2.c @@ -469,5 +469,5 @@ int ompi_mtl_psm2_progress( void ) { opal_show_help("help-mtl-psm2.txt", "error polling network", true, psm2_error_get_string(err)); - return 1; + return OMPI_ERROR; } diff --git a/ompi/request/grequest.c b/ompi/request/grequest.c index 10d8885d82..c895b4232b 100644 --- a/ompi/request/grequest.c +++ b/ompi/request/grequest.c @@ -202,14 +202,13 @@ int ompi_grequest_invoke_query(ompi_request_t *request, int rc = OMPI_SUCCESS; ompi_grequest_t *g = (ompi_grequest_t*) request; - /* MPI-2:8.2 does not say what to do with the return value from - the query function (i.e., the int return value from the C - function or the ierr argument from the Fortran function). - Making the command decision here to ignore it. If the handler - wants to pass an error back, it should set it in the MPI_ERROR - field in the status (which is always kept, regardless if the - top-level function was invoked with MPI_STATUS[ES]_IGNORE or - not). */ + /* MPI-3 mandates that the return value from the query function + * (i.e., the int return value from the C function or the ierr + * argument from the Fortran function) must be returned to the + * user. Thus, if the return of the query function is not MPI_SUCCESS + * we will update the MPI_ERROR field. Otherwise, the MPI_ERROR + * field is untouched (or left to the discretion of the query function). + */ if (NULL != g->greq_query.c_query) { if (g->greq_funcs_are_c) { rc = g->greq_query.c_query(g->greq_state, status); @@ -221,7 +220,9 @@ int ompi_grequest_invoke_query(ompi_request_t *request, rc = OMPI_FINT_2_INT(ierr); } } - + if( MPI_SUCCESS != rc ) { + status->MPI_ERROR = rc; + } return rc; } diff --git a/ompi/request/grequestx.c b/ompi/request/grequestx.c index 98678cef9a..739458db8f 100644 --- a/ompi/request/grequestx.c +++ b/ompi/request/grequestx.c @@ -44,13 +44,11 @@ static int grequestx_progress(void) { MPI_Status status; OPAL_THREAD_UNLOCK(&lock); request->greq_poll.c_poll(request->greq_state, &status); + OPAL_THREAD_LOCK(&lock); if (REQUEST_COMPLETE(&request->greq_base)) { - OPAL_THREAD_LOCK(&lock); opal_list_remove_item(&requests, &request->greq_base.super.super); - OPAL_THREAD_UNLOCK(&lock); completed++; } - OPAL_THREAD_LOCK(&lock); } in_progress = false; } diff --git a/oshmem/mca/spml/ucx/spml_ucx_component.c b/oshmem/mca/spml/ucx/spml_ucx_component.c index 5fd43bdbe5..a0348e972e 100644 --- a/oshmem/mca/spml/ucx/spml_ucx_component.c +++ b/oshmem/mca/spml/ucx/spml_ucx_component.c @@ -187,20 +187,21 @@ static int mca_spml_ucx_component_register(void) int spml_ucx_ctx_progress(void) { - int i; + int i, completed = 0; for (i = 0; i < mca_spml_ucx.active_array.ctxs_count; i++) { - ucp_worker_progress(mca_spml_ucx.active_array.ctxs[i]->ucp_worker[0]); + completed += ucp_worker_progress(mca_spml_ucx.active_array.ctxs[i]->ucp_worker[0]); } - return 1; + return completed; } int spml_ucx_default_progress(void) { unsigned int i=0; + int completed = 0; for (i = 0; i < mca_spml_ucx.ucp_workers; i++) { - ucp_worker_progress(mca_spml_ucx_ctx_default.ucp_worker[i]); + completed += ucp_worker_progress(mca_spml_ucx_ctx_default.ucp_worker[i]); } - return 1; + return completed; } int spml_ucx_progress_aux_ctx(void)