ARGOBOTS
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 #include "abtu.h"
19 #include "abti_error.h"
20 #include "abti_valgrind.h"
21 
22 /* Constants */
23 #define ABTI_SCHED_NUM_PRIO 3
24 
25 #define ABTI_XSTREAM_REQ_JOIN (1 << 0)
26 #define ABTI_XSTREAM_REQ_EXIT (1 << 1)
27 #define ABTI_XSTREAM_REQ_CANCEL (1 << 2)
28 #define ABTI_XSTREAM_REQ_STOP (1 << 3)
29 
30 #define ABTI_SCHED_REQ_FINISH (1 << 0)
31 #define ABTI_SCHED_REQ_EXIT (1 << 1)
32 
33 #define ABTI_THREAD_REQ_JOIN (1 << 0)
34 #define ABTI_THREAD_REQ_EXIT (1 << 1)
35 #define ABTI_THREAD_REQ_CANCEL (1 << 2)
36 #define ABTI_THREAD_REQ_MIGRATE (1 << 3)
37 #define ABTI_THREAD_REQ_TERMINATE (1 << 4)
38 #define ABTI_THREAD_REQ_BLOCK (1 << 5)
39 #define ABTI_THREAD_REQ_ORPHAN (1 << 6)
40 #define ABTI_THREAD_REQ_NOPUSH (1 << 7)
41 #define ABTI_THREAD_REQ_STOP (ABTI_THREAD_REQ_EXIT | ABTI_THREAD_REQ_TERMINATE)
42 #define ABTI_THREAD_REQ_NON_YIELD \
43  (ABTI_THREAD_REQ_EXIT | ABTI_THREAD_REQ_CANCEL | ABTI_THREAD_REQ_MIGRATE | \
44  ABTI_THREAD_REQ_TERMINATE | ABTI_THREAD_REQ_BLOCK | \
45  ABTI_THREAD_REQ_ORPHAN | ABTI_THREAD_REQ_NOPUSH)
46 
47 #define ABTI_TASK_REQ_CANCEL (1 << 0)
48 
49 #define ABTI_THREAD_INIT_ID 0xFFFFFFFFFFFFFFFF
50 #define ABTI_TASK_INIT_ID 0xFFFFFFFFFFFFFFFF
51 
52 #define ABTI_INDENT 4
53 
54 #define ABT_THREAD_TYPE_FULLY_FLEDGED 0
55 #define ABT_THREAD_TYPE_DYNAMIC_PROMOTION 1
56 
57 enum ABTI_xstream_type {
58  ABTI_XSTREAM_TYPE_PRIMARY,
59  ABTI_XSTREAM_TYPE_SECONDARY
60 };
61 
62 enum ABTI_sched_used {
63  ABTI_SCHED_NOT_USED,
64  ABTI_SCHED_MAIN,
65  ABTI_SCHED_IN_POOL
66 };
67 
68 enum ABTI_thread_type {
69  ABTI_THREAD_TYPE_MAIN,
70  ABTI_THREAD_TYPE_MAIN_SCHED,
71  ABTI_THREAD_TYPE_USER
72 };
73 
74 enum ABTI_mutex_attr_val {
75  ABTI_MUTEX_ATTR_NONE = 0,
76  ABTI_MUTEX_ATTR_RECURSIVE = 1 << 0
77 };
78 
79 enum ABTI_stack_type {
80  ABTI_STACK_TYPE_MEMPOOL = 0, /* Stack taken from the memory pool */
81  ABTI_STACK_TYPE_MALLOC, /* Stack allocated by malloc in Argobots */
82  ABTI_STACK_TYPE_USER, /* Stack given by a user */
83  ABTI_STACK_TYPE_MAIN, /* Stack of a main ULT. */
84 };
85 
86 /* Macro functions */
87 #define ABTI_UNUSED(a) (void)(a)
88 
89 /* Data Types */
90 typedef struct ABTI_global ABTI_global;
91 typedef struct ABTI_local ABTI_local;
92 typedef struct ABTI_local_func ABTI_local_func;
93 typedef struct ABTI_xstream ABTI_xstream;
94 typedef enum ABTI_xstream_type ABTI_xstream_type;
95 typedef struct ABTI_sched ABTI_sched;
96 typedef char *ABTI_sched_config;
97 typedef enum ABTI_sched_used ABTI_sched_used;
98 typedef void *ABTI_sched_id; /* Scheduler id */
99 typedef uintptr_t ABTI_sched_kind; /* Scheduler kind */
100 typedef struct ABTI_pool ABTI_pool;
101 typedef struct ABTI_unit ABTI_unit;
102 typedef struct ABTI_thread_attr ABTI_thread_attr;
103 typedef struct ABTI_thread ABTI_thread;
104 typedef enum ABTI_thread_type ABTI_thread_type;
105 typedef enum ABTI_stack_type ABTI_stack_type;
106 typedef struct ABTI_thread_req_arg ABTI_thread_req_arg;
107 typedef struct ABTI_thread_list ABTI_thread_list;
108 typedef struct ABTI_thread_entry ABTI_thread_entry;
109 typedef struct ABTI_thread_htable ABTI_thread_htable;
110 typedef struct ABTI_thread_queue ABTI_thread_queue;
111 typedef struct ABTI_task ABTI_task;
112 typedef struct ABTI_key ABTI_key;
113 typedef struct ABTI_ktelem ABTI_ktelem;
114 typedef struct ABTI_ktable ABTI_ktable;
115 typedef struct ABTI_mutex_attr ABTI_mutex_attr;
116 typedef struct ABTI_mutex ABTI_mutex;
117 typedef struct ABTI_cond ABTI_cond;
118 typedef struct ABTI_rwlock ABTI_rwlock;
119 typedef struct ABTI_eventual ABTI_eventual;
120 typedef struct ABTI_future ABTI_future;
121 typedef struct ABTI_barrier ABTI_barrier;
122 typedef struct ABTI_timer ABTI_timer;
123 #ifdef ABT_CONFIG_USE_MEM_POOL
124 typedef struct ABTI_stack_header ABTI_stack_header;
125 typedef struct ABTI_page_header ABTI_page_header;
126 typedef struct ABTI_sp_header ABTI_sp_header;
127 #endif
128 /* ID associated with native thread (e.g, Pthreads), which can distinguish
129  * execution streams and external threads */
130 struct ABTI_native_thread_id_opaque;
131 typedef struct ABTI_native_thread_id_opaque *ABTI_native_thread_id;
132 /* ID associated with work unit (i.e., ULTs, tasklets, and external threads) */
133 struct ABTI_unit_id_opaque;
134 typedef struct ABTI_unit_id_opaque *ABTI_unit_id;
135 
136 /* Architecture-Dependent Definitions */
137 #include "abtd.h"
138 
139 /* Spinlock */
140 typedef struct ABTI_spinlock ABTI_spinlock;
141 #include "abti_spinlock.h"
142 
143 /* Definitions */
144 struct ABTI_mutex_attr {
145  uint32_t attrs; /* bit-or'ed attributes */
146  uint32_t nesting_cnt; /* nesting count */
147  ABTI_unit_id owner_id; /* owner's ID */
148  uint32_t max_handovers; /* max. # of handovers */
149  uint32_t max_wakeups; /* max. # of wakeups */
150 };
151 
152 struct ABTI_mutex {
153  ABTD_atomic_uint32 val; /* 0: unlocked, 1: locked */
154  ABTI_mutex_attr attr; /* attributes */
155  ABTI_thread_htable *p_htable; /* a set of queues */
156  ABTI_thread *p_handover; /* next ULT for the mutex handover */
157  ABTI_thread *p_giver; /* current ULT that hands over the mutex */
158 };
159 
160 struct ABTI_global {
161  int max_xstreams; /* Max. size of p_xstreams */
162  int num_xstreams; /* Current # of ESs */
163  ABTI_xstream **p_xstreams; /* ES array */
164  ABTI_spinlock xstreams_lock; /* Spinlock protecting p_xstreams. Any write
165  * to p_xstreams and p_xstreams[*] requires a
166  * lock. Dereference does not require a lock.*/
167 
168  int num_cores; /* Number of CPU cores */
169  ABT_bool set_affinity; /* Whether CPU affinity is used */
170  ABT_bool use_logging; /* Whether logging is used */
171  ABT_bool use_debug; /* Whether debug output is used */
172  int key_table_size; /* Default key table size */
173  size_t thread_stacksize; /* Default stack size for ULT (in bytes) */
174  size_t sched_stacksize; /* Default stack size for sched (in bytes) */
175  uint32_t sched_event_freq; /* Default check frequency for sched */
176  long sched_sleep_nsec; /* Default nanoseconds for scheduler sleep */
177  ABTI_thread *p_thread_main; /* ULT of the main function */
178 
179  uint32_t mutex_max_handovers; /* Default max. # of local handovers */
180  uint32_t mutex_max_wakeups; /* Default max. # of wakeups */
181  uint32_t os_page_size; /* OS page size */
182  uint32_t huge_page_size; /* Huge page size */
183 #ifdef ABT_CONFIG_USE_MEM_POOL
184  ABTI_spinlock mem_task_lock; /* Spinlock protecting p_mem_task */
185  uint32_t mem_page_size; /* Page size for memory allocation */
186  uint32_t mem_sp_size; /* Stack page size */
187  uint32_t mem_max_stacks; /* Max. # of stacks kept in each ES */
188  int mem_lp_alloc; /* How to allocate large pages */
189  ABTI_stack_header *p_mem_stack; /* List of ULT stack */
190  ABTI_page_header *p_mem_task; /* List of task block pages */
191  ABTI_sp_header *p_mem_sph; /* List of stack pages */
192 #endif
193 
194  ABT_bool print_config; /* Whether to print config on ABT_init */
195 };
196 
197 struct ABTI_local_func {
198  char padding1[ABT_CONFIG_STATIC_CACHELINE_SIZE];
199  ABTI_local *(*get_local_f)(void);
200  void (*set_local_f)(ABTI_local *);
201  void *(*get_local_ptr_f)(void);
202  char padding2[ABT_CONFIG_STATIC_CACHELINE_SIZE];
203 };
204 
205 struct ABTI_local {
206  ABTI_xstream *p_xstream; /* Current ES */
207  ABTI_thread *p_thread; /* Current running ULT */
208  ABTI_task *p_task; /* Current running tasklet */
209 
210 #ifdef ABT_CONFIG_USE_MEM_POOL
211  uint32_t num_stacks; /* Current # of stacks */
212  ABTI_stack_header *p_mem_stack; /* Free stack list */
213  ABTI_page_header *p_mem_task_head; /* Head of page list */
214  ABTI_page_header *p_mem_task_tail; /* Tail of page list */
215 #endif
216 };
217 
218 struct ABTI_xstream {
219  int rank; /* Rank */
220  ABTI_xstream_type type; /* Type */
221  ABTD_atomic_int state; /* State (ABT_xstream_state) */
222  ABTI_sched **scheds; /* Stack of running schedulers */
223  int max_scheds; /* Allocation size of the array scheds */
224  int num_scheds; /* Number of scheds */
225  ABTI_spinlock sched_lock; /* Lock for the scheduler management */
226 
227  ABTD_atomic_uint32 request; /* Request */
228  void *p_req_arg; /* Request argument */
229  ABTI_sched *p_main_sched; /* Main scheduler */
230 
231  ABTD_xstream_context ctx; /* ES context */
232 };
233 
234 struct ABTI_sched {
235  ABTI_sched_used used; /* To know if it is used and how */
236  ABT_bool automatic; /* To know if automatic data free */
237  ABTI_sched_kind kind; /* Kind of the scheduler */
238  ABT_sched_type type; /* Can yield or not (ULT or task) */
239  ABT_sched_state state; /* State */
240  ABTD_atomic_uint32 request; /* Request */
241  ABT_pool *pools; /* Work unit pools */
242  int num_pools; /* Number of work unit pools */
243  ABTI_thread *p_thread; /* Associated ULT */
244  ABTI_task *p_task; /* Associated tasklet */
245  ABTD_thread_context *p_ctx; /* Context */
246  void *data; /* Data for a specific scheduler */
247 
248  /* Scheduler functions */
249  ABT_sched_init_fn init;
250  ABT_sched_run_fn run;
251  ABT_sched_free_fn free;
252  ABT_sched_get_migr_pool_fn get_migr_pool;
253 
254 #ifdef ABT_CONFIG_USE_DEBUG_LOG
255  uint64_t id; /* ID */
256 #endif
257 };
258 
259 struct ABTI_pool {
260  ABT_pool_access access; /* Access mode */
261  ABT_bool automatic; /* To know if automatic data free */
262 #ifndef ABT_CONFIG_DISABLE_POOL_CONSUMER_CHECK
263  ABTI_native_thread_id consumer_id; /* Associated consumer ID */
264 #endif
265 #ifndef ABT_CONFIG_DISABLE_POOL_PRODUCER_CHECK
266  ABTI_native_thread_id producer_id; /* Associated producer ID */
267 #endif
268  /* NOTE: int32_t to check if still positive */
269  ABTD_atomic_int32 num_scheds; /* Number of associated schedulers */
270  ABTD_atomic_int32 num_blocked; /* Number of blocked ULTs */
271  ABTD_atomic_int32 num_migrations; /* Number of migrating ULTs */
272  void *data; /* Specific data */
273  uint64_t id; /* ID */
274 
275  /* Functions to manage units */
276  ABT_unit_get_type_fn u_get_type;
277  ABT_unit_get_thread_fn u_get_thread;
278  ABT_unit_get_task_fn u_get_task;
279  ABT_unit_is_in_pool_fn u_is_in_pool;
280  ABT_unit_create_from_thread_fn u_create_from_thread;
281  ABT_unit_create_from_task_fn u_create_from_task;
282  ABT_unit_free_fn u_free;
283 
284  /* Functions to manage the pool */
285  ABT_pool_init_fn p_init;
286  ABT_pool_get_size_fn p_get_size;
287  ABT_pool_push_fn p_push;
288  ABT_pool_pop_fn p_pop;
289  ABT_pool_pop_timedwait_fn p_pop_timedwait;
290  ABT_pool_remove_fn p_remove;
291  ABT_pool_free_fn p_free;
292  ABT_pool_print_all_fn p_print_all;
293 };
294 
295 struct ABTI_unit {
296  ABTI_unit *p_prev;
297  ABTI_unit *p_next;
298  union {
299  ABT_thread thread;
300  ABT_task task;
301  } handle;
302  ABTD_atomic_int is_in_pool;
303  ABT_unit_type type;
304 };
305 
306 struct ABTI_thread_attr {
307  void *p_stack; /* Stack address */
308  size_t stacksize; /* Stack size (in bytes) */
309  ABTI_stack_type stacktype; /* Stack type */
310 #ifndef ABT_CONFIG_DISABLE_MIGRATION
311  ABT_bool migratable; /* Migratability */
312  void (*f_cb)(ABT_thread, void *); /* Callback function */
313  void *p_cb_arg; /* Callback function argument */
314 #endif
315 };
316 
317 struct ABTI_thread {
318  ABTD_thread_context ctx; /* Context */
319  ABTI_unit unit_def; /* Internal unit definition */
320  ABTD_atomic_int state; /* State (ABT_thread_state) */
321  ABTD_atomic_uint32 request; /* Request */
322  ABTI_xstream *p_last_xstream; /* Last ES where it ran */
323 #ifndef ABT_CONFIG_DISABLE_STACKABLE_SCHED
324  ABTI_sched *is_sched; /* If it is a scheduler, its ptr */
325 #endif
326  ABT_unit unit; /* Unit enclosing this thread */
327  ABTI_pool *p_pool; /* Associated pool */
328  uint32_t refcount; /* Reference count */
329  ABTI_thread_type type; /* Type */
330 #ifndef ABT_CONFIG_DISABLE_MIGRATION
331  ABTI_thread_req_arg *p_req_arg; /* Request argument */
332  ABTI_spinlock lock; /* Spinlock */
333 #endif
334  ABTI_ktable *p_keytable; /* ULT-specific data */
335  ABTI_thread_attr attr; /* Attributes */
336  ABT_thread_id id; /* ID */
337 };
338 
339 #ifndef ABT_CONFIG_DISABLE_MIGRATION
340 struct ABTI_thread_req_arg {
341  uint32_t request;
342  void *p_arg;
343  ABTI_thread_req_arg *next;
344 };
345 #endif
346 
347 struct ABTI_thread_list {
348  ABTI_thread_entry *head;
349  ABTI_thread_entry *tail;
350 };
351 
352 struct ABTI_thread_entry {
353  ABTI_thread *current;
354  struct ABTI_thread_entry *next;
355  ABT_unit_type type;
356 };
357 
358 struct ABTI_task {
359  ABTI_xstream *p_xstream; /* Associated ES */
360  ABTD_atomic_int state; /* State (ABT_task_state) */
361  ABTD_atomic_uint32 request; /* Request */
362  void (*f_task)(void *); /* Task function */
363  void *p_arg; /* Task arguments */
364 #ifndef ABT_CONFIG_DISABLE_STACKABLE_SCHED
365  ABTI_sched *is_sched; /* If it is a scheduler, its ptr */
366 #endif
367  ABTI_pool *p_pool; /* Associated pool */
368  ABT_unit unit; /* Unit enclosing this task */
369  ABTI_unit unit_def; /* Internal unit definition */
370  uint32_t refcount; /* Reference count */
371  ABTI_ktable *p_keytable; /* Tasklet-specific data */
372 #ifndef ABT_CONFIG_DISABLE_MIGRATION
373  ABT_bool migratable; /* Migratability */
374 #endif
375  uint64_t id; /* ID */
376 };
377 
378 struct ABTI_key {
379  void (*f_destructor)(void *value);
380  uint32_t id;
381  ABTD_atomic_uint32 refcount; /* Reference count */
382  ABT_bool freed; /* TRUE: freed, FALSE: not */
383 };
384 
385 struct ABTI_ktelem {
386  ABTI_key *p_key;
387  void *value;
388  struct ABTI_ktelem *p_next;
389 };
390 
391 struct ABTI_ktable {
392  int size; /* size of the table */
393  int num; /* number of elements stored */
394  ABTI_ktelem **p_elems; /* element array */
395 };
396 
397 struct ABTI_cond {
398  ABTI_spinlock lock;
399  ABTI_mutex *p_waiter_mutex;
400  size_t num_waiters;
401  ABTI_unit *p_head; /* Head of waiters */
402  ABTI_unit *p_tail; /* Tail of waiters */
403 };
404 
405 struct ABTI_rwlock {
406  ABTI_mutex mutex;
407  ABTI_cond cond;
408  size_t reader_count;
409  int write_flag;
410 };
411 
412 struct ABTI_eventual {
413  ABTI_spinlock lock;
414  ABT_bool ready;
415  void *value;
416  int nbytes;
417  ABTI_unit *p_head; /* Head of waiters */
418  ABTI_unit *p_tail; /* Tail of waiters */
419 };
420 
421 struct ABTI_future {
422  ABTI_spinlock lock;
423  ABTD_atomic_uint32 counter;
424  uint32_t compartments;
425  void **array;
426  void (*p_callback)(void **arg);
427  ABTI_unit *p_head; /* Head of waiters */
428  ABTI_unit *p_tail; /* Tail of waiters */
429 };
430 
431 struct ABTI_barrier {
432  uint32_t num_waiters;
433  volatile uint32_t counter;
434  ABTI_thread **waiters;
435  ABT_unit_type *waiter_type;
436  ABTI_spinlock lock;
437 };
438 
439 struct ABTI_timer {
440  ABTD_time start;
441  ABTD_time end;
442 };
443 
444 /* Global Data */
445 extern ABTI_global *gp_ABTI_global;
446 extern ABTI_local_func gp_ABTI_local_func;
447 
448 /* ES Local Data */
449 extern ABTD_XSTREAM_LOCAL ABTI_local *lp_ABTI_local;
450 
451 /* Global */
452 void ABTI_global_update_max_xstreams(int new_size);
453 
454 /* ES Local Data */
455 int ABTI_local_init(ABTI_local **pp_local);
456 int ABTI_local_finalize(ABTI_local **pp_local);
457 
458 /* Execution Stream (ES) */
459 int ABTI_xstream_create(ABTI_local **pp_local, ABTI_sched *p_sched,
460  ABTI_xstream **pp_xstream);
461 int ABTI_xstream_create_primary(ABTI_local **pp_local,
462  ABTI_xstream **pp_xstream);
463 int ABTI_xstream_start(ABTI_local *p_local, ABTI_xstream *p_xstream);
464 int ABTI_xstream_start_primary(ABTI_local **pp_local, ABTI_xstream *p_xstream,
465  ABTI_thread *p_thread);
466 int ABTI_xstream_free(ABTI_local *p_local, ABTI_xstream *p_xstream);
467 int ABTI_xstream_join(ABTI_local **pp_local, ABTI_xstream *p_xstream);
468 void ABTI_xstream_schedule(void *p_arg);
469 int ABTI_xstream_run_unit(ABTI_local **pp_local, ABTI_xstream *p_xstream,
470  ABT_unit unit, ABTI_pool *p_pool);
471 int ABTI_xstream_schedule_thread(ABTI_local **pp_local, ABTI_xstream *p_xstream,
472  ABTI_thread *p_thread);
473 void ABTI_xstream_schedule_task(ABTI_local *p_local, ABTI_xstream *p_xstream,
474  ABTI_task *p_task);
475 int ABTI_xstream_migrate_thread(ABTI_local *p_local, ABTI_thread *p_thread);
476 int ABTI_xstream_set_main_sched(ABTI_local **pp_local, ABTI_xstream *p_xstream,
477  ABTI_sched *p_sched);
478 int ABTI_xstream_check_events(ABTI_xstream *p_xstream, ABT_sched sched);
479 void *ABTI_xstream_launch_main_sched(void *p_arg);
480 void ABTI_xstream_print(ABTI_xstream *p_xstream, FILE *p_os, int indent,
481  ABT_bool print_sub);
482 
483 /* Scheduler */
484 ABT_sched_def *ABTI_sched_get_basic_def(void);
485 ABT_sched_def *ABTI_sched_get_basic_wait_def(void);
486 ABT_sched_def *ABTI_sched_get_prio_def(void);
487 ABT_sched_def *ABTI_sched_get_randws_def(void);
488 void ABTI_sched_finish(ABTI_sched *p_sched);
489 void ABTI_sched_exit(ABTI_sched *p_sched);
490 int ABTI_sched_create(ABT_sched_def *def, int num_pools, ABT_pool *pools,
491  ABT_sched_config config, ABT_bool automatic,
492  ABTI_sched **pp_newsched);
493 int ABTI_sched_create_basic(ABT_sched_predef predef, int num_pools,
494  ABT_pool *pools, ABT_sched_config config,
495  ABTI_sched **pp_newsched);
496 int ABTI_sched_free(ABTI_local *p_local, ABTI_sched *p_sched);
497 int ABTI_sched_get_migration_pool(ABTI_sched *, ABTI_pool *, ABTI_pool **);
498 ABTI_sched_kind ABTI_sched_get_kind(ABT_sched_def *def);
499 ABT_bool ABTI_sched_has_to_stop(ABTI_local **pp_local, ABTI_sched *p_sched,
500  ABTI_xstream *p_xstream);
501 size_t ABTI_sched_get_size(ABTI_sched *p_sched);
502 size_t ABTI_sched_get_total_size(ABTI_sched *p_sched);
503 size_t ABTI_sched_get_effective_size(ABTI_local *p_local, ABTI_sched *p_sched);
504 void ABTI_sched_print(ABTI_sched *p_sched, FILE *p_os, int indent,
505  ABT_bool print_sub);
506 void ABTI_sched_reset_id(void);
507 
508 /* Scheduler config */
509 size_t ABTI_sched_config_type_size(ABT_sched_config_type type);
510 int ABTI_sched_config_read(ABT_sched_config config, int type, int num_vars,
511  void **variables);
512 int ABTI_sched_config_read_global(ABT_sched_config config,
513  ABT_pool_access *access, ABT_bool *automatic);
514 
515 /* Pool */
516 int ABTI_pool_create(ABT_pool_def *def, ABT_pool_config config,
517  ABT_bool automatic, ABTI_pool **pp_newpool);
518 int ABTI_pool_create_basic(ABT_pool_kind kind, ABT_pool_access access,
519  ABT_bool automatic, ABTI_pool **pp_newpool);
520 void ABTI_pool_free(ABTI_pool *p_pool);
521 int ABTI_pool_get_fifo_def(ABT_pool_access access, ABT_pool_def *p_def);
522 int ABTI_pool_get_fifo_wait_def(ABT_pool_access access, ABT_pool_def *p_def);
523 #ifndef ABT_CONFIG_DISABLE_POOL_CONSUMER_CHECK
524 int ABTI_pool_set_consumer(ABTI_pool *p_pool,
525  ABTI_native_thread_id consumer_id);
526 #endif
527 #ifndef ABT_CONFIG_DISABLE_POOL_PRODUCER_CHECK
528 int ABTI_pool_set_producer(ABTI_pool *p_pool,
529  ABTI_native_thread_id producer_id);
530 #endif
531 int ABTI_pool_accept_migration(ABTI_pool *p_pool, ABTI_pool *source);
532 void ABTI_pool_print(ABTI_pool *p_pool, FILE *p_os, int indent);
533 void ABTI_pool_reset_id(void);
534 
535 /* Work Unit */
536 void ABTI_unit_set_associated_pool(ABT_unit unit, ABTI_pool *p_pool);
537 
538 /* User-level Thread (ULT) */
539 int ABTI_thread_migrate_to_pool(ABTI_local **pp_local, ABTI_thread *p_thread,
540  ABTI_pool *p_pool);
541 int ABTI_thread_create(ABTI_local *p_local, ABTI_pool *p_pool,
542  void (*thread_func)(void *), void *arg,
543  ABTI_thread_attr *p_attr, ABTI_thread **pp_newthread);
544 int ABTI_thread_create_main(ABTI_local *p_local, ABTI_xstream *p_xstream,
545  ABTI_thread **p_thread);
546 int ABTI_thread_create_main_sched(ABTI_local *p_local, ABTI_xstream *p_xstream,
547  ABTI_sched *p_sched);
548 int ABTI_thread_create_sched(ABTI_local *p_local, ABTI_pool *p_pool,
549  ABTI_sched *p_sched);
550 void ABTI_thread_free(ABTI_local *p_local, ABTI_thread *p_thread);
551 void ABTI_thread_free_main(ABTI_local *p_local, ABTI_thread *p_thread);
552 void ABTI_thread_free_main_sched(ABTI_local *p_local, ABTI_thread *p_thread);
553 int ABTI_thread_set_blocked(ABTI_thread *p_thread);
554 void ABTI_thread_suspend(ABTI_local **pp_local, ABTI_thread *p_thread);
555 int ABTI_thread_set_ready(ABTI_local *p_local, ABTI_thread *p_thread);
556 void ABTI_thread_print(ABTI_thread *p_thread, FILE *p_os, int indent);
557 int ABTI_thread_print_stack(ABTI_thread *p_thread, FILE *p_os);
558 #ifndef ABT_CONFIG_DISABLE_MIGRATION
559 void ABTI_thread_add_req_arg(ABTI_thread *p_thread, uint32_t req, void *arg);
560 void *ABTI_thread_extract_req_arg(ABTI_thread *p_thread, uint32_t req);
561 #endif
562 void ABTI_thread_reset_id(void);
563 ABT_thread_id ABTI_thread_get_id(ABTI_thread *p_thread);
564 ABT_thread_id ABTI_thread_self_id(ABTI_local *p_local);
565 int ABTI_thread_get_xstream_rank(ABTI_thread *p_thread);
566 int ABTI_thread_self_xstream_rank(ABTI_local *p_local);
567 
568 /* ULT Attributes */
569 void ABTI_thread_attr_print(ABTI_thread_attr *p_attr, FILE *p_os, int indent);
570 void ABTI_thread_attr_get_str(ABTI_thread_attr *p_attr, char *p_buf);
571 ABTI_thread_attr *ABTI_thread_attr_dup(ABTI_thread_attr *p_attr);
572 
573 /* ULT hash table */
574 ABTI_thread_htable *ABTI_thread_htable_create(uint32_t num_rows);
575 void ABTI_thread_htable_free(ABTI_thread_htable *p_htable);
576 void ABTI_thread_htable_push(ABTI_thread_htable *p_htable, int idx,
577  ABTI_thread *p_thread);
578 ABT_bool ABTI_thread_htable_add(ABTI_thread_htable *p_htable, int idx,
579  ABTI_thread *p_thread);
580 void ABTI_thread_htable_push_low(ABTI_thread_htable *p_htable, int idx,
581  ABTI_thread *p_thread);
582 ABT_bool ABTI_thread_htable_add_low(ABTI_thread_htable *p_htable, int idx,
583  ABTI_thread *p_thread);
584 ABTI_thread *ABTI_thread_htable_pop(ABTI_thread_htable *p_htable,
585  ABTI_thread_queue *p_queue);
586 ABTI_thread *ABTI_thread_htable_pop_low(ABTI_thread_htable *p_htable,
587  ABTI_thread_queue *p_queue);
588 ABT_bool ABTI_thread_htable_switch_low(ABTI_local **pp_local,
589  ABTI_thread_queue *p_queue,
590  ABTI_thread *p_thread,
591  ABTI_thread_htable *p_htable);
592 
593 /* Tasklet */
594 int ABTI_task_create_sched(ABTI_local *p_local, ABTI_pool *p_pool,
595  ABTI_sched *p_sched);
596 void ABTI_task_free(ABTI_local *p_local, ABTI_task *p_task);
597 void ABTI_task_print(ABTI_task *p_task, FILE *p_os, int indent);
598 void ABTI_task_reset_id(void);
599 uint64_t ABTI_task_get_id(ABTI_task *p_task);
600 
601 /* Key */
602 ABTI_ktable *ABTI_ktable_alloc(int size);
603 void ABTI_ktable_free(ABTI_ktable *p_ktable);
604 
605 /* Mutex */
606 void ABTI_mutex_wait(ABTI_local **pp_local, ABTI_mutex *p_mutex, int val);
607 void ABTI_mutex_wait_low(ABTI_local **pp_local, ABTI_mutex *p_mutex, int val);
608 void ABTI_mutex_wake_se(ABTI_mutex *p_mutex, int num);
609 void ABTI_mutex_wake_de(ABTI_local *p_local, ABTI_mutex *p_mutex);
610 
611 /* Mutex Attributes */
612 void ABTI_mutex_attr_print(ABTI_mutex_attr *p_attr, FILE *p_os, int indent);
613 void ABTI_mutex_attr_get_str(ABTI_mutex_attr *p_attr, char *p_buf);
614 
615 /* Information */
616 int ABTI_info_print_config(FILE *fp);
617 void ABTI_info_check_print_all_thread_stacks(void);
618 
619 #include "abti_log.h"
620 #include "abti_local.h"
621 #include "abti_global.h"
622 #include "abti_pool.h"
623 #include "abti_sched.h"
624 #include "abti_config.h"
625 #include "abti_stream.h"
626 #include "abti_self.h"
627 #include "abti_thread.h"
628 #include "abti_thread_attr.h"
629 #include "abti_task.h"
630 #include "abti_key.h"
631 #include "abti_mutex.h"
632 #include "abti_mutex_attr.h"
633 #include "abti_cond.h"
634 #include "abti_rwlock.h"
635 #include "abti_eventual.h"
636 #include "abti_future.h"
637 #include "abti_barrier.h"
638 #include "abti_timer.h"
639 #include "abti_mem.h"
640 
641 #endif /* ABTI_H_INCLUDED */
struct ABT_unit_opaque * ABT_unit
Definition: abt.h:275
ABT_sched_state
Definition: abt.h:137
ABT_sched_predef
Definition: abt.h:144
struct ABT_sched_opaque * ABT_sched
Definition: abt.h:257
uint64_t ABT_thread_id
Definition: abt.h:287
ABT_unit(* ABT_unit_create_from_task_fn)(ABT_task)
Definition: abt.h:402
ABT_unit(* ABT_pool_pop_fn)(ABT_pool)
Definition: abt.h:407
struct ABT_task_opaque * ABT_task
Definition: abt.h:289
size_t(* ABT_pool_get_size_fn)(ABT_pool)
Definition: abt.h:405
int ABT_bool
Definition: abt.h:309
#define ABT_CONFIG_STATIC_CACHELINE_SIZE
Definition: abt_config.h:51
void(* ABT_pool_push_fn)(ABT_pool, ABT_unit)
Definition: abt.h:406
struct ABT_pool_opaque * ABT_pool
Definition: abt.h:267
ABT_task(* ABT_unit_get_task_fn)(ABT_unit)
Definition: abt.h:399
struct ABT_thread_opaque * ABT_thread
Definition: abt.h:279
ABT_pool(* ABT_sched_get_migr_pool_fn)(ABT_sched)
Definition: abt.h:384
int(* ABT_sched_free_fn)(ABT_sched)
Definition: abt.h:382
ABT_sched_config_type
Definition: abt.h:359
int(* ABT_sched_init_fn)(ABT_sched, ABT_sched_config)
Definition: abt.h:380
ABTI_global * gp_ABTI_global
Definition: global.c:14
ABT_bool(* ABT_unit_is_in_pool_fn)(ABT_unit)
Definition: abt.h:400
ABT_unit_type(* ABT_unit_get_type_fn)(ABT_unit)
Definition: abt.h:397
ABT_pool_access
Definition: abt.h:162
ABT_unit_type
Definition: abt.h:170
void(* ABT_unit_free_fn)(ABT_unit *)
Definition: abt.h:403
ABTI_local_func gp_ABTI_local_func
Definition: local.c:27
ABTD_XSTREAM_LOCAL ABTI_local * lp_ABTI_local
Definition: local.c:33
ABT_pool_kind
Definition: abt.h:157
ABT_thread(* ABT_unit_get_thread_fn)(ABT_unit)
Definition: abt.h:398
void(* ABT_sched_run_fn)(ABT_sched)
Definition: abt.h:381
ABT_sched_type
Definition: abt.h:152
int(* ABT_pool_remove_fn)(ABT_pool, ABT_unit)
Definition: abt.h:409
struct ABT_sched_config_opaque * ABT_sched_config
Definition: abt.h:259
struct ABT_pool_config_opaque * ABT_pool_config
Definition: abt.h:269
int(* ABT_pool_free_fn)(ABT_pool)
Definition: abt.h:410
int(* ABT_pool_print_all_fn)(ABT_pool, void *arg, void(*)(void *, ABT_unit))
Definition: abt.h:411
ABT_unit(* ABT_unit_create_from_thread_fn)(ABT_thread)
Definition: abt.h:401
ABT_unit(* ABT_pool_pop_timedwait_fn)(ABT_pool, double)
Definition: abt.h:408
int(* ABT_pool_init_fn)(ABT_pool, ABT_pool_config)
Definition: abt.h:404