From: Luca Heltai Date: Mon, 2 Dec 2019 12:23:36 +0000 (+0100) Subject: Applied suggestion. X-Git-Tag: v9.2.0-rc1~828^2~2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6a04105e4407b9702d4ab36811badd9f83c1022f;p=dealii.git Applied suggestion. --- 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 }