ARGOBOTS  c6511494322293e01714f56f341b8d2b22c1e3c1
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
abti.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 ABTI_H_INCLUDED
7 #define ABTI_H_INCLUDED
8 
9 #include <stdio.h>
10 #include <stdlib.h>
11 #include <stdint.h>
12 #include <inttypes.h>
13 #include <string.h>
14 #include <limits.h>
15 
16 #include "abt_config.h"
17 #include "abt.h"
18 
19 #ifndef ABT_CONFIG_DISABLE_ERROR_CHECK
20 #define ABTI_IS_ERROR_CHECK_ENABLED 1
21 #else
22 #define ABTI_IS_ERROR_CHECK_ENABLED 0
23 #endif
24 
25 #ifdef ABT_CONFIG_DISABLE_EXT_THREAD
26 #define ABTI_IS_EXT_THREAD_ENABLED 0
27 #else
28 #define ABTI_IS_EXT_THREAD_ENABLED 1
29 #endif
30 
31 #include "abtu.h"
32 #include "abti_error.h"
33 #include "abti_valgrind.h"
34 
35 /* Constants */
36 #define ABTI_SCHED_NUM_PRIO 3
37 
38 #define ABTI_SCHED_REQ_FINISH (1 << 0)
39 #define ABTI_SCHED_REQ_EXIT (1 << 1)
40 
41 #define ABTI_THREAD_REQ_JOIN (1 << 0)
42 #define ABTI_THREAD_REQ_TERMINATE (1 << 1)
43 #define ABTI_THREAD_REQ_CANCEL (1 << 2)
44 #define ABTI_THREAD_REQ_MIGRATE (1 << 3)
45 #define ABTI_THREAD_REQ_BLOCK (1 << 4)
46 #define ABTI_THREAD_REQ_ORPHAN (1 << 5)
47 #define ABTI_THREAD_REQ_NOPUSH (1 << 6)
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 | ABTI_THREAD_REQ_NOPUSH)
52 
53 #define ABTI_THREAD_INIT_ID 0xFFFFFFFFFFFFFFFF
54 #define ABTI_TASK_INIT_ID 0xFFFFFFFFFFFFFFFF
55 
56 #define ABTI_INDENT 4
57 
58 #define ABT_THREAD_TYPE_FULLY_FLEDGED 0
59 #define ABT_THREAD_TYPE_DYNAMIC_PROMOTION 1
60 
61 enum ABTI_xstream_type {
62  ABTI_XSTREAM_TYPE_PRIMARY,
63  ABTI_XSTREAM_TYPE_SECONDARY
64 };
65 
66 enum ABTI_sched_used {
67  ABTI_SCHED_NOT_USED,
68  ABTI_SCHED_MAIN,
69  ABTI_SCHED_IN_POOL
70 };
71 
72 #define ABTI_THREAD_TYPE_EXT ((ABTI_thread_type)0)
73 #define ABTI_THREAD_TYPE_THREAD ((ABTI_thread_type)(0x1 << 0))
74 #define ABTI_THREAD_TYPE_ROOT ((ABTI_thread_type)(0x1 << 1))
75 #define ABTI_THREAD_TYPE_MAIN ((ABTI_thread_type)(0x1 << 2))
76 #define ABTI_THREAD_TYPE_MAIN_SCHED ((ABTI_thread_type)(0x1 << 3))
77 #define ABTI_THREAD_TYPE_YIELDABLE ((ABTI_thread_type)(0x1 << 4))
78 #define ABTI_THREAD_TYPE_NAMED ((ABTI_thread_type)(0x1 << 5))
79 #define ABTI_THREAD_TYPE_MIGRATABLE ((ABTI_thread_type)(0x1 << 6))
80 
81 #define ABTI_THREAD_TYPE_MEM_MEMPOOL_DESC ((ABTI_thread_type)(0x1 << 7))
82 #define ABTI_THREAD_TYPE_MEM_MALLOC_DESC ((ABTI_thread_type)(0x1 << 8))
83 #define ABTI_THREAD_TYPE_MEM_MEMPOOL_DESC_STACK ((ABTI_thread_type)(0x1 << 9))
84 #define ABTI_THREAD_TYPE_MEM_MALLOC_DESC_STACK ((ABTI_thread_type)(0x1 << 10))
85 
86 #define ABTI_THREAD_TYPES_MEM \
87  (ABTI_THREAD_TYPE_MEM_MEMPOOL_DESC | ABTI_THREAD_TYPE_MEM_MALLOC_DESC | \
88  ABTI_THREAD_TYPE_MEM_MEMPOOL_DESC_STACK | \
89  ABTI_THREAD_TYPE_MEM_MALLOC_DESC_STACK)
90 
91 enum ABTI_mutex_attr_val {
92  ABTI_MUTEX_ATTR_NONE = 0,
93  ABTI_MUTEX_ATTR_RECURSIVE = 1 << 0
94 };
95 
96 /* Macro functions */
97 #define ABTI_UNUSED(a) (void)(a)
98 
99 /* Data Types */
100 typedef struct ABTI_global ABTI_global;
101 typedef struct ABTI_local ABTI_local;
102 typedef struct ABTI_local_func ABTI_local_func;
103 typedef struct ABTI_xstream ABTI_xstream;
104 typedef enum ABTI_xstream_type ABTI_xstream_type;
105 typedef struct ABTI_sched ABTI_sched;
106 typedef char *ABTI_sched_config;
107 typedef enum ABTI_sched_used ABTI_sched_used;
108 typedef void *ABTI_sched_id; /* Scheduler id */
109 typedef uintptr_t ABTI_sched_kind; /* Scheduler kind */
110 typedef struct ABTI_pool ABTI_pool;
111 typedef struct ABTI_thread ABTI_thread;
112 typedef struct ABTI_thread_attr ABTI_thread_attr;
113 typedef struct ABTI_ythread ABTI_ythread;
114 typedef struct ABTI_thread_mig_data ABTI_thread_mig_data;
115 typedef uint32_t ABTI_thread_type;
116 typedef struct ABTI_ythread_htable ABTI_ythread_htable;
117 typedef struct ABTI_ythread_queue ABTI_ythread_queue;
118 typedef struct ABTI_key ABTI_key;
119 typedef struct ABTI_ktelem ABTI_ktelem;
120 typedef struct ABTI_ktable ABTI_ktable;
121 typedef struct ABTI_mutex_attr ABTI_mutex_attr;
122 typedef struct ABTI_mutex ABTI_mutex;
123 typedef struct ABTI_cond ABTI_cond;
124 typedef struct ABTI_rwlock ABTI_rwlock;
125 typedef struct ABTI_eventual ABTI_eventual;
126 typedef struct ABTI_future ABTI_future;
127 typedef struct ABTI_barrier ABTI_barrier;
128 typedef struct ABTI_xstream_barrier ABTI_xstream_barrier;
129 typedef struct ABTI_timer ABTI_timer;
130 #ifndef ABT_CONFIG_DISABLE_TOOL_INTERFACE
131 typedef struct ABTI_tool_context ABTI_tool_context;
132 #endif
133 /* ID associated with native thread (e.g, Pthreads), which can distinguish
134  * execution streams and external threads */
135 struct ABTI_native_thread_id_opaque;
136 typedef struct ABTI_native_thread_id_opaque *ABTI_native_thread_id;
137 /* ID associated with thread (i.e., ULTs, tasklets, and external threads) */
138 struct ABTI_thread_id_opaque;
139 typedef struct ABTI_thread_id_opaque *ABTI_thread_id;
140 
141 /* Architecture-Dependent Definitions */
142 #include "abtd.h"
143 
144 /* Spinlock */
145 typedef struct ABTI_spinlock ABTI_spinlock;
146 #include "abti_spinlock.h"
147 
148 /* Basic data structure and memory pool. */
149 #include "abti_sync_lifo.h"
150 #include "abti_mem_pool.h"
151 
152 /* Definitions */
153 struct ABTI_mutex_attr {
154  uint32_t attrs; /* bit-or'ed attributes */
155  uint32_t nesting_cnt; /* nesting count */
156  ABTI_thread_id owner_id; /* owner's ID */
157  uint32_t max_handovers; /* max. # of handovers */
158  uint32_t max_wakeups; /* max. # of wakeups */
159 };
160 
161 struct ABTI_mutex {
162  ABTD_atomic_uint32 val; /* 0: unlocked, 1: locked */
163  ABTI_mutex_attr attr; /* attributes */
164  ABTI_ythread_htable *p_htable; /* a set of queues */
165  ABTI_ythread *p_handover; /* next ULT for the mutex handover */
166  ABTI_ythread *p_giver; /* current ULT that hands over the mutex */
167 };
168 
169 struct ABTI_global {
170  int max_xstreams; /* Largest rank used in Argobots. */
171  int num_xstreams; /* Current # of ESs */
172  ABTI_xstream *p_xstream_head; /* List of ESs (head). The list is sorted. */
173  ABTI_spinlock
174  xstream_list_lock; /* Spinlock protecting ES list. Any read and
175  * write to this list requires a lock.*/
176 
177  int num_cores; /* Number of CPU cores */
178  ABT_bool set_affinity; /* Whether CPU affinity is used */
179  ABT_bool use_logging; /* Whether logging is used */
180  ABT_bool use_debug; /* Whether debug output is used */
181  int key_table_size; /* Default key table size */
182  size_t thread_stacksize; /* Default stack size for ULT (in bytes) */
183  size_t sched_stacksize; /* Default stack size for sched (in bytes) */
184  uint32_t sched_event_freq; /* Default check frequency for sched */
185  long sched_sleep_nsec; /* Default nanoseconds for scheduler sleep */
186  ABTI_ythread *p_main_ythread; /* ULT of the main function */
187 
188  uint32_t mutex_max_handovers; /* Default max. # of local handovers */
189  uint32_t mutex_max_wakeups; /* Default max. # of wakeups */
190  uint32_t os_page_size; /* OS page size */
191  uint32_t huge_page_size; /* Huge page size */
192 #ifdef ABT_CONFIG_USE_MEM_POOL
193  uint32_t mem_page_size; /* Page size for memory allocation */
194  uint32_t mem_sp_size; /* Stack page size */
195  uint32_t mem_max_stacks; /* Max. # of stacks kept in each ES */
196  uint32_t mem_max_descs; /* Max. # of descriptors kept in each ES */
197  int mem_lp_alloc; /* How to allocate large pages */
198 
199  ABTI_mem_pool_global_pool mem_pool_stack; /* Pool of stack (default size) */
200  ABTI_mem_pool_global_pool mem_pool_desc; /* Pool of descriptors that can
201  * store ABTI_task. */
202 #ifndef ABT_CONFIG_DISABLE_EXT_THREAD
203  /* They are used for external threads. */
204  ABTI_spinlock mem_pool_stack_lock;
205  ABTI_mem_pool_local_pool mem_pool_stack_ext;
206  ABTI_spinlock mem_pool_desc_lock;
207  ABTI_mem_pool_local_pool mem_pool_desc_ext;
208 #endif
209 #endif
210 
211  ABT_bool print_config; /* Whether to print config on ABT_init */
212 
213 #ifndef ABT_CONFIG_DISABLE_TOOL_INTERFACE
214  ABTI_spinlock tool_writer_lock;
215 
216  ABT_tool_thread_callback_fn tool_thread_cb_f;
217  void *tool_thread_user_arg;
218  ABT_tool_task_callback_fn tool_task_cb_f;
219  void *tool_task_user_arg;
220  ABTD_atomic_uint64 tool_thread_event_mask_tagged;
221 #endif
222 };
223 
224 struct ABTI_local; /* Empty. */
225 
226 struct ABTI_local_func {
227  char padding1[ABT_CONFIG_STATIC_CACHELINE_SIZE];
228  ABTI_local *(*get_local_f)(void);
229  void (*set_local_xstream_f)(ABTI_xstream *);
230  void *(*get_local_ptr_f)(void);
231  char padding2[ABT_CONFIG_STATIC_CACHELINE_SIZE];
232 };
233 
234 struct ABTI_xstream {
235  /* Linked list to manage all execution streams. */
236  ABTI_xstream *p_prev;
237  ABTI_xstream *p_next;
238 
239  int rank; /* Rank */
240  ABTI_xstream_type type; /* Type */
241  ABTD_atomic_int state; /* State (ABT_xstream_state) */
242  ABTI_sched *p_main_sched; /* Main scheduler, which is the bottom of the
243  * linked list of schedulers */
244  ABTD_xstream_context ctx; /* ES context */
245 
246  ABTI_ythread
247  *p_root_ythread; /* Root thread that schedulers the main scheduler. */
248  ABTI_pool *p_root_pool; /* Root pool that stores the main scheduler. */
249 
251  ABTI_thread *p_thread; /* Current running ULT/tasklet */
252 
253 #ifdef ABT_CONFIG_USE_MEM_POOL
254  ABTI_mem_pool_local_pool mem_pool_stack;
255  ABTI_mem_pool_local_pool mem_pool_desc;
256 #endif
257 };
258 
259 struct ABTI_sched {
260  ABTI_sched_used used; /* To know if it is used and how */
261  ABT_bool automatic; /* To know if automatic data free */
262  ABTI_sched_kind kind; /* Kind of the scheduler */
263  ABT_sched_type type; /* Can yield or not (ULT or task) */
264  ABTD_atomic_uint32 request; /* Request */
265  ABT_pool *pools; /* Thread pools */
266  int num_pools; /* Number of thread pools */
267  ABTI_ythread *p_ythread; /* Associated ULT */
268  void *data; /* Data for a specific scheduler */
269 
270  /* Scheduler functions */
271  ABT_sched_init_fn init;
272  ABT_sched_run_fn run;
273  ABT_sched_free_fn free;
274  ABT_sched_get_migr_pool_fn get_migr_pool;
275 
276 #ifdef ABT_CONFIG_USE_DEBUG_LOG
277  uint64_t id; /* ID */
278 #endif
279 };
280 
281 struct ABTI_pool {
282  ABT_pool_access access; /* Access mode */
283  ABT_bool automatic; /* To know if automatic data free */
284  /* NOTE: int32_t to check if still positive */
285  ABTD_atomic_int32 num_scheds; /* Number of associated schedulers */
286  ABTD_atomic_int32 num_blocked; /* Number of blocked ULTs */
287  ABTD_atomic_int32 num_migrations; /* Number of migrating ULTs */
288  void *data; /* Specific data */
289  uint64_t id; /* ID */
290 
291  /* Functions to manage units */
292  ABT_unit_get_type_fn u_get_type;
293  ABT_unit_get_thread_fn u_get_thread;
294  ABT_unit_get_task_fn u_get_task;
295  ABT_unit_is_in_pool_fn u_is_in_pool;
296  ABT_unit_create_from_thread_fn u_create_from_thread;
297  ABT_unit_create_from_task_fn u_create_from_task;
298  ABT_unit_free_fn u_free;
299 
300  /* Functions to manage the pool */
301  ABT_pool_init_fn p_init;
302  ABT_pool_get_size_fn p_get_size;
303  ABT_pool_push_fn p_push;
304  ABT_pool_pop_fn p_pop;
305  ABT_pool_pop_wait_fn p_pop_wait;
306  ABT_pool_pop_timedwait_fn p_pop_timedwait;
307  ABT_pool_remove_fn p_remove;
308  ABT_pool_free_fn p_free;
309  ABT_pool_print_all_fn p_print_all;
310 };
311 
312 struct ABTI_thread {
313  ABTI_thread *p_prev;
314  ABTI_thread *p_next;
315  ABTD_atomic_int is_in_pool; /* Whether this thread is in a pool. */
316  ABTI_thread_type type; /* Thread type */
317  ABT_unit unit; /* Unit enclosing this thread */
318  ABTI_xstream *p_last_xstream; /* Last ES where it ran */
319  ABTI_thread *p_parent; /* Parent thread */
320  void (*f_thread)(void *); /* Thread function */
321  void *p_arg; /* Thread function argument */
322  ABTD_atomic_int state; /* State (ABT_thread_state) */
323  ABTD_atomic_uint32 request; /* Request */
324  ABTI_pool *p_pool; /* Associated pool */
325  ABTD_atomic_ptr p_keytable; /* Thread-specific data (ABTI_ktable *) */
326  ABT_unit_id id; /* ID */
327 };
328 
329 struct ABTI_thread_attr {
330  void *p_stack; /* Stack address */
331  size_t stacksize; /* Stack size (in bytes) */
332  ABTI_thread_type thread_type; /* Thread type */
333 #ifndef ABT_CONFIG_DISABLE_MIGRATION
334  ABT_bool migratable; /* Migratability */
335  void (*f_cb)(ABT_thread, void *); /* Callback function */
336  void *p_cb_arg; /* Callback function argument */
337 #endif
338 };
339 
340 struct ABTI_thread_mig_data {
341  void (*f_migration_cb)(ABT_thread, void *); /* Callback function */
342  void *p_migration_cb_arg; /* Callback function argument */
343  ABTD_atomic_ptr
344  p_migration_pool; /* Destination of migration (ABTI_pool *) */
345 };
346 
347 struct ABTI_ythread {
348  ABTI_thread thread; /* Common thread definition */
349  ABTD_ythread_context ctx; /* Context */
350  void *p_stack; /* Stack address */
351  size_t stacksize; /* Stack size (in bytes) */
352 };
353 
354 struct ABTI_key {
355  void (*f_destructor)(void *value);
356  uint32_t id;
357 };
358 
359 struct ABTI_ktelem {
360  /* information of ABTI_key */
361  void (*f_destructor)(void *value);
362  uint32_t key_id;
363  void *value;
364  ABTD_atomic_ptr p_next; /* Next element (ABTI_ktelem *) */
365 };
366 
367 struct ABTI_ktable {
368  int size; /* size of the table */
369  ABTI_spinlock lock; /* Protects any new entry creation. */
370  void *p_used_mem;
371  void *p_extra_mem;
372  size_t extra_mem_size;
373  ABTD_atomic_ptr p_elems[1]; /* element array (ABTI_ktelem *) */
374 };
375 
376 struct ABTI_cond {
377  ABTI_spinlock lock;
378  ABTI_mutex *p_waiter_mutex;
379  size_t num_waiters;
380  ABTI_thread *p_head; /* Head of waiters */
381  ABTI_thread *p_tail; /* Tail of waiters */
382 };
383 
384 struct ABTI_rwlock {
385  ABTI_mutex mutex;
386  ABTI_cond cond;
387  size_t reader_count;
388  int write_flag;
389 };
390 
391 struct ABTI_eventual {
392  ABTI_spinlock lock;
393  ABT_bool ready;
394  void *value;
395  int nbytes;
396  ABTI_thread *p_head; /* Head of waiters */
397  ABTI_thread *p_tail; /* Tail of waiters */
398 };
399 
400 struct ABTI_future {
401  ABTI_spinlock lock;
402  ABTD_atomic_uint32 counter;
403  uint32_t compartments;
404  void **array;
405  void (*p_callback)(void **arg);
406  ABTI_thread *p_head; /* Head of waiters */
407  ABTI_thread *p_tail; /* Tail of waiters */
408 };
409 
410 struct ABTI_barrier {
411  uint32_t num_waiters;
412  volatile uint32_t counter;
413  ABTI_ythread **waiters;
414  ABT_unit_type *waiter_type;
415  ABTI_spinlock lock;
416 };
417 
418 struct ABTI_xstream_barrier {
419  uint32_t num_waiters;
420  ABTD_xstream_barrier bar;
421 };
422 
423 struct ABTI_timer {
424  ABTD_time start;
425  ABTD_time end;
426 };
427 
428 #ifndef ABT_CONFIG_DISABLE_TOOL_INTERFACE
429 struct ABTI_tool_context {
430  ABTI_thread *p_caller;
431  ABTI_pool *p_pool;
432  ABTI_thread
433  *p_parent; /* Parent of the target thread. Used to get the depth */
434  ABT_sync_event_type sync_event_type;
435  void *p_sync_object; /* ABTI type */
436 };
437 #endif
438 
439 /* Global Data */
440 extern ABTI_global *gp_ABTI_global;
441 extern ABTI_local_func gp_ABTI_local_func;
442 
443 /* ES Local Data */
444 extern ABTD_XSTREAM_LOCAL ABTI_local *lp_ABTI_local;
445 
446 /* Execution Stream (ES) */
447 ABTU_ret_err int ABTI_xstream_create_primary(ABTI_xstream **pp_xstream);
448 void ABTI_xstream_start_primary(ABTI_xstream **pp_local_xstream,
449  ABTI_xstream *p_xstream,
450  ABTI_ythread *p_ythread);
451 void ABTI_xstream_free(ABTI_local *p_local, ABTI_xstream *p_xstream,
452  ABT_bool force_free);
453 void ABTI_xstream_schedule(void *p_arg);
454 void ABTI_xstream_run_unit(ABTI_xstream **pp_local_xstream, ABT_unit unit,
455  ABTI_pool *p_pool);
456 void ABTI_xstream_check_events(ABTI_xstream *p_xstream, ABTI_sched *p_sched);
457 void ABTI_xstream_print(ABTI_xstream *p_xstream, FILE *p_os, int indent,
458  ABT_bool print_sub);
459 
460 /* Scheduler */
461 ABT_sched_def *ABTI_sched_get_basic_def(void);
462 ABT_sched_def *ABTI_sched_get_basic_wait_def(void);
463 ABT_sched_def *ABTI_sched_get_prio_def(void);
464 ABT_sched_def *ABTI_sched_get_randws_def(void);
465 void ABTI_sched_finish(ABTI_sched *p_sched);
466 void ABTI_sched_exit(ABTI_sched *p_sched);
467 ABTU_ret_err int ABTI_sched_create_basic(ABT_sched_predef predef, int num_pools,
468  ABT_pool *pools,
469  ABT_sched_config config,
470  ABTI_sched **pp_newsched);
471 void ABTI_sched_free(ABTI_local *p_local, ABTI_sched *p_sched,
472  ABT_bool force_free);
473 ABTU_ret_err int ABTI_sched_get_migration_pool(ABTI_sched *, ABTI_pool *,
474  ABTI_pool **);
475 ABT_bool ABTI_sched_has_to_stop(ABTI_local **pp_local, ABTI_sched *p_sched);
476 size_t ABTI_sched_get_size(ABTI_sched *p_sched);
477 size_t ABTI_sched_get_total_size(ABTI_sched *p_sched);
478 size_t ABTI_sched_get_effective_size(ABTI_local *p_local, ABTI_sched *p_sched);
479 void ABTI_sched_print(ABTI_sched *p_sched, FILE *p_os, int indent,
480  ABT_bool print_sub);
481 void ABTI_sched_reset_id(void);
482 
483 /* Scheduler config */
484 ABTU_ret_err int ABTI_sched_config_read(ABT_sched_config config, int type,
485  int num_vars, void **variables);
486 ABTU_ret_err int ABTI_sched_config_read_global(ABT_sched_config config,
487  ABT_pool_access *access,
488  ABT_bool *automatic);
489 
490 /* Pool */
491 ABTU_ret_err int ABTI_pool_create_basic(ABT_pool_kind kind,
492  ABT_pool_access access,
493  ABT_bool automatic,
494  ABTI_pool **pp_newpool);
495 void ABTI_pool_free(ABTI_pool *p_pool);
496 ABTU_ret_err int ABTI_pool_get_fifo_def(ABT_pool_access access,
497  ABT_pool_def *p_def);
498 ABTU_ret_err int ABTI_pool_get_fifo_wait_def(ABT_pool_access access,
499  ABT_pool_def *p_def);
500 void ABTI_pool_print(ABTI_pool *p_pool, FILE *p_os, int indent);
501 void ABTI_pool_reset_id(void);
502 
503 /* Work Unit */
504 void ABTI_unit_set_associated_pool(ABT_unit unit, ABTI_pool *p_pool);
505 
506 /* Threads */
507 ABTU_ret_err int ABTI_thread_get_mig_data(ABTI_local *p_local,
508  ABTI_thread *p_thread,
509  ABTI_thread_mig_data **pp_mig_data);
510 void ABTI_thread_revive(ABTI_local *p_local, ABTI_pool *p_pool,
511  void (*thread_func)(void *), void *arg,
512  ABTI_thread *p_thread);
513 void ABTI_thread_join(ABTI_local **pp_local, ABTI_thread *p_thread);
514 void ABTI_thread_free(ABTI_local *p_local, ABTI_thread *p_thread);
515 void ABTI_thread_print(ABTI_thread *p_thread, FILE *p_os, int indent);
516 void ABTI_thread_reset_id(void);
517 ABT_unit_id ABTI_thread_get_id(ABTI_thread *p_thread);
518 
519 /* Yieldable threads */
520 ABTU_ret_err int ABTI_ythread_create_root(ABTI_local *p_local,
521  ABTI_xstream *p_xstream,
522  ABTI_ythread **pp_root_ythread);
523 ABTU_ret_err int ABTI_ythread_create_main(ABTI_local *p_local,
524  ABTI_xstream *p_xstream,
525  ABTI_ythread **p_ythread);
526 ABTU_ret_err int ABTI_ythread_create_main_sched(ABTI_local *p_local,
527  ABTI_xstream *p_xstream,
528  ABTI_sched *p_sched);
529 ABTU_ret_err int ABTI_ythread_create_sched(ABTI_local *p_local,
530  ABTI_pool *p_pool,
531  ABTI_sched *p_sched);
532 ABTU_noreturn void ABTI_ythread_exit(ABTI_xstream *p_local_xstream,
533  ABTI_ythread *p_ythread);
534 void ABTI_ythread_free_main(ABTI_local *p_local, ABTI_ythread *p_ythread);
535 void ABTI_ythread_free_root(ABTI_local *p_local, ABTI_ythread *p_ythread);
536 void ABTI_ythread_set_blocked(ABTI_ythread *p_ythread);
537 void ABTI_ythread_suspend(ABTI_xstream **pp_local_xstream,
538  ABTI_ythread *p_ythread,
539  ABT_sync_event_type sync_event_type, void *p_sync);
540 void ABTI_ythread_set_ready(ABTI_local *p_local, ABTI_ythread *p_ythread);
541 void ABTI_ythread_print_stack(ABTI_ythread *p_ythread, FILE *p_os);
542 
543 /* Thread attributes */
544 void ABTI_thread_attr_print(ABTI_thread_attr *p_attr, FILE *p_os, int indent);
545 ABTU_ret_err int
546 ABTI_thread_attr_dup(const ABTI_thread_attr *p_attr,
547  ABTI_thread_attr **pp_dup_attr) ABTU_ret_err;
548 
549 /* Thread hash table */
550 ABTU_ret_err int ABTI_ythread_htable_create(uint32_t num_rows,
551  ABTI_ythread_htable **pp_htable);
552 void ABTI_ythread_htable_free(ABTI_ythread_htable *p_htable);
553 void ABTI_ythread_htable_push(ABTI_ythread_htable *p_htable, int idx,
554  ABTI_ythread *p_ythread);
555 void ABTI_ythread_htable_push_low(ABTI_ythread_htable *p_htable, int idx,
556  ABTI_ythread *p_ythread);
557 ABTI_ythread *ABTI_ythread_htable_pop(ABTI_ythread_htable *p_htable,
558  ABTI_ythread_queue *p_queue);
559 ABTI_ythread *ABTI_ythread_htable_pop_low(ABTI_ythread_htable *p_htable,
560  ABTI_ythread_queue *p_queue);
561 ABT_bool ABTI_ythread_htable_switch_low(ABTI_xstream **pp_local_xstream,
562  ABTI_ythread_queue *p_queue,
563  ABTI_ythread *p_ythread,
564  ABTI_ythread_htable *p_htable,
565  ABT_sync_event_type sync_event_type,
566  void *p_sync);
567 /* Key */
568 void ABTI_ktable_free(ABTI_local *p_local, ABTI_ktable *p_ktable);
569 
570 /* Mutex */
571 void ABTI_mutex_wait(ABTI_xstream **pp_local_xstream, ABTI_mutex *p_mutex,
572  int val);
573 void ABTI_mutex_wait_low(ABTI_xstream **pp_local_xstream, ABTI_mutex *p_mutex,
574  int val);
575 void ABTI_mutex_wake_de(ABTI_local *p_local, ABTI_mutex *p_mutex);
576 
577 /* Information */
578 void ABTI_info_print_config(FILE *fp);
579 void ABTI_info_check_print_all_thread_stacks(void);
580 
581 #include "abti_log.h"
582 #include "abti_local.h"
583 #include "abti_self.h"
584 #include "abti_pool.h"
585 #include "abti_sched.h"
586 #include "abti_config.h"
587 #include "abti_stream.h"
588 #include "abti_thread.h"
589 #include "abti_tool.h"
590 #include "abti_ythread.h"
591 #include "abti_thread_attr.h"
592 #include "abti_mutex.h"
593 #include "abti_mutex_attr.h"
594 #include "abti_cond.h"
595 #include "abti_rwlock.h"
596 #include "abti_eventual.h"
597 #include "abti_future.h"
598 #include "abti_barrier.h"
599 #include "abti_stream_barrier.h"
600 #include "abti_timer.h"
601 #include "abti_mem.h"
602 #include "abti_key.h"
603 
604 #endif /* ABTI_H_INCLUDED */
struct ABT_unit_opaque * ABT_unit
Definition: abt.h:337
uint64_t ABT_unit_id
Definition: abt.h:341
ABT_sched_predef
Definition: abt.h:143
ABT_unit(* ABT_pool_pop_wait_fn)(ABT_pool, double)
Definition: abt.h:481
int(* ABT_pool_free_fn)(ABT_pool)
Definition: abt.h:484
ABT_unit_type(* ABT_unit_get_type_fn)(ABT_unit)
Definition: abt.h:470
ABT_unit(* ABT_pool_pop_timedwait_fn)(ABT_pool, double)
Definition: abt.h:482
void(* ABT_unit_free_fn)(ABT_unit *)
Definition: abt.h:476
int ABT_bool
Definition: abt.h:373
#define ABT_CONFIG_STATIC_CACHELINE_SIZE
Definition: abt_config.h:57
void(* ABT_tool_thread_callback_fn)(ABT_thread, ABT_xstream, uint64_t event, ABT_tool_context context, void *user_arg)
Definition: abt.h:515
ABT_bool(* ABT_unit_is_in_pool_fn)(ABT_unit)
Definition: abt.h:473
struct ABT_pool_opaque * ABT_pool
Definition: abt.h:329
ABT_unit(* ABT_pool_pop_fn)(ABT_pool)
Definition: abt.h:480
int(* ABT_pool_init_fn)(ABT_pool, ABT_pool_config)
Definition: abt.h:477
struct ABT_thread_opaque * ABT_thread
Definition: abt.h:343
ABT_pool(* ABT_sched_get_migr_pool_fn)(ABT_sched)
Definition: abt.h:457
ABTI_global * gp_ABTI_global
Definition: global.c:18
ABT_pool_access
Definition: abt.h:161
ABT_unit_type
Definition: abt.h:169
int(* ABT_sched_init_fn)(ABT_sched, ABT_sched_config)
Definition: abt.h:453
ABT_unit(* ABT_unit_create_from_task_fn)(ABT_task)
Definition: abt.h:475
size_t(* ABT_pool_get_size_fn)(ABT_pool)
Definition: abt.h:478
#define ABTU_align_member_var(size)
Definition: abtu.h:64
void(* ABT_sched_run_fn)(ABT_sched)
Definition: abt.h:454
ABTI_local_func gp_ABTI_local_func
Definition: local.c:23
ABTD_XSTREAM_LOCAL ABTI_local * lp_ABTI_local
Definition: local.c:29
ABT_pool_kind
Definition: abt.h:156
void(* ABT_pool_push_fn)(ABT_pool, ABT_unit)
Definition: abt.h:479
#define ABTU_noreturn
Definition: abtu.h:31
ABT_sched_type
Definition: abt.h:151
int(* ABT_pool_print_all_fn)(ABT_pool, void *arg, void(*)(void *, ABT_unit))
Definition: abt.h:485
int(* ABT_pool_remove_fn)(ABT_pool, ABT_unit)
Definition: abt.h:483
int(* ABT_sched_free_fn)(ABT_sched)
Definition: abt.h:455
struct ABT_sched_config_opaque * ABT_sched_config
Definition: abt.h:321
ABT_unit(* ABT_unit_create_from_thread_fn)(ABT_thread)
Definition: abt.h:474
ABT_sync_event_type
Definition: abt.h:244
void(* ABT_tool_task_callback_fn)(ABT_task, ABT_xstream, uint64_t event, ABT_tool_context context, void *user_arg)
Definition: abt.h:517
ABT_task(* ABT_unit_get_task_fn)(ABT_unit)
Definition: abt.h:472
ABT_thread(* ABT_unit_get_thread_fn)(ABT_unit)
Definition: abt.h:471
#define ABTU_ret_err
Definition: abtu.h:49