]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Remove the prepare_for_answer() callback in consensus algorithms.
authorWolfgang Bangerth <bangerth@colostate.edu>
Wed, 19 Jan 2022 19:51:34 +0000 (12:51 -0700)
committerWolfgang Bangerth <bangerth@colostate.edu>
Wed, 19 Jan 2022 19:51:34 +0000 (12:51 -0700)
The implementations of the two current algorithms no longer use this callback.
Remove it from the Process class.

include/deal.II/base/mpi_compute_index_owner_internal.h
include/deal.II/base/mpi_consensus_algorithms.h
include/deal.II/base/mpi_consensus_algorithms.templates.h
include/deal.II/fe/fe_tools_extrapolate.templates.h
include/deal.II/matrix_free/matrix_free.templates.h
source/grid/grid_tools.cc
tests/base/consensus_algorithm_01.cc

index b697c56aed7a0b74ca58270afeb7a9646308c3cb..2ab4bebbd1d4bd56e44ed767fdab75ab37a647fd 100644 (file)
@@ -766,18 +766,6 @@ namespace Utilities
                                        interval->last() + 1);
           }
 
-          /**
-           * Implementation of
-           * Utilities::MPI::ConsensusAlgorithms::Process::prepare_buffer_for_answer().
-           */
-          virtual void
-          prepare_buffer_for_answer(
-            const unsigned int         other_rank,
-            std::vector<unsigned int> &recv_buffer) override
-          {
-            recv_buffer.resize(recv_indices[other_rank].size());
-          }
-
           /**
            * Implementation of
            * Utilities::MPI::ConsensusAlgorithms::Process::read_answer().
@@ -786,6 +774,8 @@ namespace Utilities
           read_answer(const unsigned int               other_rank,
                       const std::vector<unsigned int> &recv_buffer) override
           {
+            Assert(recv_buffer.size() == recv_indices[other_rank].size(),
+                   ExcInternalError());
             Assert(recv_indices[other_rank].size() == recv_buffer.size(),
                    ExcMessage("Sizes do not match!"));
 
index 997e1e55b6533a11bddb4ab60196fa7c98e2e8ca..6a41ac2146d286ffd387f8fd145abfa34624d2d0 100644 (file)
@@ -92,20 +92,6 @@ namespace Utilities
         create_request(const unsigned int other_rank,
                        std::vector<T1> &  send_buffer);
 
-        /**
-         * Prepare the buffer where the payload of the answer of the request to
-         * the process with the specified rank is saved in. The most obvious
-         * task is to resize the buffer, since it is empty when the function is
-         * called.
-         *
-         * @param[in]  other_rank Rank of the process.
-         * @param[out] recv_buffer Data to be sent as part of the request
-         * (optional).
-         */
-        virtual void
-        prepare_buffer_for_answer(const unsigned int other_rank,
-                                  std::vector<T2> &  recv_buffer);
-
         /**
          * Prepare the buffer where the payload of the answer of the request to
          * the process with the specified rank is saved in.
@@ -572,8 +558,6 @@ namespace Utilities
          * @param function_compute_targets called during `compute_targets`.
          * @param function_create_request called during `create_request`.
          * @param function_answer_request called during `answer_request`.
-         * @param function_prepare_buffer_for_answer called during
-         *   `prepare_buffer_for_answer`.
          * @param function_read_answer called during `read_answer`.
          */
         AnonymousProcess(
@@ -585,8 +569,6 @@ namespace Utilities
                                    const std::vector<T1> &,
                                    std::vector<T2> &)>
             &function_answer_request = {},
-          const std::function<void(const unsigned int, std::vector<T2> &)>
-            &function_prepare_buffer_for_answer = {},
           const std::function<void(const unsigned int, const std::vector<T2> &)>
             &function_read_answer = {});
 
@@ -611,13 +593,6 @@ namespace Utilities
                        const std::vector<T1> &buffer_recv,
                        std::vector<T2> &      request_buffer) override;
 
-        /**
-         * @copydoc Process::prepare_buffer_for_answer()
-         */
-        void
-        prepare_buffer_for_answer(const unsigned int other_rank,
-                                  std::vector<T2> &  recv_buffer) override;
-
         /**
          * @copydoc Process::read_answer()
          */
@@ -633,8 +608,6 @@ namespace Utilities
         const std::function<
           void(const unsigned int, const std::vector<T1> &, std::vector<T2> &)>
           function_answer_request;
-        const std::function<void(const int, std::vector<T2> &)>
-          function_prepare_buffer_for_answer;
         const std::function<void(const int, const std::vector<T2> &)>
           function_read_answer;
       };
@@ -650,14 +623,11 @@ namespace Utilities
         const std::function<void(const unsigned int,
                                  const std::vector<T1> &,
                                  std::vector<T2> &)> &function_answer_request,
-        const std::function<void(const unsigned int, std::vector<T2> &)>
-          &function_prepare_buffer_for_answer,
         const std::function<void(const unsigned int, const std::vector<T2> &)>
           &function_read_answer)
         : function_compute_targets(function_compute_targets)
         , function_create_request(function_create_request)
         , function_answer_request(function_answer_request)
-        , function_prepare_buffer_for_answer(function_prepare_buffer_for_answer)
         , function_read_answer(function_read_answer)
       {}
 
@@ -696,18 +666,6 @@ namespace Utilities
 
 
 
-      template <typename T1, typename T2>
-      void
-      AnonymousProcess<T1, T2>::prepare_buffer_for_answer(
-        const unsigned int other_rank,
-        std::vector<T2> &  recv_buffer)
-      {
-        if (function_prepare_buffer_for_answer)
-          function_prepare_buffer_for_answer(other_rank, recv_buffer);
-      }
-
-
-
       template <typename T1, typename T2>
       void
       AnonymousProcess<T1, T2>::read_answer(const unsigned int     other_rank,
index 18cdf4922640e55d806e9306836ff25bb1699bfc..174465c933fabf1cdd3f1f388162bfb8cb014eb9 100644 (file)
@@ -92,16 +92,6 @@ namespace Utilities
 
 
 
-      template <typename T1, typename T2>
-      void
-      Process<T1, T2>::prepare_buffer_for_answer(const unsigned int,
-                                                 std::vector<T2> &)
-      {
-        // nothing to do
-      }
-
-
-
       template <typename T1, typename T2>
       void
       Process<T1, T2>::read_answer(const unsigned int, const std::vector<T2> &)
@@ -737,7 +727,6 @@ namespace Utilities
             std::vector<T2> request_buffer;
 
             this->process.create_request(0, send_buffer);
-            this->process.prepare_buffer_for_answer(0, recv_buffer);
             this->process.answer_request(0, send_buffer, request_buffer);
             recv_buffer = request_buffer;
             this->process.read_answer(0, recv_buffer);
index cf49dcfc666155f0e6bacec627098ffe0174e78c..aa58ae54114fe22d5587634e5f3046932c78ad23 100644 (file)
@@ -1152,12 +1152,6 @@ namespace FETools
           send_buffer = Utilities::pack(cells_for_this_destination, false);
         };
 
-      const auto prepare_buffer_for_answer =
-        [](const unsigned int /*other_rank*/, std::vector<char> &recv_buffer) {
-          // Nothing to do here, we don't actually want to send an answer
-          recv_buffer.clear();
-        };
-
       const auto answer_request =
         [&received_cells](const unsigned int       other_rank,
                           const std::vector<char> &buffer_recv,
@@ -1191,7 +1185,6 @@ namespace FETools
         operations(get_destinations,
                    create_request,
                    answer_request,
-                   prepare_buffer_for_answer,
                    read_answer);
 
       Utilities::MPI::ConsensusAlgorithms::Selector<char, char>(operations,
index 3b5c7dc0466d2ce1776564d35cf3f8686bc9852b..253f141f7f1bcdda2419322452e43959d1d54c3c 100644 (file)
@@ -2138,10 +2138,10 @@ MatrixFree<dim, Number, VectorizedArrayType>::initialize_indices(
 
                   AssertDimension(request_buffer.size(), buffer_recv.size());
                 },
-                [&](const auto other_rank, auto &recv_buffer) {
-                  recv_buffer.resize(cells_shared_ghosts[other_rank].size());
-                },
                 [&](const auto other_rank, const auto &recv_buffer) {
+                  Assert(recv_buffer.size() ==
+                           cells_shared_ghosts[other_rank].size(),
+                         ExcInternalError());
                   for (unsigned int i = 0; i < recv_buffer.size(); ++i)
                     {
                       cells[cells_shared_ghosts[other_rank][i].first] = {
index 2448a8dc8cb71f3aeac4f2389138a8b26a3507d3..620ae281d1ccdc2b268a68e9e70fdb4291dc2388 100644 (file)
@@ -5998,18 +5998,6 @@ namespace GridTools
           if (perform_handshake)
             request_buffer = Utilities::pack(request_buffer_temp, false);
         },
-        [&](const unsigned int other_rank, std::vector<char> &recv_buffer) {
-          if (perform_handshake)
-            {
-              const auto other_rank_index = translate(other_rank);
-
-              recv_buffer =
-                Utilities::pack(std::vector<unsigned int>(
-                                  potential_owners_ptrs[other_rank_index + 1] -
-                                  potential_owners_ptrs[other_rank_index]),
-                                false);
-            }
-        },
         [&](const unsigned int       other_rank,
             const std::vector<char> &recv_buffer) {
           if (perform_handshake)
index bdbe93f6164d7178cdddfaee0f2aaeda3876f8c5..0cdb1d35e44ac7ac41cd9f5b9c00704e10b003d0 100644 (file)
@@ -46,9 +46,6 @@ test(const MPI_Comm &comm)
               << std::endl;
       request_buffer.push_back(my_rank);
     },
-    [&](const unsigned int other_rank, std::vector<T2> &recv_buffer) {
-      recv_buffer.resize(1);
-    },
     [&](const unsigned int other_rank, const std::vector<T2> &recv_buffer) {
       AssertDimension(other_rank, recv_buffer.front());
       deallog << "ConsensusAlgorithmProcess::function_read_answer() passed!"

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.