ARGOBOTS  1.1
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 {
86 #ifdef ABT_CONFIG_DISABLE_TOOL_INTERFACE
88 #else
89  ABTI_global *p_global;
90  ABTI_SETUP_GLOBAL(&p_global);
91 
92  if (cb_func == NULL)
93  event_mask = ABT_TOOL_EVENT_THREAD_NONE;
95  event_mask &
97  user_arg);
98  return ABT_SUCCESS;
99 #endif
100 }
101 
233 int ABT_tool_query_thread(ABT_tool_context context, uint64_t event,
234  ABT_tool_query_kind query_kind, void *val)
235 {
236 #ifdef ABT_CONFIG_DISABLE_TOOL_INTERFACE
238 #else
239  ABTI_tool_context *p_tctx = ABTI_tool_context_get_ptr(context);
241 
242  int abt_errno = tool_query(p_tctx, query_kind, val);
243  ABTI_CHECK_ERROR(abt_errno);
244  return ABT_SUCCESS;
245 #endif
246 }
247 
248 /*****************************************************************************/
249 /* Internal static functions */
250 /*****************************************************************************/
251 
252 #ifndef ABT_CONFIG_DISABLE_TOOL_INTERFACE
253 ABTU_ret_err static inline int
254 tool_query(ABTI_tool_context *p_tctx, ABT_tool_query_kind query_kind, void *val)
255 {
256  switch (query_kind) {
258  *(ABT_pool *)val = ABTI_pool_get_handle(p_tctx->p_pool);
259  break;
261  if (!p_tctx->p_parent) {
262  *(int *)val = 0;
263  } else {
264  int depth = 0;
265  ABTI_thread *p_cur = p_tctx->p_parent;
266  while (p_cur) {
267  depth++;
268  p_cur = p_cur->p_parent;
269  }
270  /* We do not count the root thread, so -1. */
271  *(int *)val = depth - 1;
272  }
273  break;
275  if (!p_tctx->p_caller) {
277  } else {
279  }
280  break;
282  if (!p_tctx->p_caller) {
283  *(void **)val = NULL;
284  } else {
285  *(ABT_thread *)val = ABTI_thread_get_handle(p_tctx->p_caller);
286  }
287  break;
289  *(ABT_sync_event_type *)val = p_tctx->sync_event_type;
290  break;
292  switch (p_tctx->sync_event_type) {
295  (ABTI_xstream *)p_tctx->p_sync_object);
296  break;
299  (ABTI_thread *)p_tctx->p_sync_object);
300  break;
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;
311  (ABTI_rwlock *)p_tctx->p_sync_object);
312  break;
315  (ABTI_eventual *)p_tctx->p_sync_object);
316  break;
319  (ABTI_future *)p_tctx->p_sync_object);
320  break;
323  (ABTI_barrier *)p_tctx->p_sync_object);
324  break;
325  default:
326  *(void **)val = NULL;
327  }
328  break;
329  default:
331  }
332  return ABT_SUCCESS;
333 }
334 #endif
ABT_tool_query_kind
ABT_tool_query_kind
Tool query kind for ABT_tool_query_thread().
Definition: abt.h:630
ABT_TOOL_QUERY_KIND_STACK_DEPTH
@ ABT_TOOL_QUERY_KIND_STACK_DEPTH
Definition: abt.h:634
ABT_EXEC_ENTITY_TYPE_EXT
@ ABT_EXEC_ENTITY_TYPE_EXT
Definition: abt.h:651
ABT_TOOL_QUERY_KIND_CALLER_HANDLE
@ ABT_TOOL_QUERY_KIND_CALLER_HANDLE
Definition: abt.h:638
ABT_thread
struct ABT_thread_opaque * ABT_thread
Work unit handle type.
Definition: abt.h:890
ABTI_SETUP_GLOBAL
#define ABTI_SETUP_GLOBAL(pp_global)
Definition: abti_error.h:59
ABTI_future
Definition: abti.h:456
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:640
ABT_exec_entity_type
ABT_exec_entity_type
Type of execution entity.
Definition: abt.h:649
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:448
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:120
ABT_SYNC_EVENT_TYPE_XSTREAM_JOIN
@ ABT_SYNC_EVENT_TYPE_XSTREAM_JOIN
Definition: abt.h:668
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:945
ABTI_tool_context
Definition: abti.h:489
ABT_SYNC_EVENT_TYPE_MUTEX
@ ABT_SYNC_EVENT_TYPE_MUTEX
Definition: abt.h:672
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:680
ABTI_thread
Definition: abti.h:371
ABTI_barrier
Definition: abti.h:465
ABTI_xstream
Definition: abti.h:264
ABT_pool
struct ABT_pool_opaque * ABT_pool
Pool handle type.
Definition: abt.h:841
ABT_TOOL_QUERY_KIND_CALLER_TYPE
@ ABT_TOOL_QUERY_KIND_CALLER_TYPE
Definition: abt.h:636
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:435
ABTI_tool_context::p_parent
ABTI_thread * p_parent
Definition: abti.h:493
ABTI_tool_context::p_sync_object
void * p_sync_object
Definition: abti.h:495
ABT_sync_event_type
ABT_sync_event_type
Type of synchronization event.
Definition: abt.h:660
abti.h
ABT_tool_context
struct ABT_tool_context_opaque * ABT_tool_context
Tool context handle type.
Definition: abt.h:1013
ABT_xstream
struct ABT_xstream_opaque * ABT_xstream
Execution stream handle type.
Definition: abt.h:789
ABTI_rwlock
Definition: abti.h:441
ABTI_CHECK_NULL_TOOL_CONTEXT_PTR
#define ABTI_CHECK_NULL_TOOL_CONTEXT_PTR(p)
Definition: abti_error.h:321
ABT_barrier
struct ABT_barrier_opaque * ABT_barrier
Barrier handle type.
Definition: abt.h:987
ABTI_HANDLE_ERROR
#define ABTI_HANDLE_ERROR(n)
Definition: abti_error.h:114
ABTI_tool_context::sync_event_type
ABT_sync_event_type sync_event_type
Definition: abti.h:494
ABT_future
struct ABT_future_opaque * ABT_future
Future handle type.
Definition: abt.h:980
ABT_TOOL_EVENT_THREAD_ALL
#define ABT_TOOL_EVENT_THREAD_ALL
Work-unit-event mask: all events.
Definition: abt.h:744
ABT_SYNC_EVENT_TYPE_COND
@ ABT_SYNC_EVENT_TYPE_COND
Definition: abt.h:674
ABT_eventual
struct ABT_eventual_opaque * ABT_eventual
Eventual handle type.
Definition: abt.h:973
ABTI_tool_context::p_pool
ABTI_pool * p_pool
Definition: abti.h:491
ABTI_cond_get_handle
static ABT_cond ABTI_cond_get_handle(ABTI_cond *p_cond)
Definition: abti_cond.h:43
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:632
ABT_SYNC_EVENT_TYPE_BARRIER
@ ABT_SYNC_EVENT_TYPE_BARRIER
Definition: abt.h:682
ABTU_ret_err
#define ABTU_ret_err
Definition: abtu.h:146
ABTI_tool_context::p_caller
ABTI_thread * p_caller
Definition: abti.h:490
ABT_SYNC_EVENT_TYPE_EVENTUAL
@ ABT_SYNC_EVENT_TYPE_EVENTUAL
Definition: abt.h:678
ABT_SYNC_EVENT_TYPE_RWLOCK
@ ABT_SYNC_EVENT_TYPE_RWLOCK
Definition: abt.h:676
ABT_SYNC_EVENT_TYPE_THREAD_JOIN
@ ABT_SYNC_EVENT_TYPE_THREAD_JOIN
Definition: abt.h:670
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
ABT_TOOL_EVENT_THREAD_NONE
#define ABT_TOOL_EVENT_THREAD_NONE
Work-unit-event mask: none.
Definition: abt.h:689
ABTI_thread::p_parent
ABTI_thread * p_parent
Definition: abti.h:378
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:254
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:233
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:959
ABT_TOOL_QUERY_KIND_SYNC_OBJECT_HANDLE
@ ABT_TOOL_QUERY_KIND_SYNC_OBJECT_HANDLE
Definition: abt.h:642
ABTI_global
Definition: abti.h:196
ABT_ERR_FEATURE_NA
#define ABT_ERR_FEATURE_NA
Error code: unsupported feature.
Definition: abt.h:381
ABT_EXEC_ENTITY_TYPE_THREAD
@ ABT_EXEC_ENTITY_TYPE_THREAD
Definition: abt.h:653
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:1683
ABT_rwlock
struct ABT_rwlock_opaque * ABT_rwlock
Readers-writer lock handle type.
Definition: abt.h:966
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:174