]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Fix a bug: Don't reuse buffers for MPI_Isend. 13206/head
authorWolfgang Bangerth <bangerth@colostate.edu>
Sun, 9 Jan 2022 18:03:16 +0000 (11:03 -0700)
committerWolfgang Bangerth <bangerth@colostate.edu>
Sun, 9 Jan 2022 18:09:31 +0000 (11:09 -0700)
The intention of the code was clearly to cycle through the existing buffers,
but we never incremented the iterator, and so accidentally reused a send buffer over and
over. This works only because MPI_Isend is specified in the MPI standard as
'standard mode', which means that it may or may not copy the data to be sent
into an MPI-internal buffer before the function returns. Apparently it does in all
implementations we use, but we shouldn't rely on this.

include/deal.II/fe/fe_tools_extrapolate.templates.h

index b85649a2bfacb429cd22407f5084b0655659983a..84f549de1023083cfac67510625228d20904682e 100644 (file)
@@ -1146,9 +1146,8 @@ namespace FETools
       std::vector<CellData> &      received_cells) const
     {
       std::vector<std::vector<char>> sendbuffers(cells_to_send.size());
-      std::vector<std::vector<char>>::iterator buffer = sendbuffers.begin();
-      std::vector<MPI_Request>                 requests(cells_to_send.size());
-      std::vector<unsigned int>                destinations;
+      std::vector<MPI_Request>       requests(cells_to_send.size());
+      std::vector<unsigned int>      destinations;
 
       // Protect the communication below:
       static Utilities::MPI::CollectiveMutex      mutex;
@@ -1159,7 +1158,8 @@ namespace FETools
         Utilities::MPI::internal::Tags::fe_tools_extrapolate + round % 10;
 
       // send data
-      unsigned int idx = 0;
+      std::vector<std::vector<char>>::iterator buffer = sendbuffers.begin();
+      unsigned int                             idx    = 0;
       for (typename std::vector<CellData>::const_iterator it =
              cells_to_send.begin();
            it != cells_to_send.end();
@@ -1176,6 +1176,8 @@ namespace FETools
                                      communicator,
                                      &requests[idx]);
           AssertThrowMPI(ierr);
+
+          ++buffer;
         }
 
       Assert(destinations.size() == cells_to_send.size(), ExcInternalError());

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.