Skip to content

Commit 49b2c6b

Browse files
committed
Add wait_sync_global_wakeup() to Qthreads and Argobots threading MCA.
Update copyright information. Signed-off-by: Jan Ciesko <[email protected]>
1 parent 4db2a50 commit 49b2c6b

File tree

4 files changed

+68
-0
lines changed

4 files changed

+68
-0
lines changed

opal/mca/threads/argobots/threads_argobots_wait_sync.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,30 @@
2121
static opal_mutex_t wait_sync_lock = OPAL_MUTEX_STATIC_INIT;
2222
static ompi_wait_sync_t *wait_sync_list = NULL;
2323

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

2650
#define WAIT_SYNC_PASS_OWNERSHIP(who) \

opal/mca/threads/argobots/threads_argobots_wait_sync.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,4 +103,14 @@ static inline int sync_wait_st(ompi_wait_sync_t *sync)
103103
} \
104104
} while (0)
105105

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

opal/mca/threads/qthreads/threads_qthreads_wait_sync.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,30 @@
2121
static opal_mutex_t wait_sync_lock = OPAL_MUTEX_STATIC_INIT;
2222
static ompi_wait_sync_t *wait_sync_list = NULL;
2323

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

2650
#define WAIT_SYNC_PASS_OWNERSHIP(who) \

opal/mca/threads/qthreads/threads_qthreads_wait_sync.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,4 +103,14 @@ static inline int sync_wait_st(ompi_wait_sync_t *sync)
103103
} while (0)
104104

105105

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

0 commit comments

Comments
 (0)