Skip to content

Commit 1b46fe2

Browse files
committed
pml/ob1: fix mca_pml_ob1_progress_needed usage
correctly use OPAL_ATOMIC_ADD32() that returns the *new* value and *not* the previous one. Signed-off-by: Gilles Gouaillardet <[email protected]>
1 parent 771f51a commit 1b46fe2

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

ompi/mca/pml/ob1/pml_ob1_progress.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
* University of Stuttgart. All rights reserved.
1111
* Copyright (c) 2004-2005 The Regents of the University of California.
1212
* All rights reserved.
13+
* Copyright (c) 2017 Research Organization for Information Science
14+
* and Technology (RIST). All rights reserved.
1315
* $COPYRIGHT$
1416
*
1517
* Additional copyrights may follow
@@ -54,8 +56,8 @@ static inline int mca_pml_ob1_process_pending_cuda_async_copies(void)
5456
static int mca_pml_ob1_progress_needed = 0;
5557
int mca_pml_ob1_enable_progress(int32_t count)
5658
{
57-
int32_t old = OPAL_ATOMIC_ADD32(&mca_pml_ob1_progress_needed, count);
58-
if( 0 != old )
59+
int32_t progress_count = OPAL_ATOMIC_ADD32(&mca_pml_ob1_progress_needed, count);
60+
if( 1 < progress_count )
5961
return 0; /* progress was already on */
6062

6163
opal_progress_register(mca_pml_ob1_progress);
@@ -118,7 +120,7 @@ int mca_pml_ob1_progress(void)
118120

119121
if( 0 != completed_requests ) {
120122
j = OPAL_ATOMIC_ADD32(&mca_pml_ob1_progress_needed, -completed_requests);
121-
if( j == completed_requests ) {
123+
if( 0 == j ) {
122124
opal_progress_unregister(mca_pml_ob1_progress);
123125
}
124126
}

0 commit comments

Comments
 (0)