From 2d1ba91485bf3a27a66d532c0b677409719385b6 Mon Sep 17 00:00:00 2001 From: "raphael.bach" <raphael.bach@etu.hesge.ch> Date: Mon, 6 Jun 2022 18:29:05 +0200 Subject: [PATCH] Add `fmpi_mpi_world_rank()` --- include/internal/fmpi_mpi.h | 7 +++++++ src/fmpi_mpi.c | 13 +++++++++++++ 2 files changed, 20 insertions(+) diff --git a/include/internal/fmpi_mpi.h b/include/internal/fmpi_mpi.h index cfb97a4..dd0119a 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 9ba26be..4df0f27 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; +} -- GitLab