From: Wolfgang Bangerth Date: Sun, 9 Jan 2022 18:03:16 +0000 (-0700) Subject: Fix a bug: Don't reuse buffers for MPI_Isend. X-Git-Tag: v9.4.0-rc1~639^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b3b2b973adcc15259e32f932a583a9fed09b2195;p=dealii.git Fix a bug: Don't reuse buffers for MPI_Isend. 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. --- diff --git a/include/deal.II/fe/fe_tools_extrapolate.templates.h b/include/deal.II/fe/fe_tools_extrapolate.templates.h index b85649a2bf..84f549de10 100644 --- a/include/deal.II/fe/fe_tools_extrapolate.templates.h +++ b/include/deal.II/fe/fe_tools_extrapolate.templates.h @@ -1146,9 +1146,8 @@ namespace FETools std::vector & received_cells) const { std::vector> sendbuffers(cells_to_send.size()); - std::vector>::iterator buffer = sendbuffers.begin(); - std::vector requests(cells_to_send.size()); - std::vector destinations; + std::vector requests(cells_to_send.size()); + std::vector 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>::iterator buffer = sendbuffers.begin(); + unsigned int idx = 0; for (typename std::vector::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());