]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Addressed Denis' comments.
authorLuca Heltai <luca.heltai@sissa.it>
Sun, 19 Nov 2017 23:14:15 +0000 (00:14 +0100)
committerLuca Heltai <luca.heltai@sissa.it>
Sun, 19 Nov 2017 23:14:15 +0000 (00:14 +0100)
include/deal.II/base/mpi.h
include/deal.II/base/mpi.templates.h

index f50191b62b8dc3562ecf4eb8f29cab48e9bd83e6..6f64cb050d572be0ff8e2f12096aba19b611db18 100644 (file)
@@ -517,9 +517,7 @@ namespace Utilities
      * argument.
      *
      * @param[in] comm MPI communicator.
-     * @param[in] objects_to_send A map of `rank:object`, where the key `rank`
-     *  is the rank of the processor we want to send to, and `object` is the
-     *  object to send
+     * @param[in] object_to_send A object to send to all other processes
      *
      * @param[out] A vector of objects, with size equal to the number of
      *  processes in the MPI communicator. Each entry contains the object
index 4fab76fcb2ea4622a5f541c5e845e6e2396457a3..2ee5ce7e678f6895986b8208e31707ba1787c581 100644 (file)
@@ -201,8 +201,8 @@ namespace Utilities
       Assert (false, ExcMessage ("The function some_to_some doesn't make"
                                  "any sense if you do not have MPI enabled. "));
 #else
-      auto n_procs = dealii::Utilities::MPI::n_mpi_processes(comm);
-      auto my_proc = dealii::Utilities::MPI::this_mpi_process(comm);
+      const auto n_procs = dealii::Utilities::MPI::n_mpi_processes(comm);
+      const auto my_proc = dealii::Utilities::MPI::this_mpi_process(comm);
 
       std::vector<unsigned int> send_to(objects_to_send.size());
       {
@@ -235,11 +235,9 @@ namespace Utilities
       // Receiving buffers
       std::map<unsigned int, T> received_objects;
       {
-        unsigned int i = 0;
         std::vector<char> buffer;
-
         // We do this on a first come/first served basis
-        while (i<receive_from.size())
+        for (unsigned int i = 0; i<receive_from.size(); ++i)
           {
             // Probe what's going on. Take data from the first available sender
             MPI_Status status;
@@ -259,9 +257,9 @@ namespace Utilities
             ierr = MPI_Recv(buffer.data(), len, MPI_CHAR,
                             rank, 21, comm, MPI_STATUS_IGNORE);
             AssertThrowMPI(ierr);
-
+            Assert(received_objects.find(rank) == received_objects.end(),
+                   ExcInternalError("I should not receive again from this rank"));
             received_objects[rank] = Utilities::unpack<T>(buffer);
-            ++i;
           }
       }
 
@@ -284,7 +282,7 @@ namespace Utilities
       Assert (false, ExcMessage ("The function all_gather doesn't make"
                                  "any sense if you do not have MPI enabled. "));
 #else
-      auto n_procs = dealii::Utilities::MPI::n_mpi_processes(comm);
+      const auto n_procs = dealii::Utilities::MPI::n_mpi_processes(comm);
 
       std::vector<char> buffer = Utilities::pack(object);
 

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.