ARGOBOTS  29b0d4cc91ca184a8278ddf690fd0bcb2119000e
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
tool.c
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 #include "abti.h"
7 
8 #ifndef ABT_CONFIG_DISABLE_TOOL_INTERFACE
9 ABTU_ret_err static inline int tool_query(ABTI_tool_context *p_tctx,
10  ABT_tool_query_kind query_kind,
11  void *val);
12 #endif
13 
45  uint64_t event_mask_thread,
46  void *user_arg)
47 {
48 #ifdef ABT_CONFIG_DISABLE_TOOL_INTERFACE
49  ABTI_HANDLE_ERROR(ABT_ERR_FEATURE_NA);
50 #else
51  if (cb_func == NULL)
52  event_mask_thread = ABT_TOOL_EVENT_THREAD_NONE;
53  ABTI_tool_event_thread_update_callback(cb_func,
54  event_mask_thread &
56  user_arg);
57  return ABT_SUCCESS;
58 #endif
59 }
60 
88  uint64_t event_mask_task, void *user_arg)
89 {
90 #ifdef ABT_CONFIG_DISABLE_TOOL_INTERFACE
91  ABTI_HANDLE_ERROR(ABT_ERR_FEATURE_NA);
92 #else
93  if (cb_func == NULL)
94  event_mask_task = ABT_TOOL_EVENT_TASK_NONE;
95  ABTI_tool_event_task_update_callback(cb_func,
96  event_mask_task &
98  user_arg);
99  return ABT_SUCCESS;
100 #endif
101 }
102 
195 int ABT_tool_query_thread(ABT_tool_context context, uint64_t event_thread,
196  ABT_tool_query_kind query_kind, void *val)
197 {
198 #ifdef ABT_CONFIG_DISABLE_TOOL_INTERFACE
199  ABTI_HANDLE_ERROR(ABT_ERR_FEATURE_NA);
200 #else
201  ABTI_tool_context *p_tctx = ABTI_tool_context_get_ptr(context);
202  ABTI_CHECK_NULL_TOOL_CONTEXT_PTR(p_tctx);
203 
204  int abt_errno = tool_query(p_tctx, query_kind, val);
205  ABTI_CHECK_ERROR(abt_errno);
206  return ABT_SUCCESS;
207 #endif
208 }
209 
225 int ABT_tool_query_task(ABT_tool_context context, uint64_t event_task,
226  ABT_tool_query_kind query_kind, void *val)
227 {
228 #ifdef ABT_CONFIG_DISABLE_TOOL_INTERFACE
229  ABTI_HANDLE_ERROR(ABT_ERR_FEATURE_NA);
230 #else
231  ABTI_tool_context *p_tctx = ABTI_tool_context_get_ptr(context);
232  ABTI_CHECK_NULL_TOOL_CONTEXT_PTR(p_tctx);
233  int abt_errno = tool_query(p_tctx, query_kind, val);
234  ABTI_CHECK_ERROR(abt_errno);
235  return ABT_SUCCESS;
236 #endif
237 }
238 
239 /*****************************************************************************/
240 /* Internal static functions */
241 /*****************************************************************************/
242 
243 #ifndef ABT_CONFIG_DISABLE_TOOL_INTERFACE
244 ABTU_ret_err static inline int
245 tool_query(ABTI_tool_context *p_tctx, ABT_tool_query_kind query_kind, void *val)
246 {
247  switch (query_kind) {
249  *(ABT_pool *)val = ABTI_pool_get_handle(p_tctx->p_pool);
250  break;
252  if (!p_tctx->p_parent) {
253  *(int *)val = 0;
254  } else {
255  int depth = 0;
256  ABTI_thread *p_cur = p_tctx->p_parent;
257  while (p_cur) {
258  depth++;
259  p_cur = p_cur->p_parent;
260  }
261  /* We do not count the root thread, so -1. */
262  *(int *)val = depth - 1;
263  }
264  break;
266  if (!p_tctx->p_caller) {
268  } else if (p_tctx->p_caller->type & ABTI_THREAD_TYPE_YIELDABLE) {
270  } else {
272  }
273  break;
275  if (!p_tctx->p_caller) {
276  *(void **)val = NULL;
277  } else if (p_tctx->p_caller->type & ABTI_THREAD_TYPE_YIELDABLE) {
278  *(ABT_thread *)val = ABTI_ythread_get_handle(
279  ABTI_thread_get_ythread(p_tctx->p_caller));
280  } else {
281  *(ABT_task *)val = ABTI_thread_get_handle(p_tctx->p_caller);
282  }
283  break;
285  *(ABT_sync_event_type *)val = p_tctx->sync_event_type;
286  break;
288  switch (p_tctx->sync_event_type) {
290  *(ABT_xstream *)val = ABTI_xstream_get_handle(
291  (ABTI_xstream *)p_tctx->p_sync_object);
292  break;
294  *(ABT_thread *)val = ABTI_ythread_get_handle(
295  (ABTI_ythread *)p_tctx->p_sync_object);
296  break;
298  *(ABT_task *)val = ABTI_thread_get_handle(
299  (ABTI_thread *)p_tctx->p_sync_object);
300  break;
302  *(ABT_mutex *)val = ABTI_mutex_get_handle(
303  (ABTI_mutex *)p_tctx->p_sync_object);
304  break;
306  *(ABT_cond *)val = ABTI_cond_get_handle(
307  (ABTI_cond *)p_tctx->p_sync_object);
308  break;
310  *(ABT_rwlock *)val = ABTI_rwlock_get_handle(
311  (ABTI_rwlock *)p_tctx->p_sync_object);
312  break;
314  *(ABT_eventual *)val = ABTI_eventual_get_handle(
315  (ABTI_eventual *)p_tctx->p_sync_object);
316  break;
318  *(ABT_future *)val = ABTI_future_get_handle(
319  (ABTI_future *)p_tctx->p_sync_object);
320  break;
322  *(ABT_barrier *)val = ABTI_barrier_get_handle(
323  (ABTI_barrier *)p_tctx->p_sync_object);
324  break;
325  default:
326  *(void **)val = NULL;
327  }
328  break;
329  default:
330  ABTI_HANDLE_ERROR(ABT_ERR_OTHER);
331  }
332  return ABT_SUCCESS;
333 }
334 #endif
struct ABT_barrier_opaque * ABT_barrier
Definition: abt.h:369
struct ABT_xstream_opaque * ABT_xstream
Definition: abt.h:313
struct ABT_thread_opaque * ABT_task
Definition: abt.h:353
#define ABT_TOOL_EVENT_THREAD_NONE
Definition: abt.h:260
int ABT_tool_register_thread_callback(ABT_tool_thread_callback_fn cb_func, uint64_t event_mask_thread, void *user_arg) ABT_API_PUBLIC
Register a callback function for ULT events.
Definition: tool.c:44
void(* ABT_tool_thread_callback_fn)(ABT_thread, ABT_xstream, uint64_t event, ABT_tool_context context, void *user_arg)
Definition: abt.h:515
#define ABT_ERR_OTHER
Definition: abt.h:67
struct ABT_pool_opaque * ABT_pool
Definition: abt.h:329
struct ABT_mutex_opaque * ABT_mutex
Definition: abt.h:357
struct ABT_rwlock_opaque * ABT_rwlock
Definition: abt.h:363
struct ABT_thread_opaque * ABT_thread
Definition: abt.h:343
static ABTU_ret_err int tool_query(ABTI_tool_context *p_tctx, ABT_tool_query_kind query_kind, void *val)
Definition: tool.c:245
#define ABT_TOOL_EVENT_THREAD_ALL
Definition: abt.h:271
#define ABT_SUCCESS
Definition: abt.h:64
int ABT_tool_query_thread(ABT_tool_context context, uint64_t event_thread, ABT_tool_query_kind query_kind, void *val) ABT_API_PUBLIC
Query information associated with a ULT event.
Definition: tool.c:195
struct ABT_future_opaque * ABT_future
Definition: abt.h:367
int ABT_tool_query_task(ABT_tool_context context, uint64_t event_task, ABT_tool_query_kind query_kind, void *val) ABT_API_PUBLIC
Query information associated with a tasklet event.
Definition: tool.c:225
struct ABT_eventual_opaque * ABT_eventual
Definition: abt.h:365
struct ABT_tool_context_opaque * ABT_tool_context
Definition: abt.h:377
ABT_tool_query_kind
Definition: abt.h:227
ABT_exec_entity_type
Definition: abt.h:237
#define ABT_ERR_FEATURE_NA
Definition: abt.h:116
#define ABT_TOOL_EVENT_TASK_NONE
Definition: abt.h:273
ABT_sync_event_type
Definition: abt.h:244
void(* ABT_tool_task_callback_fn)(ABT_task, ABT_xstream, uint64_t event, ABT_tool_context context, void *user_arg)
Definition: abt.h:517
#define ABTU_ret_err
Definition: abtu.h:49
int ABT_tool_register_task_callback(ABT_tool_task_callback_fn cb_func, uint64_t event_mask_task, void *user_arg) ABT_API_PUBLIC
Register a callback function for tasklet events.
Definition: tool.c:87
#define ABT_TOOL_EVENT_TASK_ALL
Definition: abt.h:281
struct ABT_cond_opaque * ABT_cond
Definition: abt.h:361