Skip to content

Commit 0d49c87

Browse files
committed
Reduce atomic operations by checking for empty list
Signed-off-by: Joseph Schuchart <schuchart@icl.utk.edu>
1 parent 0d2a0d0 commit 0d49c87

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

ompi/mpiext/continue/c/continuation.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -317,12 +317,12 @@ int ompi_continue_progress_n(const uint32_t max, thread_local_data_t *tld)
317317
if (!opal_list_is_empty(&continuation_list)) {
318318
/* global progress */
319319
//TODO: steal some requests and process them in chunks to reduce locking?
320-
while (max > completed) {
320+
while (max > completed && !opal_list_is_empty(&continuation_list)) {
321321
ompi_continuation_t *cont;
322322
if (using_threads) {
323-
OPAL_THREAD_LOCK(&request_cont_lock);
323+
opal_mutex_atomic_lock(&request_cont_lock);
324324
cont = (ompi_continuation_t*)opal_list_remove_first(&continuation_list);
325-
OPAL_THREAD_UNLOCK(&request_cont_lock);
325+
opal_mutex_atomic_unlock(&request_cont_lock);
326326
} else {
327327
cont = (ompi_continuation_t*)opal_list_remove_first(&continuation_list);
328328
}
@@ -733,13 +733,13 @@ static int request_completion_cb(ompi_request_t *request)
733733
while (cont->cont_request_check) {}
734734
/* we own the request so release it and let the caller know */
735735
ompi_request_free(&request);
736-
rc = 1;
737736
}
738737
opal_atomic_wmb();
739-
int32_t num_active = OPAL_THREAD_ADD_FETCH32(&cont->cont_num_active, -1);
738+
//int32_t num_active = OPAL_THREAD_ADD_FETCH32(&cont->cont_num_active, -1);
740739

741-
if (0 == num_active) {
740+
if (1 == cont->cont_num_active || 0 == OPAL_THREAD_ADD_FETCH32(&cont->cont_num_active, -1)) {
742741
/* the continuation is ready for execution */
742+
cont->cont_num_active = 0;
743743
ompi_continue_enqueue_runnable(cont);
744744
}
745745

0 commit comments

Comments
 (0)