1
+ /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
1
2
/*
2
3
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
3
4
* University Research and Technology
17
18
*
18
19
* $HEADER$
19
20
*/
21
+
20
22
#include <unistd.h>
21
23
22
24
#include "opal/mca/threads/argobots/threads_argobots.h"
@@ -51,47 +53,53 @@ OBJ_CLASS_INSTANCE(opal_thread_t,
51
53
opal_object_t ,
52
54
opal_thread_construct , NULL );
53
55
54
- static inline ABT_thread opal_thread_get_argobots_self (void ) {
56
+ static inline ABT_thread opal_thread_get_argobots_self (void )
57
+ {
55
58
ABT_thread self ;
56
59
ABT_thread_self (& self );
57
60
return self ;
58
61
}
59
62
60
- static void opal_thread_argobots_wrapper (void * arg ) {
61
- opal_thread_t * t = (opal_thread_t * ) arg ;
62
- t -> t_ret = ((void * (* )(void * )) t -> t_run )(t );
63
+ static void opal_thread_argobots_wrapper (void * arg )
64
+ {
65
+ opal_thread_t * t = (opal_thread_t * )arg ;
66
+ t -> t_ret = ((void * (* )(void * ))t -> t_run )(t );
63
67
}
64
68
65
69
opal_thread_t * opal_thread_get_self (void )
66
70
{
67
- ensure_init_argobots ();
71
+ opal_threads_argobots_ensure_init ();
68
72
opal_thread_t * t = OBJ_NEW (opal_thread_t );
69
73
t -> t_handle = opal_thread_get_argobots_self ();
70
74
return t ;
71
75
}
72
76
73
77
bool opal_thread_self_compare (opal_thread_t * t )
74
78
{
75
- ensure_init_argobots ();
76
- return t -> t_handle == opal_thread_get_argobots_self () ;
79
+ opal_threads_argobots_ensure_init ();
80
+ return opal_thread_get_argobots_self () == t -> t_handle ;
77
81
}
78
82
79
- int opal_thread_join (opal_thread_t * t , void * * thr_return ) {
80
- ensure_init_argobots ();
83
+ int opal_thread_join (opal_thread_t * t , void * * thr_return )
84
+ {
85
+ opal_threads_argobots_ensure_init ();
81
86
int rc = ABT_thread_free (& t -> t_handle );
82
- if (thr_return )
87
+ if (thr_return ) {
83
88
* thr_return = t -> t_ret ;
89
+ }
84
90
t -> t_handle = ABT_THREAD_NULL ;
85
- return (rc == 0 ) ? OPAL_SUCCESS : OPAL_ERROR ;
91
+ return (0 == rc ) ? OPAL_SUCCESS : OPAL_ERROR ;
86
92
}
87
93
88
- void opal_thread_set_main () {
89
- ensure_init_argobots ();
94
+ void opal_thread_set_main ()
95
+ {
96
+ opal_threads_argobots_ensure_init ();
90
97
opal_main_thread = opal_thread_get_argobots_self ();
91
98
}
92
99
93
- int opal_thread_start (opal_thread_t * t ) {
94
- ensure_init_argobots ();
100
+ int opal_thread_start (opal_thread_t * t )
101
+ {
102
+ opal_threads_argobots_ensure_init ();
95
103
int rc ;
96
104
if (OPAL_ENABLE_DEBUG ) {
97
105
if (NULL == t -> t_run || t -> t_handle != ABT_THREAD_NULL ) {
@@ -105,32 +113,35 @@ int opal_thread_start(opal_thread_t *t) {
105
113
opal_thread_argobots_wrapper , t ,
106
114
ABT_THREAD_ATTR_NULL , & t -> t_handle );
107
115
108
- return (rc == 0 ) ? OPAL_SUCCESS : OPAL_ERROR ;
116
+ return (0 == rc ) ? OPAL_SUCCESS : OPAL_ERROR ;
109
117
}
110
118
111
119
opal_class_t opal_thread_t_class ;
112
120
113
121
int opal_tsd_key_create (opal_tsd_key_t * key , opal_tsd_destructor_t destructor )
114
122
{
115
- ensure_init_argobots ();
123
+ opal_threads_argobots_ensure_init ();
116
124
int rc ;
117
125
rc = ABT_key_create (destructor , key );
118
126
if ((0 == rc ) && (opal_thread_get_argobots_self () == opal_main_thread )) {
119
- opal_tsd_key_values = (struct opal_tsd_key_value * )realloc (opal_tsd_key_values , (opal_tsd_key_values_count + 1 ) * sizeof (struct opal_tsd_key_value ));
127
+ opal_tsd_key_values = (struct opal_tsd_key_value * )
128
+ realloc (opal_tsd_key_values , (opal_tsd_key_values_count + 1 ) *
129
+ sizeof (struct opal_tsd_key_value ));
120
130
opal_tsd_key_values [opal_tsd_key_values_count ].key = * key ;
121
131
opal_tsd_key_values [opal_tsd_key_values_count ].destructor = destructor ;
122
- opal_tsd_key_values_count ++ ;
132
+ opal_tsd_key_values_count ++ ;
123
133
}
124
134
return rc ;
125
135
}
126
136
127
137
int opal_tsd_keys_destruct (void )
128
138
{
129
- ensure_init_argobots ();
139
+ opal_threads_argobots_ensure_init ();
130
140
int i ;
131
- void * ptr ;
132
- for (i = 0 ; i < opal_tsd_key_values_count ; i ++ ) {
133
- if (OPAL_SUCCESS == opal_tsd_getspecific (opal_tsd_key_values [i ].key , & ptr )) {
141
+ void * ptr ;
142
+ for (i = 0 ; i < opal_tsd_key_values_count ; i ++ ) {
143
+ if (OPAL_SUCCESS ==
144
+ opal_tsd_getspecific (opal_tsd_key_values [i ].key , & ptr )) {
134
145
if (NULL != opal_tsd_key_values [i ].destructor ) {
135
146
opal_tsd_key_values [i ].destructor (ptr );
136
147
opal_tsd_setspecific (opal_tsd_key_values [i ].key , NULL );
0 commit comments