ARGOBOTS  2d670346af9c36fec097ec5ab659205198ec061b
abti_event.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_EVENT_H_INCLUDED
7 #define ABTI_EVENT_H_INCLUDED
8 
9 #if !defined(ABT_CONFIG_DISABLE_TOOL_INTERFACE) || \
10  defined(ABT_CONFIG_USE_DEBUG_LOG)
11 #define ABTI_ENABLE_EVENT_INTERFACE 1
12 #else
13 #define ABTI_ENABLE_EVENT_INTERFACE 0
14 #endif
15 
16 static inline void ABTI_event_thread_create_impl(ABTI_local *p_local,
17  ABTI_thread *p_thread,
18  ABTI_thread *p_caller,
19  ABTI_pool *p_pool)
20 {
21 #ifdef ABT_CONFIG_USE_DEBUG_LOG
22  ABTI_log_debug_thread("create", p_thread);
23 #endif
24 #ifndef ABT_CONFIG_DISABLE_TOOL_INTERFACE
25  ABTI_tool_event_thread(p_local, ABT_TOOL_EVENT_THREAD_CREATE, p_thread,
26  p_caller, p_pool, NULL, ABT_SYNC_EVENT_TYPE_UNKNOWN,
27  NULL);
28 #endif
29 }
30 
31 static inline void ABTI_event_thread_join_impl(ABTI_local *p_local,
32  ABTI_thread *p_thread,
33  ABTI_thread *p_caller)
34 {
35 #ifdef ABT_CONFIG_USE_DEBUG_LOG
36  ABTI_log_debug_thread("join", p_thread);
37 #endif
38 #ifndef ABT_CONFIG_DISABLE_TOOL_INTERFACE
39  ABTI_tool_event_thread(p_local, ABT_TOOL_EVENT_THREAD_JOIN, p_thread,
40  p_caller, NULL, NULL, ABT_SYNC_EVENT_TYPE_UNKNOWN,
41  NULL);
42 #endif
43 }
44 
45 static inline void ABTI_event_thread_free_impl(ABTI_local *p_local,
46  ABTI_thread *p_thread,
47  ABTI_thread *p_caller)
48 {
49 #ifdef ABT_CONFIG_USE_DEBUG_LOG
50  ABTI_log_debug_thread("free", p_thread);
51 #endif
52 #ifndef ABT_CONFIG_DISABLE_TOOL_INTERFACE
53  ABTI_tool_event_thread(p_local, ABT_TOOL_EVENT_THREAD_FREE, p_thread,
54  p_caller, NULL, NULL, ABT_SYNC_EVENT_TYPE_UNKNOWN,
55  NULL);
56 #endif
57 }
58 
59 static inline void ABTI_event_thread_revive_impl(ABTI_local *p_local,
60  ABTI_thread *p_thread,
61  ABTI_thread *p_caller,
62  ABTI_pool *p_pool)
63 {
64 #ifdef ABT_CONFIG_USE_DEBUG_LOG
65  ABTI_log_debug_thread("revive", p_thread);
66 #endif
67 #ifndef ABT_CONFIG_DISABLE_TOOL_INTERFACE
68  ABTI_tool_event_thread(p_local, ABT_TOOL_EVENT_THREAD_REVIVE, p_thread,
69  p_caller, p_pool, NULL, ABT_SYNC_EVENT_TYPE_UNKNOWN,
70  NULL);
71 #endif
72 }
73 
74 static inline void ABTI_event_thread_run_impl(ABTI_xstream *p_local_xstream,
75  ABTI_thread *p_thread,
76  ABTI_thread *p_prev,
77  ABTI_thread *p_parent)
78 {
79 #ifdef ABT_CONFIG_USE_DEBUG_LOG
80  ABTI_log_debug_thread("run", p_thread);
81 #endif
82 #ifndef ABT_CONFIG_DISABLE_TOOL_INTERFACE
83  ABTI_tool_event_thread(ABTI_xstream_get_local(p_local_xstream),
84  ABT_TOOL_EVENT_THREAD_RUN, p_thread, p_prev, NULL,
85  p_parent, ABT_SYNC_EVENT_TYPE_UNKNOWN, NULL);
86 #endif
87 }
88 
89 static inline void ABTI_event_thread_finish_impl(ABTI_xstream *p_local_xstream,
90  ABTI_thread *p_thread,
91  ABTI_thread *p_parent)
92 {
93 #ifdef ABT_CONFIG_USE_DEBUG_LOG
94  ABTI_log_debug_thread("finish", p_thread);
95 #endif
96 #ifndef ABT_CONFIG_DISABLE_TOOL_INTERFACE
97  ABTI_tool_event_thread(ABTI_xstream_get_local(p_local_xstream),
98  ABT_TOOL_EVENT_THREAD_FINISH, p_thread, NULL, NULL,
99  p_parent, ABT_SYNC_EVENT_TYPE_UNKNOWN, NULL);
100 #endif
101 }
102 
103 static inline void ABTI_event_thread_cancel_impl(ABTI_xstream *p_local_xstream,
104  ABTI_thread *p_thread)
105 {
106 #ifdef ABT_CONFIG_USE_DEBUG_LOG
107  ABTI_log_debug_thread("cancel", p_thread);
108 #endif
109 #ifndef ABT_CONFIG_DISABLE_TOOL_INTERFACE
110  ABTI_tool_event_thread(ABTI_xstream_get_local(p_local_xstream),
111  ABT_TOOL_EVENT_THREAD_CANCEL, p_thread, NULL, NULL,
112  NULL, ABT_SYNC_EVENT_TYPE_UNKNOWN, NULL);
113 #endif
114 }
115 
116 static inline void
117 ABTI_event_ythread_yield_impl(ABTI_xstream *p_local_xstream,
118  ABTI_ythread *p_ythread, ABTI_thread *p_parent,
119  ABT_sync_event_type sync_event_type, void *p_sync)
120 {
121 #ifdef ABT_CONFIG_USE_DEBUG_LOG
122  ABTI_log_debug_thread("yield", &p_ythread->thread);
123 #endif
124 #ifndef ABT_CONFIG_DISABLE_TOOL_INTERFACE
125  ABTI_tool_event_thread(ABTI_xstream_get_local(p_local_xstream),
126  ABT_TOOL_EVENT_THREAD_YIELD, &p_ythread->thread,
127  NULL, p_ythread->thread.p_pool, p_parent,
128  sync_event_type, p_sync);
129 #endif
130 }
131 
132 static inline void ABTI_event_ythread_suspend_impl(
133  ABTI_xstream *p_local_xstream, ABTI_ythread *p_ythread,
134  ABTI_thread *p_parent, ABT_sync_event_type sync_event_type, void *p_sync)
135 {
136 #ifdef ABT_CONFIG_USE_DEBUG_LOG
137  ABTI_log_debug_thread("suspend", &p_ythread->thread);
138 #endif
139 #ifndef ABT_CONFIG_DISABLE_TOOL_INTERFACE
140  ABTI_tool_event_thread(ABTI_xstream_get_local(p_local_xstream),
141  ABT_TOOL_EVENT_THREAD_SUSPEND, &p_ythread->thread,
142  NULL, p_ythread->thread.p_pool, p_parent,
143  sync_event_type, p_sync);
144 #endif
145 }
146 
147 static inline void ABTI_event_ythread_resume_impl(ABTI_local *p_local,
148  ABTI_ythread *p_ythread,
149  ABTI_thread *p_caller)
150 {
151 #ifdef ABT_CONFIG_USE_DEBUG_LOG
152  ABTI_log_debug_thread("resume", &p_ythread->thread);
153 #endif
154 #ifndef ABT_CONFIG_DISABLE_TOOL_INTERFACE
155  ABTI_tool_event_thread(p_local, ABT_TOOL_EVENT_THREAD_RESUME,
156  &p_ythread->thread, p_caller,
157  p_ythread->thread.p_pool, NULL,
159 #endif
160 }
161 
162 #define ABTI_event_thread_create(p_local, p_thread, p_caller, p_pool) \
163  do { \
164  if (ABTI_ENABLE_EVENT_INTERFACE) { \
165  ABTI_event_thread_create_impl(p_local, p_thread, p_caller, \
166  p_pool); \
167  } \
168  } while (0)
169 
170 #define ABTI_event_thread_join(p_local, p_thread, p_caller) \
171  do { \
172  if (ABTI_ENABLE_EVENT_INTERFACE) { \
173  ABTI_event_thread_join_impl(p_local, p_thread, p_caller); \
174  } \
175  } while (0)
176 
177 #define ABTI_event_thread_free(p_local, p_thread, p_caller) \
178  do { \
179  if (ABTI_ENABLE_EVENT_INTERFACE) { \
180  ABTI_event_thread_free_impl(p_local, p_thread, p_caller); \
181  } \
182  } while (0)
183 
184 #define ABTI_event_thread_revive(p_local, p_thread, p_caller, p_pool) \
185  do { \
186  if (ABTI_ENABLE_EVENT_INTERFACE) { \
187  ABTI_event_thread_revive_impl(p_local, p_thread, p_caller, \
188  p_pool); \
189  } \
190  } while (0)
191 
192 #define ABTI_event_thread_run(p_local_xstream, p_thread, p_prev, p_parent) \
193  do { \
194  if (ABTI_ENABLE_EVENT_INTERFACE) { \
195  ABTI_event_thread_run_impl(p_local_xstream, p_thread, p_prev, \
196  p_parent); \
197  } \
198  } while (0)
199 
200 #define ABTI_event_thread_finish(p_local_xstream, p_thread, p_parent) \
201  do { \
202  if (ABTI_ENABLE_EVENT_INTERFACE) { \
203  ABTI_event_thread_finish_impl(p_local_xstream, p_thread, \
204  p_parent); \
205  } \
206  } while (0)
207 
208 #define ABTI_event_thread_cancel(p_local_xstream, p_thread) \
209  do { \
210  if (ABTI_ENABLE_EVENT_INTERFACE) { \
211  ABTI_event_thread_cancel_impl(p_local_xstream, p_thread); \
212  } \
213  } while (0)
214 
215 #define ABTI_event_ythread_yield(p_local_xstream, p_ythread, p_parent, \
216  sync_event_type, p_sync) \
217  do { \
218  if (ABTI_ENABLE_EVENT_INTERFACE) { \
219  ABTI_event_ythread_yield_impl(p_local_xstream, p_ythread, \
220  p_parent, sync_event_type, p_sync); \
221  } \
222  } while (0)
223 
224 #define ABTI_event_ythread_suspend(p_local_xstream, p_ythread, p_parent, \
225  sync_event_type, p_sync) \
226  do { \
227  if (ABTI_ENABLE_EVENT_INTERFACE) { \
228  ABTI_event_ythread_suspend_impl(p_local_xstream, p_ythread, \
229  p_parent, sync_event_type, \
230  p_sync); \
231  } \
232  } while (0)
233 
234 #define ABTI_event_ythread_resume(p_local, p_ythread, p_caller) \
235  do { \
236  if (ABTI_ENABLE_EVENT_INTERFACE) { \
237  ABTI_event_ythread_resume_impl(p_local, p_ythread, p_caller); \
238  } \
239  } while (0)
240 
241 #endif /* ABTI_EVENT_H_INCLUDED */
ABT_TOOL_EVENT_THREAD_CREATE
#define ABT_TOOL_EVENT_THREAD_CREATE
Work-unit-event mask: creating a work unit.
Definition: abt.h:704
ABT_TOOL_EVENT_THREAD_RUN
#define ABT_TOOL_EVENT_THREAD_RUN
Work-unit-event mask: running a work unit.
Definition: abt.h:724
ABT_TOOL_EVENT_THREAD_REVIVE
#define ABT_TOOL_EVENT_THREAD_REVIVE
Work-unit-event mask: reviving a work unit.
Definition: abt.h:719
ABT_TOOL_EVENT_THREAD_RESUME
#define ABT_TOOL_EVENT_THREAD_RESUME
Work-unit-event mask: resuming a work unit.
Definition: abt.h:749
ABT_SYNC_EVENT_TYPE_UNKNOWN
@ ABT_SYNC_EVENT_TYPE_UNKNOWN
Definition: abt.h:672
ABT_sync_event_type
ABT_sync_event_type
Type of synchronization event.
Definition: abt.h:670
ABT_TOOL_EVENT_THREAD_CANCEL
#define ABT_TOOL_EVENT_THREAD_CANCEL
Work-unit-event mask: canceling a work unit.
Definition: abt.h:734
ABT_TOOL_EVENT_THREAD_YIELD
#define ABT_TOOL_EVENT_THREAD_YIELD
Work-unit-event mask: yielding a work unit.
Definition: abt.h:739
ABT_TOOL_EVENT_THREAD_FINISH
#define ABT_TOOL_EVENT_THREAD_FINISH
Work-unit-event mask: finishing a work unit.
Definition: abt.h:729
ABT_TOOL_EVENT_THREAD_SUSPEND
#define ABT_TOOL_EVENT_THREAD_SUSPEND
Work-unit-event mask: suspending a work unit.
Definition: abt.h:744
ABT_TOOL_EVENT_THREAD_JOIN
#define ABT_TOOL_EVENT_THREAD_JOIN
Work-unit-event mask: joining a work unit.
Definition: abt.h:709
ABT_TOOL_EVENT_THREAD_FREE
#define ABT_TOOL_EVENT_THREAD_FREE
Work-unit-event mask: freeing a work unit.
Definition: abt.h:714