Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Use simgrid function instead of MPI in collectives
[simgrid.git] / src / smpi / colls / allgather-lr.c
index 407cc25..7656069 100644 (file)
@@ -1,4 +1,4 @@
-#include "colls.h"
+#include "colls_private.h"
 
 // Allgather-Non-Topoloty-Scecific-Logical-Ring algorithm
 int
@@ -12,14 +12,17 @@ smpi_coll_tuned_allgather_lr(void *sbuf, int scount, MPI_Datatype stype,
   int send_offset, recv_offset;
   int tag = 500;
 
-  MPI_Comm_rank(comm, &rank);
-  MPI_Comm_size(comm, &size);
-  MPI_Type_extent(rtype, &rextent);
-  MPI_Type_extent(stype, &sextent);
+  rank = smpi_comm_rank(comm);
+  size = smpi_comm_size(comm);
+  rextent = smpi_datatype_get_extent(rtype);
+  sextent = smpi_datatype_get_extent(stype);
 
   // irregular case use default MPI fucntions
-  if (scount * sextent != rcount * rextent)
-    MPI_Allgather(sbuf, scount, stype, rbuf, rcount, rtype, comm);
+  if (scount * sextent != rcount * rextent) {
+    XBT_WARN("MPI_allgather_lr use default MPI_allgather.");     
+    smpi_mpi_allgather(sbuf, scount, stype, rbuf, rcount, rtype, comm);
+    return MPI_SUCCESS;
+  }
 
   // topo non-specific
   to = (rank + 1) % size;
@@ -27,7 +30,7 @@ smpi_coll_tuned_allgather_lr(void *sbuf, int scount, MPI_Datatype stype,
 
   //copy a single segment from sbuf to rbuf
   send_offset = rank * scount * sextent;
-  MPI_Sendrecv(sbuf, scount, stype, rank, tag,
+  smpi_mpi_sendrecv(sbuf, scount, stype, rank, tag,
                (char *) rbuf + send_offset, rcount, rtype, rank, tag,
                comm, &status);
 
@@ -36,7 +39,7 @@ smpi_coll_tuned_allgather_lr(void *sbuf, int scount, MPI_Datatype stype,
   for (i = 0; i < size - 1; i++) {
     send_offset = ((rank - i + size) % size) * increment;
     recv_offset = ((rank - i - 1 + size) % size) * increment;
-    MPI_Sendrecv((char *) rbuf + send_offset, scount, stype, to, tag + i,
+    smpi_mpi_sendrecv((char *) rbuf + send_offset, scount, stype, to, tag + i,
                  (char *) rbuf + recv_offset, rcount, rtype, from, tag + i,
                  comm, &status);
   }