/* This function is the second callback function for the event, * ABT_EVENT_ADD_XSTREAM. After all the first callback functions registered * for ABT_EVENT_ADD_XSTREAM return ABT_TRUE for the target ES, the Argobots * runtime will call this second callback function to notify that we have * reached an agreement. For now, the creation of the target ES needs to be * happened in this callback function. * * Parameters: * [in] user_arg: user-provided argument * [in] abt_arg : runtime-provided argument, the rank of ES to create */ static ABT_bool rt1_act_add_xstream(void *user_arg, void *abt_arg) { rt1_data_t *my_data = (rt1_data_t *)user_arg; int tar_rank = (int)(intptr_t)abt_arg; ABT_bool result = ABT_TRUE; ABT_pool pool; ABT_xstream tar_xstream; int rank, ret; /* Create a new ES */ if (tar_rank == ABT_XSTREAM_ANY_RANK) { ret = ABT_xstream_create(ABT_SCHED_NULL, &tar_xstream); if (ret != ABT_SUCCESS) { result = ABT_FALSE; goto fn_exit; } ABT_xstream_get_rank(tar_xstream, &rank); } else { rank = tar_rank; ret = ABT_xstream_create_with_rank(ABT_SCHED_NULL, rank, &tar_xstream); if (ret != ABT_SUCCESS) { printf("ES%d: failed to create\n", rank); result = ABT_FALSE; goto fn_exit; } } ABT_mutex_spinlock(my_data->mutex); assert(rank < my_data->max_xstreams && my_data->xstreams[rank] == ABT_XSTREAM_NULL); my_data->xstreams[rank] = tar_xstream; my_data->num_xstreams++; g_xstreams[rank] = tar_xstream; ABT_mutex_unlock(my_data->mutex); ABT_xstream_get_main_pools(tar_xstream, 1, &pool); ABT_thread_create(pool, rt1_launcher, (void *)(intptr_t)rank, ABT_THREAD_ATTR_NULL, NULL); printf("ES%d: created\n", rank); fn_exit: return result; }
GLT_func_prefix void glt_mutex_spinlock(GLT_mutex mutex) { CHECK(ABT_mutex_spinlock(mutex),ABT_SUCCESS); }