ARGOBOTS  1.1
pool.c
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 #include "abti.h"
7 
9  ABT_bool automatic, ABT_bool is_builtin,
10  ABTI_pool **pp_newpool);
11 
74  ABT_pool *newpool)
75 {
76 #ifndef ABT_CONFIG_ENABLE_VER_20_API
77  /* Argobots 1.x sets newpool to NULL on error. */
78  *newpool = ABT_POOL_NULL;
79 #endif
80  /* Copy def */
81  ABTI_pool_def internal_def;
82 
83  internal_def.access = def->access;
84  internal_def.u_is_in_pool = def->u_is_in_pool;
85  internal_def.u_create_from_thread = def->u_create_from_thread;
86  internal_def.u_free = def->u_free;
87  internal_def.p_init = def->p_init;
88  internal_def.p_get_size = def->p_get_size;
89  internal_def.p_push = def->p_push;
90  internal_def.p_pop = def->p_pop;
91 #ifdef ABT_CONFIG_ENABLE_VER_20_API
92  internal_def.p_pop_wait = def->p_pop_wait;
93 #else
94  internal_def.p_pop_wait = NULL;
95 #endif
96  internal_def.p_pop_timedwait = def->p_pop_timedwait;
97  internal_def.p_remove = def->p_remove;
98  internal_def.p_free = def->p_free;
99  internal_def.p_print_all = def->p_print_all;
100 
101  ABTI_pool *p_newpool;
102  int abt_errno =
103  pool_create(&internal_def, config, ABT_FALSE, ABT_FALSE, &p_newpool);
104  ABTI_CHECK_ERROR(abt_errno);
105 
106  *newpool = ABTI_pool_get_handle(p_newpool);
107  return ABT_SUCCESS;
108 }
109 
168  ABT_bool automatic, ABT_pool *newpool)
169 {
170 #ifndef ABT_CONFIG_ENABLE_VER_20_API
171  /* Argobots 1.x sets newpool to NULL on error. */
172  *newpool = ABT_POOL_NULL;
173 #endif
174  ABTI_pool *p_newpool;
175  int abt_errno = ABTI_pool_create_basic(kind, access, automatic, &p_newpool);
176  ABTI_CHECK_ERROR(abt_errno);
177 
178  *newpool = ABTI_pool_get_handle(p_newpool);
179  return ABT_SUCCESS;
180 }
181 
212 {
213  ABT_pool h_pool = *pool;
214  ABTI_pool *p_pool = ABTI_pool_get_ptr(h_pool);
215  ABTI_CHECK_NULL_POOL_PTR(p_pool);
216 
217  ABTI_pool_free(p_pool);
218 
219  *pool = ABT_POOL_NULL;
220  return ABT_SUCCESS;
221 }
222 
246 {
247  ABTI_pool *p_pool = ABTI_pool_get_ptr(pool);
248  ABTI_CHECK_NULL_POOL_PTR(p_pool);
249 
250  *access = p_pool->access;
251  return ABT_SUCCESS;
252 }
253 
291 int ABT_pool_get_total_size(ABT_pool pool, size_t *size)
292 {
293  ABTI_pool *p_pool = ABTI_pool_get_ptr(pool);
294  ABTI_CHECK_NULL_POOL_PTR(p_pool);
295 
296  *size = ABTI_pool_get_total_size(p_pool);
297  return ABT_SUCCESS;
298 }
299 
334 int ABT_pool_get_size(ABT_pool pool, size_t *size)
335 {
336  ABTI_pool *p_pool = ABTI_pool_get_ptr(pool);
337  ABTI_CHECK_NULL_POOL_PTR(p_pool);
338 
339  *size = ABTI_pool_get_size(p_pool);
340  return ABT_SUCCESS;
341 }
342 
388 int ABT_pool_pop(ABT_pool pool, ABT_unit *p_unit)
389 {
390  ABTI_pool *p_pool = ABTI_pool_get_ptr(pool);
391  ABTI_CHECK_NULL_POOL_PTR(p_pool);
392 
393  *p_unit = ABTI_pool_pop(p_pool);
394  return ABT_SUCCESS;
395 }
396 
446 int ABT_pool_pop_wait(ABT_pool pool, ABT_unit *p_unit, double time_secs)
447 {
448  ABTI_pool *p_pool = ABTI_pool_get_ptr(pool);
449  ABTI_CHECK_NULL_POOL_PTR(p_pool);
451 
452  *p_unit = ABTI_pool_pop_wait(p_pool, time_secs);
453  return ABT_SUCCESS;
454 }
455 
510 int ABT_pool_pop_timedwait(ABT_pool pool, ABT_unit *p_unit, double abstime_secs)
511 {
512  ABTI_pool *p_pool = ABTI_pool_get_ptr(pool);
513  ABTI_CHECK_NULL_POOL_PTR(p_pool);
515 
516  *p_unit = ABTI_pool_pop_timedwait(p_pool, abstime_secs);
517  return ABT_SUCCESS;
518 }
519 
559 int ABT_pool_push(ABT_pool pool, ABT_unit unit)
560 {
561  ABTI_global *p_global = ABTI_global_get_global();
562  ABTI_pool *p_pool = ABTI_pool_get_ptr(pool);
563  ABTI_CHECK_NULL_POOL_PTR(p_pool);
564 
566 
567  ABTI_thread *p_thread;
568  int abt_errno =
569  ABTI_unit_set_associated_pool(p_global, unit, p_pool, &p_thread);
570  ABTI_CHECK_ERROR(abt_errno);
571  /* ABTI_unit_set_associated_pool() might change unit, so "unit" must be read
572  * again from p_thread. */
573  ABTI_pool_push(p_pool, p_thread->unit);
574  return ABT_SUCCESS;
575 }
576 
617 int ABT_pool_remove(ABT_pool pool, ABT_unit unit)
618 {
619  ABTI_pool *p_pool = ABTI_pool_get_ptr(pool);
620  ABTI_CHECK_NULL_POOL_PTR(p_pool);
622 
623  /* unit must be in this pool, so we do not need to reset its associated
624  * pool. */
625  int abt_errno = ABTI_pool_remove(p_pool, unit);
626  ABTI_CHECK_ERROR(abt_errno);
627  return ABT_SUCCESS;
628 }
629 
673 int ABT_pool_print_all(ABT_pool pool, void *arg,
674  void (*print_fn)(void *, ABT_unit))
675 {
676  ABTI_pool *p_pool = ABTI_pool_get_ptr(pool);
677  ABTI_CHECK_NULL_POOL_PTR(p_pool);
679 
680  p_pool->p_print_all(pool, arg, print_fn);
681  return ABT_SUCCESS;
682 }
683 
706 int ABT_pool_set_data(ABT_pool pool, void *data)
707 {
708  ABTI_pool *p_pool = ABTI_pool_get_ptr(pool);
709  ABTI_CHECK_NULL_POOL_PTR(p_pool);
710 
711  p_pool->data = data;
712  return ABT_SUCCESS;
713 }
714 
739 int ABT_pool_get_data(ABT_pool pool, void **data)
740 {
741  ABTI_pool *p_pool = ABTI_pool_get_ptr(pool);
742  ABTI_CHECK_NULL_POOL_PTR(p_pool);
743 
744  *data = p_pool->data;
745  return ABT_SUCCESS;
746 }
747 
791 int ABT_pool_add_sched(ABT_pool pool, ABT_sched sched)
792 {
793  ABTI_local *p_local = ABTI_local_get_local();
794 
795  ABTI_global *p_global;
796  ABTI_SETUP_GLOBAL(&p_global);
797 
798  ABTI_pool *p_pool = ABTI_pool_get_ptr(pool);
799  ABTI_CHECK_NULL_POOL_PTR(p_pool);
800 
801  ABTI_sched *p_sched = ABTI_sched_get_ptr(sched);
802  ABTI_CHECK_NULL_SCHED_PTR(p_sched);
803 
804  /* Mark the scheduler as it is used in pool */
805 #ifndef ABT_CONFIG_ENABLE_VER_20_API
807 #endif
808  p_sched->used = ABTI_SCHED_IN_POOL;
809 
810 #ifndef ABT_CONFIG_ENABLE_VER_20_API
811  /* In both ABT_SCHED_TYPE_ULT and ABT_SCHED_TYPE_TASK cases, we use ULT-type
812  * scheduler to reduce the code maintenance cost. */
813 #endif
814  int abt_errno =
815  ABTI_ythread_create_sched(p_global, p_local, p_pool, p_sched);
816  if (abt_errno != ABT_SUCCESS) {
817  p_sched->used = ABTI_SCHED_NOT_USED;
818  ABTI_HANDLE_ERROR(abt_errno);
819  }
820  return ABT_SUCCESS;
821 }
822 
844 int ABT_pool_get_id(ABT_pool pool, int *id)
845 {
846  ABTI_pool *p_pool = ABTI_pool_get_ptr(pool);
847  ABTI_CHECK_NULL_POOL_PTR(p_pool);
848 
849  *id = (int)p_pool->id;
850  return ABT_SUCCESS;
851 }
852 
853 /*****************************************************************************/
854 /* Private APIs */
855 /*****************************************************************************/
856 
859  ABT_bool automatic,
860  ABTI_pool **pp_newpool)
861 {
862  int abt_errno;
863  ABTI_pool_def def;
864 
866  access == ABT_POOL_ACCESS_SPSC ||
867  access == ABT_POOL_ACCESS_MPSC ||
868  access == ABT_POOL_ACCESS_SPMC ||
869  access == ABT_POOL_ACCESS_MPMC,
871  switch (kind) {
872  case ABT_POOL_FIFO:
873  abt_errno = ABTI_pool_get_fifo_def(access, &def);
874  break;
875  case ABT_POOL_FIFO_WAIT:
876  abt_errno = ABTI_pool_get_fifo_wait_def(access, &def);
877  break;
878  default:
879  abt_errno = ABT_ERR_INV_POOL_KIND;
880  break;
881  }
882  ABTI_CHECK_ERROR(abt_errno);
883 
884  abt_errno = pool_create(&def, ABT_POOL_CONFIG_NULL, automatic, ABT_TRUE,
885  pp_newpool);
886  ABTI_CHECK_ERROR(abt_errno);
887  return ABT_SUCCESS;
888 }
889 
890 void ABTI_pool_free(ABTI_pool *p_pool)
891 {
892  LOG_DEBUG("[P%" PRIu64 "] freed\n", p_pool->id);
893  ABT_pool h_pool = ABTI_pool_get_handle(p_pool);
894  if (p_pool->p_free) {
895  p_pool->p_free(h_pool);
896  }
897  ABTU_free(p_pool);
898 }
899 
900 void ABTI_pool_print(ABTI_pool *p_pool, FILE *p_os, int indent)
901 {
902  if (p_pool == NULL) {
903  fprintf(p_os, "%*s== NULL POOL ==\n", indent, "");
904  } else {
905  const char *access;
906 
907  switch (p_pool->access) {
909  access = "PRIV";
910  break;
912  access = "SPSC";
913  break;
915  access = "MPSC";
916  break;
918  access = "SPMC";
919  break;
921  access = "MPMC";
922  break;
923  default:
924  access = "UNKNOWN";
925  break;
926  }
927 
928  fprintf(p_os,
929  "%*s== POOL (%p) ==\n"
930  "%*sid : %" PRIu64 "\n"
931  "%*saccess : %s\n"
932  "%*sautomatic : %s\n"
933  "%*snum_scheds : %d\n"
934  "%*ssize : %zu\n"
935  "%*snum_blocked : %d\n"
936  "%*sdata : %p\n",
937  indent, "", (void *)p_pool, indent, "", p_pool->id, indent, "",
938  access, indent, "",
939  (p_pool->automatic == ABT_TRUE) ? "TRUE" : "FALSE", indent, "",
940  ABTD_atomic_acquire_load_int32(&p_pool->num_scheds), indent, "",
941  ABTI_pool_get_size(p_pool), indent, "",
942  ABTD_atomic_acquire_load_int32(&p_pool->num_blocked), indent,
943  "", p_pool->data);
944  }
945  fflush(p_os);
946 }
947 
950 {
952 }
953 
954 /*****************************************************************************/
955 /* Internal static functions */
956 /*****************************************************************************/
957 
958 static inline uint64_t pool_get_new_id(void);
959 ABTU_ret_err static int pool_create(ABTI_pool_def *def, ABT_pool_config config,
960  ABT_bool automatic, ABT_bool is_builtin,
961  ABTI_pool **pp_newpool)
962 {
963  int abt_errno;
964  ABTI_pool *p_pool;
965  abt_errno = ABTU_malloc(sizeof(ABTI_pool), (void **)&p_pool);
966  ABTI_CHECK_ERROR(abt_errno);
967 
968  p_pool->access = def->access;
969  p_pool->automatic = automatic;
970  p_pool->is_builtin = is_builtin;
971  ABTD_atomic_release_store_int32(&p_pool->num_scheds, 0);
972  ABTD_atomic_release_store_int32(&p_pool->num_blocked, 0);
973  p_pool->data = NULL;
974 
975  /* Set up the pool functions from def */
976  p_pool->u_is_in_pool = def->u_is_in_pool;
977  p_pool->u_create_from_thread = def->u_create_from_thread;
978  p_pool->u_free = def->u_free;
979  p_pool->p_init = def->p_init;
980  p_pool->p_get_size = def->p_get_size;
981  p_pool->p_push = def->p_push;
982  p_pool->p_pop = def->p_pop;
983  p_pool->p_pop_wait = def->p_pop_wait;
984  p_pool->p_pop_timedwait = def->p_pop_timedwait;
985  p_pool->p_remove = def->p_remove;
986  p_pool->p_free = def->p_free;
987  p_pool->p_print_all = def->p_print_all;
988  p_pool->id = pool_get_new_id();
989  LOG_DEBUG("[P%" PRIu64 "] created\n", p_pool->id);
990 
991  /* Configure the pool */
992  if (p_pool->p_init) {
993  abt_errno = p_pool->p_init(ABTI_pool_get_handle(p_pool), config);
994  if (abt_errno != ABT_SUCCESS) {
995  ABTU_free(p_pool);
996  return abt_errno;
997  }
998  }
999  *pp_newpool = p_pool;
1000  return ABT_SUCCESS;
1001 }
1002 
1003 static inline uint64_t pool_get_new_id(void)
1005  return (uint64_t)ABTD_atomic_fetch_add_uint64(&g_pool_id, 1);
1006 }
ABTI_pool_def::p_init
ABT_pool_init_fn p_init
Definition: abti.h:360
ABTI_CHECK_NULL_SCHED_PTR
#define ABTI_CHECK_NULL_SCHED_PTR(p)
Definition: abti_error.h:177
ABTI_pool_def::p_get_size
ABT_pool_get_size_fn p_get_size
Definition: abti.h:361
ABTI_sched_get_ptr
static ABTI_sched * ABTI_sched_get_ptr(ABT_sched sched)
Definition: abti_sched.h:11
ABT_pool_get_data
int ABT_pool_get_data(ABT_pool pool, void **data)
Retrieve user data from a pool.
Definition: pool.c:740
ABT_pool_pop_wait
int ABT_pool_pop_wait(ABT_pool pool, ABT_unit *p_unit, double time_secs)
Pop a unit from a pool with wait.
Definition: pool.c:446
ABT_bool
int ABT_bool
Boolean type.
Definition: abt.h:1001
ABT_pool_get_size
int ABT_pool_get_size(ABT_pool pool, size_t *size)
Get the size of a pool.
Definition: pool.c:334
ABTI_SCHED_NOT_USED
@ ABTI_SCHED_NOT_USED
Definition: abti.h:76
ABTI_pool::p_print_all
ABT_pool_print_all_fn p_print_all
Definition: abti.h:351
ABTD_atomic_uint64
Definition: abtd_atomic.h:35
ABT_pool_create
int ABT_pool_create(ABT_pool_def *def, ABT_pool_config config, ABT_pool *newpool)
Create a new pool.
Definition: pool.c:73
ABTI_pool_def::p_remove
ABT_pool_remove_fn p_remove
Definition: abti.h:366
ABT_pool_add_sched
int ABT_pool_add_sched(ABT_pool pool, ABT_sched sched)
Create a new work unit associated with a scheduler and push it to a pool.
Definition: pool.c:792
ABTI_pool_def::p_print_all
ABT_pool_print_all_fn p_print_all
Definition: abti.h:368
ABTI_SETUP_GLOBAL
#define ABTI_SETUP_GLOBAL(pp_global)
Definition: abti_error.h:59
ABTI_unit_set_associated_pool
static ABTU_ret_err int ABTI_unit_set_associated_pool(ABTI_global *p_global, ABT_unit unit, ABTI_pool *p_pool, ABTI_thread **pp_thread)
Definition: abti_unit.h:55
ABTI_pool_def
Definition: abti.h:354
ABTI_global_get_global
static ABTI_global * ABTI_global_get_global(void)
Definition: abti_global.h:9
ABT_ERR_POOL
#define ABT_ERR_POOL
Error code: error related to a pool.
Definition: abt.h:282
ABTI_CHECK_ERROR
#define ABTI_CHECK_ERROR(abt_errno)
Definition: abti_error.h:120
data
Definition: fifo.c:29
ABT_pool_def::u_free
ABT_unit_free_fn u_free
Function that frees a work unit.
Definition: abt.h:1531
ABT_POOL_ACCESS_MPMC
@ ABT_POOL_ACCESS_MPMC
Definition: abt.h:541
ABTI_thread::unit
ABT_unit unit
Definition: abti.h:376
ABTI_pool_push
static void ABTI_pool_push(ABTI_pool *p_pool, ABT_unit unit)
Definition: abti_pool.h:53
ABTI_pool_get_size
static size_t ABTI_pool_get_size(ABTI_pool *p_pool)
Definition: abti_pool.h:121
ABT_pool_def::p_remove
ABT_pool_remove_fn p_remove
Function that removes a work unit from a pool.
Definition: abt.h:1648
ABTD_atomic_release_store_int32
static void ABTD_atomic_release_store_int32(ABTD_atomic_int32 *ptr, int32_t val)
Definition: abtd_atomic.h:1088
ABTI_thread
Definition: abti.h:371
ABT_pool_def::u_is_in_pool
ABT_unit_is_in_pool_fn u_is_in_pool
Function that returns whether a work unit is in its associated pool or not.
Definition: abt.h:1475
ABTI_pool_get_fifo_def
ABTU_ret_err int ABTI_pool_get_fifo_def(ABT_pool_access access, ABTI_pool_def *p_def)
Definition: fifo.c:68
ABT_pool
struct ABT_pool_opaque * ABT_pool
Pool handle type.
Definition: abt.h:841
ABTI_pool_def::u_free
ABT_unit_free_fn u_free
Definition: abti.h:359
ABT_POOL_ACCESS_MPSC
@ ABT_POOL_ACCESS_MPSC
Definition: abt.h:535
ABTI_SCHED_IN_POOL
@ ABTI_SCHED_IN_POOL
Definition: abti.h:78
ABT_POOL_ACCESS_PRIV
@ ABT_POOL_ACCESS_PRIV
Definition: abt.h:526
ABTI_sched::used
ABTI_sched_used used
Definition: abti.h:290
ABT_sched
struct ABT_sched_opaque * ABT_sched
Scheduler handle type.
Definition: abt.h:808
ABTD_atomic_acquire_load_int32
static int32_t ABTD_atomic_acquire_load_int32(const ABTD_atomic_int32 *ptr)
Definition: abtd_atomic.h:911
ABT_ERR_INV_SCHED
#define ABT_ERR_INV_SCHED
Error code: invalid scheduler.
Definition: abt.h:129
ABTI_pool
Definition: abti.h:327
ABT_pool_print_all
int ABT_pool_print_all(ABT_pool pool, void *arg, void(*print_fn)(void *, ABT_unit))
Apply a print function to every work unit in a pool using a user-defined function.
Definition: pool.c:674
ABT_POOL_NULL
#define ABT_POOL_NULL
Definition: abt.h:1059
ABTI_pool_def::u_is_in_pool
ABT_unit_is_in_pool_fn u_is_in_pool
Definition: abti.h:357
ABTD_atomic_release_store_uint64
static void ABTD_atomic_release_store_uint64(ABTD_atomic_uint64 *ptr, uint64_t val)
Definition: abtd_atomic.h:1124
abti.h
ABTI_pool::data
void * data
Definition: abti.h:334
ABT_pool_def
A struct that defines a pool.
Definition: abt.h:1426
ABTI_pool::p_pop_wait
ABT_pool_pop_wait_fn p_pop_wait
Definition: abti.h:347
ABT_pool_remove
int ABT_pool_remove(ABT_pool pool, ABT_unit unit)
Remove a specified work unit from a pool.
Definition: pool.c:618
ABT_POOL_CONFIG_NULL
#define ABT_POOL_CONFIG_NULL
Definition: abt.h:1060
ABTI_HANDLE_ERROR
#define ABTI_HANDLE_ERROR(n)
Definition: abti_error.h:114
g_pool_id
static ABTD_atomic_uint64 g_pool_id
Definition: pool.c:949
ABT_pool_config
struct ABT_pool_config_opaque * ABT_pool_config
Pool configuration handle type.
Definition: abt.h:848
ABTI_pool_create_basic
ABTU_ret_err int ABTI_pool_create_basic(ABT_pool_kind kind, ABT_pool_access access, ABT_bool automatic, ABTI_pool **pp_newpool)
Definition: pool.c:858
ABTU_malloc
static ABTU_ret_err int ABTU_malloc(size_t size, void **p_ptr)
Definition: abtu.h:262
LOG_DEBUG
#define LOG_DEBUG(fmt,...)
Definition: abti_log.h:26
ABTI_pool_remove
static ABTU_ret_err int ABTI_pool_remove(ABTI_pool *p_pool, ABT_unit unit)
Definition: abti_pool.h:68
ABT_pool_def::p_pop_timedwait
ABT_pool_pop_timedwait_fn p_pop_timedwait
Function that pops a work unit from a pool with wait.
Definition: abt.h:1634
ABT_pool_def::p_pop
ABT_pool_pop_fn p_pop
Function that pops a work unit from a pool.
Definition: abt.h:1590
ABT_pool_def::p_free
ABT_pool_free_fn p_free
Function that frees a pool.
Definition: abt.h:1661
ABT_ERR_INV_UNIT
#define ABT_ERR_INV_UNIT
Error code: invalid work unit for scheduling.
Definition: abt.h:171
ABT_POOL_FIFO
@ ABT_POOL_FIFO
Definition: abt.h:506
ABTD_ATOMIC_UINT64_STATIC_INITIALIZER
#define ABTD_ATOMIC_UINT64_STATIC_INITIALIZER(val)
Definition: abtd_atomic.h:67
ABTI_pool::p_remove
ABT_pool_remove_fn p_remove
Definition: abti.h:349
ABT_ERR_INV_POOL_ACCESS
#define ABT_ERR_INV_POOL_ACCESS
Error code: invalid pool access type.
Definition: abt.h:166
ABT_pool_def::p_print_all
ABT_pool_print_all_fn p_print_all
Function that applies a user-given function to all work units in a pool.
Definition: abt.h:1679
ABT_pool_def::access
ABT_pool_access access
Access type.
Definition: abt.h:1439
ABTI_pool_get_total_size
static size_t ABTI_pool_get_total_size(ABTI_pool *p_pool)
Definition: abti_pool.h:126
ABT_POOL_FIFO_WAIT
@ ABT_POOL_FIFO_WAIT
Definition: abt.h:515
ABT_unit
struct ABT_unit_opaque * ABT_unit
Work unit handle type for scheduling.
Definition: abt.h:869
ABTI_pool_def::u_create_from_thread
ABT_unit_create_from_thread_fn u_create_from_thread
Definition: abti.h:358
ABTI_pool_def::p_push
ABT_pool_push_fn p_push
Definition: abti.h:362
ABTI_pool_def::p_pop_timedwait
ABT_pool_pop_timedwait_fn p_pop_timedwait
Definition: abti.h:365
ABTI_local_get_local
static ABTI_local * ABTI_local_get_local(void)
Definition: abti_local.h:41
ABT_pool_pop
int ABT_pool_pop(ABT_pool pool, ABT_unit *p_unit)
Pop a work unit from a pool.
Definition: pool.c:388
ABT_pool_def::p_get_size
ABT_pool_get_size_fn p_get_size
Function that returns a work unit.
Definition: abt.h:1563
ABT_pool_def::p_push
ABT_pool_push_fn p_push
Function that pushes a work unit to a pool.
Definition: abt.h:1577
ABT_SUCCESS
#define ABT_SUCCESS
Error code: the routine returns successfully.
Definition: abt.h:92
ABT_pool_push
int ABT_pool_push(ABT_pool pool, ABT_unit unit)
Push a unit to a pool.
Definition: pool.c:560
ABTU_ret_err
#define ABTU_ret_err
Definition: abtu.h:146
ABTI_pool_def::p_free
ABT_pool_free_fn p_free
Definition: abti.h:367
pool_get_new_id
static uint64_t pool_get_new_id(void)
Definition: pool.c:1004
ABTI_pool_def::p_pop_wait
ABT_pool_pop_wait_fn p_pop_wait
Definition: abti.h:364
ABT_pool_get_total_size
int ABT_pool_get_total_size(ABT_pool pool, size_t *size)
Get the total size of a pool.
Definition: pool.c:291
ABTI_pool::p_free
ABT_pool_free_fn p_free
Definition: abti.h:350
ABT_pool_create_basic
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.
Definition: pool.c:167
ABT_TRUE
#define ABT_TRUE
True constant for ABT_bool.
Definition: abt.h:748
ABTI_pool_get_ptr
static ABTI_pool * ABTI_pool_get_ptr(ABT_pool pool)
Definition: abti_pool.h:11
ABTI_pool_pop
static ABT_unit ABTI_pool_pop(ABTI_pool *p_pool)
Definition: abti_pool.h:96
ABT_POOL_ACCESS_SPMC
@ ABT_POOL_ACCESS_SPMC
Definition: abt.h:539
pool_create
static ABTU_ret_err int pool_create(ABTI_pool_def *def, ABT_pool_config config, ABT_bool automatic, ABT_bool is_builtin, ABTI_pool **pp_newpool)
Definition: pool.c:960
ABTI_sched
Definition: abti.h:289
ABT_FALSE
#define ABT_FALSE
False constant for ABT_bool.
Definition: abt.h:750
ABTI_pool::access
ABT_pool_access access
Definition: abti.h:328
ABTI_pool_def::p_pop
ABT_pool_pop_fn p_pop
Definition: abti.h:363
ABTI_CHECK_NULL_POOL_PTR
#define ABTI_CHECK_NULL_POOL_PTR(p)
Definition: abti_error.h:168
ABTD_atomic_fetch_add_uint64
static uint64_t ABTD_atomic_fetch_add_uint64(ABTD_atomic_uint64 *ptr, uint64_t v)
Definition: abtd_atomic.h:477
ABT_ERR_INV_POOL_KIND
#define ABT_ERR_INV_POOL_KIND
Error code: invalid pool kind.
Definition: abt.h:161
ABT_POOL_ACCESS_SPSC
@ ABT_POOL_ACCESS_SPSC
Definition: abt.h:531
ABTI_pool_reset_id
void ABTI_pool_reset_id(void)
Definition: pool.c:950
ABTU_free
static void ABTU_free(void *ptr)
Definition: abtu.h:217
ABT_pool_set_data
int ABT_pool_set_data(ABT_pool pool, void *data)
Set user data in a pool.
Definition: pool.c:707
ABT_pool_def::u_create_from_thread
ABT_unit_create_from_thread_fn u_create_from_thread
Function that creates an ABT_unit handle that is associated with an ABT_thread handle.
Definition: abt.h:1505
ABTI_pool_print
void ABTI_pool_print(ABTI_pool *p_pool, FILE *p_os, int indent)
Definition: pool.c:901
ABTI_pool_get_fifo_wait_def
ABTU_ret_err int ABTI_pool_get_fifo_wait_def(ABT_pool_access access, ABTI_pool_def *p_def)
Definition: fifo_wait.c:39
ABTI_pool_pop_wait
static ABT_unit ABTI_pool_pop_wait(ABTI_pool *p_pool, double time_secs)
Definition: abti_pool.h:75
ABT_pool_pop_timedwait
int ABT_pool_pop_timedwait(ABT_pool pool, ABT_unit *p_unit, double abstime_secs)
Pop a unit from a pool with timed wait.
Definition: pool.c:510
ABT_pool_free
int ABT_pool_free(ABT_pool *pool)
Free a pool.
Definition: pool.c:211
ABTI_local
struct ABTI_local ABTI_local
Definition: abti.h:110
ABTI_pool_pop_timedwait
static ABT_unit ABTI_pool_pop_timedwait(ABTI_pool *p_pool, double abstime_secs)
Definition: abti_pool.h:85
ABTI_pool::id
uint64_t id
Definition: abti.h:335
ABTI_CHECK_TRUE
#define ABTI_CHECK_TRUE(cond, abt_errno)
Definition: abti_error.h:130
ABTI_global
Definition: abti.h:196
ABTI_pool_free
void ABTI_pool_free(ABTI_pool *p_pool)
Definition: pool.c:891
ABT_pool_def::p_init
ABT_pool_init_fn p_init
Function that frees a work unit.
Definition: abt.h:1545
ABTI_pool_def::access
ABT_pool_access access
Definition: abti.h:355
ABT_UNIT_NULL
#define ABT_UNIT_NULL
Definition: abt.h:1061
ABTI_ythread_create_sched
ABTU_ret_err int ABTI_ythread_create_sched(ABTI_global *p_global, ABTI_local *p_local, ABTI_pool *p_pool, ABTI_sched *p_sched)
Definition: thread.c:2376
ABT_pool_kind
ABT_pool_kind
Predefined pool type.
Definition: abt.h:504
ABTI_pool::p_pop_timedwait
ABT_pool_pop_timedwait_fn p_pop_timedwait
Definition: abti.h:348
ABTI_pool_get_handle
static ABT_pool ABTI_pool_get_handle(ABTI_pool *p_pool)
Definition: abti_pool.h:26
ABT_pool_get_access
int ABT_pool_get_access(ABT_pool pool, ABT_pool_access *access)
Get an access type of a pool.
Definition: pool.c:245
ABT_pool_get_id
int ABT_pool_get_id(ABT_pool pool, int *id)
Get ID of a pool.
Definition: pool.c:845
ABT_pool_access
ABT_pool_access
Pool access type.
Definition: abt.h:522