Skip to content

Commit 43c21f4

Browse files
opal/mca/threads/argobots: implement wait_sync_global_wakeup()
Signed-off-by: Shintaro Iwasaki <siwasaki@anl.gov>
1 parent 8baab96 commit 43c21f4

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

opal/mca/threads/argobots/threads_argobots_wait_sync.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* reserved.
88
* Copyright (c) 2017 IBM Corporation. All rights reserved.
99
* Copyright (c) 2019 Sandia National Laboratories. All rights reserved.
10+
* Copyright (c) 2021 Argonne National Laboratory. All rights reserved.
1011
*
1112
* $COPYRIGHT$
1213
*
@@ -21,6 +22,32 @@
2122
static opal_mutex_t wait_sync_lock = OPAL_MUTEX_STATIC_INIT;
2223
static ompi_wait_sync_t *wait_sync_list = NULL;
2324

25+
void wait_sync_global_wakeup_st(int status)
26+
{
27+
ompi_wait_sync_t *sync;
28+
for (sync = wait_sync_list; sync != NULL; sync = sync->next) {
29+
wait_sync_update(sync, 0, status);
30+
}
31+
}
32+
33+
void wait_sync_global_wakeup_mt(int status)
34+
{
35+
ompi_wait_sync_t *sync;
36+
opal_mutex_lock(&wait_sync_lock);
37+
for (sync = wait_sync_list; sync != NULL; sync = sync->next) {
38+
/* sync_update is going to take the sync->lock from within
39+
* the wait_sync_lock. Thread lightly here: Idealy we should
40+
* find a way to not take a lock in a lock as this is deadlock prone,
41+
* but as of today we are the only place doing this so it is safe.
42+
*/
43+
wait_sync_update(sync, 0, status);
44+
if (sync->next == wait_sync_list) {
45+
break; /* special case for rings */
46+
}
47+
}
48+
opal_mutex_unlock(&wait_sync_lock);
49+
}
50+
2451
static opal_atomic_int32_t num_thread_in_progress = 0;
2552

2653
#define WAIT_SYNC_PASS_OWNERSHIP(who) \

opal/mca/threads/argobots/threads_argobots_wait_sync.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
* Copyright (c) 2015 Research Organization for Information Science
1616
* and Technology (RIST). All rights reserved.
1717
* Copyright (c) 2019 Sandia National Laboratories. All rights reserved.
18+
* Copyright (c) 2021 Argonne National Laboratory. All rights reserved.
1819
*
1920
* $COPYRIGHT$
2021
*
@@ -100,4 +101,14 @@ static inline int sync_wait_st(ompi_wait_sync_t *sync)
100101
} \
101102
} while (0)
102103

104+
/**
105+
* Wake up all syncs with a particular status. If status is OMPI_SUCCESS this
106+
* operation is a NO-OP. Otherwise it will trigger the "error condition" from
107+
* all registered sync.
108+
*/
109+
OPAL_DECLSPEC void wait_sync_global_wakeup_st(int status);
110+
OPAL_DECLSPEC void wait_sync_global_wakeup_mt(int status);
111+
#define wait_sync_global_wakeup(st) \
112+
(opal_using_threads() ? wait_sync_global_wakeup_mt(st) : wait_sync_global_wakeup_st(st))
113+
103114
#endif /* OPAL_MCA_THREADS_ARGOBOTS_THREADS_ARGOBOTS_WAIT_SYNC_H */

0 commit comments

Comments
 (0)