ARGOBOTS
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 
8 static inline uint64_t ABTI_pool_get_new_id(void);
9 
31  ABT_pool *newpool)
32 {
33  int abt_errno = ABT_SUCCESS;
34  ABTI_pool *p_newpool;
35 
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);
39 
40 fn_exit:
41  return abt_errno;
42 
43 fn_fail:
44  *newpool = ABT_POOL_NULL;
45  HANDLE_ERROR_FUNC_WITH_CODE(abt_errno);
46  goto fn_exit;
47 }
48 
64  ABT_bool automatic, ABT_pool *newpool)
65 {
66  int abt_errno = ABT_SUCCESS;
67  ABTI_pool *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);
71 
72 fn_exit:
73  return abt_errno;
74 
75 fn_fail:
76  HANDLE_ERROR_FUNC_WITH_CODE(abt_errno);
77  *newpool = ABT_POOL_NULL;
78  goto fn_exit;
79 }
80 
90 {
91  int abt_errno = ABT_SUCCESS;
92 
93  ABT_pool h_pool = *pool;
94  ABTI_pool *p_pool = ABTI_pool_get_ptr(h_pool);
95 
96  ABTI_CHECK_TRUE(p_pool != NULL && h_pool != ABT_POOL_NULL,
98  ABTI_pool_free(p_pool);
99 
100  *pool = ABT_POOL_NULL;
101 
102 fn_exit:
103  return abt_errno;
104 
105 fn_fail:
106  HANDLE_ERROR_FUNC_WITH_CODE(abt_errno);
107  goto fn_exit;
108 }
109 
120 {
121  int abt_errno = ABT_SUCCESS;
122  ABTI_pool *p_pool = ABTI_pool_get_ptr(pool);
123  ABTI_CHECK_NULL_POOL_PTR(p_pool);
124 
125  *access = p_pool->access;
126 
127 fn_exit:
128  return abt_errno;
129 
130 fn_fail:
131  HANDLE_ERROR_FUNC_WITH_CODE(abt_errno);
132  goto fn_exit;
133 }
134 
148 int ABT_pool_get_total_size(ABT_pool pool, size_t *size)
149 {
150  int abt_errno = ABT_SUCCESS;
151 
152  ABTI_pool *p_pool = ABTI_pool_get_ptr(pool);
153  ABTI_CHECK_NULL_POOL_PTR(p_pool);
154 
155  *size = ABTI_pool_get_total_size(p_pool);
156 
157 fn_exit:
158  return abt_errno;
159 
160 fn_fail:
161  HANDLE_ERROR_FUNC_WITH_CODE(abt_errno);
162  goto fn_exit;
163 }
164 
177 int ABT_pool_get_size(ABT_pool pool, size_t *size)
178 {
179  int abt_errno = ABT_SUCCESS;
180 
181  ABTI_pool *p_pool = ABTI_pool_get_ptr(pool);
182  ABTI_CHECK_NULL_POOL_PTR(p_pool);
183 
184  *size = ABTI_pool_get_size(p_pool);
185 
186 fn_exit:
187  return abt_errno;
188 
189 fn_fail:
190  HANDLE_ERROR_FUNC_WITH_CODE(abt_errno);
191  goto fn_exit;
192 }
193 
203 int ABT_pool_pop(ABT_pool pool, ABT_unit *p_unit)
204 {
205  int abt_errno = ABT_SUCCESS;
206  ABT_unit unit;
207 
208  /* If called by an external thread, return an error. */
209  ABTI_CHECK_TRUE(ABTI_local_get_local() != NULL, ABT_ERR_INV_XSTREAM);
210 
211  ABTI_pool *p_pool = ABTI_pool_get_ptr(pool);
212  ABTI_CHECK_NULL_POOL_PTR(p_pool);
213 
214  unit = ABTI_pool_pop(p_pool);
215 
216 fn_exit:
217  *p_unit = unit;
218  return abt_errno;
219 
220 fn_fail:
221  HANDLE_ERROR_FUNC_WITH_CODE(abt_errno);
222  unit = ABT_UNIT_NULL;
223  goto fn_exit;
224 }
225 
226 int ABT_pool_pop_timedwait(ABT_pool pool, ABT_unit *p_unit, double abstime_secs)
227 {
228  int abt_errno = ABT_SUCCESS;
229  ABT_unit unit;
230 
231  /* If called by an external thread, return an error. */
232  ABTI_CHECK_TRUE(ABTI_local_get_local() != NULL, ABT_ERR_INV_XSTREAM);
233 
234  ABTI_pool *p_pool = ABTI_pool_get_ptr(pool);
235  ABTI_CHECK_NULL_POOL_PTR(p_pool);
236 
237  unit = ABTI_pool_pop_timedwait(p_pool, abstime_secs);
238 
239 fn_exit:
240  *p_unit = unit;
241  return abt_errno;
242 
243 fn_fail:
244  HANDLE_ERROR_FUNC_WITH_CODE(abt_errno);
245  unit = ABT_UNIT_NULL;
246  goto fn_exit;
247 }
248 
259 {
260  int abt_errno = ABT_SUCCESS;
261 
262  ABTI_pool *p_pool = ABTI_pool_get_ptr(pool);
263  ABTI_CHECK_NULL_POOL_PTR(p_pool);
264 
265  ABTI_CHECK_TRUE(unit != ABT_UNIT_NULL, ABT_ERR_UNIT);
266 
267 #ifdef ABT_CONFIG_DISABLE_POOL_PRODUCER_CHECK
268  ABTI_pool_push(p_pool, unit);
269 #else
270  /* Save the producer ES information in the pool */
271  abt_errno =
272  ABTI_pool_push(p_pool, unit,
273  ABTI_self_get_native_thread_id(ABTI_local_get_local()));
274  ABTI_CHECK_ERROR(abt_errno);
275 #endif
276 
277 fn_exit:
278  return abt_errno;
279 
280 fn_fail:
281  HANDLE_ERROR_FUNC_WITH_CODE(abt_errno);
282  goto fn_exit;
283 }
284 
295 {
296  int abt_errno = ABT_SUCCESS;
297 
298  /* If called by an external thread, return an error. */
299  ABTI_CHECK_TRUE(ABTI_local_get_local() != NULL, ABT_ERR_INV_XSTREAM);
300 
301  ABTI_pool *p_pool = ABTI_pool_get_ptr(pool);
302  ABTI_CHECK_NULL_POOL_PTR(p_pool);
303 
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);
308 
309 fn_exit:
310  return abt_errno;
311 
312 fn_fail:
313  HANDLE_ERROR_FUNC_WITH_CODE(abt_errno);
314  goto fn_exit;
315 }
316 
336 int ABT_pool_print_all(ABT_pool pool, void *arg,
337  void (*print_fn)(void *, ABT_unit))
338 {
339  int abt_errno = ABT_SUCCESS;
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) {
343  abt_errno = ABT_ERR_POOL;
344  goto fn_fail;
345  }
346 
347  p_pool->p_print_all(pool, arg, print_fn);
348 
349 fn_exit:
350  return abt_errno;
351 
352 fn_fail:
353  HANDLE_ERROR_FUNC_WITH_CODE(abt_errno);
354  goto fn_exit;
355 }
356 
369 int ABT_pool_set_data(ABT_pool pool, void *data)
370 {
371  int abt_errno = ABT_SUCCESS;
372 
373  ABTI_pool *p_pool = ABTI_pool_get_ptr(pool);
374  ABTI_CHECK_NULL_POOL_PTR(p_pool);
375 
376  p_pool->data = data;
377 
378 fn_exit:
379  return abt_errno;
380 
381 fn_fail:
382  HANDLE_ERROR_FUNC_WITH_CODE(abt_errno);
383  goto fn_exit;
384 }
385 
398 int ABT_pool_get_data(ABT_pool pool, void **data)
399 {
400  int abt_errno = ABT_SUCCESS;
401 
402  ABTI_pool *p_pool = ABTI_pool_get_ptr(pool);
403  ABTI_CHECK_NULL_POOL_PTR(p_pool);
404 
405  *data = p_pool->data;
406 
407 fn_exit:
408  return abt_errno;
409 
410 fn_fail:
411  HANDLE_ERROR_FUNC_WITH_CODE(abt_errno);
412  goto fn_exit;
413 }
414 
434 {
435 #ifdef ABT_CONFIG_DISABLE_STACKABLE_SCHED
436  return ABT_ERR_FEATURE_NA;
437 #else
438  int abt_errno = ABT_SUCCESS;
439  ABTI_local *p_local = ABTI_local_get_local();
440 
441  ABTI_pool *p_pool = ABTI_pool_get_ptr(pool);
442  ABTI_CHECK_NULL_POOL_PTR(p_pool);
443 
444  ABTI_sched *p_sched = ABTI_sched_get_ptr(sched);
445  ABTI_CHECK_NULL_SCHED_PTR(p_sched);
446 
447 #ifndef ABT_CONFIG_DISABLE_POOL_CONSUMER_CHECK
448  int p;
449 
450  switch (p_pool->access) {
454  /* we need to ensure that the target pool has already an
455  * associated ES */
456  ABTI_CHECK_TRUE(p_pool->consumer_id != 0, ABT_ERR_POOL);
457 
458  /* We check that from the pool set of the scheduler we do not find
459  * a pool with another associated pool, and set the right value if
460  * it is okay */
461  for (p = 0; p < p_sched->num_pools; p++) {
462  abt_errno =
463  ABTI_pool_set_consumer(ABTI_pool_get_ptr(p_sched->pools[p]),
464  p_pool->consumer_id);
465  ABTI_CHECK_ERROR(abt_errno);
466  }
467  break;
468 
471  /* we need to ensure that the pool set of the scheduler does
472  * not contain an ES private pool */
473  for (p = 0; p < p_sched->num_pools; p++) {
474  ABTI_pool *p_local_pool = ABTI_pool_get_ptr(p_sched->pools[p]);
475  ABTI_CHECK_TRUE(p_local_pool->access != ABT_POOL_ACCESS_PRIV &&
476  p_local_pool->access !=
478  p_local_pool->access !=
480  ABT_ERR_POOL);
481  }
482  break;
483 
484  default:
485  ABTI_CHECK_TRUE(0, ABT_ERR_INV_POOL_ACCESS);
486  }
487 #endif
488 
489  /* Mark the scheduler as it is used in pool */
490  ABTI_CHECK_TRUE(p_sched->used == ABTI_SCHED_NOT_USED, ABT_ERR_INV_SCHED);
491  p_sched->used = ABTI_SCHED_IN_POOL;
492 
493  if (p_sched->type == ABT_SCHED_TYPE_ULT) {
494  abt_errno = ABTI_thread_create_sched(p_local, p_pool, p_sched);
495  ABTI_CHECK_ERROR(abt_errno);
496  } else if (p_sched->type == ABT_SCHED_TYPE_TASK) {
497  abt_errno = ABTI_task_create_sched(p_local, p_pool, p_sched);
498  ABTI_CHECK_ERROR(abt_errno);
499  } else {
500  ABTI_CHECK_TRUE(0, ABT_ERR_SCHED);
501  }
502 
503 fn_exit:
504  return abt_errno;
505 
506 fn_fail:
507  HANDLE_ERROR_FUNC_WITH_CODE(abt_errno);
508  goto fn_exit;
509 #endif
510 }
511 
523 int ABT_pool_get_id(ABT_pool pool, int *id)
524 {
525  int abt_errno = ABT_SUCCESS;
526 
527  ABTI_pool *p_pool = ABTI_pool_get_ptr(pool);
528  ABTI_CHECK_NULL_POOL_PTR(p_pool);
529 
530  *id = (int)p_pool->id;
531 
532 fn_exit:
533  return abt_errno;
534 
535 fn_fail:
536  HANDLE_ERROR_FUNC_WITH_CODE(abt_errno);
537  goto fn_exit;
538 }
539 
540 /*****************************************************************************/
541 /* Private APIs */
542 /*****************************************************************************/
543 
544 int ABTI_pool_create(ABT_pool_def *def, ABT_pool_config config,
545  ABT_bool automatic, ABTI_pool **pp_newpool)
546 {
547  int abt_errno = ABT_SUCCESS;
548  ABTI_pool *p_pool;
549 
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;
556 #endif
557 #ifndef ABT_CONFIG_DISABLE_POOL_PRODUCER_CHECK
558  p_pool->producer_id = 0;
559 #endif
560  ABTD_atomic_release_store_int32(&p_pool->num_blocked, 0);
561  ABTD_atomic_release_store_int32(&p_pool->num_migrations, 0);
562  p_pool->data = NULL;
563 
564  /* Set up the pool functions from def */
565  p_pool->u_get_type = def->u_get_type;
566  p_pool->u_get_thread = def->u_get_thread;
567  p_pool->u_get_task = def->u_get_task;
568  p_pool->u_is_in_pool = def->u_is_in_pool;
569  p_pool->u_create_from_thread = def->u_create_from_thread;
570  p_pool->u_create_from_task = def->u_create_from_task;
571  p_pool->u_free = def->u_free;
572  p_pool->p_init = def->p_init;
573  p_pool->p_get_size = def->p_get_size;
574  p_pool->p_push = def->p_push;
575  p_pool->p_pop = def->p_pop;
576  p_pool->p_pop_timedwait = def->p_pop_timedwait;
577  p_pool->p_remove = def->p_remove;
578  p_pool->p_free = def->p_free;
579  p_pool->p_print_all = def->p_print_all;
580  p_pool->id = ABTI_pool_get_new_id();
581  LOG_EVENT("[P%" PRIu64 "] created\n", p_pool->id);
582 
583  /* Configure the pool */
584  if (p_pool->p_init) {
585  abt_errno = p_pool->p_init(ABTI_pool_get_handle(p_pool), config);
586  if (abt_errno != ABT_SUCCESS) {
587  ABTU_free(p_pool);
588  goto fn_fail;
589  }
590  }
591  *pp_newpool = p_pool;
592 
593 fn_exit:
594  return abt_errno;
595 
596 fn_fail:
597  HANDLE_ERROR_FUNC_WITH_CODE(abt_errno);
598  goto fn_exit;
599 }
600 
601 int ABTI_pool_create_basic(ABT_pool_kind kind, ABT_pool_access access,
602  ABT_bool automatic, ABTI_pool **pp_newpool)
603 {
604  int abt_errno = ABT_SUCCESS;
605  ABT_pool_def def;
606 
607  switch (kind) {
608  case ABT_POOL_FIFO:
609  abt_errno = ABTI_pool_get_fifo_def(access, &def);
610  break;
611  case ABT_POOL_FIFO_WAIT:
612  abt_errno = ABTI_pool_get_fifo_wait_def(access, &def);
613  break;
614  default:
615  abt_errno = ABT_ERR_INV_POOL_KIND;
616  break;
617  }
618  ABTI_CHECK_ERROR(abt_errno);
619 
620  abt_errno =
621  ABTI_pool_create(&def, ABT_POOL_CONFIG_NULL, automatic, pp_newpool);
622  ABTI_CHECK_ERROR(abt_errno);
623 
624 fn_exit:
625  return abt_errno;
626 
627 fn_fail:
628  HANDLE_ERROR_FUNC_WITH_CODE(abt_errno);
629  goto fn_exit;
630 }
631 
632 void ABTI_pool_free(ABTI_pool *p_pool)
633 {
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);
637  ABTU_free(p_pool);
638 }
639 
640 void ABTI_pool_print(ABTI_pool *p_pool, FILE *p_os, int indent)
641 {
642  char *prefix = ABTU_get_indent_str(indent);
643 
644  if (p_pool == NULL) {
645  fprintf(p_os, "%s== NULL POOL ==\n", prefix);
646  goto fn_exit;
647  }
648 
649  char *access;
650 
651  switch (p_pool->access) {
653  access = "PRIV";
654  break;
656  access = "SPSC";
657  break;
659  access = "MPSC";
660  break;
662  access = "SPMC";
663  break;
665  access = "MPMC";
666  break;
667  default:
668  access = "UNKNOWN";
669  break;
670  }
671 
672  fprintf(p_os,
673  "%s== POOL (%p) ==\n"
674  "%sid : %" PRIu64 "\n"
675  "%saccess : %s\n"
676  "%sautomatic : %s\n"
677  "%snum_scheds : %d\n"
678 #ifndef ABT_CONFIG_DISABLE_POOL_CONSUMER_CHECK
679  "%sconsumer ID : %p\n"
680 #endif
681 #ifndef ABT_CONFIG_DISABLE_POOL_PRODUCER_CHECK
682  "%sproducer ID : %p\n"
683 #endif
684  "%ssize : %zu\n"
685  "%snum_blocked : %d\n"
686  "%snum_migrations: %d\n"
687  "%sdata : %p\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,
693 #endif
694 #ifndef ABT_CONFIG_DISABLE_POOL_PRODUCER_CHECK
695  prefix, (void *)p_pool->producer_id,
696 #endif
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,
700  p_pool->data);
701 
702 fn_exit:
703  fflush(p_os);
704  ABTU_free(prefix);
705 }
706 
707 #ifndef ABT_CONFIG_DISABLE_POOL_CONSUMER_CHECK
708 /* Set the associated consumer ES of a pool. This function has no effect on
709  * pools of shared-read access mode. If a pool is private-read to an ES, we
710  * check that the previous value of "consumer_id" is the same as the argument of
711  * the function "consumer_id"
712  * */
713 int ABTI_pool_set_consumer(ABTI_pool *p_pool, ABTI_native_thread_id consumer_id)
714 {
715  int abt_errno = ABT_SUCCESS;
716 
717  if (ABTD_atomic_acquire_load_int32(&p_pool->num_scheds) == 0) {
718  return abt_errno;
719  }
720 
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,
727 #endif
728  ABTI_CHECK_TRUE(!p_pool->consumer_id ||
729  p_pool->consumer_id == consumer_id,
731  p_pool->consumer_id = consumer_id;
732  break;
733 
736  ABTI_CHECK_TRUE(!p_pool->consumer_id ||
737  p_pool->consumer_id == consumer_id,
739  /* NB: as we do not want to use a mutex, the function can be wrong
740  * here */
741  p_pool->consumer_id = consumer_id;
742  break;
743 
746  p_pool->consumer_id = consumer_id;
747  break;
748 
749  default:
750  abt_errno = ABT_ERR_INV_POOL_ACCESS;
751  ABTI_CHECK_ERROR(abt_errno);
752  }
753 
754 fn_exit:
755  return abt_errno;
756 
757 fn_fail:
758  HANDLE_ERROR_FUNC_WITH_CODE(abt_errno);
759  goto fn_exit;
760 }
761 #endif
762 
763 #ifndef ABT_CONFIG_DISABLE_POOL_PRODUCER_CHECK
764 /* Set the associated producer ES of a pool. This function has no effect on
765  * pools of shared-write access mode. If a pool is private-write to an ES, we
766  * check that the previous value of "producer_id" is the same as the argument of
767  * the function "producer_id"
768  * */
769 int ABTI_pool_set_producer(ABTI_pool *p_pool, ABTI_native_thread_id producer_id)
770 {
771  int abt_errno = ABT_SUCCESS;
772 
773  if (ABTD_atomic_acquire_load_int32(&p_pool->num_scheds) == 0) {
774  return abt_errno;
775  }
776 
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,
783 #endif
784  ABTI_CHECK_TRUE(!p_pool->producer_id ||
785  p_pool->producer_id == producer_id,
787  p_pool->producer_id = producer_id;
788  break;
789 
792  ABTI_CHECK_TRUE(!p_pool->producer_id ||
793  p_pool->producer_id == producer_id,
795  /* NB: as we do not want to use a mutex, the function can be wrong
796  * here */
797  p_pool->producer_id = producer_id;
798  break;
799 
802  p_pool->producer_id = producer_id;
803  break;
804 
805  default:
806  abt_errno = ABT_ERR_INV_POOL_ACCESS;
807  ABTI_CHECK_ERROR(abt_errno);
808  }
809 
810 fn_exit:
811  return abt_errno;
812 
813 fn_fail:
814  HANDLE_ERROR_FUNC_WITH_CODE(abt_errno);
815  goto fn_exit;
816 }
817 #endif
818 
819 /* Check if a pool accept migrations or not. When the producer of the
820  * destination pool is ES private, we have to ensure that we are on the right
821  * ES */
822 int ABTI_pool_accept_migration(ABTI_pool *p_pool, ABTI_pool *source)
823 {
824 #if !defined(ABT_CONFIG_DISABLE_POOL_PRODUCER_CHECK) && \
825  !defined(ABT_CONFIG_DISABLE_POOL_CONSUMER_CHECK)
826  switch (p_pool->access) {
827  /* Need producer in the same ES */
831  if (p_pool->consumer_id == source->producer_id)
832  return ABT_TRUE;
833  return ABT_FALSE;
834 
837  return ABT_TRUE;
838  default:
839  return ABT_FALSE;
840  }
841 #else
842  return ABT_TRUE;
843 #endif
844 }
845 
846 static ABTD_atomic_uint64 g_pool_id = ABTD_ATOMIC_UINT64_STATIC_INITIALIZER(0);
847 void ABTI_pool_reset_id(void)
848 {
849  ABTD_atomic_release_store_uint64(&g_pool_id, 0);
850 }
851 
852 /*****************************************************************************/
853 /* Internal static functions */
854 /*****************************************************************************/
855 
856 static inline uint64_t ABTI_pool_get_new_id(void)
857 {
858  return (uint64_t)ABTD_atomic_fetch_add_uint64(&g_pool_id, 1);
859 }
static ABTD_atomic_uint64 g_pool_id
Definition: pool.c:846
struct ABT_unit_opaque * ABT_unit
Definition: abt.h:275
int ABT_pool_pop(ABT_pool pool, ABT_unit *p_unit)
Pop a unit from the target pool.
Definition: pool.c:203
ABT_unit_get_task_fn u_get_task
Definition: abt.h:420
#define ABT_POOL_NULL
Definition: abt.h:341
#define ABT_ERR_INV_POOL_ACCESS
Definition: abt.h:78
ABT_pool_init_fn p_init
Definition: abt.h:427
struct ABT_sched_opaque * ABT_sched
Definition: abt.h:257
char * ABTU_get_indent_str(int indent)
Definition: util.c:12
int ABT_pool_get_size(ABT_pool pool, size_t *size)
Return the size of a pool.
Definition: pool.c:177
#define ABT_ERR_INV_POOL
Definition: abt.h:76
#define ABT_UNIT_NULL
Definition: abt.h:343
static void * ABTU_malloc(size_t size)
Definition: abtu.h:39
int ABT_bool
Definition: abt.h:309
ABT_unit_get_thread_fn u_get_thread
Definition: abt.h:419
ABT_pool_pop_fn p_pop
Definition: abt.h:430
#define ABT_ERR_SCHED
Definition: abt.h:96
ABT_pool_access access
Definition: abt.h:415
struct ABT_pool_opaque * ABT_pool
Definition: abt.h:267
ABT_unit_is_in_pool_fn u_is_in_pool
Definition: abt.h:421
ABT_pool_push_fn p_push
Definition: abt.h:429
int ABT_pool_get_data(ABT_pool pool, void **data)
Retrieve the specific data of the target user-defined pool.
Definition: pool.c:398
#define ABT_FALSE
Definition: abt.h:224
int ABT_pool_get_id(ABT_pool pool, int *id)
Get the ID of the target pool.
Definition: pool.c:523
#define HANDLE_ERROR_FUNC_WITH_CODE(n)
Definition: abti_error.h:241
int ABT_pool_set_data(ABT_pool pool, void *data)
Set the specific data of the target user-defined pool.
Definition: pool.c:369
ABT_pool_free_fn p_free
Definition: abt.h:433
#define ABT_ERR_INV_POOL_KIND
Definition: abt.h:77
int ABT_pool_free(ABT_pool *pool)
Free the given pool, and modify its value to ABT_POOL_NULL.
Definition: pool.c:89
#define ABT_SUCCESS
Definition: abt.h:64
ABT_unit_free_fn u_free
Definition: abt.h:424
ABT_pool_access
Definition: abt.h:162
#define LOG_EVENT(fmt,...)
Definition: abti_log.h:60
#define ABT_TRUE
Definition: abt.h:223
int ABT_pool_remove(ABT_pool pool, ABT_unit unit)
Remove a specified unit from the target pool.
Definition: pool.c:294
int ABT_pool_push(ABT_pool pool, ABT_unit unit)
Push a unit to the target pool.
Definition: pool.c:258
int ABT_pool_add_sched(ABT_pool pool, ABT_sched sched)
Push a scheduler to a pool.
Definition: pool.c:433
ABT_pool_kind
Definition: abt.h:157
ABT_unit_create_from_task_fn u_create_from_task
Definition: abt.h:423
int ABT_pool_get_access(ABT_pool pool, ABT_pool_access *access)
Get the access type of target pool.
Definition: pool.c:119
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.
Definition: pool.c:63
#define ABT_ERR_FEATURE_NA
Definition: abt.h:115
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.
Definition: pool.c:30
ABT_unit_create_from_thread_fn u_create_from_thread
Definition: abt.h:422
#define ABT_ERR_UNIT
Definition: abt.h:99
#define ABT_ERR_INV_SCHED
Definition: abt.h:71
struct ABT_pool_config_opaque * ABT_pool_config
Definition: abt.h:269
ABT_unit_get_type_fn u_get_type
Definition: abt.h:418
ABT_pool_get_size_fn p_get_size
Definition: abt.h:428
#define ABT_ERR_INV_XSTREAM
Definition: abt.h:68
int ABT_pool_get_total_size(ABT_pool pool, size_t *size)
Return the total size of a pool.
Definition: pool.c:148
static void ABTU_free(void *ptr)
Definition: abtu.h:32
ABT_pool_remove_fn p_remove
Definition: abt.h:432
#define ABT_POOL_CONFIG_NULL
Definition: abt.h:342
ABT_pool_print_all_fn p_print_all
Definition: abt.h:434
#define ABT_ERR_POOL
Definition: abt.h:98
ABT_pool_pop_timedwait_fn p_pop_timedwait
Definition: abt.h:431
int ABT_pool_pop_timedwait(ABT_pool pool, ABT_unit *p_unit, double abstime_secs)
Definition: pool.c:226
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.
Definition: pool.c:336