diff --git a/include/internal/fmpi_mpi.h b/include/internal/fmpi_mpi.h index cfb97a4a484f25e8a183ec066cf2fe90a4148a63..dd0119acddc432ec04277f0646257c1de37f7e7c 100644 --- a/include/internal/fmpi_mpi.h +++ b/include/internal/fmpi_mpi.h @@ -160,6 +160,13 @@ _Bool fmpi_mpi_check_error( * } */ void fmpi_mpi_ctx_print(const struct fmpi_mpi_ctx * ctx); +/*------------------------------------------------------------------------------ + fmpi_mpi_world_rank() +------------------------------------------------------------------------------*/ +/** + * TODO + */ +int fmpi_mpi_world_rank(const struct fmpi_mpi_ctx * ctx); /*============================================================================== GUARD ==============================================================================*/ diff --git a/src/fmpi_mpi.c b/src/fmpi_mpi.c index 9ba26be0ee9dcd84af149a9a6a45e1956b5b9807..4df0f27070475309b1782ec98a317e1e439f9995 100644 --- a/src/fmpi_mpi.c +++ b/src/fmpi_mpi.c @@ -139,3 +139,16 @@ void fmpi_mpi_ctx_print(const struct fmpi_mpi_ctx * const ctx) printf("MPI futhark error class: %d\n", ctx->futhark_err_class); printf("MPI futhark error code: %d\n", ctx->futhark_err_code); } +/*------------------------------------------------------------------------------ + fmpi_mpi_world_rank() +------------------------------------------------------------------------------*/ +int fmpi_mpi_world_rank(const struct fmpi_mpi_ctx * const ctx) +{ + assert(ctx != NULL); + int rank = -1; + int err_id = MPI_Comm_rank(MPI_COMM_WORLD, &rank); + if(fmpi_mpi_check_error(ctx, err_id, "MPI_Comm_rank") == true) { + return -1; + } + return rank; +}