22     ABTD_ATOMIC_UINT32_STATIC_INITIALIZER(0);
    63     ABTI_thread_reset_id();
    65     ABTI_sched_reset_id();
    71                                      sizeof(ABTI_xstream *));
    78     ABTI_local *p_local = NULL;
    79     abt_errno = ABTI_local_init(&p_local);
    80     ABTI_CHECK_ERROR_MSG(abt_errno, 
"ABTI_local_init");
    83     ABTI_xstream *p_newxstream;
    84     abt_errno = ABTI_xstream_create_primary(&p_local, &p_newxstream);
    85     ABTI_CHECK_ERROR_MSG(abt_errno, 
"ABTI_xstream_create_primary");
    86     p_local->p_xstream = p_newxstream;
    89     ABTI_thread *p_main_thread;
    90     abt_errno = ABTI_thread_create_main(p_local, p_newxstream, &p_main_thread);
    92     ABTD_atomic_relaxed_store_int(&p_main_thread->state,
    94     p_main_thread->p_last_xstream = p_newxstream;
    95     ABTI_CHECK_ERROR_MSG(abt_errno, 
"ABTI_thread_create_main");
    97     p_local->p_thread = p_main_thread;
   101         ABTI_xstream_start_primary(&p_local, p_newxstream, p_main_thread);
   102     ABTI_CHECK_ERROR_MSG(abt_errno, 
"ABTI_xstream_start_primary");
   105         ABTI_info_print_config(stdout);
   138     ABTI_local *p_local = ABTI_local_get_local();
   156     ABTI_xstream *p_xstream = p_local->p_xstream;
   157     ABTI_CHECK_TRUE_MSG(p_xstream->type == ABTI_XSTREAM_TYPE_PRIMARY,
   159                         "ABT_finalize must be called by the primary ES.");
   161     ABTI_thread *p_thread = p_local->p_thread;
   162     ABTI_CHECK_TRUE_MSG(p_thread->type == ABTI_THREAD_TYPE_MAIN,
   164                         "ABT_finalize must be called by the primary ULT.");
   167     ABTI_xstream_set_request(p_xstream, ABTI_XSTREAM_REQ_JOIN);
   170     if (ABTD_atomic_acquire_load_int(&p_xstream->state) !=
   173         ABTI_thread_set_request(p_thread, ABTI_THREAD_REQ_ORPHAN);
   175         LOG_EVENT(
"[U%" PRIu64 
":E%d] yield to scheduler\n",
   176                   ABTI_thread_get_id(p_thread), p_thread->p_last_xstream->rank);
   179         ABTI_sched *p_sched =
   180             ABTI_xstream_get_top_sched(p_thread->p_last_xstream);
   181         ABTI_thread_context_switch_thread_to_sched(&p_local, p_thread, p_sched);
   184         LOG_EVENT(
"[U%" PRIu64 
":E%d] resume after yield\n",
   185                   ABTI_thread_get_id(p_thread), p_thread->p_last_xstream->rank);
   189     ABTI_thread_free_main(p_local, p_thread);
   190     p_local->p_thread = NULL;
   193     abt_errno = ABTI_xstream_free(p_local, p_xstream);
   194     p_local->p_xstream = NULL;
   195     ABTI_CHECK_ERROR(abt_errno);
   198     abt_errno = ABTI_local_finalize(&p_local);
   199     ABTI_CHECK_ERROR(abt_errno);
   209         ABTD_affinity_finalize();
   253 void ABTI_global_update_max_xstreams(
int new_size)
   257     if (new_size != 0 && new_size < gp_ABTI_global->max_xstreams)
   262     static int max_xstreams_warning_once = 0;
   263     if (max_xstreams_warning_once == 0) {
   271         char *warning_message = (
char *)malloc(
sizeof(
char) * 1024);
   272         snprintf(warning_message, 1024,
   273                  "Warning: the number of execution streams exceeds "   274                  "ABT_MAX_NUM_XSTREAMS (=%d), which may cause an unexpected "   278         free(warning_message);
   279         max_xstreams_warning_once = 1;
   283     new_size = (new_size > 0) ? new_size : cur_size * 2;
   287                                       cur_size * 
sizeof(ABTI_xstream *),
   288                                       new_size * 
sizeof(ABTI_xstream *));
 int ABT_init(int argc, char **argv)
Initialize the Argobots execution environment. 
 
static ABTD_atomic_uint32 g_ABTI_initialized
 
ABTI_global * gp_ABTI_global
 
static ABTI_spinlock g_ABTI_init_lock
 
#define ABT_ERR_INV_THREAD
 
static void * ABTU_malloc(size_t size)
 
#define HANDLE_WARNING(msg)
 
#define HANDLE_ERROR_FUNC_WITH_CODE(n)
 
static uint32_t g_ABTI_num_inits
 
static void * ABTU_realloc(void *ptr, size_t old_size, size_t new_size)
 
int ABT_finalize(void)
Terminate the Argobots execution environment. 
 
#define LOG_EVENT(fmt,...)
 
#define ABT_ERR_UNINITIALIZED
 
#define ABT_ERR_INV_XSTREAM
 
static void ABTU_free(void *ptr)
 
int ABT_initialized(void)
Check whether ABT_init() has been called. 
 
static void * ABTU_calloc(size_t num, size_t size)