Skip to content

Commit 6cdb2df

Browse files
committed
address some feedback from PR review
Signed-off-by: Howard Pritchard <hppritcha@gmail.com>
1 parent 3f6b636 commit 6cdb2df

15 files changed

+99
-144
lines changed

opal/mca/threads/argobots/threads_argobots_component.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@
3131

3232
static int opal_threads_argobots_open(void);
3333

34-
const opal_threads_base_component_2_0_0_t mca_threads_argobots_component = {
34+
const opal_threads_base_component_1_0_0_t mca_threads_argobots_component = {
3535
/* First, the mca_component_t struct containing meta information
3636
about the component itself */
3737
.threadsc_version = {
38-
OPAL_THREADS_BASE_VERSION_2_0_0,
38+
OPAL_THREADS_BASE_VERSION_1_0_0,
3939

4040
/* Component name and version */
4141
.mca_component_name = "argobots",

opal/mca/threads/argobots/threads_argobots_event.c

Lines changed: 70 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ static void *
1111
evthread_argobots_lock_alloc(unsigned locktype)
1212
{
1313
ABT_mutex lock;
14-
if (locktype & EVTHREAD_LOCKTYPE_RECURSIVE) {
14+
if (locktype & EVTHREAD_LOCKTYPE_RECURSIVE) {
1515
ABT_mutex_attr abt_mutex_attr;
1616
ABT_mutex_attr_create(&abt_mutex_attr);
1717
ABT_mutex_attr_set_recursive(abt_mutex_attr, ABT_TRUE);
@@ -20,117 +20,117 @@ evthread_argobots_lock_alloc(unsigned locktype)
2020
} else {
2121
ABT_mutex_create(&lock);
2222
}
23-
return lock;
23+
return lock;
2424
}
2525

2626
static void
2727
evthread_argobots_lock_free(void *_lock, unsigned locktype)
2828
{
29-
ABT_mutex lock = _lock;
30-
ABT_mutex_free(&lock);
29+
ABT_mutex lock = _lock;
30+
ABT_mutex_free(&lock);
3131
}
3232

3333
static int
3434
evthread_argobots_lock(unsigned mode, void *_lock)
3535
{
36-
int ret;
37-
ABT_mutex lock = _lock;
38-
if (mode & EVTHREAD_TRY) {
39-
ret = ABT_mutex_trylock(lock);
40-
} else {
41-
ret = ABT_mutex_lock(lock);
42-
}
43-
return ret;
36+
int ret;
37+
ABT_mutex lock = _lock;
38+
if (mode & EVTHREAD_TRY) {
39+
ret = ABT_mutex_trylock(lock);
40+
} else {
41+
ret = ABT_mutex_lock(lock);
42+
}
43+
return ret;
4444
}
4545

4646
static int
4747
evthread_argobots_unlock(unsigned mode, void *_lock)
4848
{
49-
ABT_mutex lock = _lock;
50-
int ret = ABT_mutex_unlock(lock);
51-
/* This yield is necessary to avoid taking a lock consecutively. */
52-
ABT_thread_yield();
53-
return ret;
49+
ABT_mutex lock = _lock;
50+
int ret = ABT_mutex_unlock(lock);
51+
/* This yield is necessary to avoid taking a lock consecutively. */
52+
ABT_thread_yield();
53+
return ret;
5454
}
5555

5656
static unsigned long
5757
evthread_argobots_get_id(void)
5858
{
59-
ABT_thread thr;
60-
ABT_thread_self(&thr);
61-
return (unsigned long)((intptr_t)thr);
59+
ABT_thread thr;
60+
ABT_thread_self(&thr);
61+
return (unsigned long)((intptr_t)thr);
6262
}
6363

6464
static void *
6565
evthread_argobots_cond_alloc(unsigned condflags)
6666
{
67-
ABT_cond cond;
68-
ABT_cond_create(&cond);
69-
return cond;
67+
ABT_cond cond;
68+
ABT_cond_create(&cond);
69+
return cond;
7070
}
7171

7272
static void
7373
evthread_argobots_cond_free(void *_cond)
7474
{
75-
ABT_cond cond = _cond;
76-
ABT_cond_free(&cond);
75+
ABT_cond cond = _cond;
76+
ABT_cond_free(&cond);
7777
}
7878

7979
static int
8080
evthread_argobots_cond_signal(void *_cond, int broadcast)
8181
{
82-
ABT_cond cond = _cond;
83-
int r;
84-
if (broadcast)
85-
r = ABT_cond_broadcast(cond);
86-
else
87-
r = ABT_cond_signal(cond);
88-
return r ? -1 : 0;
82+
ABT_cond cond = _cond;
83+
int r;
84+
if (broadcast)
85+
r = ABT_cond_broadcast(cond);
86+
else
87+
r = ABT_cond_signal(cond);
88+
return r ? -1 : 0;
8989
}
9090

9191
static int
9292
evthread_argobots_cond_wait(void *_cond, void *_lock, const struct timeval *tv)
9393
{
94-
int r;
95-
ABT_cond cond = _cond;
96-
ABT_mutex lock = _lock;
94+
int r;
95+
ABT_cond cond = _cond;
96+
ABT_mutex lock = _lock;
9797

98-
if (tv) {
99-
struct timeval now, abstime;
100-
struct timespec ts;
101-
evutil_gettimeofday(&now, NULL);
102-
evutil_timeradd(&now, tv, &abstime);
103-
ts.tv_sec = abstime.tv_sec;
104-
ts.tv_nsec = abstime.tv_usec*1000;
105-
r = ABT_cond_timedwait(cond, lock, &ts);
106-
if (r != 0)
107-
return 1;
108-
else
109-
return 0;
110-
} else {
111-
r = ABT_cond_wait(cond, lock);
112-
return r ? -1 : 0;
113-
}
98+
if (tv) {
99+
struct timeval now, abstime;
100+
struct timespec ts;
101+
evutil_gettimeofday(&now, NULL);
102+
evutil_timeradd(&now, tv, &abstime);
103+
ts.tv_sec = abstime.tv_sec;
104+
ts.tv_nsec = abstime.tv_usec*1000;
105+
r = ABT_cond_timedwait(cond, lock, &ts);
106+
if (r != 0)
107+
return 1;
108+
else
109+
return 0;
110+
} else {
111+
r = ABT_cond_wait(cond, lock);
112+
return r ? -1 : 0;
113+
}
114114
}
115115

116116
void opal_event_use_threads(void) {
117-
struct evthread_lock_callbacks cbs = {
118-
EVTHREAD_LOCK_API_VERSION,
119-
EVTHREAD_LOCKTYPE_RECURSIVE,
120-
evthread_argobots_lock_alloc,
121-
evthread_argobots_lock_free,
122-
evthread_argobots_lock,
123-
evthread_argobots_unlock
124-
};
125-
struct evthread_condition_callbacks cond_cbs = {
126-
EVTHREAD_CONDITION_API_VERSION,
127-
evthread_argobots_cond_alloc,
128-
evthread_argobots_cond_free,
129-
evthread_argobots_cond_signal,
130-
evthread_argobots_cond_wait
131-
};
132-
ensure_init_argobots();
133-
evthread_set_lock_callbacks(&cbs);
134-
evthread_set_condition_callbacks(&cond_cbs);
135-
evthread_set_id_callback(evthread_argobots_get_id);
117+
struct evthread_lock_callbacks cbs = {
118+
EVTHREAD_LOCK_API_VERSION,
119+
EVTHREAD_LOCKTYPE_RECURSIVE,
120+
evthread_argobots_lock_alloc,
121+
evthread_argobots_lock_free,
122+
evthread_argobots_lock,
123+
evthread_argobots_unlock
124+
};
125+
struct evthread_condition_callbacks cond_cbs = {
126+
EVTHREAD_CONDITION_API_VERSION,
127+
evthread_argobots_cond_alloc,
128+
evthread_argobots_cond_free,
129+
evthread_argobots_cond_signal,
130+
evthread_argobots_cond_wait
131+
};
132+
ensure_init_argobots();
133+
evthread_set_lock_callbacks(&cbs);
134+
evthread_set_condition_callbacks(&cond_cbs);
135+
evthread_set_id_callback(evthread_argobots_get_id);
136136
}

opal/mca/threads/base/base.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,6 @@ OPAL_DECLSPEC extern mca_base_framework_t opal_threads_base_framework;
4242
END_C_DECLS
4343

4444
/* include implementation to call */
45-
#include MCA_threads_IMPLEMENTATION_HEADER
45+
#include MCA_threads_base_include_HEADER
4646

4747
#endif /* OPAL_BASE_THREADS_H */

opal/mca/threads/base/threads_base_open.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535

3636
static int mca_threads_base_register(mca_base_register_flag_t flags)
3737
{
38-
// Do I need to register anything here?
3938
return OPAL_SUCCESS;
4039
}
4140

opal/mca/threads/condition.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,18 @@
1414
* Copyright (c) 2015 Research Organization for Information Science
1515
* and Technology (RIST). All rights reserved.
1616
* Copyright (c) 2019 Sandia National Laboratories. All rights reserved.
17+
* Copyright (c) 2019 Triad National Security, LLC. All rights
18+
* reserved.
19+
*
1720
*
1821
* $COPYRIGHT$
1922
*
2023
* Additional copyrights may follow
2124
*
2225
* $HEADER$
2326
*/
24-
#ifndef OPAL_MCA_CONDITION_SPINLOCK_H
25-
#define OPAL_MCA_CONDITION_SPINLOCK_H
27+
#ifndef OPAL_MCA_THREADS_CONDITION_H
28+
#define OPAL_MCA_THREADS_CONDITION_H
2629

2730
#include "opal_config.h"
2831
#ifdef HAVE_SYS_TIME_H
@@ -143,5 +146,4 @@ static inline int opal_condition_broadcast(opal_condition_t *c)
143146

144147
END_C_DECLS
145148

146-
#endif // OPAL_MCA_CONDITION_SPINLOCK_H
147-
149+
#endif // OPAL_MCA_THREADS_CONDITION_H

opal/mca/threads/configure.m4

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,19 +37,19 @@ AC_DEFUN([MCA_opal_threads_CONFIG],[
3737
tsd_base_include="${thread_type}/threads_${thread_type}_tsd.h"
3838
wait_sync_base_include="${thread_type}/threads_${thread_type}_wait_sync.h"
3939

40-
AC_DEFINE_UNQUOTED([MCA_threads_IMPLEMENTATION_HEADER],
40+
AC_DEFINE_UNQUOTED([MCA_threads_base_include_HEADER],
4141
["opal/mca/threads/$threads_base_include"],
4242
[Header to include for threads implementation])
4343

44-
AC_DEFINE_UNQUOTED([MCA_mutex_IMPLEMENTATION_HEADER],
44+
AC_DEFINE_UNQUOTED([MCA_threads_mutex_base_include_HEADER],
4545
["opal/mca/threads/$mutex_base_include"],
4646
[Header to include for mutex implementation])
4747

48-
AC_DEFINE_UNQUOTED([MCA_tsd_IMPLEMENTATION_HEADER],
48+
AC_DEFINE_UNQUOTED([MCA_threads_tsd_base_include_HEADER],
4949
["opal/mca/threads/$tsd_base_include"],
5050
[Header to include for tsd implementation])
5151

52-
AC_DEFINE_UNQUOTED([MCA_wait_sync_IMPLEMENTATION_HEADER],
52+
AC_DEFINE_UNQUOTED([MCA_threads_wait_sync_base_include_HEADER],
5353
["opal/mca/threads/$wait_sync_base_include"],
5454
[Header to include for wait_sync implementation])
5555
])

opal/mca/threads/mutex.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
* $HEADER$
2525
*/
2626

27-
#ifndef OPAL_MCA_MUTEX_H
28-
#define OPAL_MCA_MUTEX_H 1
27+
#ifndef OPAL_MCA_THREADS_MUTEX_H
28+
#define OPAL_MCA_THREADS_MUTEX_H 1
2929

3030
#include "opal_config.h"
3131

@@ -46,7 +46,7 @@ BEGIN_C_DECLS
4646
typedef struct opal_mutex_t opal_mutex_t;
4747
typedef struct opal_mutex_t opal_recursive_mutex_t;
4848

49-
#include MCA_mutex_IMPLEMENTATION_HEADER
49+
#include MCA_threads_mutex_base_include_HEADER
5050

5151
OBJ_CLASS_DECLARATION(opal_mutex_t);
5252
OBJ_CLASS_DECLARATION(opal_recursive_mutex_t);
@@ -190,4 +190,4 @@ static inline void opal_mutex_atomic_unlock(opal_mutex_t *mutex);
190190

191191
END_C_DECLS
192192

193-
#endif /* OPAL_MCA_MUTEX_H */
193+
#endif /* OPAL_MCA_THREADS_MUTEX_H */

opal/mca/threads/pthreads/threads_pthreads_component.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@
2929

3030
static int opal_threads_pthreads_open(void);
3131

32-
const opal_threads_base_component_2_0_0_t mca_threads_pthreads_component = {
32+
const opal_threads_base_component_1_0_0_t mca_threads_pthreads_component = {
3333
/* First, the mca_component_t struct containing meta information
3434
about the component itself */
3535
.threadsc_version = {
36-
OPAL_THREADS_BASE_VERSION_2_0_0,
36+
OPAL_THREADS_BASE_VERSION_1_0_0,
3737

3838
/* Component name and version */
3939
.mca_component_name = "pthreads",

opal/mca/threads/pthreads/threads_pthreads_mutex.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
#include <pthread.h>
3030

3131
#include "opal/mca/threads/mutex.h"
32-
//#include "opal/mca/threads/pthreads/mutex_unix.h"
3332

3433
/*
3534
* Wait and see if some upper layer wants to use threads, if support

opal/mca/threads/qthreads/threads_qthreads_component.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@
2828

2929
static int opal_threads_qthreads_open(void);
3030

31-
const opal_threads_base_component_2_0_0_t mca_threads_qthreads_component = {
31+
const opal_threads_base_component_1_0_0_t mca_threads_qthreads_component = {
3232
/* First, the mca_component_t struct containing meta information
3333
about the component itself */
3434
.threadsc_version = {
35-
OPAL_THREADS_BASE_VERSION_2_0_0,
35+
OPAL_THREADS_BASE_VERSION_1_0_0,
3636

3737
/* Component name and version */
3838
.mca_component_name = "qthreads",

opal/mca/threads/qthreads/threads_qthreads_module.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ static void opal_thread_construct(opal_thread_t *t)
4545
OBJ_CLASS_INSTANCE(opal_thread_t,
4646
opal_object_t,
4747
opal_thread_construct, NULL);
48-
4948

5049

5150
opal_thread_t *opal_thread_get_self(void)
@@ -61,7 +60,7 @@ bool opal_thread_self_compare(opal_thread_t *t)
6160
}
6261

6362
int sync_wait_mt(void *p) {
64-
return 0;
63+
return 0;
6564
}
6665

6766
int opal_thread_join(opal_thread_t *t, void **thr_return) {

0 commit comments

Comments
 (0)