From 96e2c18730ff8670c07521527b4c25bb6da5dd81 Mon Sep 17 00:00:00 2001
From: "raphael.bach" <raphael.bach@etu.hesge.ch>
Date: Sun, 26 Jun 2022 21:57:35 +0200
Subject: [PATCH] Remove unnecessary parameters from `
 fmpi_mpi_gather_in_place()`

---
 include/internal/fmpi_mpi.h |  5 ++---
 src/fmpi_mpi.c              | 22 +++++++++-------------
 2 files changed, 11 insertions(+), 16 deletions(-)

diff --git a/include/internal/fmpi_mpi.h b/include/internal/fmpi_mpi.h
index d3de3ee..5519e3b 100644
--- a/include/internal/fmpi_mpi.h
+++ b/include/internal/fmpi_mpi.h
@@ -213,9 +213,8 @@ MPI_Datatype fmpi_mpi_type(enum fmpi_type_base type);
     fmpi_mpi_gather_in_place()
 ------------------------------------------------------------------------------*/
 int fmpi_mpi_gather_in_place(
-    const struct fmpi_mpi_ctx * ctx, const void * send_buf, size_t send_cnt,
-    MPI_Datatype send_type, void * recv_buf, size_t recv_cnt,
-    MPI_Datatype recv_type, int root, MPI_Comm comm
+    const struct fmpi_mpi_ctx * ctx, void * buf, MPI_Datatype type,
+    size_t send_cnt, size_t recv_cnt, int root, MPI_Comm comm
 );
 /*==============================================================================
     GUARD
diff --git a/src/fmpi_mpi.c b/src/fmpi_mpi.c
index 912c1c0..8229836 100644
--- a/src/fmpi_mpi.c
+++ b/src/fmpi_mpi.c
@@ -226,30 +226,26 @@ MPI_Datatype fmpi_mpi_type(const enum fmpi_type_base type)
     fmpi_mpi_gather_in_place()
 ------------------------------------------------------------------------------*/
 int fmpi_mpi_gather_in_place(
-    const struct fmpi_mpi_ctx * const ctx,
-    const void * const send_buf, const size_t send_cnt, MPI_Datatype send_type,
-    void * const recv_buf, const size_t recv_cnt, MPI_Datatype recv_type,
-    const int root, MPI_Comm comm
+    const struct fmpi_mpi_ctx * const ctx, void * const buf, MPI_Datatype type,
+    const size_t send_cnt, const size_t recv_cnt, const int root, MPI_Comm comm
 ) {
     assert(ctx != NULL);
-    assert(send_buf != NULL);
-    assert(recv_buf != NULL);
+    assert(buf != NULL);
     assert(send_cnt <= INT_MAX);
     assert(recv_cnt <= INT_MAX);
-    if(send_type == recv_type) {
-        assert(send_cnt <= recv_cnt);
-    }
+    assert(send_cnt <= recv_cnt);
+
     int err = MPI_SUCCESS;
     if(ctx->rank == root) {
         err = MPI_Gather(
-            MPI_IN_PLACE, (int)send_cnt, send_type,
-            recv_buf    , (int)recv_cnt, recv_type,
+            MPI_IN_PLACE, (int)send_cnt, type,
+            buf    , (int)recv_cnt, type,
             root, comm
         );
     } else {
         err = MPI_Gather(
-            send_buf, (int)send_cnt, send_type,
-            recv_buf, (int)recv_cnt, recv_type,
+            buf, (int)send_cnt, type,
+            buf, (int)recv_cnt, type,
             root, comm
         );
     }
-- 
GitLab