Skip to content
Snippets Groups Projects
Select Git revision
  • 13474a472d06f1e0544e59b3b2b1f18d2b5e8894
  • main default protected
  • add_export_route
  • add_route_assignments
  • add_route_user
  • 4.1.0-dev
  • Pre-alpha
  • 4.0.1
  • Latest
  • 4.0.0
  • 3.5.0
  • 3.4.2
  • 3.4.1
  • 3.3.0
  • 3.2.3
  • 3.2.2
  • 3.2.0
  • 3.1.2
  • 3.1.1
  • 3.1.0
  • 3.0.1
  • 3.0.0
  • 2.2.0
  • 2.1.0
  • 2.0.0
25 results

UserCreateResumeCommand.ts

Blame
  • Forked from Dojo Project (HES-SO) / Projects / UI / DojoCLI
    Source project has a limited visibility.
    fmpi_core.c 5.46 KiB
    // SPDX-License-Identifier: 0BSD
    /*!
     * @file
     * @license{
     * BSD Zero Clause License
     *
     * Copyright (c) 2022 by Raphael Bach
     *
     * Permission to use, copy, modify, and/or distribute this software for any
     * purpose with or without fee is hereby granted.
     *
     * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
     * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
     * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
     * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
     * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
     * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
     * PERFORMANCE OF THIS SOFTWARE.
     * }
     */
    /*==============================================================================
        INCLUDE
    ==============================================================================*/
    // Own header
    #include "fmpi_core.h"
    // C Standard Library
    #include <assert.h>
    #include <stdio.h>  // fprintf()
    #include <stdlib.h> // NULL, abort()
    // Internal
    #include "fmpi_task.h"
    #include "internal/fmpi_ctx.h"
    #include "internal/fmpi_error.h"
    #include "internal/fmpi_futhark.h"
    #include "internal/fmpi_mpi.h"
    /*==============================================================================
        PUBLIC FUNCTION DEFINITION
    ==============================================================================*/
    /*------------------------------------------------------------------------------
        fmpi_init()
    ------------------------------------------------------------------------------*/
    struct fmpi_ctx * fmpi_init(int * const argc, char ** argv[])
    {
        struct fmpi_ctx * ctx = fmpi_ctx_create(argc, argv);
        if(ctx == NULL) {
            fprintf(stderr, "fmpi_ctx_create() failed!\n");
        }
        return ctx;
    }
    /*------------------------------------------------------------------------------
        fmpi_exit()
    ------------------------------------------------------------------------------*/
    int fmpi_exit(struct fmpi_ctx ** const ctx)
    {
        assert(ctx != NULL);
        assert(*ctx != NULL);
        const int err = fmpi_ctx_destroy(ctx);
        if(err != FMPI_SUCCESS) {
            fprintf(stderr, "fmpi_ctx_destroy() failed!\n");
        }
        return err;
    }
    /*------------------------------------------------------------------------------
        fmpi_abort()
    ------------------------------------------------------------------------------*/
    _Noreturn void fmpi_abort(const struct fmpi_ctx * const ctx)
    {
        assert(ctx != NULL);
        fmpi_mpi_abort(ctx->mpi);
        abort();
    }
    /*------------------------------------------------------------------------------
        fmpi_is_root()
    ------------------------------------------------------------------------------*/
    _Bool fmpi_is_root(const struct fmpi_ctx * const ctx)
    {
        assert(ctx != NULL);
        return fmpi_mpi_is_root(ctx->mpi);
    }
    /*------------------------------------------------------------------------------
        fmpi_world_rank()
    ------------------------------------------------------------------------------*/
    int fmpi_world_rank(const struct fmpi_ctx * const ctx)
    {
        assert(ctx != NULL);
        const int rank = fmpi_mpi_world_rank(ctx->mpi);
        if(rank < FMPI_SUCCESS) {
            FMPI_RAISE_ERROR(ctx->err_handler, "FMPI", "fmpi_mpi_world_rank() failed!");
        }
        return rank;
    }
    /*------------------------------------------------------------------------------
        fmpi_world_barrier()
    ------------------------------------------------------------------------------*/
    int fmpi_world_barrier(const struct fmpi_ctx * const ctx)
    {
        assert(ctx != NULL);
        const int err = fmpi_mpi_world_barrier(ctx->mpi);
        if(err != FMPI_SUCCESS) {
            FMPI_RAISE_ERROR(ctx->err_handler, "FMPI", "fmpi_mpi_world_barrier() failed!");
        }
        return err;
    }
    /*------------------------------------------------------------------------------
        fmpi_run_task()
    ------------------------------------------------------------------------------*/
    int fmpi_run_task(
        const struct fmpi_ctx * const ctx, struct fmpi_task * const task
    ){
        assert(ctx != NULL);
        assert(task != NULL);
        if(task->type == FMPI_TASK_TYPE_SYNC) {
            const int err = fmpi_task_run_sync(ctx, task);
            if(err != FMPI_SUCCESS) {
                FMPI_RAISE_ERROR(ctx->err_handler, "FMPI", "fmpi_task_run_sync() failed!");
            }
            return err;
        }
        if(task->type == FMPI_TASK_TYPE_ASYNC) {
            const int err = fmpi_task_run_async(ctx, task);
            if(err != FMPI_SUCCESS) {
                FMPI_RAISE_ERROR(ctx->err_handler, "FMPI", "fmpi_task_run_async() failed!");
            }
            return err;
        }
        return FMPI_ERROR;
    }
    /*------------------------------------------------------------------------------
        fmpi_sync()
    ------------------------------------------------------------------------------*/
    int fmpi_sync(const struct fmpi_ctx * const ctx)
    {
        assert(ctx != NULL);
        const int err = fmpi_futhark_sync(ctx->fut);
        if(err != FMPI_SUCCESS) {
            FMPI_RAISE_ERROR(ctx->err_handler, "FMPI", "fmpi_futhark_sync() failed!");
        }
        return err;
    }
    /*------------------------------------------------------------------------------
        fmpi_world_size()
    ------------------------------------------------------------------------------*/
    int fmpi_world_size(const struct fmpi_ctx * const ctx)
    {
        assert(ctx != NULL);
        const int size = fmpi_mpi_world_size(ctx->mpi);
        if(size < FMPI_SUCCESS) {
            FMPI_RAISE_ERROR(ctx->err_handler, "FMPI", "fmpi_mpi_world_size() failed!");
        }
        return size;
    }