]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Sort PEX member functions in the order in which they are called.
authorWolfgang Bangerth <bangerth@colostate.edu>
Thu, 13 Jan 2022 04:10:38 +0000 (21:10 -0700)
committerWolfgang Bangerth <bangerth@colostate.edu>
Fri, 14 Jan 2022 12:01:05 +0000 (05:01 -0700)
include/deal.II/base/mpi_consensus_algorithms.h
include/deal.II/base/mpi_consensus_algorithms.templates.h

index 814bc1610e5286036ce5b7b72599eef18c1c3ed6..f60b69312e52336643a59fcd7164e14c668e8454 100644 (file)
@@ -484,13 +484,6 @@ namespace Utilities
          */
         std::set<unsigned int> requesting_processes;
 
-        /**
-         * The ith request message from another rank has been received: process
-         * the request and send an answer.
-         */
-        void
-        answer_requests(int index);
-
         /**
          * Start to send all requests via ISend and post IRecvs for the incoming
          * answer messages.
@@ -498,6 +491,13 @@ namespace Utilities
         unsigned int
         start_communication();
 
+        /**
+         * The ith request message from another rank has been received: process
+         * the request and send an answer.
+         */
+        void
+        answer_requests(int index);
+
         /**
          * After all answers have been exchanged, the MPI data structures can be
          * freed and the received answers can be processed.
index 78f97ba518380ecf959d357d238ea41efb443087..ffdecedb097d7fce3a989a0202244d0c9d18efac 100644 (file)
@@ -422,67 +422,6 @@ namespace Utilities
 
 
 
-      template <typename T1, typename T2>
-      void
-      PEX<T1, T2>::answer_requests(int index)
-      {
-#ifdef DEAL_II_WITH_MPI
-        const int tag_request = Utilities::MPI::internal::Tags::
-          consensus_algorithm_pex_answer_request;
-        const int tag_deliver = Utilities::MPI::internal::Tags::
-          consensus_algorithm_pex_process_deliver;
-
-        MPI_Status status;
-        auto ierr = MPI_Probe(MPI_ANY_SOURCE, tag_request, this->comm, &status);
-        AssertThrowMPI(ierr);
-
-        // get rank of incoming message
-        const auto other_rank = status.MPI_SOURCE;
-
-        Assert(requesting_processes.find(other_rank) ==
-                 requesting_processes.end(),
-               ExcMessage("Process is requesting a second time!"));
-        requesting_processes.insert(other_rank);
-
-        std::vector<T1> buffer_recv;
-
-        // get size of incoming message
-        int number_amount;
-        ierr = MPI_Get_count(&status, MPI_BYTE, &number_amount);
-        AssertThrowMPI(ierr);
-
-        // allocate memory for incoming message
-        Assert(number_amount % sizeof(T1) == 0, ExcInternalError());
-        buffer_recv.resize(number_amount / sizeof(T1));
-        ierr = MPI_Recv(buffer_recv.data(),
-                        number_amount,
-                        MPI_BYTE,
-                        other_rank,
-                        tag_request,
-                        this->comm,
-                        &status);
-        AssertThrowMPI(ierr);
-
-        // process request
-        auto &request_buffer = requests_buffers[index];
-        this->process.answer_request(other_rank, buffer_recv, request_buffer);
-
-        // start to send answer back
-        ierr = MPI_Isend(request_buffer.data(),
-                         request_buffer.size() * sizeof(T2),
-                         MPI_BYTE,
-                         other_rank,
-                         tag_deliver,
-                         this->comm,
-                         &requests_answers[index]);
-        AssertThrowMPI(ierr);
-#else
-        (void)index;
-#endif
-      }
-
-
-
       template <typename T1, typename T2>
       unsigned int
       PEX<T1, T2>::start_communication()
@@ -552,6 +491,67 @@ namespace Utilities
 
 
 
+      template <typename T1, typename T2>
+      void
+      PEX<T1, T2>::answer_requests(int index)
+      {
+#ifdef DEAL_II_WITH_MPI
+        const int tag_request = Utilities::MPI::internal::Tags::
+          consensus_algorithm_pex_answer_request;
+        const int tag_deliver = Utilities::MPI::internal::Tags::
+          consensus_algorithm_pex_process_deliver;
+
+        MPI_Status status;
+        auto ierr = MPI_Probe(MPI_ANY_SOURCE, tag_request, this->comm, &status);
+        AssertThrowMPI(ierr);
+
+        // get rank of incoming message
+        const auto other_rank = status.MPI_SOURCE;
+
+        Assert(requesting_processes.find(other_rank) ==
+                 requesting_processes.end(),
+               ExcMessage("Process is requesting a second time!"));
+        requesting_processes.insert(other_rank);
+
+        std::vector<T1> buffer_recv;
+
+        // get size of incoming message
+        int number_amount;
+        ierr = MPI_Get_count(&status, MPI_BYTE, &number_amount);
+        AssertThrowMPI(ierr);
+
+        // allocate memory for incoming message
+        Assert(number_amount % sizeof(T1) == 0, ExcInternalError());
+        buffer_recv.resize(number_amount / sizeof(T1));
+        ierr = MPI_Recv(buffer_recv.data(),
+                        number_amount,
+                        MPI_BYTE,
+                        other_rank,
+                        tag_request,
+                        this->comm,
+                        &status);
+        AssertThrowMPI(ierr);
+
+        // process request
+        auto &request_buffer = requests_buffers[index];
+        this->process.answer_request(other_rank, buffer_recv, request_buffer);
+
+        // start to send answer back
+        ierr = MPI_Isend(request_buffer.data(),
+                         request_buffer.size() * sizeof(T2),
+                         MPI_BYTE,
+                         other_rank,
+                         tag_deliver,
+                         this->comm,
+                         &requests_answers[index]);
+        AssertThrowMPI(ierr);
+#else
+        (void)index;
+#endif
+      }
+
+
+
       template <typename T1, typename T2>
       void
       PEX<T1, T2>::clean_up_and_end_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.