Skip to content

Commit 0d1336b

Browse files
markallejjhursey
authored andcommitted
osc/pt2pt: Fix Lock/Unlock and Get wrong answer
* When using `MPI_Lock`/`MPI_Unlock` with `MPI_Get` and non-contiguous datatypes is is possible that the unlock finishes too early before the data is actually present in the recv buffer. * We need to wait for the irecv to complete before unlocking the target. This commit waits for the outgoing fragment counts to become equal before unlocking. Signed-off-by: Joshua Hursey <[email protected]>
1 parent 1ebf9fd commit 0d1336b

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

ompi/mca/osc/pt2pt/osc_pt2pt_passive_target.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* All rights reserved.
1111
* Copyright (c) 2007-2016 Los Alamos National Security, LLC. All rights
1212
* reserved.
13-
* Copyright (c) 2010 IBM Corporation. All rights reserved.
13+
* Copyright (c) 2010-2016 IBM Corporation. All rights reserved.
1414
* Copyright (c) 2012-2013 Sandia National Laboratories. All rights reserved.
1515
* Copyright (c) 2015 Intel, Inc. All rights reserved.
1616
* Copyright (c) 2015-2016 Research Organization for Information Science
@@ -421,6 +421,16 @@ static int ompi_osc_pt2pt_unlock_internal (int target, ompi_win_t *win)
421421
/* wait for unlock acks. this signals remote completion of fragments */
422422
ompi_osc_pt2pt_sync_wait_expected (lock);
423423

424+
/* It is possible for the unlock to finish too early before the data
425+
* is actually present in the recv buffer (for non-contiguous datatypes)
426+
* So make sure to wait for all of the fragments to arrive.
427+
*/
428+
OPAL_THREAD_LOCK(&module->lock);
429+
while (module->outgoing_frag_count < module->outgoing_frag_signal_count) {
430+
opal_condition_wait(&module->cond, &module->lock);
431+
}
432+
OPAL_THREAD_UNLOCK(&module->lock);
433+
424434
OPAL_OUTPUT_VERBOSE((25, ompi_osc_base_framework.framework_output,
425435
"ompi_osc_pt2pt_unlock: unlock of %d complete", target));
426436
} else {

0 commit comments

Comments
 (0)