ARGOBOTS  dce6e727ffc4ca5b3ffc04cb9517c6689be51ec5
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 
84  uint64_t event_mask, void *user_arg)
85 {
87 
88 #ifdef ABT_CONFIG_DISABLE_TOOL_INTERFACE
90 #else
91  ABTI_global *p_global;
92  ABTI_SETUP_GLOBAL(&p_global);
93 
94  if (cb_func == NULL)
95  event_mask = ABT_TOOL_EVENT_THREAD_NONE;
97  event_mask &
99  user_arg);
100  return ABT_SUCCESS;
101 #endif
102 }
103 
235 int ABT_tool_query_thread(ABT_tool_context context, uint64_t event,
236  ABT_tool_query_kind query_kind, void *val)
237 {
239  ABTI_UB_ASSERT(val);
240 
241 #ifdef ABT_CONFIG_DISABLE_TOOL_INTERFACE
243 #else
244  ABTI_tool_context *p_tctx = ABTI_tool_context_get_ptr(context);
246 
247  int abt_errno = tool_query(p_tctx, query_kind, val);
248  ABTI_CHECK_ERROR(abt_errno);
249  return ABT_SUCCESS;
250 #endif
251 }
252 
253 /*****************************************************************************/
254 /* Internal static functions */
255 /*****************************************************************************/
256 
257 #ifndef ABT_CONFIG_DISABLE_TOOL_INTERFACE
258 ABTU_ret_err static inline int
259 tool_query(ABTI_tool_context *p_tctx, ABT_tool_query_kind query_kind, void *val)
260 {
261  switch (query_kind) {
263  *(ABT_pool *)val = ABTI_pool_get_handle(p_tctx->p_pool);
264  break;
266  if (!p_tctx->p_parent) {
267  *(int *)val = 0;
268  } else {
269  int depth = 0;
270  ABTI_thread *p_cur = p_tctx->p_parent;
271  while (p_cur) {
272  depth++;
273  p_cur = p_cur->p_parent;
274  }
275  /* We do not count the root thread, so -1. */
276  *(int *)val = depth - 1;
277  }
278  break;
280  if (!p_tctx->p_caller) {
282  } else {
284  }
285  break;
287  if (!p_tctx->p_caller) {
288  *(void **)val = NULL;
289  } else {
290  *(ABT_thread *)val = ABTI_thread_get_handle(p_tctx->p_caller);
291  }
292  break;
294  *(ABT_sync_event_type *)val = p_tctx->sync_event_type;
295  break;
297  switch (p_tctx->sync_event_type) {
300  (ABTI_xstream *)p_tctx->p_sync_object);
301  break;
304  (ABTI_thread *)p_tctx->p_sync_object);
305  break;
308  (ABTI_mutex *)p_tctx->p_sync_object);
309  break;
311  *(ABT_cond *)val = ABTI_cond_get_handle(
312  (ABTI_cond *)p_tctx->p_sync_object);
313  break;
316  (ABTI_rwlock *)p_tctx->p_sync_object);
317  break;
320  (ABTI_eventual *)p_tctx->p_sync_object);
321  break;
324  (ABTI_future *)p_tctx->p_sync_object);
325  break;
328  (ABTI_barrier *)p_tctx->p_sync_object);
329  break;
330  default:
331  *(void **)val = NULL;
332  }
333  break;
334  default:
336  }
337  return ABT_SUCCESS;
338 }
339 #endif
ABT_tool_query_kind
ABT_tool_query_kind
Tool query kind for ABT_tool_query_thread().
Definition: abt.h:666
ABT_TOOL_QUERY_KIND_STACK_DEPTH
@ ABT_TOOL_QUERY_KIND_STACK_DEPTH
Definition: abt.h:670
ABT_EXEC_ENTITY_TYPE_EXT
@ ABT_EXEC_ENTITY_TYPE_EXT
Definition: abt.h:687
ABT_TOOL_QUERY_KIND_CALLER_HANDLE
@ ABT_TOOL_QUERY_KIND_CALLER_HANDLE
Definition: abt.h:674
ABT_thread
struct ABT_thread_opaque * ABT_thread
Work unit handle type.
Definition: abt.h:932
ABTI_SETUP_GLOBAL
#define ABTI_SETUP_GLOBAL(pp_global)
Definition: abti_error.h:75
ABTI_future
Definition: abti.h:504
ABTI_eventual_get_handle
static ABT_eventual ABTI_eventual_get_handle(ABTI_eventual *p_eventual)
Definition: abti_eventual.h:26
ABT_TOOL_QUERY_KIND_SYNC_OBJECT_TYPE
@ ABT_TOOL_QUERY_KIND_SYNC_OBJECT_TYPE
Definition: abt.h:676
ABT_exec_entity_type
ABT_exec_entity_type
Type of execution entity.
Definition: abt.h:685
ABTI_tool_context_get_ptr
static ABTI_tool_context * ABTI_tool_context_get_ptr(ABT_tool_context tctx)
Definition: abti_tool.h:14
ABTI_eventual
Definition: abti.h:496
ABT_tool_register_thread_callback
int ABT_tool_register_thread_callback(ABT_tool_thread_callback_fn cb_func, uint64_t event_mask, void *user_arg)
Register a callback function for work-unit events.
Definition: tool.c:83
ABTI_CHECK_ERROR
#define ABTI_CHECK_ERROR(abt_errno)
Definition: abti_error.h:136
ABT_SYNC_EVENT_TYPE_XSTREAM_JOIN
@ ABT_SYNC_EVENT_TYPE_XSTREAM_JOIN
Definition: abt.h:704
ABTI_future_get_handle
static ABT_future ABTI_future_get_handle(ABTI_future *p_future)
Definition: abti_future.h:26
ABT_mutex
struct ABT_mutex_opaque * ABT_mutex
Mutex handle type.
Definition: abt.h:987
ABT_SYNC_EVENT_TYPE_MUTEX
@ ABT_SYNC_EVENT_TYPE_MUTEX
Definition: abt.h:708
ABTI_thread_get_handle
static ABT_thread ABTI_thread_get_handle(ABTI_thread *p_thread)
Definition: abti_thread.h:24
ABTI_barrier_get_handle
static ABT_barrier ABTI_barrier_get_handle(ABTI_barrier *p_barrier)
Definition: abti_barrier.h:27
ABT_SYNC_EVENT_TYPE_FUTURE
@ ABT_SYNC_EVENT_TYPE_FUTURE
Definition: abt.h:716
ABTI_thread
Definition: abti.h:422
ABTI_barrier
Definition: abti.h:513
ABTI_xstream
Definition: abti.h:294
ABT_pool
struct ABT_pool_opaque * ABT_pool
Pool handle type.
Definition: abt.h:878
ABT_TOOL_QUERY_KIND_CALLER_TYPE
@ ABT_TOOL_QUERY_KIND_CALLER_TYPE
Definition: abt.h:672
ABTI_xstream_get_handle
static ABT_xstream ABTI_xstream_get_handle(ABTI_xstream *p_xstream)
Definition: abti_stream.h:26
ABTI_cond
Definition: abti.h:483
ABT_sync_event_type
ABT_sync_event_type
Type of synchronization event.
Definition: abt.h:696
abti.h
ABT_tool_context
struct ABT_tool_context_opaque * ABT_tool_context
Tool context handle type.
Definition: abt.h:1055
ABT_xstream
struct ABT_xstream_opaque * ABT_xstream
Execution stream handle type.
Definition: abt.h:826
ABTI_rwlock
Definition: abti.h:489
ABTI_CHECK_NULL_TOOL_CONTEXT_PTR
#define ABTI_CHECK_NULL_TOOL_CONTEXT_PTR(p)
Definition: abti_error.h:355
ABT_barrier
struct ABT_barrier_opaque * ABT_barrier
Barrier handle type.
Definition: abt.h:1029
ABTI_HANDLE_ERROR
#define ABTI_HANDLE_ERROR(n)
Definition: abti_error.h:130
ABT_future
struct ABT_future_opaque * ABT_future
Future handle type.
Definition: abt.h:1022
ABT_TOOL_EVENT_THREAD_ALL
#define ABT_TOOL_EVENT_THREAD_ALL
Work-unit-event mask: all events.
Definition: abt.h:780
ABTI_initialized
ABT_bool ABTI_initialized(void)
Definition: global.c:187
ABT_SYNC_EVENT_TYPE_COND
@ ABT_SYNC_EVENT_TYPE_COND
Definition: abt.h:710
ABT_eventual
struct ABT_eventual_opaque * ABT_eventual
Eventual handle type.
Definition: abt.h:1015
ABTI_cond_get_handle
static ABT_cond ABTI_cond_get_handle(ABTI_cond *p_cond)
Definition: abti_cond.h:44
ABT_SUCCESS
#define ABT_SUCCESS
Error code: the routine returns successfully.
Definition: abt.h:92
ABT_TOOL_QUERY_KIND_POOL
@ ABT_TOOL_QUERY_KIND_POOL
Definition: abt.h:668
ABT_SYNC_EVENT_TYPE_BARRIER
@ ABT_SYNC_EVENT_TYPE_BARRIER
Definition: abt.h:718
ABTU_ret_err
#define ABTU_ret_err
Definition: abtu.h:155
ABT_SYNC_EVENT_TYPE_EVENTUAL
@ ABT_SYNC_EVENT_TYPE_EVENTUAL
Definition: abt.h:714
ABT_SYNC_EVENT_TYPE_RWLOCK
@ ABT_SYNC_EVENT_TYPE_RWLOCK
Definition: abt.h:712
ABT_SYNC_EVENT_TYPE_THREAD_JOIN
@ ABT_SYNC_EVENT_TYPE_THREAD_JOIN
Definition: abt.h:706
ABTI_tool_event_thread_update_callback
static void ABTI_tool_event_thread_update_callback(ABTI_global *p_global, ABT_tool_thread_callback_fn cb_func, uint64_t event_mask, void *user_arg)
Definition: abti_tool.h:54
ABTI_UB_ASSERT
#define ABTI_UB_ASSERT(cond)
Definition: abti_error.h:19
ABT_TOOL_EVENT_THREAD_NONE
#define ABT_TOOL_EVENT_THREAD_NONE
Work-unit-event mask: none.
Definition: abt.h:725
ABTI_thread::p_parent
ABTI_thread * p_parent
Definition: abti.h:429
tool_query
static ABTU_ret_err int tool_query(ABTI_tool_context *p_tctx, ABT_tool_query_kind query_kind, void *val)
Definition: tool.c:259
ABT_tool_query_thread
int ABT_tool_query_thread(ABT_tool_context context, uint64_t event, ABT_tool_query_kind query_kind, void *val)
Query information associated with a work-unit event.
Definition: tool.c:235
ABT_ERR_OTHER
#define ABT_ERR_OTHER
Error code: other error.
Definition: abt.h:109
ABT_cond
struct ABT_cond_opaque * ABT_cond
Condition variable handle type.
Definition: abt.h:1001
ABT_TOOL_QUERY_KIND_SYNC_OBJECT_HANDLE
@ ABT_TOOL_QUERY_KIND_SYNC_OBJECT_HANDLE
Definition: abt.h:678
ABTI_global
Definition: abti.h:223
ABT_ERR_FEATURE_NA
#define ABT_ERR_FEATURE_NA
Error code: unsupported feature.
Definition: abt.h:391
ABT_EXEC_ENTITY_TYPE_THREAD
@ ABT_EXEC_ENTITY_TYPE_THREAD
Definition: abt.h:689
ABT_tool_thread_callback_fn
void(* ABT_tool_thread_callback_fn)(ABT_thread, ABT_xstream, uint64_t event, ABT_tool_context context, void *user_arg)
Definition: abt.h:2307
ABT_rwlock
struct ABT_rwlock_opaque * ABT_rwlock
Readers-writer lock handle type.
Definition: abt.h:1008
ABTI_mutex_get_handle
static ABT_mutex ABTI_mutex_get_handle(ABTI_mutex *p_mutex)
Definition: abti_mutex.h:24
ABTI_pool_get_handle
static ABT_pool ABTI_pool_get_handle(ABTI_pool *p_pool)
Definition: abti_pool.h:26
ABTI_rwlock_get_handle
static ABT_rwlock ABTI_rwlock_get_handle(ABTI_rwlock *p_rwlock)
Definition: abti_rwlock.h:29
ABTI_mutex
Definition: abti.h:201