Beispiel #1
0
int
main(int argc, char *argv[])
{
    hg_class_t *hg_class = NULL;
    hg_context_t *context = NULL;
    unsigned int number_of_peers;
    hg_return_t ret = HG_SUCCESS;

    hg_class = HG_Test_server_init(argc, argv, &na_addr_table,
            NULL, &number_of_peers, &context);

    do {
        unsigned int actual_count = 0;

        do {
            ret = HG_Trigger(hg_class, context, 0, 1, &actual_count);
        } while ((ret == HG_SUCCESS) && actual_count);

        if (hg_atomic_cas32(&hg_test_finalizing_count_g, 1, 1))
            break;

        ret = HG_Progress(hg_class, context, HG_MAX_IDLE_TIME);
    } while (ret == HG_SUCCESS);

    printf("# Finalizing...\n");
    HG_Test_finalize(hg_class);

    return EXIT_SUCCESS;
}
Beispiel #2
0
/*---------------------------------------------------------------------------*/
static int
hg_bulk_transfer_cb(const struct na_cb_info *callback_info)
{
    struct hg_bulk_op_id *hg_bulk_op_id =
        (struct hg_bulk_op_id *) callback_info->arg;
    na_return_t na_ret = NA_SUCCESS;
    int ret = 0;

    if (callback_info->ret == NA_CANCELED) {
        /* If canceled, mark handle as canceled */
        hg_atomic_cas32(&hg_bulk_op_id->canceled, 0, 1);
    } else if (callback_info->ret != NA_SUCCESS) {
        HG_LOG_ERROR("Error in NA callback: %s",
            NA_Error_to_string(callback_info->ret));
        na_ret = NA_PROTOCOL_ERROR;
        goto done;
    }

    /* When all NA transfers that correspond to bulk operation complete
     * add HG user callback to completion queue
     */
    if ((unsigned int) hg_atomic_incr32(&hg_bulk_op_id->op_completed_count)
        == hg_bulk_op_id->op_count) {
        hg_bulk_complete(hg_bulk_op_id);
        ret++;
    }

done:
    (void) na_ret;
    return ret;
}
Beispiel #3
0
/*---------------------------------------------------------------------------*/
hg_return_t
HG_Bulk_cancel(hg_op_id_t op_id)
{
    struct hg_bulk_op_id *hg_bulk_op_id = (struct hg_bulk_op_id *) op_id;
    hg_return_t ret = HG_SUCCESS;

    if (!hg_bulk_op_id) {
        HG_LOG_ERROR("NULL HG bulk operation ID");
        ret = HG_INVALID_PARAM;
        goto done;
    }

    if (HG_UTIL_TRUE != hg_atomic_cas32(&hg_bulk_op_id->completed, 1, 0)) {
        unsigned int i = 0;

        /* Cancel all NA operations issued */
        for (i = 0; i < hg_bulk_op_id->op_count; i++) {
            na_return_t na_ret;

            /* Cancel NA operation */
            na_ret = NA_Cancel(HG_Core_class_get_na(hg_bulk_op_id->hg_class),
                HG_Core_context_get_na(hg_bulk_op_id->context),
                hg_bulk_op_id->na_op_ids[i]);
            if (na_ret != NA_SUCCESS) {
                HG_LOG_ERROR("Could not cancel op id");
                ret = HG_NA_ERROR;
                goto done;
            }
        }
    }

done:
    return ret;
}
Beispiel #4
0
static HG_THREAD_RETURN_TYPE
thread_cb_cas32(void *arg)
{
    hg_thread_ret_t thread_ret = (hg_thread_ret_t) 0;
    hg_atomic_int32_t *atomic_int32 = (hg_atomic_int32_t *) arg;

    hg_atomic_incr32(atomic_int32);

    if (HG_UTIL_TRUE == hg_atomic_cas32(atomic_int32, 2, 99)) {
        hg_atomic_incr32(atomic_int32);
    }

    hg_thread_exit(thread_ret);
    return thread_ret;
}