diff --git a/include/fmpi_task.h b/include/fmpi_task.h index 39d9f887ad93c6c691999707276f531f466d010d..7f835302ebff5f36451ea6d4101e4fd0995889fe 100644 --- a/include/fmpi_task.h +++ b/include/fmpi_task.h @@ -124,10 +124,10 @@ struct fmpi_task fmpi_task_register( struct fmpi_stencil stencil, const struct fmpi_task_args * args ); /*------------------------------------------------------------------------------ - fmpi_task_run() + fmpi_task_run_sync() ------------------------------------------------------------------------------*/ /** - * TODO + * Runs a task synchronously. * * @param[in] ctx : A pointer to a fmpi_ctx. * @param[in] task : A pointer to a fmpi_task. @@ -142,43 +142,43 @@ struct fmpi_task fmpi_task_register( * TODO * } */ -void fmpi_task_run(const struct fmpi_ctx * ctx, const struct fmpi_task * task); -/*============================================================================== - MACRO -==============================================================================*/ +void fmpi_task_run_sync(const struct fmpi_ctx * ctx, const struct fmpi_task * task); /*------------------------------------------------------------------------------ - FMPI_TASK_REGISTER() -------------------------------------------------------------------------------*/ -#define FMPI_TASK_REGISTER(ctx, func, stencil, ...) \ - FMPI_TASK_REGISTER_IMPL(ctx, func, stencil, __VA_ARGS__) -/*------------------------------------------------------------------------------ - FMPI_TASK_FUTHARK_SYNC() + fmpi_task_run_async() ------------------------------------------------------------------------------*/ /** - * Declares and defines a task running a `futhark` function synchronously. + * Runs a task asynchronously. * - * @param[in] func : TODO - * @param[in] arg_cnt : TODO + * @param[in] ctx : A pointer to a fmpi_ctx. + * @param[in] task : A pointer to a fmpi_task. * * @return Nothing. * * @warning - * - \b [UB] \p{func} must not be `NULL`. + * - \b [UB] \p{ctx} must not be `NULL`. + * - \b [UB] \p{task} must not be `NULL`. * * @example{ - * FMPI_TASK_FUTHARK_SYNC(array_sum, 1) + * TODO * } */ -#define FMPI_TASK_FUTHARK_SYNC(func, arg_cnt) \ - FMPI_TASK_DEFINITION(func, arg_cnt) +void fmpi_task_run_async(const struct fmpi_ctx * ctx, const struct fmpi_task * task); +/*============================================================================== + MACRO +==============================================================================*/ +/*------------------------------------------------------------------------------ + FMPI_TASK_REGISTER() +------------------------------------------------------------------------------*/ +#define FMPI_TASK_REGISTER(ctx, func, stencil, ...) \ + FMPI_TASK_REGISTER_IMPL(ctx, func, stencil, __VA_ARGS__) /*------------------------------------------------------------------------------ - FMPI_TASK_FUTHARK_ASYNC() + FMPI_TASK_FUTHARK() ------------------------------------------------------------------------------*/ /** - * Declares and defines a task running a `futhark` function asynchronously. + * Declares and defines a task running a `futhark` function. * - * @param[in] task_name : The name to give to this task. - * @param[in] func : A pointer to a futhark function. + * @param[in] func : TODO + * @param[in] arg_cnt : TODO * * @return Nothing. * @@ -186,16 +186,11 @@ void fmpi_task_run(const struct fmpi_ctx * ctx, const struct fmpi_task * task); * - \b [UB] \p{func} must not be `NULL`. * * @example{ - * FMPI_TASK_FUTHARK_ASYNC(fut_array_sum, futhark_entry_array_sum) + * FMPI_TASK_FUTHARK(array_sum, 1) * } */ -#define FMPI_TASK_FUTHARK_ASYNC(task_name, func) \ -void task_name(const struct fmpi_ctx * ctx, const struct fmpi_task_args * args); \ -void task_name(const struct fmpi_ctx * const ctx, const struct fmpi_task_args * const args) { \ - assert(ctx != NULL); \ - assert(args != NULL); \ - func(ctx->fut->ctx, args->out.start, args->in[0].start); \ -} +#define FMPI_TASK_FUTHARK(func, arg_cnt) \ + FMPI_TASK_DEFINITION(func, arg_cnt) /*============================================================================== GUARD ==============================================================================*/ diff --git a/include/internal/generic/fmpi_task_generic.h b/include/internal/generic/fmpi_task_generic.h index dee037add182b4d4b8aef69ecb673bafcd485546..d3173d580eb725392ba1b9bc44ad7b45ef3e62be 100644 --- a/include/internal/generic/fmpi_task_generic.h +++ b/include/internal/generic/fmpi_task_generic.h @@ -43,7 +43,6 @@ void FUNC##_##N( \ assert(args != NULL); \ assert(args->cnt == N); \ FMPI_TASK_FUNC_##N(FUNC, ctx->fut->ctx, args); \ - fmpi_futhark_sync(ctx->fut); \ } #define FMPI_TASK_REGISTER_IMPL(ctx, func, stencil, ...) \ diff --git a/src/fmpi_task.c b/src/fmpi_task.c index f3554e8aedb014125af42bec20545841399cefe0..58bc6079ae6d94d555d458f89af45f84d1f98ea5 100644 --- a/src/fmpi_task.c +++ b/src/fmpi_task.c @@ -72,11 +72,22 @@ struct fmpi_task fmpi_task_register( return task; } /*------------------------------------------------------------------------------ - fmpi_task_run() + fmpi_task_run_sync() ------------------------------------------------------------------------------*/ -void fmpi_task_run( +void 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); + fmpi_futhark_sync(ctx->fut); +} +/*------------------------------------------------------------------------------ + fmpi_task_run_async() +------------------------------------------------------------------------------*/ +void 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);