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

Update error handling in `fmpi_core` module

parent eb7d315f
No related branches found
No related tags found
No related merge requests found
......@@ -53,7 +53,12 @@ struct fmpi_ctx * fmpi_init(int * const argc, char ** argv[])
int fmpi_exit(struct fmpi_ctx ** const ctx)
{
assert(ctx != NULL);
return fmpi_ctx_destroy(ctx);
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()
......@@ -79,7 +84,7 @@ int fmpi_world_rank(const struct fmpi_ctx * const ctx)
{
assert(ctx != NULL);
const int rank = fmpi_mpi_world_rank(ctx->mpi);
if(rank < 0) {
if(rank < FMPI_SUCCESS) {
FMPI_RAISE_ERROR(ctx->err_handler, "FMPI", "fmpi_mpi_world_rank() failed!");
}
return rank;
......@@ -90,11 +95,11 @@ int fmpi_world_rank(const struct fmpi_ctx * const ctx)
int fmpi_world_barrier(const struct fmpi_ctx * const ctx)
{
assert(ctx != NULL);
const int err_id = fmpi_mpi_world_barrier(ctx->mpi);
if(err_id == -1) {
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_id;
return err;
}
/*------------------------------------------------------------------------------
fmpi_run_task()
......@@ -105,9 +110,20 @@ int fmpi_run_task(
assert(ctx != NULL);
assert(task != NULL);
if(task->type == FMPI_TASK_TYPE_SYNC) {
return fmpi_task_run_sync(ctx, task);
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 fmpi_task_run_async(ctx, task);
return err;
}
return FMPI_ERROR;
}
/*------------------------------------------------------------------------------
fmpi_sync()
......@@ -115,5 +131,9 @@ int fmpi_run_task(
int fmpi_sync(const struct fmpi_ctx * const ctx)
{
assert(ctx != NULL);
return fmpi_futhark_sync(ctx->fut);
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;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment