]> AND Public Git Repository - simgrid.git/commitdiff
Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fix a few potential memory leaks in SMPI colls
authorJean-Michel Gorius <jean-michel.gorius@ens-rennes.fr>
Sun, 17 Jan 2021 15:04:29 +0000 (16:04 +0100)
committerJean-Michel Gorius <jean-michel.gorius@ens-rennes.fr>
Sun, 17 Jan 2021 15:04:29 +0000 (16:04 +0100)
src/smpi/colls/allgather/allgather-NTSLR-NB.cpp
src/smpi/colls/reduce_scatter/reduce_scatter-mpich.cpp

index ae9d1951c373a5d633f0013970b9586222fd644d..1745ced72166ca3a958f5ad1720a062c32dc83c6 100644 (file)
@@ -25,8 +25,6 @@ allgather__NTSLR_NB(const void *sbuf, int scount, MPI_Datatype stype,
   size = comm->size();
   rextent = rtype->get_extent();
   sextent = stype->get_extent();
   size = comm->size();
   rextent = rtype->get_extent();
   sextent = stype->get_extent();
-  auto* rrequest_array = new MPI_Request[size];
-  auto* srequest_array = new MPI_Request[size];
 
   // irregular case use default MPI functions
   if (scount * sextent != rcount * rextent) {
 
   // irregular case use default MPI functions
   if (scount * sextent != rcount * rextent) {
@@ -49,6 +47,9 @@ allgather__NTSLR_NB(const void *sbuf, int scount, MPI_Datatype stype,
   //start sending logical ring message
   int increment = scount * sextent;
 
   //start sending logical ring message
   int increment = scount * sextent;
 
+  auto* rrequest_array = new MPI_Request[size];
+  auto* srequest_array = new MPI_Request[size];
+
   //post all irecv first
   for (i = 0; i < size - 1; i++) {
     recv_offset = ((rank - i - 1 + size) % size) * increment;
   //post all irecv first
   for (i = 0; i < size - 1; i++) {
     recv_offset = ((rank - i - 1 + size) % size) * increment;
index c8a101b4851824e6aef37e46f2eb341c7592f20c..46f59c69b9ceca7336db03196b41b3a39c378e74 100644 (file)
@@ -108,8 +108,11 @@ int reduce_scatter__mpich_pair(const void *sendbuf, void *recvbuf, const int rec
                   /* copy result back into recvbuf */
                   mpi_errno =
                       Datatype::copy(tmp_recvbuf, recvcounts[rank], datatype, recvbuf, recvcounts[rank], datatype);
                   /* copy result back into recvbuf */
                   mpi_errno =
                       Datatype::copy(tmp_recvbuf, recvcounts[rank], datatype, recvbuf, recvcounts[rank], datatype);
-                  if (mpi_errno)
+                  if (mpi_errno) {
+                   delete[] disps;
+                    smpi_free_tmp_buffer(tmp_recvbuf);
                     return (mpi_errno);
                     return (mpi_errno);
+                 }
                 }
                 else {
                   if (op != MPI_OP_NULL)
                 }
                 else {
                   if (op != MPI_OP_NULL)
@@ -117,8 +120,11 @@ int reduce_scatter__mpich_pair(const void *sendbuf, void *recvbuf, const int rec
                   /* copy result back into recvbuf */
                   mpi_errno = Datatype::copy(tmp_recvbuf, recvcounts[rank], datatype,
                                              ((char*)recvbuf + disps[rank] * extent), recvcounts[rank], datatype);
                   /* copy result back into recvbuf */
                   mpi_errno = Datatype::copy(tmp_recvbuf, recvcounts[rank], datatype,
                                              ((char*)recvbuf + disps[rank] * extent), recvcounts[rank], datatype);
-                  if (mpi_errno)
+                  if (mpi_errno) {
+                   delete[] disps;
+                    smpi_free_tmp_buffer(tmp_recvbuf);
                     return (mpi_errno);
                     return (mpi_errno);
+                 }
                 }
             }
         }
                 }
             }
         }
@@ -131,7 +137,11 @@ int reduce_scatter__mpich_pair(const void *sendbuf, void *recvbuf, const int rec
                                        recvcounts[rank], datatype,
                                        recvbuf,
                                        recvcounts[rank], datatype );
                                        recvcounts[rank], datatype,
                                        recvbuf,
                                        recvcounts[rank], datatype );
-            if (mpi_errno) return(mpi_errno);
+            if (mpi_errno) {
+             delete[] disps;
+              smpi_free_tmp_buffer(tmp_recvbuf);
+             return (mpi_errno);
+           }
         }
 
         delete[] disps;
         }
 
         delete[] disps;
@@ -307,8 +317,10 @@ int reduce_scatter__mpich_rdb(const void *sendbuf, void *recvbuf, const int recv
     else
       mpi_errno = Datatype::copy(recvbuf, total_count, datatype, tmp_results, total_count, datatype);
 
     else
       mpi_errno = Datatype::copy(recvbuf, total_count, datatype, tmp_results, total_count, datatype);
 
-    if (mpi_errno)
+    if (mpi_errno) {
+      delete[] disps;
       return (mpi_errno);
       return (mpi_errno);
+    }
 
     mask = 0x1;
     i    = 0;
 
     mask = 0x1;
     i    = 0;