]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Fix missing MPI_Wait in compute_point_to_point_communication_pattern 8939/head
authorTimo Heister <timo.heister@gmail.com>
Mon, 21 Oct 2019 18:13:28 +0000 (20:13 +0200)
committerTimo Heister <timo.heister@gmail.com>
Mon, 21 Oct 2019 18:13:28 +0000 (20:13 +0200)
Remove the early return (we will just execute 0 MPI_Recv) as we forgot
to Wailall. Also add some error checking while I am here.

source/base/mpi.cc

index 0e05f412cedf1e6806597d4bff3ef3ef38d13b75..4de6ac44eff8972f3918203baf8d1e4345f3025d 100644 (file)
@@ -244,34 +244,43 @@ namespace Utilities
       // Send myid to every process in `destinations` vector...
       std::vector<MPI_Request> send_requests(destinations.size());
       for (const auto &el : destinations)
-        MPI_Isend(&myid,
-                  1,
-                  MPI_UNSIGNED,
-                  el,
-                  32766,
-                  mpi_comm,
-                  send_requests.data() + (&el - destinations.data()));
+        {
+          const int ierr =
+            MPI_Isend(&myid,
+                      1,
+                      MPI_UNSIGNED,
+                      el,
+                      32766,
+                      mpi_comm,
+                      send_requests.data() + (&el - destinations.data()));
+          AssertThrowMPI(ierr);
+        }
 
-      // if no one to receive from, return an empty vector
-      if (n_recv_from == 0)
-        return std::vector<unsigned int>();
 
-      // ...otherwise receive `n_recv_from` times from the processes
+      // Receive `n_recv_from` times from the processes
       // who communicate with this one. Store the obtained id's
       // in the resulting vector
       std::vector<unsigned int> origins(n_recv_from);
       for (auto &el : origins)
-        MPI_Recv(&el,
-                 1,
-                 MPI_UNSIGNED,
-                 MPI_ANY_SOURCE,
-                 32766,
-                 mpi_comm,
-                 MPI_STATUS_IGNORE);
+        {
+          const int ierr = MPI_Recv(&el,
+                                    1,
+                                    MPI_UNSIGNED,
+                                    MPI_ANY_SOURCE,
+                                    32766,
+                                    mpi_comm,
+                                    MPI_STATUS_IGNORE);
+          AssertThrowMPI(ierr);
+        }
+
+
+      {
+        const int ierr = MPI_Waitall(destinations.size(),
+                                     send_requests.data(),
+                                     MPI_STATUSES_IGNORE);
+        AssertThrowMPI(ierr);
+      }
 
-      MPI_Waitall(destinations.size(),
-                  send_requests.data(),
-                  MPI_STATUSES_IGNORE);
       return origins;
 #  else
       // let all processors communicate the maximal number of destinations

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.