6 #ifndef ABTD_H_INCLUDED
7 #define ABTD_H_INCLUDED
18 ABTD_XSTREAM_CONTEXT_STATE_RUNNING,
19 ABTD_XSTREAM_CONTEXT_STATE_WAITING,
20 ABTD_XSTREAM_CONTEXT_STATE_REQ_JOIN,
21 ABTD_XSTREAM_CONTEXT_STATE_REQ_TERMINATE,
22 ABTD_XSTREAM_CONTEXT_STATE_UNINIT,
23 } ABTD_xstream_context_state;
24 typedef struct ABTD_xstream_context {
25 pthread_t native_thread;
26 void *(*thread_f)(
void *);
28 ABTD_xstream_context_state state;
29 pthread_mutex_t state_lock;
30 pthread_cond_t state_cond;
31 } ABTD_xstream_context;
32 typedef pthread_mutex_t ABTD_xstream_mutex;
33 #ifdef HAVE_PTHREAD_BARRIER_INIT
34 typedef pthread_barrier_t ABTD_xstream_barrier;
36 typedef void *ABTD_xstream_barrier;
38 typedef struct ABTD_affinity_cpuset {
41 } ABTD_affinity_cpuset;
44 #define ABTD_XSTREAM_LOCAL __thread
47 void ABTD_env_init(ABTI_global *p_global);
49 ABT_bool ABTD_env_get_use_debug(
void);
50 ABT_bool ABTD_env_get_use_logging(
void);
51 ABT_bool ABTD_env_get_print_config(
void);
52 int ABTD_env_get_max_xstreams(
void);
53 uint32_t ABTD_env_key_table_size(
void);
54 size_t ABTD_env_get_sys_pagesize(
void);
55 size_t ABTD_env_get_thread_stacksize(
void);
56 size_t ABTD_env_get_sched_stacksize(
void);
57 uint32_t ABTD_env_get_sched_event_freq(
void);
58 uint64_t ABTD_env_get_sched_sleep_nsec(
void);
62 ABTU_ret_err int ABTD_xstream_context_create(
void *(*f_xstream)(
void *),
64 ABTD_xstream_context *p_ctx);
65 void ABTD_xstream_context_free(ABTD_xstream_context *p_ctx);
66 void ABTD_xstream_context_join(ABTD_xstream_context *p_ctx);
67 void ABTD_xstream_context_revive(ABTD_xstream_context *p_ctx);
68 void ABTD_xstream_context_set_self(ABTD_xstream_context *p_ctx);
69 void ABTD_xstream_context_print(ABTD_xstream_context *p_ctx, FILE *p_os,
73 void ABTD_affinity_init(ABTI_global *p_global,
const char *affinity_str);
74 void ABTD_affinity_finalize(ABTI_global *p_global);
75 ABTU_ret_err int ABTD_affinity_cpuset_read(ABTD_xstream_context *p_ctx,
76 int max_cpuids,
int *cpuids,
79 ABTD_affinity_cpuset_apply(ABTD_xstream_context *p_ctx,
80 const ABTD_affinity_cpuset *p_cpuset);
81 int ABTD_affinity_cpuset_apply_default(ABTD_xstream_context *p_ctx,
int rank);
82 void ABTD_affinity_cpuset_destroy(ABTD_affinity_cpuset *p_cpuset);
85 typedef struct ABTD_affinity_id_list {
88 } ABTD_affinity_id_list;
89 typedef struct ABTD_affinity_list {
91 ABTD_affinity_id_list **p_id_lists;
95 ABTD_affinity_list_create(
const char *affinity_str,
96 ABTD_affinity_list **pp_affinity_list);
97 void ABTD_affinity_list_free(ABTD_affinity_list *p_list);
101 #if defined(ABT_CONFIG_USE_CLOCK_GETTIME)
103 typedef struct timespec ABTD_time;
105 #elif defined(ABT_CONFIG_USE_MACH_ABSOLUTE_TIME)
106 #include <mach/mach_time.h>
107 typedef uint64_t ABTD_time;
109 #elif defined(ABT_CONFIG_USE_GETTIMEOFDAY)
110 #include <sys/time.h>
111 typedef struct timeval ABTD_time;
115 void ABTD_time_init(
void);
116 void ABTD_time_get(ABTD_time *p_time);
117 double ABTD_time_read_sec(ABTD_time *p_time);