Skip to content
Snippets Groups Projects
Verified Commit bc64a248 authored by raphael.bach's avatar raphael.bach
Browse files

Add `fmpi_task_run_async()`

- Rename `fmpi_task_run()` to `fmpi_task_run_sync()`
- Rename `FMPI_TASK_FUTHARK_SYNC()` to `FMPI_TASK_FUTHARK()`
- Remove `FMPI_TASK_FUTHARK_ASYNC()`
parent ad5ef1b2
Branches
No related tags found
No related merge requests found
......@@ -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
==============================================================================*/
......
......@@ -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, ...) \
......
......@@ -72,9 +72,20 @@ 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);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment