8 static inline uint64_t ABTI_pool_get_new_id(
void);
36 abt_errno = ABTI_pool_create(def, config,
ABT_FALSE, &p_newpool);
37 ABTI_CHECK_ERROR(abt_errno);
38 *newpool = ABTI_pool_get_handle(p_newpool);
68 abt_errno = ABTI_pool_create_basic(kind, access, automatic, &p_newpool);
69 ABTI_CHECK_ERROR(abt_errno);
70 *newpool = ABTI_pool_get_handle(p_newpool);
94 ABTI_pool *p_pool = ABTI_pool_get_ptr(h_pool);
98 ABTI_pool_free(p_pool);
122 ABTI_pool *p_pool = ABTI_pool_get_ptr(pool);
123 ABTI_CHECK_NULL_POOL_PTR(p_pool);
125 *access = p_pool->access;
152 ABTI_pool *p_pool = ABTI_pool_get_ptr(pool);
153 ABTI_CHECK_NULL_POOL_PTR(p_pool);
155 *size = ABTI_pool_get_total_size(p_pool);
181 ABTI_pool *p_pool = ABTI_pool_get_ptr(pool);
182 ABTI_CHECK_NULL_POOL_PTR(p_pool);
184 *size = ABTI_pool_get_size(p_pool);
211 ABTI_pool *p_pool = ABTI_pool_get_ptr(pool);
212 ABTI_CHECK_NULL_POOL_PTR(p_pool);
214 unit = ABTI_pool_pop(p_pool);
234 ABTI_pool *p_pool = ABTI_pool_get_ptr(pool);
235 ABTI_CHECK_NULL_POOL_PTR(p_pool);
237 unit = ABTI_pool_pop_timedwait(p_pool, abstime_secs);
262 ABTI_pool *p_pool = ABTI_pool_get_ptr(pool);
263 ABTI_CHECK_NULL_POOL_PTR(p_pool);
267 #ifdef ABT_CONFIG_DISABLE_POOL_PRODUCER_CHECK 268 ABTI_pool_push(p_pool, unit);
272 ABTI_pool_push(p_pool, unit,
273 ABTI_self_get_native_thread_id(ABTI_local_get_local()));
274 ABTI_CHECK_ERROR(abt_errno);
301 ABTI_pool *p_pool = ABTI_pool_get_ptr(pool);
302 ABTI_CHECK_NULL_POOL_PTR(p_pool);
304 abt_errno = ABTI_POOL_REMOVE(p_pool, unit,
305 ABTI_self_get_native_thread_id(
306 ABTI_local_get_local()));
307 ABTI_CHECK_ERROR(abt_errno);
340 ABTI_pool *p_pool = ABTI_pool_get_ptr(pool);
341 ABTI_CHECK_NULL_POOL_PTR(p_pool);
342 if (!p_pool->p_print_all) {
347 p_pool->p_print_all(pool, arg, print_fn);
373 ABTI_pool *p_pool = ABTI_pool_get_ptr(pool);
374 ABTI_CHECK_NULL_POOL_PTR(p_pool);
402 ABTI_pool *p_pool = ABTI_pool_get_ptr(pool);
403 ABTI_CHECK_NULL_POOL_PTR(p_pool);
405 *data = p_pool->data;
435 #ifdef ABT_CONFIG_DISABLE_STACKABLE_SCHED 439 ABTI_local *p_local = ABTI_local_get_local();
441 ABTI_pool *p_pool = ABTI_pool_get_ptr(pool);
442 ABTI_CHECK_NULL_POOL_PTR(p_pool);
444 ABTI_sched *p_sched = ABTI_sched_get_ptr(sched);
445 ABTI_CHECK_NULL_SCHED_PTR(p_sched);
447 #ifndef ABT_CONFIG_DISABLE_POOL_CONSUMER_CHECK 450 switch (p_pool->access) {
456 ABTI_CHECK_TRUE(p_pool->consumer_id != 0,
ABT_ERR_POOL);
461 for (p = 0; p < p_sched->num_pools; p++) {
463 ABTI_pool_set_consumer(ABTI_pool_get_ptr(p_sched->pools[p]),
464 p_pool->consumer_id);
465 ABTI_CHECK_ERROR(abt_errno);
473 for (p = 0; p < p_sched->num_pools; p++) {
474 ABTI_pool *p_local_pool = ABTI_pool_get_ptr(p_sched->pools[p]);
476 p_local_pool->access !=
478 p_local_pool->access !=
491 p_sched->used = ABTI_SCHED_IN_POOL;
494 abt_errno = ABTI_thread_create_sched(p_local, p_pool, p_sched);
495 ABTI_CHECK_ERROR(abt_errno);
497 abt_errno = ABTI_task_create_sched(p_local, p_pool, p_sched);
498 ABTI_CHECK_ERROR(abt_errno);
527 ABTI_pool *p_pool = ABTI_pool_get_ptr(pool);
528 ABTI_CHECK_NULL_POOL_PTR(p_pool);
530 *
id = (int)p_pool->id;
545 ABT_bool automatic, ABTI_pool **pp_newpool)
550 p_pool = (ABTI_pool *)
ABTU_malloc(
sizeof(ABTI_pool));
551 p_pool->access = def->
access;
552 p_pool->automatic = automatic;
553 ABTD_atomic_release_store_int32(&p_pool->num_scheds, 0);
554 #ifndef ABT_CONFIG_DISABLE_POOL_CONSUMER_CHECK 555 p_pool->consumer_id = 0;
557 #ifndef ABT_CONFIG_DISABLE_POOL_PRODUCER_CHECK 558 p_pool->producer_id = 0;
560 ABTD_atomic_release_store_int32(&p_pool->num_blocked, 0);
561 ABTD_atomic_release_store_int32(&p_pool->num_migrations, 0);
571 p_pool->u_free = def->
u_free;
572 p_pool->p_init = def->
p_init;
574 p_pool->p_push = def->
p_push;
575 p_pool->p_pop = def->
p_pop;
578 p_pool->p_free = def->
p_free;
580 p_pool->id = ABTI_pool_get_new_id();
581 LOG_EVENT(
"[P%" PRIu64
"] created\n", p_pool->id);
584 if (p_pool->p_init) {
585 abt_errno = p_pool->p_init(ABTI_pool_get_handle(p_pool), config);
591 *pp_newpool = p_pool;
602 ABT_bool automatic, ABTI_pool **pp_newpool)
609 abt_errno = ABTI_pool_get_fifo_def(access, &def);
612 abt_errno = ABTI_pool_get_fifo_wait_def(access, &def);
618 ABTI_CHECK_ERROR(abt_errno);
622 ABTI_CHECK_ERROR(abt_errno);
632 void ABTI_pool_free(ABTI_pool *p_pool)
634 LOG_EVENT(
"[P%" PRIu64
"] freed\n", p_pool->id);
635 ABT_pool h_pool = ABTI_pool_get_handle(p_pool);
636 p_pool->p_free(h_pool);
640 void ABTI_pool_print(ABTI_pool *p_pool, FILE *p_os,
int indent)
644 if (p_pool == NULL) {
645 fprintf(p_os,
"%s== NULL POOL ==\n", prefix);
651 switch (p_pool->access) {
673 "%s== POOL (%p) ==\n" 674 "%sid : %" PRIu64
"\n" 677 "%snum_scheds : %d\n" 678 #ifndef ABT_CONFIG_DISABLE_POOL_CONSUMER_CHECK
679 "%sconsumer ID : %p\n" 681 #ifndef ABT_CONFIG_DISABLE_POOL_PRODUCER_CHECK
682 "%sproducer ID : %p\n" 685 "%snum_blocked : %d\n" 686 "%snum_migrations: %d\n" 688 prefix, (
void *)p_pool, prefix, p_pool->id, prefix, access, prefix,
689 (p_pool->automatic ==
ABT_TRUE) ?
"TRUE" :
"FALSE", prefix,
690 ABTD_atomic_acquire_load_int32(&p_pool->num_scheds),
691 #ifndef ABT_CONFIG_DISABLE_POOL_CONSUMER_CHECK
692 prefix, (
void *)p_pool->consumer_id,
694 #ifndef ABT_CONFIG_DISABLE_POOL_PRODUCER_CHECK
695 prefix, (
void *)p_pool->producer_id,
697 prefix, ABTI_pool_get_size(p_pool), prefix,
698 ABTD_atomic_acquire_load_int32(&p_pool->num_blocked), prefix,
699 ABTD_atomic_acquire_load_int32(&p_pool->num_migrations), prefix,
707 #ifndef ABT_CONFIG_DISABLE_POOL_CONSUMER_CHECK 713 int ABTI_pool_set_consumer(ABTI_pool *p_pool, ABTI_native_thread_id consumer_id)
717 if (ABTD_atomic_acquire_load_int32(&p_pool->num_scheds) == 0) {
721 switch (p_pool->access) {
723 #ifndef ABT_CONFIG_DISABLE_POOL_PRODUCER_CHECK 724 ABTI_CHECK_TRUE(!p_pool->producer_id ||
725 p_pool->producer_id == consumer_id,
728 ABTI_CHECK_TRUE(!p_pool->consumer_id ||
729 p_pool->consumer_id == consumer_id,
731 p_pool->consumer_id = consumer_id;
736 ABTI_CHECK_TRUE(!p_pool->consumer_id ||
737 p_pool->consumer_id == consumer_id,
741 p_pool->consumer_id = consumer_id;
746 p_pool->consumer_id = consumer_id;
751 ABTI_CHECK_ERROR(abt_errno);
763 #ifndef ABT_CONFIG_DISABLE_POOL_PRODUCER_CHECK 769 int ABTI_pool_set_producer(ABTI_pool *p_pool, ABTI_native_thread_id producer_id)
773 if (ABTD_atomic_acquire_load_int32(&p_pool->num_scheds) == 0) {
777 switch (p_pool->access) {
779 #ifndef ABT_CONFIG_DISABLE_POOL_CONSUMER_CHECK 780 ABTI_CHECK_TRUE(!p_pool->consumer_id ||
781 p_pool->consumer_id == producer_id,
784 ABTI_CHECK_TRUE(!p_pool->producer_id ||
785 p_pool->producer_id == producer_id,
787 p_pool->producer_id = producer_id;
792 ABTI_CHECK_TRUE(!p_pool->producer_id ||
793 p_pool->producer_id == producer_id,
797 p_pool->producer_id = producer_id;
802 p_pool->producer_id = producer_id;
807 ABTI_CHECK_ERROR(abt_errno);
822 int ABTI_pool_accept_migration(ABTI_pool *p_pool, ABTI_pool *source)
824 #if !defined(ABT_CONFIG_DISABLE_POOL_PRODUCER_CHECK) && \ 825 !defined(ABT_CONFIG_DISABLE_POOL_CONSUMER_CHECK) 826 switch (p_pool->access) {
831 if (p_pool->consumer_id == source->producer_id)
846 static ABTD_atomic_uint64
g_pool_id = ABTD_ATOMIC_UINT64_STATIC_INITIALIZER(0);
847 void ABTI_pool_reset_id(
void)
849 ABTD_atomic_release_store_uint64(&g_pool_id, 0);
856 static inline uint64_t ABTI_pool_get_new_id(
void)
858 return (uint64_t)ABTD_atomic_fetch_add_uint64(&g_pool_id, 1);
static ABTD_atomic_uint64 g_pool_id
struct ABT_unit_opaque * ABT_unit
int ABT_pool_pop(ABT_pool pool, ABT_unit *p_unit)
Pop a unit from the target pool.
ABT_unit_get_task_fn u_get_task
#define ABT_ERR_INV_POOL_ACCESS
struct ABT_sched_opaque * ABT_sched
char * ABTU_get_indent_str(int indent)
int ABT_pool_get_size(ABT_pool pool, size_t *size)
Return the size of a pool.
static void * ABTU_malloc(size_t size)
ABT_unit_get_thread_fn u_get_thread
struct ABT_pool_opaque * ABT_pool
ABT_unit_is_in_pool_fn u_is_in_pool
int ABT_pool_get_data(ABT_pool pool, void **data)
Retrieve the specific data of the target user-defined pool.
int ABT_pool_get_id(ABT_pool pool, int *id)
Get the ID of the target pool.
#define HANDLE_ERROR_FUNC_WITH_CODE(n)
int ABT_pool_set_data(ABT_pool pool, void *data)
Set the specific data of the target user-defined pool.
#define ABT_ERR_INV_POOL_KIND
int ABT_pool_free(ABT_pool *pool)
Free the given pool, and modify its value to ABT_POOL_NULL.
#define LOG_EVENT(fmt,...)
int ABT_pool_remove(ABT_pool pool, ABT_unit unit)
Remove a specified unit from the target pool.
int ABT_pool_push(ABT_pool pool, ABT_unit unit)
Push a unit to the target pool.
int ABT_pool_add_sched(ABT_pool pool, ABT_sched sched)
Push a scheduler to a pool.
ABT_unit_create_from_task_fn u_create_from_task
int ABT_pool_get_access(ABT_pool pool, ABT_pool_access *access)
Get the access type of target pool.
int ABT_pool_create_basic(ABT_pool_kind kind, ABT_pool_access access, ABT_bool automatic, ABT_pool *newpool)
Create a new pool from a predefined type and return its handle through newpool.
#define ABT_ERR_FEATURE_NA
int ABT_pool_create(ABT_pool_def *def, ABT_pool_config config, ABT_pool *newpool)
Create a new pool and return its handle through newpool.
ABT_unit_create_from_thread_fn u_create_from_thread
#define ABT_ERR_INV_SCHED
struct ABT_pool_config_opaque * ABT_pool_config
ABT_unit_get_type_fn u_get_type
ABT_pool_get_size_fn p_get_size
#define ABT_ERR_INV_XSTREAM
int ABT_pool_get_total_size(ABT_pool pool, size_t *size)
Return the total size of a pool.
static void ABTU_free(void *ptr)
ABT_pool_remove_fn p_remove
#define ABT_POOL_CONFIG_NULL
ABT_pool_print_all_fn p_print_all
ABT_pool_pop_timedwait_fn p_pop_timedwait
int ABT_pool_pop_timedwait(ABT_pool pool, ABT_unit *p_unit, double abstime_secs)
int ABT_pool_print_all(ABT_pool pool, void *arg, void(*print_fn)(void *, ABT_unit))
Apply a print function to every unit in a pool using a user-defined function.