From 6a04105e4407b9702d4ab36811badd9f83c1022f Mon Sep 17 00:00:00 2001 From: Luca Heltai Date: Mon, 2 Dec 2019 13:23:36 +0100 Subject: [PATCH] Applied suggestion. --- include/deal.II/base/mpi.h | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/include/deal.II/base/mpi.h b/include/deal.II/base/mpi.h index 3845b752c2..3f1277a0c4 100644 --- a/include/deal.II/base/mpi.h +++ b/include/deal.II/base/mpi.h @@ -1490,15 +1490,19 @@ namespace Utilities # else const auto my_proc = this_mpi_process(comm); + std::map received_objects; + std::vector send_to; send_to.reserve(objects_to_send.size()); for (const auto &m : objects_to_send) - if (m.first != my_proc) + if (m.first == my_proc) + received_objects[my_proc] = m.second; + else send_to.emplace_back(m.first); // Shortcut, when running in serial if (send_to.size() == 0) - return objects_to_send; + return received_objects; const auto receive_from = Utilities::MPI::compute_point_to_point_communication_pattern(comm, @@ -1533,8 +1537,7 @@ namespace Utilities } } - // Receiving buffers - std::map received_objects; + // Fill the output map { std::vector buffer; // We do this on a first come/first served basis @@ -1575,10 +1578,6 @@ namespace Utilities buffer_send_requests.data(), MPI_STATUSES_IGNORE); - // If necessary, insert my own objects into the received_objects - if (objects_to_send.find(my_proc) != objects_to_send.end()) - received_objects[my_proc] = objects_to_send.at(my_proc); - return received_objects; # endif // deal.II with MPI } -- 2.39.5