ARGOBOTS  2d670346af9c36fec097ec5ab659205198ec061b
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 #ifdef ABT_CONFIG_DISABLE_UB_ASSERT
32 #define ABTI_IS_UB_ASSERT_ENABLED 0
33 #else
34 #define ABTI_IS_UB_ASSERT_ENABLED 1
35 #endif
36 
37 #include "abtu.h"
38 #include "abti_error.h"
39 #include "abti_valgrind.h"
40 
41 /* Constants */
42 #define ABTI_SCHED_NUM_PRIO 3
43 
44 #define ABTI_SCHED_REQ_FINISH (1 << 0)
45 #define ABTI_SCHED_REQ_EXIT (1 << 1)
46 #define ABTI_SCHED_REQ_REPLACE (1 << 2)
47 
48 #define ABTI_THREAD_REQ_JOIN (1 << 0)
49 #define ABTI_THREAD_REQ_CANCEL (1 << 1)
50 #define ABTI_THREAD_REQ_MIGRATE (1 << 2)
51 
52 #define ABTI_THREAD_INIT_ID 0xFFFFFFFFFFFFFFFF
53 #define ABTI_TASK_INIT_ID 0xFFFFFFFFFFFFFFFF
54 
55 #define ABTI_INDENT 4
56 
57 #define ABTI_UNIT_HASH_TABLE_SIZE_EXP 8 /* N -> 2^N table entries */
58 #define ABTI_UNIT_HASH_TABLE_SIZE ((size_t)(1 << ABTI_UNIT_HASH_TABLE_SIZE_EXP))
59 
60 #define ABTI_STACK_CHECK_TYPE_NONE 0
61 #define ABTI_STACK_CHECK_TYPE_CANARY 1
62 #define ABTI_STACK_CHECK_TYPE_MPROTECT 2
63 #define ABTI_STACK_CHECK_TYPE_MPROTECT_STRICT 3
64 
65 enum ABTI_xstream_type {
66  ABTI_XSTREAM_TYPE_PRIMARY,
67  ABTI_XSTREAM_TYPE_SECONDARY
68 };
69 
70 enum ABTI_sched_used {
71  ABTI_SCHED_NOT_USED,
72  ABTI_SCHED_MAIN,
73  ABTI_SCHED_IN_POOL
74 };
75 
76 enum ABTI_stack_guard {
77  ABTI_STACK_GUARD_NONE = 0,
78  ABTI_STACK_GUARD_MPROTECT,
79  ABTI_STACK_GUARD_MPROTECT_STRICT,
80 };
81 
82 #define ABTI_THREAD_TYPE_EXT ((ABTI_thread_type)0)
83 #define ABTI_THREAD_TYPE_THREAD ((ABTI_thread_type)(0x1 << 0))
84 #define ABTI_THREAD_TYPE_ROOT ((ABTI_thread_type)(0x1 << 1))
85 #define ABTI_THREAD_TYPE_PRIMARY ((ABTI_thread_type)(0x1 << 2))
86 #define ABTI_THREAD_TYPE_MAIN_SCHED ((ABTI_thread_type)(0x1 << 3))
87 #define ABTI_THREAD_TYPE_YIELDABLE ((ABTI_thread_type)(0x1 << 4))
88 #define ABTI_THREAD_TYPE_NAMED ((ABTI_thread_type)(0x1 << 5))
89 #define ABTI_THREAD_TYPE_MIGRATABLE ((ABTI_thread_type)(0x1 << 6))
90 
91 #define ABTI_THREAD_TYPE_MEM_MEMPOOL_DESC ((ABTI_thread_type)(0x1 << 7))
92 #define ABTI_THREAD_TYPE_MEM_MALLOC_DESC ((ABTI_thread_type)(0x1 << 8))
93 #define ABTI_THREAD_TYPE_MEM_MEMPOOL_DESC_STACK ((ABTI_thread_type)(0x1 << 9))
94 #define ABTI_THREAD_TYPE_MEM_MALLOC_DESC_STACK ((ABTI_thread_type)(0x1 << 10))
95 
96 #define ABTI_THREAD_TYPES_MEM \
97  (ABTI_THREAD_TYPE_MEM_MEMPOOL_DESC | ABTI_THREAD_TYPE_MEM_MALLOC_DESC | \
98  ABTI_THREAD_TYPE_MEM_MEMPOOL_DESC_STACK | \
99  ABTI_THREAD_TYPE_MEM_MALLOC_DESC_STACK)
100 
101 /* ABTI_MUTEX_ATTR_NONE must be 0. See ABT_MUTEX_INITIALIZER. */
102 #define ABTI_MUTEX_ATTR_NONE 0
103 /* ABTI_MUTEX_ATTR_RECURSIVE must be 1. See ABT_RECURSIVE_MUTEX_INITIALIZER. */
104 #define ABTI_MUTEX_ATTR_RECURSIVE 1
105 
106 /* Macro functions */
107 #define ABTI_UNUSED(a) (void)(a)
108 
109 /* Data Types */
110 typedef struct ABTI_global ABTI_global;
111 typedef struct ABTI_local ABTI_local;
112 typedef struct ABTI_local_func ABTI_local_func;
113 typedef struct ABTI_xstream ABTI_xstream;
114 typedef enum ABTI_xstream_type ABTI_xstream_type;
115 typedef struct ABTI_sched ABTI_sched;
116 typedef struct ABTI_sched_config ABTI_sched_config;
117 typedef enum ABTI_sched_used ABTI_sched_used;
118 typedef void *ABTI_sched_id; /* Scheduler id */
119 typedef uintptr_t ABTI_sched_kind; /* Scheduler kind */
120 typedef struct ABTI_pool ABTI_pool;
121 typedef struct ABTI_pool_required_def ABTI_pool_required_def;
122 typedef struct ABTI_pool_optional_def ABTI_pool_optional_def;
123 typedef struct ABTI_pool_deprecated_def ABTI_pool_deprecated_def;
124 typedef struct ABTI_pool_old_def ABTI_pool_old_def;
125 typedef struct ABTI_pool_user_def ABTI_pool_user_def;
126 typedef struct ABTI_pool_config ABTI_pool_config;
127 typedef struct ABTI_thread ABTI_thread;
128 typedef struct ABTI_thread_attr ABTI_thread_attr;
129 typedef struct ABTI_ythread ABTI_ythread;
130 typedef struct ABTI_thread_mig_data ABTI_thread_mig_data;
131 typedef uint32_t ABTI_thread_type;
132 typedef struct ABTI_key ABTI_key;
133 typedef struct ABTI_ktelem ABTI_ktelem;
134 typedef struct ABTI_ktable ABTI_ktable;
135 typedef struct ABTI_waitlist ABTI_waitlist;
136 typedef struct ABTI_mutex_attr ABTI_mutex_attr;
137 typedef struct ABTI_mutex ABTI_mutex;
138 typedef struct ABTI_cond ABTI_cond;
139 typedef struct ABTI_rwlock ABTI_rwlock;
140 typedef struct ABTI_eventual ABTI_eventual;
141 typedef struct ABTI_future ABTI_future;
142 typedef struct ABTI_barrier ABTI_barrier;
143 typedef struct ABTI_xstream_barrier ABTI_xstream_barrier;
144 typedef struct ABTI_timer ABTI_timer;
145 #ifndef ABT_CONFIG_DISABLE_TOOL_INTERFACE
146 typedef struct ABTI_tool_context ABTI_tool_context;
147 #endif
148 /* ID associated with native thread (e.g, Pthreads), which can distinguish
149  * execution streams and external threads */
150 struct ABTI_native_thread_id_opaque;
151 typedef struct ABTI_native_thread_id_opaque *ABTI_native_thread_id;
152 /* ID associated with thread (i.e., ULTs, tasklets, and external threads) */
153 struct ABTI_thread_id_opaque;
154 typedef struct ABTI_thread_id_opaque *ABTI_thread_id;
155 /* Unit-to-thread hash table. */
156 typedef struct ABTI_atomic_unit_to_thread ABTI_atomic_unit_to_thread;
157 typedef struct ABTI_unit_to_thread_entry ABTI_unit_to_thread_entry;
158 typedef enum ABTI_stack_guard ABTI_stack_guard;
159 
160 /* Architecture-Dependent Definitions */
161 #include "abtd.h"
162 
163 /* Basic data structure and memory pool. */
164 #include "abti_sync_lifo.h"
165 #include "abti_mem_pool.h"
166 
167 /* Definitions */
168 struct ABTI_waitlist {
169 #ifndef ABT_CONFIG_ACTIVE_WAIT_POLICY
170  ABTD_futex_multiple futex;
171 #endif
172  ABTI_thread *p_head;
173  ABTI_thread *p_tail;
174 };
175 
176 struct ABTI_mutex_attr {
177  int attrs; /* bit-or'ed attributes */
178 };
179 
180 struct ABTI_mutex {
181  int attrs; /* attributes copied from ABTI_mutex_attr. Check
182  * ABT_(RECURSIVE_)MUTEX_INITIALIZER to see how
183  * this variable can be initialized. */
184  ABTD_spinlock lock; /* lock */
185  int nesting_cnt; /* nesting count (if recursive) */
186  ABTI_thread_id owner_id; /* owner's ID (if recursive) */
187 #ifndef ABT_CONFIG_USE_SIMPLE_MUTEX
188  ABTD_spinlock waiter_lock; /* lock */
189  ABTI_waitlist waitlist; /* waiting list */
190 #endif
191 };
192 
193 struct ABTI_atomic_unit_to_thread {
194  ABTD_atomic_ptr val;
195 };
196 
197 struct ABTI_unit_to_thread_entry {
198  ABTI_atomic_unit_to_thread list;
199  ABTD_spinlock lock; /* Protecting any list update. */
200 };
201 
202 struct ABTI_global {
203  int max_xstreams; /* Largest rank used in Argobots. */
204  int num_xstreams; /* Current # of ESs */
205  ABTI_xstream *p_xstream_head; /* List of ESs (head). The list is sorted. */
206  ABTD_spinlock
207  xstream_list_lock; /* Spinlock protecting ES list. Any read and
208  * write to this list requires a lock.*/
209 
210  int num_cores; /* Number of CPU cores */
211  ABT_bool set_affinity; /* Whether CPU affinity is used */
212  ABT_bool use_logging; /* Whether logging is used */
213  ABT_bool use_debug; /* Whether debug output is used */
214  ABT_bool print_raw_stack; /* Print raw stack or not. */
215  uint32_t key_table_size; /* Default key table size */
216  size_t thread_stacksize; /* Default stack size for ULT (in bytes) */
217  size_t sched_stacksize; /* Default stack size for sched (in bytes) */
218  uint32_t sched_event_freq; /* Default check frequency for sched */
219  uint64_t sched_sleep_nsec; /* Default nanoseconds for scheduler sleep */
220  ABTI_ythread *p_primary_ythread; /* Primary ULT */
221 
222  uint32_t
223  mutex_max_handovers; /* Default max. # of local handovers (unused) */
224  uint32_t mutex_max_wakeups; /* Default max. # of wakeups (unused) */
225  size_t sys_page_size; /* System page size (typically, 4KB) */
226  size_t huge_page_size; /* Huge page size */
227 #ifdef ABT_CONFIG_USE_MEM_POOL
228  size_t mem_page_size; /* Page size for memory allocation */
229  size_t mem_sp_size; /* Stack page size */
230  uint32_t mem_max_stacks; /* Max. # of stacks kept in each ES */
231  uint32_t mem_max_descs; /* Max. # of descriptors kept in each ES */
232  int mem_lp_alloc; /* How to allocate large pages */
233 
234  ABTI_mem_pool_global_pool mem_pool_stack; /* Pool of stack (default size) */
235  ABTI_mem_pool_global_pool mem_pool_desc; /* Pool of descriptors that can
236  * store ABTI_task. */
237 #ifndef ABT_CONFIG_DISABLE_EXT_THREAD
238  /* They are used for external threads. */
239  ABTD_spinlock mem_pool_stack_lock;
240  ABTI_mem_pool_local_pool mem_pool_stack_ext;
241  ABTD_spinlock mem_pool_desc_lock;
242  ABTI_mem_pool_local_pool mem_pool_desc_ext;
243 #endif
244 #endif
245  ABTI_stack_guard stack_guard_kind; /* Stack guard type. */
246 
247  ABT_bool print_config; /* Whether to print config on ABT_init */
248 
249 #ifndef ABT_CONFIG_DISABLE_TOOL_INTERFACE
250  ABTD_spinlock tool_writer_lock;
251 
252  ABT_tool_thread_callback_fn tool_thread_cb_f;
253  void *tool_thread_user_arg;
254  ABTD_atomic_uint64 tool_thread_event_mask_tagged;
255 #endif
256 
257  ABTI_unit_to_thread_entry
258  unit_to_thread_entires[ABTI_UNIT_HASH_TABLE_SIZE]; /* Hash table that
259  maps ABT_unit to
260  ABTI_thread */
261 };
262 
263 struct ABTI_local; /* Empty. */
264 
265 struct ABTI_local_func {
266  char padding1[ABT_CONFIG_STATIC_CACHELINE_SIZE];
267  ABTI_local *(*get_local_f)(void);
268  void (*set_local_xstream_f)(ABTI_xstream *);
269  void *(*get_local_ptr_f)(void);
270  char padding2[ABT_CONFIG_STATIC_CACHELINE_SIZE];
271 };
272 
273 struct ABTI_xstream {
274  /* Linked list to manage all execution streams. */
275  ABTI_xstream *p_prev;
276  ABTI_xstream *p_next;
277 
278  int rank; /* Rank */
279  ABTI_xstream_type type; /* Type */
280  ABTD_atomic_int state; /* State (ABT_xstream_state) */
281  ABTI_sched *p_main_sched; /* Main scheduler, which is the bottom of the
282  * linked list of schedulers */
283  ABTD_xstream_context ctx; /* ES context */
284 
285  ABTI_ythread
286  *p_root_ythread; /* Root thread that schedulers the main scheduler. */
287  ABTI_pool *p_root_pool; /* Root pool that stores the main scheduler. */
288 
290  ABTI_thread *p_thread; /* Current running ULT/tasklet */
291 
292 #ifdef ABT_CONFIG_USE_MEM_POOL
293  ABTI_mem_pool_local_pool mem_pool_stack;
294  ABTI_mem_pool_local_pool mem_pool_desc;
295 #endif
296 };
297 
298 struct ABTI_sched {
299  ABTI_sched_used used; /* To know if it is used and how */
300  ABT_bool automatic; /* To know if automatic data free */
301  ABTI_sched_kind kind; /* Kind of the scheduler */
302  ABT_sched_type type; /* Can yield or not (ULT or task) */
303  ABTI_sched *p_replace_sched; /* Main scheduler that should replace this.
304  * ABTI_SCHED_REQ_REPLACE should be set. */
305  ABTI_ythread *p_replace_waiter; /* Thread waiting for replacement. */
306  ABTD_atomic_uint32 request; /* Request */
307  ABT_pool *pools; /* Thread pools */
308  size_t num_pools; /* Number of thread pools */
309  ABTI_ythread *p_ythread; /* Associated ULT */
310  void *data; /* Data for a specific scheduler */
311 
312  /* Scheduler functions */
313  ABT_sched_init_fn init;
314  ABT_sched_run_fn run;
315  ABT_sched_free_fn free;
316  ABT_sched_get_migr_pool_fn get_migr_pool;
317 
318 #ifdef ABT_CONFIG_USE_DEBUG_LOG
319  uint64_t id; /* ID */
320 #endif
321 };
322 
323 struct ABTI_sched_config {
324  ABTU_hashtable *p_table;
325 };
326 
327 struct ABTI_pool_required_def {
328  /* Required pool operations */
329  ABT_pool_user_create_unit_fn p_create_unit;
330  ABT_pool_user_free_unit_fn p_free_unit;
331  ABT_pool_user_is_empty_fn p_is_empty;
332  ABT_pool_user_pop_fn p_pop;
333  ABT_pool_user_push_fn p_push;
334 };
335 
336 struct ABTI_pool_optional_def {
337  /* Optional pool operations */
338  ABT_pool_user_init_fn p_init;
339  ABT_pool_user_free_fn p_free;
340  ABT_pool_user_get_size_fn p_get_size;
341  ABT_pool_user_pop_wait_fn p_pop_wait;
342  ABT_pool_user_pop_many_fn p_pop_many;
343  ABT_pool_user_push_many_fn p_push_many;
344  ABT_pool_user_print_all_fn p_print_all;
345 };
346 
347 struct ABTI_pool_deprecated_def {
348  /* Pool operations that might be directly called even now, but
349  * deprecated. All operations are optional. */
350  ABT_unit_is_in_pool_fn u_is_in_pool;
351  ABT_pool_pop_timedwait_fn p_pop_timedwait;
352  ABT_pool_remove_fn p_remove;
353 };
354 
355 struct ABTI_pool_old_def {
356  /* Pool operations that are not directly called now. */
357  ABT_unit_create_from_thread_fn u_create_from_thread;
358  ABT_unit_free_fn u_free;
359  ABT_pool_init_fn p_init;
360  ABT_pool_get_size_fn p_get_size;
361  ABT_pool_push_fn p_push;
362  ABT_pool_pop_fn p_pop;
363  ABT_pool_pop_wait_fn p_pop_wait;
364  ABT_pool_free_fn p_free;
365  ABT_pool_print_all_fn p_print_all;
366 };
367 
368 struct ABTI_pool {
369  ABT_pool_access access; /* Access mode */
370  ABT_bool automatic; /* To know if automatic data free */
371  ABT_bool is_builtin; /* Built-in pool. */
372  /* NOTE: int32_t to check if still positive */
373  ABTD_atomic_int32 num_scheds; /* Number of associated schedulers */
374  ABTD_atomic_int32 num_blocked; /* Number of blocked ULTs */
375  void *data; /* Specific data */
376  uint64_t id; /* ID */
377 
378  ABTI_pool_required_def required_def;
379  ABTI_pool_optional_def optional_def;
380  ABTI_pool_deprecated_def deprecated_def;
381  ABTI_pool_old_def old_def;
382 };
383 
384 struct ABTI_pool_user_def {
385  ABT_pool_access dummy_access;
386  ABT_unit_get_type_fn dummy_fn1;
387  ABT_unit_get_thread_fn dummy_fn2;
388  ABT_unit_get_task_fn dummy_fn3;
389  ABT_unit_is_in_pool_fn dummy_fn4;
391  symbol; /* This value is to check if ABT_pool_user_def points to
392  ABTI_pool_user_def or ABT_pool_def. */
393  ABTI_pool_required_def required_def;
394  ABTI_pool_optional_def optional_def;
395 };
396 
397 struct ABTI_pool_config {
398  ABTU_hashtable *p_table;
399 };
400 
401 struct ABTI_thread {
402  ABTI_thread *p_prev;
403  ABTI_thread *p_next;
404  ABTD_atomic_int is_in_pool; /* Whether this thread is in a pool. */
405  ABTI_thread_type type; /* Thread type */
406  ABT_unit unit; /* Unit enclosing this thread */
407  ABTI_xstream *p_last_xstream; /* Last ES where it ran */
408  ABTI_thread *p_parent; /* Parent thread */
409  void (*f_thread)(void *); /* Thread function */
410  void *p_arg; /* Thread function argument */
411  ABTD_atomic_int state; /* State (ABT_thread_state) */
412  ABTD_atomic_uint32 request; /* Request */
413  ABTI_pool *p_pool; /* Associated pool */
414  ABTD_atomic_ptr p_keytable; /* Thread-specific data (ABTI_ktable *) */
415  ABT_unit_id id; /* ID */
416 };
417 
418 struct ABTI_thread_attr {
419  void *p_stack; /* Stack address */
420  size_t stacksize; /* Stack size (in bytes) */
421  ABTI_thread_type thread_type; /* Thread type */
422 #ifndef ABT_CONFIG_DISABLE_MIGRATION
423  ABT_bool migratable; /* Migratability */
424  void (*f_cb)(ABT_thread, void *); /* Callback function */
425  void *p_cb_arg; /* Callback function argument */
426 #endif
427 };
428 
429 struct ABTI_thread_mig_data {
430  void (*f_migration_cb)(ABT_thread, void *); /* Callback function */
431  void *p_migration_cb_arg; /* Callback function argument */
432  ABTD_atomic_ptr
433  p_migration_pool; /* Destination of migration (ABTI_pool *) */
434 };
435 
436 struct ABTI_ythread {
437  ABTI_thread thread; /* Common thread definition */
438  ABTD_ythread_context ctx; /* Context */
439 };
440 
441 struct ABTI_key {
442  void (*f_destructor)(void *value);
443  uint32_t id;
444 };
445 
446 struct ABTI_ktelem {
447  /* information of ABTI_key */
448  void (*f_destructor)(void *value);
449  uint32_t key_id;
450  void *value;
451  ABTD_atomic_ptr p_next; /* Next element (ABTI_ktelem *) */
452 };
453 
454 struct ABTI_ktable {
455  int size; /* size of the table */
456  ABTD_spinlock lock; /* Protects any new entry creation. */
457  void *p_used_mem;
458  void *p_extra_mem;
459  size_t extra_mem_size;
460  ABTD_atomic_ptr p_elems[1]; /* element array (ABTI_ktelem *) */
461 };
462 
463 struct ABTI_cond {
464  ABTD_spinlock lock;
465  ABTI_mutex *p_waiter_mutex;
466  ABTI_waitlist waitlist;
467 };
468 
469 struct ABTI_rwlock {
470  ABTI_mutex mutex;
471  ABTI_cond cond;
472  size_t reader_count;
473  int write_flag;
474 };
475 
476 struct ABTI_eventual {
477  ABTD_spinlock lock;
478  ABT_bool ready;
479  void *value;
480  size_t nbytes;
481  ABTI_waitlist waitlist;
482 };
483 
484 struct ABTI_future {
485  ABTD_spinlock lock;
486  ABTD_atomic_size counter;
487  size_t num_compartments;
488  void **array;
489  void (*p_callback)(void **arg);
490  ABTI_waitlist waitlist;
491 };
492 
493 struct ABTI_barrier {
494  size_t num_waiters;
495  volatile size_t counter;
496  ABTD_spinlock lock;
497  ABTI_waitlist waitlist;
498 };
499 
500 struct ABTI_xstream_barrier {
501  uint32_t num_waiters;
502 #ifdef HAVE_PTHREAD_BARRIER_INIT
503  ABTD_xstream_barrier bar;
504 #else
505  ABTD_spinlock lock;
506  uint32_t counter;
507  ABTD_atomic_uint64 tag;
508 #endif
509 };
510 
511 struct ABTI_timer {
512  ABTD_time start;
513  ABTD_time end;
514 };
515 
516 #ifndef ABT_CONFIG_DISABLE_TOOL_INTERFACE
517 struct ABTI_tool_context {
518  ABTI_thread *p_caller;
519  ABTI_pool *p_pool;
520  ABTI_thread
521  *p_parent; /* Parent of the target thread. Used to get the depth */
522  ABT_sync_event_type sync_event_type;
523  void *p_sync_object; /* ABTI type */
524 };
525 #endif
526 
527 /* Global Data */
528 extern ABTI_global *gp_ABTI_global;
529 extern ABTI_local_func gp_ABTI_local_func;
530 
531 /* ES Local Data */
532 extern ABTD_XSTREAM_LOCAL ABTI_local *lp_ABTI_local;
533 
534 /* Global information */
535 ABT_bool ABTI_initialized(void);
536 
537 /* Execution Stream (ES) */
538 ABTU_ret_err int ABTI_xstream_create_primary(ABTI_global *p_global,
539  ABTI_xstream **pp_xstream);
540 void ABTI_xstream_start_primary(ABTI_global *p_global,
541  ABTI_xstream **pp_local_xstream,
542  ABTI_xstream *p_xstream,
543  ABTI_ythread *p_ythread);
544 void ABTI_xstream_free(ABTI_global *p_global, ABTI_local *p_local,
545  ABTI_xstream *p_xstream, ABT_bool force_free);
546 void ABTI_xstream_schedule(void *p_arg);
547 void ABTI_xstream_check_events(ABTI_xstream *p_xstream, ABTI_sched *p_sched);
548 void ABTI_xstream_print(ABTI_xstream *p_xstream, FILE *p_os, int indent,
549  ABT_bool print_sub);
550 
551 /* Scheduler */
552 ABT_sched_def *ABTI_sched_get_basic_def(void);
553 ABT_sched_def *ABTI_sched_get_basic_wait_def(void);
554 ABT_sched_def *ABTI_sched_get_prio_def(void);
555 ABT_sched_def *ABTI_sched_get_randws_def(void);
556 void ABTI_sched_finish(ABTI_sched *p_sched);
557 void ABTI_sched_exit(ABTI_sched *p_sched);
558 ABTU_ret_err int ABTI_sched_create_basic(ABT_sched_predef predef, int num_pools,
559  ABT_pool *pools,
560  ABTI_sched_config *p_config,
561  ABTI_sched **pp_newsched);
562 void ABTI_sched_free(ABTI_global *p_global, ABTI_local *p_local,
563  ABTI_sched *p_sched, ABT_bool force_free);
564 ABTU_ret_err int ABTI_sched_get_migration_pool(ABTI_sched *, ABTI_pool *,
565  ABTI_pool **);
566 ABT_bool ABTI_sched_has_to_stop(ABTI_sched *p_sched);
567 ABT_bool ABTI_sched_has_unit(ABTI_sched *p_sched);
568 void ABTI_sched_print(ABTI_sched *p_sched, FILE *p_os, int indent,
569  ABT_bool print_sub);
570 void ABTI_sched_reset_id(void);
571 
572 /* Scheduler config */
573 ABTU_ret_err int ABTI_sched_config_read(const ABTI_sched_config *p_config,
574  int idx, void *p_val);
575 
576 /* Pool */
577 ABTU_ret_err int ABTI_pool_create_basic(ABT_pool_kind kind,
578  ABT_pool_access access,
579  ABT_bool automatic,
580  ABTI_pool **pp_newpool);
581 void ABTI_pool_free(ABTI_pool *p_pool);
582 ABTU_ret_err int
583 ABTI_pool_get_fifo_def(ABT_pool_access access,
584  ABTI_pool_required_def *p_required_def,
585  ABTI_pool_optional_def *p_optional_def,
586  ABTI_pool_deprecated_def *p_deprecated_def);
587 ABTU_ret_err int
588 ABTI_pool_get_fifo_wait_def(ABT_pool_access access,
589  ABTI_pool_required_def *p_required_def,
590  ABTI_pool_optional_def *p_optional_def,
591  ABTI_pool_deprecated_def *p_deprecated_def);
592 void ABTI_pool_print(ABTI_pool *p_pool, FILE *p_os, int indent);
593 void ABTI_pool_reset_id(void);
594 
595 /* Pool config */
596 ABTU_ret_err int ABTI_pool_config_read(const ABTI_pool_config *p_config,
597  int key, void *p_val);
598 
599 /* Pool definition */
600 ABT_bool ABTI_pool_user_def_is_new(const ABT_pool_user_def def);
601 
602 /* Work Unit */
603 void ABTI_unit_init_hash_table(ABTI_global *p_global);
604 void ABTI_unit_finalize_hash_table(ABTI_global *p_global);
605 ABTU_ret_err int ABTI_unit_map_thread(ABTI_global *p_global, ABT_unit unit,
606  ABTI_thread *p_thread);
607 void ABTI_unit_unmap_thread(ABTI_global *p_global, ABT_unit unit);
608 ABTI_thread *ABTI_unit_get_thread_from_user_defined_unit(ABTI_global *p_global,
609  ABT_unit unit);
610 /* Threads */
611 ABTU_ret_err int ABTI_thread_get_mig_data(ABTI_global *p_global,
612  ABTI_local *p_local,
613  ABTI_thread *p_thread,
614  ABTI_thread_mig_data **pp_mig_data);
615 ABTU_ret_err int ABTI_thread_revive(ABTI_global *p_global, ABTI_local *p_local,
616  ABTI_pool *p_pool,
617  void (*thread_func)(void *), void *arg,
618  ABTI_thread *p_thread);
619 void ABTI_thread_join(ABTI_local **pp_local, ABTI_thread *p_thread);
620 void ABTI_thread_free(ABTI_global *p_global, ABTI_local *p_local,
621  ABTI_thread *p_thread);
622 void ABTI_thread_handle_request_cancel(ABTI_global *p_global,
623  ABTI_xstream *p_local_xstream,
624  ABTI_thread *p_thread);
625 ABTU_ret_err int ABTI_thread_handle_request_migrate(ABTI_global *p_global,
626  ABTI_local *p_local,
627  ABTI_thread *p_thread);
628 void ABTI_thread_print(ABTI_thread *p_thread, FILE *p_os, int indent);
629 void ABTI_thread_reset_id(void);
630 ABT_unit_id ABTI_thread_get_id(ABTI_thread *p_thread);
631 
632 /* Yieldable threads */
633 ABTU_ret_err int ABTI_ythread_create_root(ABTI_global *p_global,
634  ABTI_local *p_local,
635  ABTI_xstream *p_xstream,
636  ABTI_ythread **pp_root_ythread);
637 ABTU_ret_err int ABTI_ythread_create_primary(ABTI_global *p_global,
638  ABTI_local *p_local,
639  ABTI_xstream *p_xstream,
640  ABTI_ythread **p_ythread);
641 ABTU_ret_err int ABTI_ythread_create_main_sched(ABTI_global *p_global,
642  ABTI_local *p_local,
643  ABTI_xstream *p_xstream,
644  ABTI_sched *p_sched);
645 ABTU_ret_err int ABTI_ythread_create_sched(ABTI_global *p_global,
646  ABTI_local *p_local,
647  ABTI_pool *p_pool,
648  ABTI_sched *p_sched);
649 void ABTI_ythread_free_primary(ABTI_global *p_global, ABTI_local *p_local,
650  ABTI_ythread *p_ythread);
651 void ABTI_ythread_free_root(ABTI_global *p_global, ABTI_local *p_local,
652  ABTI_ythread *p_ythread);
653 void ABTI_ythread_print_stack(ABTI_global *p_global, ABTI_ythread *p_ythread,
654  FILE *p_os);
655 
656 /* Thread attributes */
657 void ABTI_thread_attr_print(ABTI_thread_attr *p_attr, FILE *p_os, int indent);
658 ABTU_ret_err int
659 ABTI_thread_attr_dup(const ABTI_thread_attr *p_attr,
660  ABTI_thread_attr **pp_dup_attr) ABTU_ret_err;
661 
662 /* Key */
663 void ABTI_ktable_free(ABTI_global *p_global, ABTI_local *p_local,
664  ABTI_ktable *p_ktable);
665 
666 /* Information */
667 void ABTI_info_print_config(ABTI_global *p_global, FILE *fp);
668 void ABTI_info_check_print_all_thread_stacks(void);
669 
670 #include "abti_timer.h"
671 #include "abti_log.h"
672 #include "abti_local.h"
673 #include "abti_global.h"
674 #include "abti_self.h"
675 #include "abti_pool.h"
676 #include "abti_pool_config.h"
677 #include "abti_pool_user_def.h"
678 #include "abti_sched.h"
679 #include "abti_sched_config.h"
680 #include "abti_stream.h"
681 #include "abti_thread.h"
682 #include "abti_unit.h"
683 #include "abti_tool.h"
684 #include "abti_event.h"
685 #include "abti_ythread.h"
686 #include "abti_thread_attr.h"
687 #include "abti_waitlist.h"
688 #include "abti_mutex.h"
689 #include "abti_mutex_attr.h"
690 #include "abti_cond.h"
691 #include "abti_rwlock.h"
692 #include "abti_eventual.h"
693 #include "abti_future.h"
694 #include "abti_barrier.h"
695 #include "abti_stream_barrier.h"
696 #include "abti_mem.h"
697 #include "abti_key.h"
698 
699 #endif /* ABTI_H_INCLUDED */
ABT_pool_pop_fn
ABT_unit(* ABT_pool_pop_fn)(ABT_pool)
Definition: abt.h:1946
ABT_unit_get_task_fn
ABT_task(* ABT_unit_get_task_fn)(ABT_unit)
Definition: abt.h:1938
gp_ABTI_local_func
ABTI_local_func gp_ABTI_local_func
Definition: local.c:23
ABT_sched_predef
ABT_sched_predef
Predefined scheduler type.
Definition: abt.h:475
abti_global.h
abti_ythread.h
ABT_bool
int ABT_bool
Boolean type.
Definition: abt.h:1017
abti_pool_user_def.h
abti_thread_attr.h
abti_key.h
ABT_unit_is_in_pool_fn
ABT_bool(* ABT_unit_is_in_pool_fn)(ABT_unit)
Definition: abt.h:1939
abti_rwlock.h
abti_sched.h
ABT_sched_run_fn
void(* ABT_sched_run_fn)(ABT_sched)
Definition: abt.h:1311
abti_cond.h
ABT_thread
struct ABT_thread_opaque * ABT_thread
Work unit handle type.
Definition: abt.h:906
abti_thread.h
ABT_unit_get_type_fn
ABT_unit_type(* ABT_unit_get_type_fn)(ABT_unit)
Definition: abt.h:1936
abti_log.h
ABT_pool_user_create_unit_fn
ABT_unit(* ABT_pool_user_create_unit_fn)(ABT_pool, ABT_thread)
Function that creates an ABT_unit handle that is associated with an ABT_thread handle.
Definition: abt.h:1716
abti_stream.h
ABT_pool_pop_wait_fn
ABT_unit(* ABT_pool_pop_wait_fn)(ABT_pool, double)
Definition: abt.h:1947
gp_ABTI_global
ABTI_global * gp_ABTI_global
Definition: global.c:19
abti_timer.h
abti_barrier.h
abti_sched_config.h
abtd.h
ABT_pool_pop_timedwait_fn
ABT_unit(* ABT_pool_pop_timedwait_fn)(ABT_pool, double)
Definition: abt.h:1948
ABT_pool_user_print_all_fn
void(* ABT_pool_user_print_all_fn)(ABT_pool, void *arg, void(*)(void *, ABT_unit))
Function that applies a user-given function to all work units in a pool.
Definition: abt.h:1932
ABT_sched_type
ABT_sched_type
Scheduler's work unit type.
Definition: abt.h:500
ABT_pool_print_all_fn
int(* ABT_pool_print_all_fn)(ABT_pool, void *arg, void(*)(void *, ABT_unit))
Definition: abt.h:1951
abti_future.h
ABT_pool_user_push_many_fn
void(* ABT_pool_user_push_many_fn)(ABT_pool, const ABT_unit *, size_t, ABT_pool_context)
Function that pushes work units to a pool.
Definition: abt.h:1912
ABT_pool
struct ABT_pool_opaque * ABT_pool
Pool handle type.
Definition: abt.h:852
ABT_pool_user_get_size_fn
size_t(* ABT_pool_user_get_size_fn)(ABT_pool)
Function that returns the number of work units in a pool.
Definition: abt.h:1836
ABT_pool_user_push_fn
void(* ABT_pool_user_push_fn)(ABT_pool, ABT_unit, ABT_pool_context)
Function that pushes a work unit to a pool.
Definition: abt.h:1788
ABT_unit_free_fn
void(* ABT_unit_free_fn)(ABT_unit *)
Definition: abt.h:1942
abti_pool.h
ABT_sync_event_type
ABT_sync_event_type
Type of synchronization event.
Definition: abt.h:670
ABT_unit_id
uint64_t ABT_unit_id
Work unit ID type.
Definition: abt.h:895
ABT_pool_def
A struct that defines a pool.
Definition: abt.h:1958
ABT_pool_remove_fn
int(* ABT_pool_remove_fn)(ABT_pool, ABT_unit)
Definition: abt.h:1949
ABT_pool_init_fn
int(* ABT_pool_init_fn)(ABT_pool, ABT_pool_config)
Definition: abt.h:1943
abti_stream_barrier.h
abti_unit.h
ABT_sched_init_fn
int(* ABT_sched_init_fn)(ABT_sched, ABT_sched_config)
Definition: abt.h:1310
abti_mem.h
ABT_unit
struct ABT_unit_opaque * ABT_unit
Work unit handle type for scheduling.
Definition: abt.h:885
abt_config.h
ABT_CONFIG_STATIC_CACHELINE_SIZE
#define ABT_CONFIG_STATIC_CACHELINE_SIZE
Definition: abt_config.h:78
ABT_pool_user_pop_many_fn
void(* ABT_pool_user_pop_many_fn)(ABT_pool, ABT_unit *, size_t, size_t *, ABT_pool_context)
Function that pops work units from a pool.
Definition: abt.h:1887
ABT_pool_user_pop_wait_fn
ABT_unit(* ABT_pool_user_pop_wait_fn)(ABT_pool, double, ABT_pool_context)
Function that pops a work unit from a pool with wait.
Definition: abt.h:1859
abti_valgrind.h
ABTU_ret_err
#define ABTU_ret_err
Definition: abtu.h:155
ABT_pool_user_free_fn
void(* ABT_pool_user_free_fn)(ABT_pool)
Function that frees a pool.
Definition: abt.h:1820
abt.h
ABT_unit_get_thread_fn
ABT_thread(* ABT_unit_get_thread_fn)(ABT_unit)
Definition: abt.h:1937
abti_pool_config.h
ABT_pool_push_fn
void(* ABT_pool_push_fn)(ABT_pool, ABT_unit)
Definition: abt.h:1945
abti_waitlist.h
abti_sync_lifo.h
ABT_pool_user_free_unit_fn
void(* ABT_pool_user_free_unit_fn)(ABT_pool, ABT_unit)
Function that frees an ABT_unit handle.
Definition: abt.h:1733
abti_mem_pool.h
abti_tool.h
ABT_pool_user_is_empty_fn
ABT_bool(* ABT_pool_user_is_empty_fn)(ABT_pool)
Function that returns if a pool is empty.
Definition: abt.h:1749
abti_eventual.h
ABT_sched_def
A struct that defines a scheduler.
Definition: abt.h:1320
lp_ABTI_local
ABTD_XSTREAM_LOCAL ABTI_local * lp_ABTI_local
Definition: local.c:29
ABT_pool_user_pop_fn
ABT_unit(* ABT_pool_user_pop_fn)(ABT_pool, ABT_pool_context)
Function that pops a work unit from a pool.
Definition: abt.h:1768
abti_event.h
ABT_sched_get_migr_pool_fn
ABT_pool(* ABT_sched_get_migr_pool_fn)(ABT_sched)
Definition: abt.h:1314
ABT_pool_get_size_fn
size_t(* ABT_pool_get_size_fn)(ABT_pool)
Definition: abt.h:1944
ABT_pool_free_fn
int(* ABT_pool_free_fn)(ABT_pool)
Definition: abt.h:1950
ABTU_align_member_var
#define ABTU_align_member_var(size)
Definition: abtu.h:170
ABT_pool_user_init_fn
int(* ABT_pool_user_init_fn)(ABT_pool, ABT_pool_config)
Function that creates a pool.
Definition: abt.h:1805
abti_mutex_attr.h
abtu.h
ABT_tool_thread_callback_fn
void(* ABT_tool_thread_callback_fn)(ABT_thread, ABT_xstream, uint64_t event, ABT_tool_context context, void *user_arg)
Definition: abt.h:2216
abti_error.h
ABT_sched_free_fn
int(* ABT_sched_free_fn)(ABT_sched)
Definition: abt.h:1312
ABT_pool_kind
ABT_pool_kind
Predefined pool type.
Definition: abt.h:514
abti_self.h
abti_local.h
ABTU_hashtable
Definition: abtu.h:347
ABT_unit_create_from_thread_fn
ABT_unit(* ABT_unit_create_from_thread_fn)(ABT_thread)
Definition: abt.h:1940
ABT_pool_access
ABT_pool_access
Pool access type.
Definition: abt.h:532
abti_mutex.h