コード例 #1
0
ファイル: fib.c プロジェクト: habanero-rice/hclib
static FibDDtArgs *setup_fib_ddt_args(int n) {
    FibDDtArgs *args = malloc(sizeof(*args));
    args->n = n;
    args->res = hclib_promise_create();
    args->subres[2] = NULL;
    return args;
}
コード例 #2
0
hclib_promise_t *hclib_async_memset(place_t *pl, void *ptr, int val,
                                    size_t nbytes, hclib_future_t **future_list, void *user_arg) {
    hclib_promise_t *promise = hclib_promise_create();
    hclib_async_memset_helper(pl, ptr, val, nbytes, future_list, user_arg,
                              promise);
    return promise;
}
コード例 #3
0
hclib_promise_t *hclib_async_copy(place_t *dst_pl, void *dst, place_t *src_pl,
                                  void *src, size_t nbytes, hclib_future_t **future_list,
                                  void *user_arg) {
    hclib_promise_t *promise = hclib_promise_create();
    hclib_async_copy_helper(dst_pl, dst, src_pl, src, nbytes, future_list,
                            user_arg, promise);
    return promise;
}
コード例 #4
0
ファイル: hclib-runtime.c プロジェクト: habanero-rice/hclib
void help_finish(finish_t *finish) {
    /*
     * Creating a new context to switch to is necessary here because the
     * current context needs to become the continuation for this finish
     * (which will be switched back to by _finish_ctx_resume, for which an
     * async is created inside _help_finish_ctx).
     */

    if (finish->counter == 1) {
        /*
         * Quick optimization: if no asyncs remain in this finish scope, just
         * return. finish counter will be 1 here because we haven't checked out
         * the main thread (this thread) yet.
         */
        return;
    }

    hclib_worker_state *ws = CURRENT_WS_INTERNAL;
    hclib_task_t *need_to_swap_ctx = NULL;
    while (finish->counter > 1 && need_to_swap_ctx == NULL) {
        need_to_swap_ctx = find_and_run_task(ws, 0, &(finish->counter), 1,
                finish);
    }

    if (need_to_swap_ctx) {
        // create finish event
        hclib_promise_t *finish_promise = hclib_promise_create();
        finish->finish_dep = &finish_promise->future;
        LiteCtx *currentCtx = get_curr_lite_ctx();
        HASSERT(currentCtx);
        LiteCtx *newCtx = LiteCtx_create(_help_finish_ctx);
        newCtx->arg1 = finish;
        newCtx->arg2 = need_to_swap_ctx;
#ifdef HCLIB_STATS
        worker_stats[CURRENT_WS_INTERNAL->id].count_ctx_creates++;
#endif

#ifdef VERBOSE
        printf("help_finish: newCtx = %p, newCtx->arg = %p\n", newCtx, newCtx->arg);
#endif
        ctx_swap(currentCtx, newCtx, __func__);
        /*
         * destroy the context that resumed this one since it's now defunct
         * (there are no other handles to it, and it will never be resumed)
         */
        LiteCtx_destroy(currentCtx->prev);
        hclib_promise_free(finish_promise);

        HASSERT(finish->counter == 0);
    } else {
        HASSERT(finish->counter == 1);
    }
}
コード例 #5
0
ファイル: hclib-runtime.c プロジェクト: habanero-rice/hclib
hclib_future_t *hclib_end_finish_nonblocking() {
    hclib_promise_t *event = hclib_promise_create();
    hclib_end_finish_nonblocking_helper(event);
    return &event->future;
}
コード例 #6
0
ファイル: api.c プロジェクト: openshmem-org/openshmem-async
shmem_promise_t *shmem_malloc_promise() {
  return ((shmem_promise_t *) hclib_promise_create());
}