ARGOBOTS  66b1c39742507d8df30e8d28c54839b961a14814
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
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 
11 static inline ABTI_xstream *ABTI_xstream_get_ptr(ABT_xstream xstream)
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 
26 static inline ABT_xstream ABTI_xstream_get_handle(ABTI_xstream *p_xstream)
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. */
42 static inline ABTI_pool *ABTI_xstream_get_main_pool(ABTI_xstream *p_xstream)
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_local *p_local,
49  ABTI_thread *p_thread)
50 {
51  LOG_DEBUG("[U%" PRIu64 ":E%d] terminated\n", ABTI_thread_get_id(p_thread),
52  p_thread->p_last_xstream->rank);
53  if (!(p_thread->type & ABTI_THREAD_TYPE_NAMED)) {
54  ABTD_atomic_release_store_int(&p_thread->state,
56  ABTI_thread_free(p_local, p_thread);
57  } else {
58  /* NOTE: We set the ULT's state as TERMINATED after checking refcount
59  * because the ULT can be freed on a different ES. In other words, we
60  * must not access any field of p_thead after changing the state to
61  * TERMINATED. */
62  ABTD_atomic_release_store_int(&p_thread->state,
64  }
65 }
66 
67 static inline ABTI_local *ABTI_xstream_get_local(ABTI_xstream *p_xstream)
68 {
69  return (ABTI_local *)p_xstream;
70 }
71 
72 #endif /* ABTI_XSTREAM_H_INCLUDED */
struct ABT_xstream_opaque * ABT_xstream
Definition: abt.h:313
#define ABT_XSTREAM_NULL
Definition: abt.h:409
struct ABT_pool_opaque * ABT_pool
Definition: abt.h:329
#define LOG_DEBUG(fmt,...)
Definition: abti_log.h:26