ARGOBOTS  1.1
abti_stream.h
Go to the documentation of this file.
1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
2 /*
3  * See COPYRIGHT in top-level directory.
4  */
5 
6 #ifndef ABTI_XSTREAM_H_INCLUDED
7 #define ABTI_XSTREAM_H_INCLUDED
8 
9 /* Inlined functions for Execution Stream (ES) */
10 
12 {
13 #ifndef ABT_CONFIG_DISABLE_ERROR_CHECK
14  ABTI_xstream *p_xstream;
15  if (xstream == ABT_XSTREAM_NULL) {
16  p_xstream = NULL;
17  } else {
18  p_xstream = (ABTI_xstream *)xstream;
19  }
20  return p_xstream;
21 #else
22  return (ABTI_xstream *)xstream;
23 #endif
24 }
25 
27 {
28 #ifndef ABT_CONFIG_DISABLE_ERROR_CHECK
29  ABT_xstream h_xstream;
30  if (p_xstream == NULL) {
31  h_xstream = ABT_XSTREAM_NULL;
32  } else {
33  h_xstream = (ABT_xstream)p_xstream;
34  }
35  return h_xstream;
36 #else
37  return (ABT_xstream)p_xstream;
38 #endif
39 }
40 
41 /* Get the first pool of the main scheduler. */
43 {
44  ABT_pool pool = p_xstream->p_main_sched->pools[0];
45  return ABTI_pool_get_ptr(pool);
46 }
47 
48 static inline void ABTI_xstream_terminate_thread(ABTI_global *p_global,
49  ABTI_local *p_local,
50  ABTI_thread *p_thread)
51 {
52  LOG_DEBUG("[U%" PRIu64 ":E%d] terminated\n", ABTI_thread_get_id(p_thread),
53  p_thread->p_last_xstream->rank);
54  if (!(p_thread->type & ABTI_THREAD_TYPE_NAMED)) {
57  ABTI_thread_free(p_global, p_local, p_thread);
58  } else {
59  /* NOTE: We set the ULT's state as TERMINATED after checking refcount
60  * because the ULT can be freed on a different ES. In other words, we
61  * must not access any field of p_thead after changing the state to
62  * TERMINATED. */
65  }
66 }
67 
69 {
70  return (ABTI_local *)p_xstream;
71 }
72 
73 #endif /* ABTI_XSTREAM_H_INCLUDED */
ABT_THREAD_STATE_TERMINATED
@ ABT_THREAD_STATE_TERMINATED
Definition: abt.h:423
ABTI_thread::type
ABTI_thread_type type
Definition: abti.h:375
ABTI_xstream::rank
int rank
Definition: abti.h:269
ABTI_thread_get_id
ABT_unit_id ABTI_thread_get_id(ABTI_thread *p_thread)
Definition: thread.c:2561
ABTI_thread_free
void ABTI_thread_free(ABTI_global *p_global, ABTI_local *p_local, ABTI_thread *p_thread)
Definition: thread.c:2400
ABTI_thread
Definition: abti.h:371
ABTI_xstream
Definition: abti.h:264
ABT_pool
struct ABT_pool_opaque * ABT_pool
Pool handle type.
Definition: abt.h:841
ABTI_pool
Definition: abti.h:327
ABTI_xstream_get_handle
static ABT_xstream ABTI_xstream_get_handle(ABTI_xstream *p_xstream)
Definition: abti_stream.h:26
ABT_xstream
struct ABT_xstream_opaque * ABT_xstream
Execution stream handle type.
Definition: abt.h:789
ABTI_thread::state
ABTD_atomic_int state
Definition: abti.h:381
LOG_DEBUG
#define LOG_DEBUG(fmt,...)
Definition: abti_log.h:26
ABTI_xstream::p_main_sched
ABTI_sched * p_main_sched
Definition: abti.h:272
ABTI_xstream_terminate_thread
static void ABTI_xstream_terminate_thread(ABTI_global *p_global, ABTI_local *p_local, ABTI_thread *p_thread)
Definition: abti_stream.h:48
ABTI_sched::pools
ABT_pool * pools
Definition: abti.h:298
ABTI_xstream_get_main_pool
static ABTI_pool * ABTI_xstream_get_main_pool(ABTI_xstream *p_xstream)
Definition: abti_stream.h:42
ABTI_xstream_get_local
static ABTI_local * ABTI_xstream_get_local(ABTI_xstream *p_xstream)
Definition: abti_stream.h:68
ABTI_pool_get_ptr
static ABTI_pool * ABTI_pool_get_ptr(ABT_pool pool)
Definition: abti_pool.h:11
ABTI_THREAD_TYPE_NAMED
#define ABTI_THREAD_TYPE_NAMED
Definition: abti.h:87
ABTI_xstream_get_ptr
static ABTI_xstream * ABTI_xstream_get_ptr(ABT_xstream xstream)
Definition: abti_stream.h:11
ABTI_thread::p_last_xstream
ABTI_xstream * p_last_xstream
Definition: abti.h:377
ABTI_local
struct ABTI_local ABTI_local
Definition: abti.h:110
ABT_XSTREAM_NULL
#define ABT_XSTREAM_NULL
Definition: abt.h:1055
ABTI_global
Definition: abti.h:196
ABTD_atomic_release_store_int
static void ABTD_atomic_release_store_int(ABTD_atomic_int *ptr, int val)
Definition: abtd_atomic.h:1065