Skip to content

Commit edccf46

Browse files
authored
Merge pull request #9548 from awlauria/gfortran_updates
v5.0.x: grequest updates
2 parents 7fa73f1 + 8e4faed commit edccf46

File tree

1 file changed

+25
-4
lines changed

1 file changed

+25
-4
lines changed

ompi/request/grequest.c

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@
99
* University of Stuttgart. All rights reserved.
1010
* Copyright (c) 2004-2005 The Regents of the University of California.
1111
* All rights reserved.
12-
* Copyright (c) 2006-2012 Cisco Systems, Inc. All rights reserved.
12+
* Copyright (c) 2006-2021 Cisco Systems, Inc. All rights reserved
1313
* Copyright (c) 2009 Sun Microsystems, Inc. All rights reserved.
14+
* Copyright (c) 2021 IBM Corporation. All rights reserved.
1415
* $COPYRIGHT$
1516
*
1617
* Additional copyrights may follow
@@ -121,13 +122,20 @@ static void ompi_grequest_construct(ompi_grequest_t* greq)
121122
*/
122123
static void ompi_grequest_destruct(ompi_grequest_t* greq)
123124
{
124-
MPI_Fint ierr;
125-
126125
if (greq->greq_free.c_free != NULL) {
126+
/* We were already putting query_fn()'s return value into
127+
* status.MPI_ERROR but for MPI_{Wait,Test}*. If there's a
128+
* free callback to invoke, the standard says to use the
129+
* return value from free_fn() callback, too.
130+
*/
127131
if (greq->greq_funcs_are_c) {
128-
greq->greq_free.c_free(greq->greq_state);
132+
greq->greq_base.req_status.MPI_ERROR =
133+
greq->greq_free.c_free(greq->greq_state);
129134
} else {
135+
MPI_Fint ierr;
130136
greq->greq_free.f_free((MPI_Aint*)greq->greq_state, &ierr);
137+
greq->greq_base.req_status.MPI_ERROR =
138+
OMPI_FINT_2_INT(ierr);
131139
}
132140
}
133141

@@ -214,8 +222,21 @@ int ompi_grequest_invoke_query(ompi_request_t *request,
214222
if (g->greq_funcs_are_c) {
215223
rc = g->greq_query.c_query(g->greq_state, status);
216224
} else {
225+
/* request->req_status.MPI_ERROR was initialized to success
226+
* and it's meant to be unmodified in the case of callback
227+
* success, and set when callbacks return a failure. But
228+
* if we leave fstatus uninitialized this sets
229+
* req_status.MPI_ERROR to whatever happened to be on the
230+
* stack at fstatus (f_query isn't supposed to directly set
231+
* its status.MPI_ERROR, according to the standard)
232+
*
233+
* So the Status_c2f below only really cares about transferring
234+
* the MPI_ERROR setting into fstatus so that when it's transferred
235+
* back in the f2c call, it has the starting value.
236+
*/
217237
MPI_Fint ierr;
218238
MPI_Fint fstatus[sizeof(MPI_Status) / sizeof(int)];
239+
MPI_Status_c2f(status, fstatus);
219240
g->greq_query.f_query((MPI_Aint*)g->greq_state, fstatus, &ierr);
220241
MPI_Status_f2c(fstatus, status);
221242
rc = OMPI_FINT_2_INT(ierr);

0 commit comments

Comments
 (0)