]> https://gitweb.dealii.org/ - dealii.git/commitdiff
In PEX, do not compute sources but just the number of sources.
authorWolfgang Bangerth <bangerth@colostate.edu>
Fri, 14 Jan 2022 11:58:12 +0000 (04:58 -0700)
committerWolfgang Bangerth <bangerth@colostate.edu>
Tue, 18 Jan 2022 03:16:26 +0000 (20:16 -0700)
We don't actually need to know where we will get messages from, just how many messages
we will get. This is a question that at least in some contexts is cheaper to answer.

include/deal.II/base/mpi_consensus_algorithms.h
include/deal.II/base/mpi_consensus_algorithms.templates.h

index 3c34b591b422b91527416325717cc09bbf52cb9d..b4570107dc43ec4c2886bd79d5933aef9f39e808 100644 (file)
@@ -446,11 +446,6 @@ namespace Utilities
          */
         std::vector<unsigned int> targets;
 
-        /**
-         * List of ranks of processes wanting to send a request to this process.
-         */
-        std::vector<unsigned int> sources;
-
         // data structures to send and receive requests
 
         /**
index b0c2993bed49d03a791568be64c37f5e36949090..f03687e7f5c6d272e89e0ad799a9a5590517e8eb 100644 (file)
@@ -479,13 +479,11 @@ namespace Utilities
                ExcMessage("The consensus algorithms expect that each process "
                           "only sends a single message to another process, "
                           "but the targets provided include duplicates."));
+        const unsigned int n_targets = targets.size();
 
         // 2) determine who wants to communicate with this process
-        sources =
-          compute_point_to_point_communication_pattern(this->comm, targets);
-
-        const unsigned int n_targets = targets.size();
-        const unsigned int n_sources = sources.size();
+        const unsigned int n_sources =
+          compute_n_point_to_point_communications(this->comm, targets);
 
         // 2) allocate memory
         recv_buffers.resize(n_targets);
@@ -529,7 +527,7 @@ namespace Utilities
             AssertThrowMPI(ierr);
           }
 
-        return sources.size();
+        return n_sources;
 #else
         return 0;
 #endif
@@ -548,17 +546,13 @@ namespace Utilities
           consensus_algorithm_pex_process_deliver;
 
         // Wait until we have a message ready for retrieval, though we don't
-        // care which process it is from. We know that the source must be
-        // listed in the 'sources' array, though.
+        // care which process it is from.
         MPI_Status status;
         int ierr = MPI_Probe(MPI_ANY_SOURCE, tag_request, this->comm, &status);
         AssertThrowMPI(ierr);
 
         // Get rank of incoming message and verify that it makes sense
         const unsigned int other_rank = status.MPI_SOURCE;
-        Assert(std::find(sources.begin(), sources.end(), other_rank) !=
-                 sources.end(),
-               ExcInternalError());
 
         Assert(requesting_processes.find(other_rank) ==
                  requesting_processes.end(),

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.