ARGOBOTS  140a356fc09a44696eb3487150e459266f9b5405
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 
14 /* Data Types */
15 typedef enum {
21 typedef struct ABTD_xstream_context {
22  pthread_t native_thread;
23  void *(*thread_f)(void *);
24  void *p_arg;
26  pthread_mutex_t state_lock;
27  pthread_cond_t state_cond;
29 typedef pthread_mutex_t ABTD_xstream_mutex;
30 #ifdef HAVE_PTHREAD_BARRIER_INIT
31 typedef pthread_barrier_t ABTD_xstream_barrier;
32 #else
33 typedef void *ABTD_xstream_barrier;
34 #endif
35 typedef struct ABTD_affinity_cpuset {
36  size_t num_cpuids;
37  int *cpuids;
39 
40 /* ES Storage Qualifier */
41 #define ABTD_XSTREAM_LOCAL __thread
42 
43 /* Environment */
44 void ABTD_env_init(ABTI_global *p_global);
45 
46 /* ES Context */
47 ABTU_ret_err int ABTD_xstream_context_create(void *(*f_xstream)(void *),
48  void *p_arg,
49  ABTD_xstream_context *p_ctx);
54 void ABTD_xstream_context_print(ABTD_xstream_context *p_ctx, FILE *p_os,
55  int indent);
56 
57 /* ES Affinity */
58 void ABTD_affinity_init(const char *affinity_str);
59 void ABTD_affinity_finalize(void);
61  int max_cpuids, int *cpuids,
62  int *p_num_cpuids);
63 ABTU_ret_err int
65  const ABTD_affinity_cpuset *p_cpuset);
68 
69 /* ES Affinity Parser */
70 typedef struct ABTD_affinity_id_list {
71  uint32_t num;
72  int *ids; /* id here can be negative. */
74 typedef struct ABTD_affinity_parser_list {
75  uint32_t num;
78 ABTD_affinity_list *ABTD_affinity_list_create(const char *affinity_str);
80 
81 #include "abtd_stream.h"
82 
83 /* ULT Context */
84 #include "abtd_ythread.h"
85 void ABTD_ythread_exit(ABTI_xstream *p_local_xstream, ABTI_ythread *p_ythread);
86 void ABTD_ythread_cancel(ABTI_xstream *p_local_xstream,
87  ABTI_ythread *p_ythread);
88 
89 #if defined(ABT_CONFIG_USE_CLOCK_GETTIME)
90 #include <time.h>
91 typedef struct timespec ABTD_time;
92 
93 #elif defined(ABT_CONFIG_USE_MACH_ABSOLUTE_TIME)
94 #include <mach/mach_time.h>
95 typedef uint64_t ABTD_time;
96 
97 #elif defined(ABT_CONFIG_USE_GETTIMEOFDAY)
98 #include <sys/time.h>
99 typedef struct timeval ABTD_time;
100 
101 #endif
102 
103 void ABTD_time_init(void);
104 void ABTD_time_get(ABTD_time *p_time);
105 double ABTD_time_read_sec(ABTD_time *p_time);
106 
107 #endif /* ABTD_H_INCLUDED */
ABTD_affinity_init
void ABTD_affinity_init(const char *affinity_str)
Definition: abtd_affinity.c:296
ABTD_xstream_context_state
ABTD_xstream_context_state
Definition: abtd.h:15
ABTD_xstream_context::native_thread
pthread_t native_thread
Definition: abtd.h:22
ABTD_time
struct timespec ABTD_time
Definition: abtd.h:91
ABTD_XSTREAM_CONTEXT_STATE_WAITING
@ ABTD_XSTREAM_CONTEXT_STATE_WAITING
Definition: abtd.h:17
ABTD_ythread_exit
void ABTD_ythread_exit(ABTI_xstream *p_local_xstream, ABTI_ythread *p_ythread)
Definition: abtd_ythread.c:30
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:426
ABTD_XSTREAM_CONTEXT_STATE_RUNNING
@ ABTD_XSTREAM_CONTEXT_STATE_RUNNING
Definition: abtd.h:16
ABTD_xstream_context_print
void ABTD_xstream_context_print(ABTD_xstream_context *p_ctx, FILE *p_os, int indent)
Definition: abtd_stream.c:109
ABTD_xstream_context
Definition: abtd.h:21
ABTD_xstream_context_free
void ABTD_xstream_context_free(ABTD_xstream_context *p_ctx)
Definition: abtd_stream.c:63
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:29
ABTD_XSTREAM_CONTEXT_STATE_REQ_JOIN
@ ABTD_XSTREAM_CONTEXT_STATE_REQ_JOIN
Definition: abtd.h:18
ABTI_xstream
Definition: abti.h:240
ABTD_xstream_context::state_lock
pthread_mutex_t state_lock
Definition: abtd.h:26
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:94
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:19
ABTD_affinity_list
struct ABTD_affinity_parser_list ABTD_affinity_list
ABTD_xstream_context_set_self
void ABTD_xstream_context_set_self(ABTD_xstream_context *p_ctx)
Definition: abtd_stream.c:104
ABTD_affinity_parser_list
Definition: abtd.h:74
ABTD_xstream_context::state_cond
pthread_cond_t state_cond
Definition: abtd.h:27
ABTD_xstream_barrier
pthread_barrier_t ABTD_xstream_barrier
Definition: abtd.h:31
ABTD_xstream_context::p_arg
void * p_arg
Definition: abtd.h:24
ABTD_time_init
void ABTD_time_init(void)
Definition: abtd_time.c:11
ABTD_env_init
void ABTD_env_init(ABTI_global *p_global)
Definition: abtd_env.c:44
ABTU_ret_err
#define ABTU_ret_err
Definition: abtu.h:138
ABTD_affinity_parser_list::p_id_lists
ABTD_affinity_id_list ** p_id_lists
Definition: abtd.h:76
ABTD_xstream_context::state
ABTD_xstream_context_state state
Definition: abtd.h:25
ABTD_time_read_sec
double ABTD_time_read_sec(ABTD_time *p_time)
Definition: abtd_time.c:35
ABTD_affinity_parser_list::num
uint32_t num
Definition: abtd.h:75
ABTI_ythread
Definition: abti.h:379
ABTD_affinity_finalize
void ABTD_affinity_finalize(void)
Definition: abtd_affinity.c:395
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:432
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:36
ABTD_affinity_list_create
ABTD_affinity_list * ABTD_affinity_list_create(const char *affinity_str)
Definition: abtd_affinity_parser.c:254
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:418
ABTD_xstream_context_join
void ABTD_xstream_context_join(ABTD_xstream_context *p_ctx)
Definition: abtd_stream.c:78
ABTD_affinity_list_free
void ABTD_affinity_list_free(ABTD_affinity_list *p_list)
Definition: abtd_affinity_parser.c:259
abtd_stream.h
ABTD_affinity_id_list::num
uint32_t num
Definition: abtd.h:71
ABTD_ythread_cancel
void ABTD_ythread_cancel(ABTI_xstream *p_local_xstream, ABTI_ythread *p_ythread)
Definition: abtd_ythread.c:113
ABTI_global
Definition: abti.h:177
ABTD_affinity_id_list
Definition: abtd.h:70
ABTD_affinity_cpuset
Definition: abtd.h:35
abtd_atomic.h
ABTD_affinity_cpuset_destroy
void ABTD_affinity_cpuset_destroy(ABTD_affinity_cpuset *p_cpuset)
Definition: abtd_affinity.c:443
ABTD_affinity_id_list::ids
int * ids
Definition: abtd.h:72
abtd_ythread.h
ABTD_affinity_cpuset::cpuids
int * cpuids
Definition: abtd.h:37