Skip to content

Commit 58244b3

Browse files
author
Thananon Patinyasakdikul
authored
Merge pull request #6320 from thananon/pr/wait_sync_fix
opal/threads: reverted #6199
2 parents 2c8f745 + 56d3e0a commit 58244b3

File tree

1 file changed

+20
-27
lines changed

1 file changed

+20
-27
lines changed

opal/threads/wait_sync.c

Lines changed: 20 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -47,19 +47,17 @@ int ompi_sync_wait_mt(ompi_wait_sync_t *sync)
4747
}
4848

4949
/* Insert sync on the list of pending synchronization constructs */
50-
if (num_thread_in_progress >= opal_max_thread_in_progress) {
51-
OPAL_THREAD_LOCK(&wait_sync_lock);
52-
if( NULL == wait_sync_list ) {
53-
sync->next = sync->prev = sync;
54-
wait_sync_list = sync;
55-
} else {
56-
sync->prev = wait_sync_list->prev;
57-
sync->prev->next = sync;
58-
sync->next = wait_sync_list;
59-
wait_sync_list->prev = sync;
60-
}
61-
OPAL_THREAD_UNLOCK(&wait_sync_lock);
50+
OPAL_THREAD_LOCK(&wait_sync_lock);
51+
if( NULL == wait_sync_list ) {
52+
sync->next = sync->prev = sync;
53+
wait_sync_list = sync;
54+
} else {
55+
sync->prev = wait_sync_list->prev;
56+
sync->prev->next = sync;
57+
sync->next = wait_sync_list;
58+
wait_sync_list->prev = sync;
6259
}
60+
OPAL_THREAD_UNLOCK(&wait_sync_lock);
6361

6462
/**
6563
* If we are not responsible for progresing, go silent until something worth noticing happen:
@@ -91,23 +89,18 @@ int ompi_sync_wait_mt(ompi_wait_sync_t *sync)
9189
}
9290
OPAL_THREAD_ADD_FETCH32(&num_thread_in_progress, -1);
9391

94-
if (NULL != wait_sync_list) {
95-
assert(sync == wait_sync_list);
96-
}
97-
9892
i_am_done:
9993
/* My sync is now complete. Trim the list: remove self, wake next */
100-
if (num_thread_in_progress >= opal_max_thread_in_progress) {
101-
OPAL_THREAD_LOCK(&wait_sync_lock);
102-
sync->prev->next = sync->next;
103-
sync->next->prev = sync->prev;
104-
/* In case I am the progress manager, pass the duties on */
105-
if( sync == wait_sync_list ) {
106-
wait_sync_list = (sync == sync->next) ? NULL : sync->next;
107-
if( NULL != wait_sync_list )
108-
WAIT_SYNC_PASS_OWNERSHIP(wait_sync_list);
109-
}
110-
OPAL_THREAD_UNLOCK(&wait_sync_lock);
94+
OPAL_THREAD_LOCK(&wait_sync_lock);
95+
sync->prev->next = sync->next;
96+
sync->next->prev = sync->prev;
97+
/* In case I am the progress manager, pass the duties on */
98+
if( sync == wait_sync_list ) {
99+
wait_sync_list = (sync == sync->next) ? NULL : sync->next;
100+
if( NULL != wait_sync_list )
101+
WAIT_SYNC_PASS_OWNERSHIP(wait_sync_list);
111102
}
103+
OPAL_THREAD_UNLOCK(&wait_sync_lock);
104+
112105
return (0 == sync->status) ? OPAL_SUCCESS : OPAL_ERROR;
113106
}

0 commit comments

Comments
 (0)