]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Only deal with one answer at a time.
authorWolfgang Bangerth <bangerth@colostate.edu>
Tue, 18 Jan 2022 20:41:09 +0000 (13:41 -0700)
committerWolfgang Bangerth <bangerth@colostate.edu>
Tue, 18 Jan 2022 20:47:51 +0000 (13:47 -0700)
include/deal.II/base/mpi_consensus_algorithms.templates.h

index 9289073dc84cfeb4b33ae007c1fdef1c982873b5..831bde91a0c8c8dcb27ea80c3f9b0192e5152c54 100644 (file)
@@ -240,7 +240,9 @@ namespace Utilities
         // immediately with a return code that indicates whether
         // it has found a message from any process with a given
         // tag.
-        while (outstanding_answers.size() > 0)
+        if (outstanding_answers.size() == 0)
+          return true;
+        else
           {
             const int tag_deliver = Utilities::MPI::internal::Tags::
               consensus_algorithm_nbx_process_deliver;
@@ -302,19 +304,19 @@ namespace Utilities
                 // Finally, remove this rank from the list of outstanding
                 // targets:
                 outstanding_answers.erase(target);
-              }
 
-            // Do another round of the 'while' loop above. It will either
-            // terminate because there are no outstanding answers left,
-            // or its body will return false because there are no other
-            // pending messages, or there is another pending message and
-            // we can process that too.
+                // We could do another go-around from the top of this
+                // else-branch to see whether there are actually other messages
+                // that are currently pending. But that would mean spending
+                // substantial time in receiving answers while we should also be
+                // sending answers to requests we have received from other
+                // places. So let it be enough for now. If there are outstanding
+                // answers, we will get back to this function before long and
+                // can take care of them then.
+                return (outstanding_answers.size() == 0);
+              }
           }
 
-        // If we have made it here, then we have received an answer
-        // from everyone and can return true:
-        return true;
-
 #else
         return true;
 #endif

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.