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

Update error handling in `fmpi_ctx` module

parent 2bc8471b
No related branches found
No related tags found
No related merge requests found
...@@ -74,8 +74,10 @@ struct fmpi_ctx * fmpi_ctx_create(int * const argc, char ** argv[]) ...@@ -74,8 +74,10 @@ struct fmpi_ctx * fmpi_ctx_create(int * const argc, char ** argv[])
.user_data = ctx .user_data = ctx
}); });
if(ctx->mpi == NULL) { if(ctx->mpi == NULL) {
FMPI_RAISE_ERROR(ctx->err_handler, "FMPI", "fmpi_mpi_init() failed!"); FMPI_RAISE_ERROR(err_handler, "FMPI", "fmpi_mpi_init() failed!");
fmpi_ctx_destroy(&ctx); if(fmpi_ctx_destroy(&ctx) != FMPI_SUCCESS) {
FMPI_RAISE_ERROR(err_handler, "FMPI", "fmpi_ctx_destroy() failed!");
}
return NULL; return NULL;
} }
// Futhark Initialization // Futhark Initialization
...@@ -84,8 +86,11 @@ struct fmpi_ctx * fmpi_ctx_create(int * const argc, char ** argv[]) ...@@ -84,8 +86,11 @@ struct fmpi_ctx * fmpi_ctx_create(int * const argc, char ** argv[])
.user_data = ctx .user_data = ctx
}); });
if(ctx->fut == NULL) { if(ctx->fut == NULL) {
FMPI_RAISE_ERROR(ctx->err_handler, "FMPI", "fmpi_futhark_init() failed!"); FMPI_RAISE_ERROR(err_handler, "FMPI", "fmpi_futhark_init() failed!");
fmpi_ctx_destroy(&ctx); if(fmpi_ctx_destroy(&ctx) != FMPI_SUCCESS) {
FMPI_RAISE_ERROR(err_handler, "FMPI", "fmpi_ctx_destroy() failed!");
}
return NULL;
} }
return ctx; return ctx;
} }
...@@ -97,15 +102,17 @@ int fmpi_ctx_destroy(struct fmpi_ctx ** const ctx) ...@@ -97,15 +102,17 @@ int fmpi_ctx_destroy(struct fmpi_ctx ** const ctx)
assert(ctx != NULL); assert(ctx != NULL);
assert(*ctx != NULL); assert(*ctx != NULL);
int err_id = -1; int err = FMPI_SUCCESS;
if((*ctx)->fut != NULL) { if((*ctx)->fut != NULL && fmpi_futhark_exit(&(*ctx)->fut) != FMPI_SUCCESS) {
err_id = fmpi_futhark_exit(&(*ctx)->fut); FMPI_RAISE_ERROR((*ctx)->err_handler, "FMPI", "fmpi_futhark_exit() failed!");
err = FMPI_ERROR;
} }
if((*ctx)->mpi != NULL) { if((*ctx)->mpi != NULL && fmpi_mpi_exit(&(*ctx)->mpi) != FMPI_SUCCESS) {
err_id = fmpi_mpi_exit(&(*ctx)->mpi); FMPI_RAISE_ERROR((*ctx)->err_handler, "FMPI", "fmpi_mpi_exit() failed!");
err = FMPI_ERROR;
} }
free(*ctx); *ctx = NULL; free(*ctx); *ctx = NULL;
return err_id; return err;
} }
/*============================================================================== /*==============================================================================
PRIVATE FUNCTION DEFINITION PRIVATE FUNCTION DEFINITION
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment