ARGOBOTS  dce6e727ffc4ca5b3ffc04cb9517c6689be51ec5
abtd.h
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 #ifndef ABTD_H_INCLUDED
7 #define ABTD_H_INCLUDED
8 
9 #define __USE_GNU 1
10 #include <pthread.h>
11 #include "abtd_atomic.h"
12 #include "abtd_context.h"
13 #include "abtd_spinlock.h"
14 #include "abtd_futex.h"
15 
16 /* Data Types */
17 typedef enum {
24 typedef struct ABTD_xstream_context {
25  pthread_t native_thread;
26  void *(*thread_f)(void *);
27  void *p_arg;
29  pthread_mutex_t state_lock;
30  pthread_cond_t state_cond;
32 typedef pthread_mutex_t ABTD_xstream_mutex;
33 #ifdef HAVE_PTHREAD_BARRIER_INIT
34 typedef pthread_barrier_t ABTD_xstream_barrier;
35 #else
36 typedef void *ABTD_xstream_barrier;
37 #endif
38 typedef struct ABTD_affinity_cpuset {
39  size_t num_cpuids;
40  int *cpuids;
42 
43 /* ES Storage Qualifier */
44 #define ABTD_XSTREAM_LOCAL __thread
45 
46 /* Environment */
47 void ABTD_env_init(ABTI_global *p_global);
48 /* Following does not need p_global. */
53 uint32_t ABTD_env_key_table_size(void);
54 size_t ABTD_env_get_sys_pagesize(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);
60 
61 /* ES Context */
62 ABTU_ret_err int ABTD_xstream_context_create(void *(*f_xstream)(void *),
63  void *p_arg,
64  ABTD_xstream_context *p_ctx);
69 void ABTD_xstream_context_print(ABTD_xstream_context *p_ctx, FILE *p_os,
70  int indent);
71 
72 /* ES Affinity */
73 void ABTD_affinity_init(ABTI_global *p_global, const char *affinity_str);
74 void ABTD_affinity_finalize(ABTI_global *p_global);
76  int max_cpuids, int *cpuids,
77  int *p_num_cpuids);
78 ABTU_ret_err int
80  const ABTD_affinity_cpuset *p_cpuset);
83 
84 /* ES Affinity Parser */
85 typedef struct ABTD_affinity_id_list {
86  uint32_t num;
87  int *ids; /* id here can be negative. */
89 typedef struct ABTD_affinity_list {
90  uint32_t num;
92  void *p_mem_head; /* List to free all the allocated memory easily */
94 ABTU_ret_err int
95 ABTD_affinity_list_create(const char *affinity_str,
96  ABTD_affinity_list **pp_affinity_list);
98 
99 #include "abtd_stream.h"
100 
101 #if defined(ABT_CONFIG_USE_CLOCK_GETTIME)
102 #include <time.h>
103 typedef struct timespec ABTD_time;
104 
105 #elif defined(ABT_CONFIG_USE_MACH_ABSOLUTE_TIME)
106 #include <mach/mach_time.h>
107 typedef uint64_t ABTD_time;
108 
109 #elif defined(ABT_CONFIG_USE_GETTIMEOFDAY)
110 #include <sys/time.h>
111 typedef struct timeval ABTD_time;
112 
113 #endif
114 
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);
118 
119 #endif /* ABTD_H_INCLUDED */
ABTD_xstream_context_state
ABTD_xstream_context_state
Definition: abtd.h:17
ABTD_xstream_context::native_thread
pthread_t native_thread
Definition: abtd.h:25
ABTD_time
struct timespec ABTD_time
Definition: abtd.h:103
ABT_bool
int ABT_bool
Boolean type.
Definition: abt.h:1043
ABTD_XSTREAM_CONTEXT_STATE_WAITING
@ ABTD_XSTREAM_CONTEXT_STATE_WAITING
Definition: abtd.h:19
ABTD_affinity_cpuset_apply
ABTU_ret_err int ABTD_affinity_cpuset_apply(ABTD_xstream_context *p_ctx, const ABTD_affinity_cpuset *p_cpuset)
Definition: abtd_affinity.c:436
ABTD_XSTREAM_CONTEXT_STATE_RUNNING
@ ABTD_XSTREAM_CONTEXT_STATE_RUNNING
Definition: abtd.h:18
ABTD_xstream_context_print
void ABTD_xstream_context_print(ABTD_xstream_context *p_ctx, FILE *p_os, int indent)
Definition: abtd_stream.c:143
ABTD_xstream_context
Definition: abtd.h:24
ABTD_xstream_context_free
void ABTD_xstream_context_free(ABTD_xstream_context *p_ctx)
Definition: abtd_stream.c:90
abtd_context.h
ABTD_affinity_cpuset
struct ABTD_affinity_cpuset ABTD_affinity_cpuset
ABTD_xstream_mutex
pthread_mutex_t ABTD_xstream_mutex
Definition: abtd.h:32
ABTD_XSTREAM_CONTEXT_STATE_REQ_JOIN
@ ABTD_XSTREAM_CONTEXT_STATE_REQ_JOIN
Definition: abtd.h:20
ABTD_xstream_context::state_lock
pthread_mutex_t state_lock
Definition: abtd.h:29
ABTD_xstream_context
struct ABTD_xstream_context ABTD_xstream_context
ABTD_xstream_context_revive
void ABTD_xstream_context_revive(ABTD_xstream_context *p_ctx)
Definition: abtd_stream.c:128
ABTD_affinity_list
Definition: abtd.h:89
ABTD_xstream_context_create
ABTU_ret_err int ABTD_xstream_context_create(void *(*f_xstream)(void *), void *p_arg, ABTD_xstream_context *p_ctx)
Definition: abtd_stream.c:48
ABTD_XSTREAM_CONTEXT_STATE_REQ_TERMINATE
@ ABTD_XSTREAM_CONTEXT_STATE_REQ_TERMINATE
Definition: abtd.h:21
ABTD_env_get_print_config
ABT_bool ABTD_env_get_print_config(void)
Definition: abtd_env.c:255
ABTD_env_get_sys_pagesize
size_t ABTD_env_get_sys_pagesize(void)
Definition: abtd_env.c:276
ABTD_xstream_context_set_self
void ABTD_xstream_context_set_self(ABTD_xstream_context *p_ctx)
Definition: abtd_stream.c:138
ABTD_env_get_use_debug
ABT_bool ABTD_env_get_use_debug(void)
Definition: abtd_env.c:230
ABTD_env_get_sched_stacksize
size_t ABTD_env_get_sched_stacksize(void)
Definition: abtd_env.c:304
ABTD_env_get_sched_event_freq
uint32_t ABTD_env_get_sched_event_freq(void)
Definition: abtd_env.c:320
ABTD_xstream_context::state_cond
pthread_cond_t state_cond
Definition: abtd.h:30
ABTD_xstream_barrier
pthread_barrier_t ABTD_xstream_barrier
Definition: abtd.h:34
ABTD_xstream_context::p_arg
void * p_arg
Definition: abtd.h:27
ABTD_time_init
void ABTD_time_init(void)
Definition: abtd_time.c:11
ABTD_affinity_list_create
ABTU_ret_err int ABTD_affinity_list_create(const char *affinity_str, ABTD_affinity_list **pp_affinity_list)
Definition: abtd_affinity_parser.c:337
ABTD_env_get_thread_stacksize
size_t ABTD_env_get_thread_stacksize(void)
Definition: abtd_env.c:288
ABTD_affinity_list::p_mem_head
void * p_mem_head
Definition: abtd.h:92
ABTD_env_init
void ABTD_env_init(ABTI_global *p_global)
Definition: abtd_env.c:45
ABTU_ret_err
#define ABTU_ret_err
Definition: abtu.h:155
ABTD_affinity_finalize
void ABTD_affinity_finalize(ABTI_global *p_global)
Definition: abtd_affinity.c:404
ABTD_XSTREAM_CONTEXT_STATE_UNINIT
@ ABTD_XSTREAM_CONTEXT_STATE_UNINIT
Definition: abtd.h:22
ABTD_affinity_list::num
uint32_t num
Definition: abtd.h:90
ABTD_env_get_use_logging
ABT_bool ABTD_env_get_use_logging(void)
Definition: abtd_env.c:241
ABTD_xstream_context::state
ABTD_xstream_context_state state
Definition: abtd.h:28
ABTD_time_read_sec
double ABTD_time_read_sec(ABTD_time *p_time)
Definition: abtd_time.c:35
abtd_spinlock.h
ABTD_env_key_table_size
uint32_t ABTD_env_key_table_size(void)
Definition: abtd_env.c:268
ABTD_time_get
void ABTD_time_get(ABTD_time *p_time)
Definition: abtd_time.c:21
ABTD_affinity_cpuset_apply_default
int ABTD_affinity_cpuset_apply_default(ABTD_xstream_context *p_ctx, int rank)
Definition: abtd_affinity.c:442
ABTD_affinity_id_list
struct ABTD_affinity_id_list ABTD_affinity_id_list
ABTD_affinity_cpuset::num_cpuids
size_t num_cpuids
Definition: abtd.h:39
ABTD_affinity_cpuset_read
ABTU_ret_err int ABTD_affinity_cpuset_read(ABTD_xstream_context *p_ctx, int max_cpuids, int *cpuids, int *p_num_cpuids)
Definition: abtd_affinity.c:428
ABTD_xstream_context_join
void ABTD_xstream_context_join(ABTD_xstream_context *p_ctx)
Definition: abtd_stream.c:112
ABTD_env_get_max_xstreams
int ABTD_env_get_max_xstreams(void)
Definition: abtd_env.c:261
ABTD_affinity_init
void ABTD_affinity_init(ABTI_global *p_global, const char *affinity_str)
Definition: abtd_affinity.c:296
ABTD_affinity_list_free
void ABTD_affinity_list_free(ABTD_affinity_list *p_list)
Definition: abtd_affinity_parser.c:356
abtd_stream.h
ABTD_affinity_id_list::num
uint32_t num
Definition: abtd.h:86
abtd_futex.h
ABTI_global
Definition: abti.h:223
ABTD_affinity_id_list
Definition: abtd.h:85
ABTD_affinity_cpuset
Definition: abtd.h:38
abtd_atomic.h
ABTD_env_get_sched_sleep_nsec
uint64_t ABTD_env_get_sched_sleep_nsec(void)
Definition: abtd_env.c:327
ABTD_affinity_cpuset_destroy
void ABTD_affinity_cpuset_destroy(ABTD_affinity_cpuset *p_cpuset)
Definition: abtd_affinity.c:450
ABTD_env_get_stack_guard_mprotect
ABT_bool ABTD_env_get_stack_guard_mprotect(ABT_bool *is_strict)
Definition: abtd_env.c:334
ABTD_affinity_list
struct ABTD_affinity_list ABTD_affinity_list
ABTD_affinity_list::p_id_lists
ABTD_affinity_id_list ** p_id_lists
Definition: abtd.h:91
ABTD_affinity_id_list::ids
int * ids
Definition: abtd.h:87
ABTD_affinity_cpuset::cpuids
int * cpuids
Definition: abtd.h:40