]> https://gitweb.dealii.org/ - dealii.git/commitdiff
use MPI::CollectiveMutex in several places
authorTimo Heister <timo.heister@gmail.com>
Fri, 1 Nov 2019 18:53:11 +0000 (14:53 -0400)
committerTimo Heister <timo.heister@gmail.com>
Mon, 4 Nov 2019 19:07:56 +0000 (14:07 -0500)
include/deal.II/base/mpi_compute_index_owner_internal.h
source/base/mpi.cc

index bf246890a3733df6eaf6e7c4a9c8043c0c72f5fd..b2e63c0a3498bc9d31b6985437fdb64e4a060212 100644 (file)
@@ -119,6 +119,10 @@ namespace Utilities
             this->partition(owned_indices, comm);
 
 #ifdef DEAL_II_WITH_MPI
+
+            static CollectiveMutex      mutex;
+            CollectiveMutex::ScopedLock lock(mutex, comm);
+
             unsigned int my_rank = this_mpi_process(comm);
 
             types::global_dof_index dic_local_received = 0;
@@ -630,6 +634,9 @@ namespace Utilities
 
 #ifdef DEAL_II_WITH_MPI
 
+            static CollectiveMutex      mutex;
+            CollectiveMutex::ScopedLock lock(mutex, comm);
+
             // reserve enough slots for the requests ahead; depending on
             // whether the owning rank is one of the requesters or not, we
             // might have one less requests to execute, so fill the requests
@@ -768,11 +775,6 @@ namespace Utilities
               }
 #  endif
 
-            // This barrier is important to make sure that two successive calls
-            // to this functions do not overlap and we confuse messages. See the
-            // discussion in https://github.com/dealii/dealii/issues/8929
-            MPI_Barrier(comm);
-
 #endif // DEAL_II_WITH_MPI
 
             return requested_indices;
index 9520a9e709ad1e8ddf397bd90288c04fb98a1418..c5c84b33107dc03295070949a1e4826f7c15b849 100644 (file)
@@ -237,6 +237,10 @@ namespace Utilities
         }
 
 #  if DEAL_II_MPI_VERSION_GTE(2, 2)
+
+      static CollectiveMutex      mutex;
+      CollectiveMutex::ScopedLock lock(mutex, mpi_comm);
+
       // Calculate the number of messages to send to each process
       std::vector<unsigned int> dest_vector(n_procs);
       for (const auto &el : destinations)
@@ -947,6 +951,9 @@ namespace Utilities
     void
     ConsensusAlgorithm_NBX<T1, T2>::run()
     {
+      static CollectiveMutex      mutex;
+      CollectiveMutex::ScopedLock lock(mutex, this->comm);
+
       // 1) send requests and start receiving the answers
       start_communication();
 
@@ -1273,6 +1280,9 @@ namespace Utilities
     void
     ConsensusAlgorithm_PEX<T1, T2>::run()
     {
+      static CollectiveMutex      mutex;
+      CollectiveMutex::ScopedLock lock(mutex, this->comm);
+
       // 1) send requests and start receiving the answers
       //    especially determine how many requests are expected
       const unsigned int n_requests = start_communication();

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.