diff --git a/include/fmpi_task.h b/include/fmpi_task.h index 7f835302ebff5f36451ea6d4101e4fd0995889fe..eb9d64a10be00ebf2d2c19c1d7077753a62de0c7 100644 --- a/include/fmpi_task.h +++ b/include/fmpi_task.h @@ -80,7 +80,7 @@ typedef struct fmpi_task_args { * TODO * } */ -typedef void (* fmpi_task_func)( +typedef int (* fmpi_task_func)( const struct fmpi_ctx * ctx, const struct fmpi_task_args * args ); /*------------------------------------------------------------------------------ @@ -132,7 +132,9 @@ struct fmpi_task fmpi_task_register( * @param[in] ctx : A pointer to a fmpi_ctx. * @param[in] task : A pointer to a fmpi_task. * - * @return Nothing. + * @return + * - @success: `0`. + * - @failure: An error code different from `0`. * * @warning * - \b [UB] \p{ctx} must not be `NULL`. @@ -142,7 +144,7 @@ struct fmpi_task fmpi_task_register( * TODO * } */ -void fmpi_task_run_sync(const struct fmpi_ctx * ctx, const struct fmpi_task * task); +int fmpi_task_run_sync(const struct fmpi_ctx * ctx, const struct fmpi_task * task); /*------------------------------------------------------------------------------ fmpi_task_run_async() ------------------------------------------------------------------------------*/ @@ -152,7 +154,9 @@ void fmpi_task_run_sync(const struct fmpi_ctx * ctx, const struct fmpi_task * ta * @param[in] ctx : A pointer to a fmpi_ctx. * @param[in] task : A pointer to a fmpi_task. * - * @return Nothing. + * @return + * - @success: `0`. + * - @failure: An error code different from `0`. * * @warning * - \b [UB] \p{ctx} must not be `NULL`. @@ -162,7 +166,7 @@ void fmpi_task_run_sync(const struct fmpi_ctx * ctx, const struct fmpi_task * ta * TODO * } */ -void fmpi_task_run_async(const struct fmpi_ctx * ctx, const struct fmpi_task * task); +int fmpi_task_run_async(const struct fmpi_ctx * ctx, const struct fmpi_task * task); /*============================================================================== MACRO ==============================================================================*/ diff --git a/include/internal/generic/fmpi_task_generic.h b/include/internal/generic/fmpi_task_generic.h index d3173d580eb725392ba1b9bc44ad7b45ef3e62be..f71ae8dbf4c5b830cfdfd960a155e4e6483f5773 100644 --- a/include/internal/generic/fmpi_task_generic.h +++ b/include/internal/generic/fmpi_task_generic.h @@ -35,14 +35,14 @@ #define FMPI_PRIV_TASK_CONCAT_(A, B) A##B #define FMPI_TASK_DEFINITION(FUNC, N) \ -void FUNC##_##N(const struct fmpi_ctx * ctx, const struct fmpi_task_args * args); \ -void FUNC##_##N( \ +int FUNC##_##N(const struct fmpi_ctx * ctx, const struct fmpi_task_args * args); \ +int FUNC##_##N( \ const struct fmpi_ctx * const ctx, const struct fmpi_task_args * const args \ ){ \ assert(ctx != NULL); \ assert(args != NULL); \ assert(args->cnt == N); \ - FMPI_TASK_FUNC_##N(FUNC, ctx->fut->ctx, args); \ + return FMPI_TASK_FUNC_##N(FUNC, ctx->fut->ctx, args); \ } #define FMPI_TASK_REGISTER_IMPL(ctx, func, stencil, ...) \ diff --git a/src/fmpi_task.c b/src/fmpi_task.c index 58bc6079ae6d94d555d458f89af45f84d1f98ea5..2a245f5e64a3dfa487a76afcbb318941e1a915bf 100644 --- a/src/fmpi_task.c +++ b/src/fmpi_task.c @@ -25,6 +25,7 @@ #include "fmpi_task.h" // C Standard Library #include <assert.h> +#include <stdbool.h> #include <stddef.h> // NULL, size_t // Internal #include "fmpi_domain.h" @@ -74,21 +75,25 @@ struct fmpi_task fmpi_task_register( /*------------------------------------------------------------------------------ fmpi_task_run_sync() ------------------------------------------------------------------------------*/ -void fmpi_task_run_sync( +int fmpi_task_run_sync( const struct fmpi_ctx * const ctx, const struct fmpi_task * const task ){ assert(ctx != NULL); assert(task != NULL); - task->func(ctx, &task->args); + const int err_id = task->func(ctx, &task->args); fmpi_futhark_sync(ctx->fut); + if(fmpi_futhark_check_error(ctx->fut, "") == true) { + return -1; + } + return err_id; } /*------------------------------------------------------------------------------ fmpi_task_run_async() ------------------------------------------------------------------------------*/ -void fmpi_task_run_async( +int fmpi_task_run_async( const struct fmpi_ctx * const ctx, const struct fmpi_task * const task ){ assert(ctx != NULL); assert(task != NULL); - task->func(ctx, &task->args); + return task->func(ctx, &task->args); }