@@ -11,7 +11,7 @@ static void *
1111evthread_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
2626static void
2727evthread_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
3333static int
3434evthread_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
4646static int
4747evthread_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
5656static unsigned long
5757evthread_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
6464static void *
6565evthread_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
7272static void
7373evthread_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
7979static int
8080evthread_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
9191static int
9292evthread_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
116116void 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}
0 commit comments