ARGOBOTS  66b1c39742507d8df30e8d28c54839b961a14814
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
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 {
16  ABTD_XSTREAM_CONTEXT_STATE_RUNNING,
17  ABTD_XSTREAM_CONTEXT_STATE_WAITING,
18  ABTD_XSTREAM_CONTEXT_STATE_REQ_JOIN,
19  ABTD_XSTREAM_CONTEXT_STATE_REQ_TERMINATE,
20 } ABTD_xstream_context_state;
21 typedef struct ABTD_xstream_context {
22  pthread_t native_thread;
23  void *(*thread_f)(void *);
24  void *p_arg;
25  ABTD_xstream_context_state state;
26  pthread_mutex_t state_lock;
27  pthread_cond_t state_cond;
28 } ABTD_xstream_context;
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;
38 } ABTD_affinity_cpuset;
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);
50 void ABTD_xstream_context_free(ABTD_xstream_context *p_ctx);
51 void ABTD_xstream_context_join(ABTD_xstream_context *p_ctx);
52 void ABTD_xstream_context_revive(ABTD_xstream_context *p_ctx);
53 void ABTD_xstream_context_set_self(ABTD_xstream_context *p_ctx);
54 
55 /* ES Affinity */
56 void ABTD_affinity_init(const char *affinity_str);
57 void ABTD_affinity_finalize(void);
58 ABTU_ret_err int ABTD_affinity_cpuset_read(ABTD_xstream_context *p_ctx,
59  ABTD_affinity_cpuset *p_cpuset);
60 ABTU_ret_err int
61 ABTD_affinity_cpuset_apply(ABTD_xstream_context *p_ctx,
62  const ABTD_affinity_cpuset *p_cpuset);
63 int ABTD_affinity_cpuset_apply_default(ABTD_xstream_context *p_ctx, int rank);
64 void ABTD_affinity_cpuset_destroy(ABTD_affinity_cpuset *p_cpuset);
65 
66 /* ES Affinity Parser */
67 typedef struct ABTD_affinity_id_list {
68  int num;
69  int *ids; /* id here can be negative. */
70 } ABTD_affinity_id_list;
71 typedef struct ABTD_affinity_parser_list {
72  int num;
73  ABTD_affinity_id_list **p_id_lists;
74 } ABTD_affinity_list;
75 ABTD_affinity_list *ABTD_affinity_list_create(const char *affinity_str);
76 void ABTD_affinity_list_free(ABTD_affinity_list *p_list);
77 
78 #include "abtd_stream.h"
79 
80 /* ULT Context */
81 #include "abtd_ythread.h"
82 void ABTD_ythread_exit(ABTI_xstream *p_local_xstream, ABTI_ythread *p_ythread);
83 void ABTD_ythread_cancel(ABTI_xstream *p_local_xstream,
84  ABTI_ythread *p_ythread);
85 
86 #if defined(ABT_CONFIG_USE_CLOCK_GETTIME)
87 #include <time.h>
88 typedef struct timespec ABTD_time;
89 
90 #elif defined(ABT_CONFIG_USE_MACH_ABSOLUTE_TIME)
91 #include <mach/mach_time.h>
92 typedef uint64_t ABTD_time;
93 
94 #elif defined(ABT_CONFIG_USE_GETTIMEOFDAY)
95 #include <sys/time.h>
96 typedef struct timeval ABTD_time;
97 
98 #endif
99 
100 void ABTD_time_init(void);
101 void ABTD_time_get(ABTD_time *p_time);
102 double ABTD_time_read_sec(ABTD_time *p_time);
103 
104 #endif /* ABTD_H_INCLUDED */
#define ABTU_ret_err
Definition: abtu.h:49