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

Make `fmpi_task_run_{sync, async}()` return an error code

parent bc64a248
No related branches found
No related tags found
No related merge requests found
......@@ -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
==============================================================================*/
......
......@@ -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, ...) \
......
......@@ -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);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment