6 #ifndef ABTI_TOOL_H_INCLUDED
7 #define ABTI_TOOL_H_INCLUDED
9 static inline ABT_thread ABTI_ythread_get_handle(ABTI_ythread *p_thread);
10 static inline ABT_task ABTI_thread_get_handle(ABTI_thread *p_task);
12 #ifndef ABT_CONFIG_DISABLE_TOOL_INTERFACE
13 static inline ABTI_tool_context *
16 #ifndef ABT_CONFIG_DISABLE_ERROR_CHECK
17 ABTI_tool_context *p_tctx;
21 p_tctx = (ABTI_tool_context *)tctx;
25 return (ABTI_tool_context *)tctx;
30 ABTI_tool_context_get_handle(ABTI_tool_context *p_tctx)
32 #ifndef ABT_CONFIG_DISABLE_ERROR_CHECK
45 #define ABTI_TOOL_EVENT_TAG_SIZE 20
46 #define ABTI_TOOL_EVENT_TAG_MASK \
47 ((((uint64_t)1 << (uint64_t)ABTI_TOOL_EVENT_TAG_SIZE) - 1) \
48 << (uint64_t)(64 - 1 - ABTI_TOOL_EVENT_TAG_SIZE))
49 #define ABTI_TOOL_EVENT_TAG_INC \
50 ((uint64_t)1 << (uint64_t)(64 - 1 - ABTI_TOOL_EVENT_TAG_SIZE))
51 #define ABTI_TOOL_EVENT_TAG_DIRTY_BIT ((uint64_t)1 << (uint64_t)(64 - 1))
54 ABTI_tool_event_thread_update_callback(ABTI_global *p_global,
56 uint64_t event_mask,
void *user_arg)
59 ABTD_spinlock_acquire(&p_global->tool_writer_lock);
78 uint64_t current = ABTD_atomic_acquire_load_uint64(
79 &p_global->tool_thread_event_mask_tagged);
81 (current + ABTI_TOOL_EVENT_TAG_INC) & ABTI_TOOL_EVENT_TAG_MASK;
83 ~ABTI_TOOL_EVENT_TAG_DIRTY_BIT);
84 uint64_t dirty_mask = ABTI_TOOL_EVENT_TAG_DIRTY_BIT | new_mask;
86 ABTD_atomic_release_store_uint64(&p_global->tool_thread_event_mask_tagged,
88 p_global->tool_thread_cb_f = cb_func;
89 p_global->tool_thread_user_arg = user_arg;
90 ABTD_atomic_release_store_uint64(&p_global->tool_thread_event_mask_tagged,
93 ABTD_spinlock_release(&p_global->tool_writer_lock);
97 ABTI_tool_event_thread(ABTI_local *p_local, uint64_t event_code,
98 ABTI_thread *p_thread, ABTI_thread *p_caller,
99 ABTI_pool *p_pool, ABTI_thread *p_parent,
102 if (p_thread->type & ABTI_THREAD_TYPE_ROOT)
106 uint64_t current_mask = ABTD_atomic_acquire_load_uint64(
107 &p_global->tool_thread_event_mask_tagged);
108 if (current_mask & event_code) {
110 p_global->tool_thread_cb_f;
111 void *user_arg_thread = p_global->tool_thread_user_arg;
113 uint64_t current_mask2 = ABTD_atomic_acquire_load_uint64(
114 &p_global->tool_thread_event_mask_tagged);
116 (current_mask & ABTI_TOOL_EVENT_TAG_DIRTY_BIT)))
118 ABTI_tool_context tctx;
119 tctx.p_pool = p_pool;
120 tctx.p_parent = p_parent;
121 tctx.p_caller = p_caller;
122 tctx.sync_event_type = sync_event_type;
123 tctx.p_sync_object = p_sync_object;
125 ABTI_xstream *p_local_xstream =
126 ABTI_local_get_xstream_or_null(p_local);
128 p_local_xstream ? ABTI_xstream_get_handle(p_local_xstream)
130 ABT_thread h_thread = ABTI_thread_get_handle(p_thread);
132 cb_func_thread(h_thread, h_xstream, event_code, h_tctx,