Go to the documentation of this file.
6 #ifndef ABTI_H_INCLUDED
7 #define ABTI_H_INCLUDED
19 #ifndef ABT_CONFIG_DISABLE_ERROR_CHECK
20 #define ABTI_IS_ERROR_CHECK_ENABLED 1
22 #define ABTI_IS_ERROR_CHECK_ENABLED 0
25 #ifdef ABT_CONFIG_DISABLE_EXT_THREAD
26 #define ABTI_IS_EXT_THREAD_ENABLED 0
28 #define ABTI_IS_EXT_THREAD_ENABLED 1
36 #define ABTI_SCHED_NUM_PRIO 3
38 #define ABTI_SCHED_REQ_FINISH (1 << 0)
39 #define ABTI_SCHED_REQ_EXIT (1 << 1)
40 #define ABTI_SCHED_REQ_REPLACE (1 << 2)
42 #define ABTI_THREAD_REQ_JOIN (1 << 0)
43 #define ABTI_THREAD_REQ_TERMINATE (1 << 1)
44 #define ABTI_THREAD_REQ_CANCEL (1 << 2)
45 #define ABTI_THREAD_REQ_MIGRATE (1 << 3)
46 #define ABTI_THREAD_REQ_BLOCK (1 << 4)
47 #define ABTI_THREAD_REQ_ORPHAN (1 << 5)
48 #define ABTI_THREAD_REQ_NON_YIELD \
49 (ABTI_THREAD_REQ_CANCEL | ABTI_THREAD_REQ_MIGRATE | \
50 ABTI_THREAD_REQ_TERMINATE | ABTI_THREAD_REQ_BLOCK | \
51 ABTI_THREAD_REQ_ORPHAN)
53 #define ABTI_THREAD_INIT_ID 0xFFFFFFFFFFFFFFFF
54 #define ABTI_TASK_INIT_ID 0xFFFFFFFFFFFFFFFF
58 #define ABTI_UNIT_HASH_TABLE_SIZE_EXP 8
59 #define ABTI_UNIT_HASH_TABLE_SIZE ((size_t)(1 << ABTI_UNIT_HASH_TABLE_SIZE_EXP))
61 #define ABTI_SCHED_CONFIG_HTABLE_SIZE 8
62 #define ABTI_SCHED_CONFIG_UNUSED_INDEX INT_MIN
64 #define ABT_THREAD_TYPE_FULLY_FLEDGED 0
65 #define ABT_THREAD_TYPE_DYNAMIC_PROMOTION 1
67 #define ABTI_STACK_CHECK_TYPE_NONE 0
68 #define ABTI_STACK_CHECK_TYPE_CANARY 1
81 #define ABTI_THREAD_TYPE_EXT ((ABTI_thread_type)0)
82 #define ABTI_THREAD_TYPE_THREAD ((ABTI_thread_type)(0x1 << 0))
83 #define ABTI_THREAD_TYPE_ROOT ((ABTI_thread_type)(0x1 << 1))
84 #define ABTI_THREAD_TYPE_PRIMARY ((ABTI_thread_type)(0x1 << 2))
85 #define ABTI_THREAD_TYPE_MAIN_SCHED ((ABTI_thread_type)(0x1 << 3))
86 #define ABTI_THREAD_TYPE_YIELDABLE ((ABTI_thread_type)(0x1 << 4))
87 #define ABTI_THREAD_TYPE_NAMED ((ABTI_thread_type)(0x1 << 5))
88 #define ABTI_THREAD_TYPE_MIGRATABLE ((ABTI_thread_type)(0x1 << 6))
90 #define ABTI_THREAD_TYPE_MEM_MEMPOOL_DESC ((ABTI_thread_type)(0x1 << 7))
91 #define ABTI_THREAD_TYPE_MEM_MALLOC_DESC ((ABTI_thread_type)(0x1 << 8))
92 #define ABTI_THREAD_TYPE_MEM_MEMPOOL_DESC_STACK ((ABTI_thread_type)(0x1 << 9))
93 #define ABTI_THREAD_TYPE_MEM_MALLOC_DESC_STACK ((ABTI_thread_type)(0x1 << 10))
95 #define ABTI_THREAD_TYPES_MEM \
96 (ABTI_THREAD_TYPE_MEM_MEMPOOL_DESC | ABTI_THREAD_TYPE_MEM_MALLOC_DESC | \
97 ABTI_THREAD_TYPE_MEM_MEMPOOL_DESC_STACK | \
98 ABTI_THREAD_TYPE_MEM_MALLOC_DESC_STACK)
101 #define ABTI_MUTEX_ATTR_NONE 0
103 #define ABTI_MUTEX_ATTR_RECURSIVE 1
106 #define ABTI_UNUSED(a) (void)(a)
140 #ifndef ABT_CONFIG_DISABLE_TOOL_INTERFACE
145 struct ABTI_native_thread_id_opaque;
148 struct ABTI_thread_id_opaque;
163 #ifndef ABT_CONFIG_ACTIVE_WAIT_POLICY
181 #ifndef ABT_CONFIG_USE_SIMPLE_MUTEX
219 #ifdef ABT_CONFIG_USE_MEM_POOL
220 size_t mem_page_size;
222 uint32_t mem_max_stacks;
223 uint32_t mem_max_descs;
229 #ifndef ABT_CONFIG_DISABLE_EXT_THREAD
240 #ifndef ABT_CONFIG_DISABLE_TOOL_INTERFACE
260 void *(*get_local_ptr_f)(void);
283 #ifdef ABT_CONFIG_USE_MEM_POOL
309 #ifdef ABT_CONFIG_USE_DEBUG_LOG
317 char val[
sizeof(double) >
sizeof(
void *)
392 #ifndef ABT_CONFIG_DISABLE_MIGRATION
474 #ifdef HAVE_PTHREAD_BARRIER_INIT
488 #ifndef ABT_CONFIG_DISABLE_TOOL_INTERFACE
548 int idx,
void *p_val);
578 void (*thread_func)(
void *),
void *arg,
ABT_unit(* ABT_pool_pop_fn)(ABT_pool)
ABTI_local_func gp_ABTI_local_func
ABT_pool_get_size_fn p_get_size
ABTD_spinlock tool_writer_lock
ABT_sched_predef
Predefined scheduler type.
#define ABTI_SCHED_CONFIG_HTABLE_SIZE
ABTD_atomic_int32 num_blocked
ABTD_futex_multiple futex
uint64_t sched_sleep_nsec
void(* f_migration_cb)(ABT_thread, void *)
int ABT_bool
Boolean type.
char val[sizeof(double) > sizeof(void *) ? sizeof(double) :sizeof(void *)]
@ ABTI_XSTREAM_TYPE_PRIMARY
ABTI_sched_config_element elements[ABTI_SCHED_CONFIG_HTABLE_SIZE]
size_t ABTI_sched_get_total_size(ABTI_sched *p_sched)
ABTU_ret_err int ABTI_sched_create_basic(ABT_sched_predef predef, int num_pools, ABT_pool *pools, ABTI_sched_config *p_config, ABTI_sched **pp_newsched)
ABT_bool(* ABT_unit_is_in_pool_fn)(ABT_unit)
ABT_pool_print_all_fn p_print_all
void(* ABT_sched_run_fn)(ABT_sched)
ABT_pool_remove_fn p_remove
struct ABT_thread_opaque * ABT_thread
Work unit handle type.
ABTD_atomic_ptr p_migration_pool
ABT_pool_print_all_fn p_print_all
ABTD_spinlock xstream_list_lock
void ABTI_xstream_schedule(void *p_arg)
ABTU_ret_err int ABTI_thread_revive(ABTI_global *p_global, ABTI_local *p_local, ABTI_pool *p_pool, void(*thread_func)(void *), void *arg, ABTI_thread *p_thread)
void ABTI_sched_exit(ABTI_sched *p_sched)
void ABTI_pool_reset_id(void)
void ABTI_thread_print(ABTI_thread *p_thread, FILE *p_os, int indent)
ABT_unit(* ABT_pool_pop_wait_fn)(ABT_pool, double)
ABTI_global * gp_ABTI_global
ABTD_atomic_uint32 request
ABT_unit_id ABTI_thread_get_id(ABTI_thread *p_thread)
ABT_tool_thread_callback_fn tool_thread_cb_f
#define ABTD_XSTREAM_LOCAL
void ABTI_thread_free(ABTI_global *p_global, ABTI_local *p_local, ABTI_thread *p_thread)
ABT_unit_create_from_thread_fn u_create_from_thread
ABTU_ret_err int ABTI_ythread_create_primary(ABTI_global *p_global, ABTI_local *p_local, ABTI_xstream *p_xstream, ABTI_ythread **p_ythread)
ABT_unit(* ABT_pool_pop_timedwait_fn)(ABT_pool, double)
void ABTI_unit_unmap_thread(ABTI_global *p_global, ABT_unit unit)
ABTU_ret_err int ABTI_pool_get_fifo_def(ABT_pool_access access, ABTI_pool_def *p_def)
ABT_sched_type
Scheduler's work unit type.
int(* ABT_pool_print_all_fn)(ABT_pool, void *arg, void(*)(void *, ABT_unit))
struct ABT_pool_opaque * ABT_pool
Pool handle type.
ABT_bool ABTI_sched_has_to_stop(ABTI_local **pp_local, ABTI_sched *p_sched)
void ABTI_thread_attr_print(ABTI_thread_attr *p_attr, FILE *p_os, int indent)
void(* ABT_unit_free_fn)(ABT_unit *)
ABT_sched_def * ABTI_sched_get_basic_wait_def(void)
ABT_unit_is_in_pool_fn u_is_in_pool
void ABTI_pool_free(ABTI_pool *p_pool)
void ABTI_info_check_print_all_thread_stacks(void)
ABTU_noreturn void ABTI_ythread_exit(ABTI_xstream *p_local_xstream, ABTI_ythread *p_ythread)
void ABTI_ythread_free_root(ABTI_global *p_global, ABTI_local *p_local, ABTI_ythread *p_ythread)
uint64_t ABT_unit_id
Work unit ID type.
ABTI_unit_to_thread_entry unit_to_thread_entires[ABTI_UNIT_HASH_TABLE_SIZE]
int(* ABT_pool_remove_fn)(ABT_pool, ABT_unit)
int(* ABT_pool_init_fn)(ABT_pool, ABT_pool_config)
ABT_unit_is_in_pool_fn u_is_in_pool
ABT_pool_pop_wait_fn p_pop_wait
ABT_sync_event_type sync_event_type
void ABTI_xstream_free(ABTI_global *p_global, ABTI_local *p_local, ABTI_xstream *p_xstream, ABT_bool force_free)
void ABTI_sched_finish(ABTI_sched *p_sched)
void ABTI_unit_finalize_hash_table(ABTI_global *p_global)
ABT_sched_config_type type
ABTU_ret_err int ABTI_pool_create_basic(ABT_pool_kind kind, ABT_pool_access access, ABT_bool automatic, ABTI_pool **pp_newpool)
ABTI_sched * p_main_sched
ABT_pool_remove_fn p_remove
int(* ABT_sched_init_fn)(ABT_sched, ABT_sched_config)
void * p_migration_cb_arg
ABTU_ret_err int ABTI_sched_get_migration_pool(ABTI_sched *, ABTI_pool *, ABTI_pool **)
ABT_sched_get_migr_pool_fn get_migr_pool
uint32_t sched_event_freq
@ ABTI_XSTREAM_TYPE_SECONDARY
void ABTI_sched_reset_id(void)
void ABTI_thread_join(ABTI_local **pp_local, ABTI_thread *p_thread)
ABT_sched_def * ABTI_sched_get_basic_def(void)
ABTU_ret_err int ABTI_sched_config_read(const ABTI_sched_config *p_config, int idx, void *p_val)
struct ABT_unit_opaque * ABT_unit
Work unit handle type for scheduling.
void * tool_thread_user_arg
ABT_sched_def * ABTI_sched_get_randws_def(void)
ABTD_spinlock waiter_lock
void ABTI_xstream_print(ABTI_xstream *p_xstream, FILE *p_os, int indent, ABT_bool print_sub)
ABT_unit_create_from_thread_fn u_create_from_thread
uint32_t mutex_max_handovers
ABTI_mutex * p_waiter_mutex
ABT_pool_pop_timedwait_fn p_pop_timedwait
ABTI_sched * p_replace_sched
ABT_pool_get_size_fn p_get_size
ABTD_atomic_int is_in_pool
#define ABT_CONFIG_STATIC_CACHELINE_SIZE
ABTI_thread * ABTI_unit_get_thread_from_user_defined_unit(ABTI_global *p_global, ABT_unit unit)
void ABTI_unit_init_hash_table(ABTI_global *p_global)
ABTI_ythread * p_primary_ythread
char padding2[ABT_CONFIG_STATIC_CACHELINE_SIZE]
void ABTI_xstream_check_events(ABTI_xstream *p_xstream, ABTI_sched *p_sched)
ABTI_sched_config_element * p_next
char padding1[ABT_CONFIG_STATIC_CACHELINE_SIZE]
struct ABTI_thread_id_opaque * ABTI_thread_id
ABT_pool_pop_wait_fn p_pop_wait
ABTI_xstream * p_xstream_head
void ABTI_ythread_set_blocked(ABTI_ythread *p_ythread)
ABT_thread(* ABT_unit_get_thread_fn)(ABT_unit)
void(* set_local_xstream_f)(ABTI_xstream *)
ABTU_ret_err int ABTI_thread_attr_dup(const ABTI_thread_attr *p_attr, ABTI_thread_attr **pp_dup_attr) ABTU_ret_err
uint32_t mutex_max_wakeups
void(* ABT_pool_push_fn)(ABT_pool, ABT_unit)
uint32_t ABTI_thread_type
ABTD_atomic_uint32 request
ABTD_atomic_uint64 tool_thread_event_mask_tagged
void ABTI_xstream_start_primary(ABTI_global *p_global, ABTI_xstream **pp_local_xstream, ABTI_xstream *p_xstream, ABTI_ythread *p_ythread)
ABTU_ret_err int ABTI_ythread_create_root(ABTI_global *p_global, ABTI_local *p_local, ABTI_xstream *p_xstream, ABTI_ythread **pp_root_ythread)
ABTI_ythread * p_root_ythread
uintptr_t ABTI_sched_kind
ABTI_atomic_unit_to_thread list
void ABTI_ythread_set_ready(ABTI_local *p_local, ABTI_ythread *p_ythread)
void ABTI_ythread_free_primary(ABTI_global *p_global, ABTI_local *p_local, ABTI_ythread *p_ythread)
void ABTI_ythread_suspend(ABTI_xstream **pp_local_xstream, ABTI_ythread *p_ythread, ABT_sync_event_type sync_event_type, void *p_sync)
void(* f_destructor)(void *value)
A struct that defines a scheduler.
ABTD_XSTREAM_LOCAL ABTI_local * lp_ABTI_local
void ABTI_xstream_run_thread(ABTI_global *p_global, ABTI_xstream **pp_local_xstream, ABTI_thread *p_thread)
ABTU_ret_err int ABTI_ythread_create_main_sched(ABTI_global *p_global, ABTI_local *p_local, ABTI_xstream *p_xstream, ABTI_sched *p_sched)
#define ABTI_UNIT_HASH_TABLE_SIZE
ABT_pool(* ABT_sched_get_migr_pool_fn)(ABT_sched)
ABTI_xstream * p_last_xstream
size_t(* ABT_pool_get_size_fn)(ABT_pool)
ABTU_ret_err int ABTI_pool_get_fifo_wait_def(ABT_pool_access access, ABTI_pool_def *p_def)
void ABTI_sched_free(ABTI_global *p_global, ABTI_local *p_local, ABTI_sched *p_sched, ABT_bool force_free)
void ABTI_ythread_print_stack(ABTI_ythread *p_ythread, FILE *p_os)
ABTD_atomic_ptr p_keytable
ABTU_ret_err int ABTI_thread_get_mig_data(ABTI_global *p_global, ABTI_local *p_local, ABTI_thread *p_thread, ABTI_thread_mig_data **pp_mig_data)
ABTI_thread_type thread_type
struct ABTI_local ABTI_local
ABTU_align_member_var(ABT_CONFIG_STATIC_CACHELINE_SIZE) ABTI_thread *p_thread
void(* f_cb)(ABT_thread, void *)
int(* ABT_pool_free_fn)(ABT_pool)
ABTD_atomic_ptr p_elems[1]
void ABTI_pool_print(ABTI_pool *p_pool, FILE *p_os, int indent)
ABT_unit_get_thread_fn u_get_thread
void ABTI_ktable_free(ABTI_global *p_global, ABTI_local *p_local, ABTI_ktable *p_ktable)
void ABTI_thread_reset_id(void)
void(* ABT_tool_thread_callback_fn)(ABT_thread, ABT_xstream, uint64_t event, ABT_tool_context context, void *user_arg)
ABTU_ret_err int ABTI_ythread_create_sched(ABTI_global *p_global, ABTI_local *p_local, ABTI_pool *p_pool, ABTI_sched *p_sched)
struct ABTI_native_thread_id_opaque * ABTI_native_thread_id
size_t ABTI_sched_get_size(ABTI_sched *p_sched)
ABTU_ret_err int ABTI_unit_map_thread(ABTI_global *p_global, ABT_unit unit, ABTI_thread *p_thread)
int(* ABT_sched_free_fn)(ABT_sched)
ABTU_ret_err int ABTI_xstream_create_primary(ABTI_global *p_global, ABTI_xstream **pp_xstream)
ABT_pool_kind
Predefined pool type.
void(* p_callback)(void **arg)
void * ABTD_xstream_barrier
ABTI_ythread * p_replace_waiter
ABTD_atomic_int32 num_scheds
ABT_pool_pop_timedwait_fn p_pop_timedwait
size_t ABTI_sched_get_effective_size(ABTI_local *p_local, ABTI_sched *p_sched)
void ABTI_info_print_config(ABTI_global *p_global, FILE *fp)
ABT_sched_def * ABTI_sched_get_prio_def(void)
void(* f_destructor)(void *value)
ABT_unit(* ABT_unit_create_from_thread_fn)(ABT_thread)
ABT_sched_config_type
A struct that sets and gets a scheduler configuration.
ABT_pool_access
Pool access type.
void ABTI_sched_print(ABTI_sched *p_sched, FILE *p_os, int indent, ABT_bool print_sub)