From: Timo Heister Date: Mon, 21 Oct 2019 18:13:28 +0000 (+0200) Subject: Fix missing MPI_Wait in compute_point_to_point_communication_pattern X-Git-Tag: v9.2.0-rc1~958^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0ef30433e86698f0415b099fdc916fade9fea76b;p=dealii.git Fix missing MPI_Wait in compute_point_to_point_communication_pattern Remove the early return (we will just execute 0 MPI_Recv) as we forgot to Wailall. Also add some error checking while I am here. --- diff --git a/source/base/mpi.cc b/source/base/mpi.cc index 0e05f412ce..4de6ac44ef 100644 --- a/source/base/mpi.cc +++ b/source/base/mpi.cc @@ -244,34 +244,43 @@ namespace Utilities // Send myid to every process in `destinations` vector... std::vector send_requests(destinations.size()); for (const auto &el : destinations) - MPI_Isend(&myid, - 1, - MPI_UNSIGNED, - el, - 32766, - mpi_comm, - send_requests.data() + (&el - destinations.data())); + { + const int ierr = + MPI_Isend(&myid, + 1, + MPI_UNSIGNED, + el, + 32766, + mpi_comm, + send_requests.data() + (&el - destinations.data())); + AssertThrowMPI(ierr); + } - // if no one to receive from, return an empty vector - if (n_recv_from == 0) - return std::vector(); - // ...otherwise receive `n_recv_from` times from the processes + // Receive `n_recv_from` times from the processes // who communicate with this one. Store the obtained id's // in the resulting vector std::vector origins(n_recv_from); for (auto &el : origins) - MPI_Recv(&el, - 1, - MPI_UNSIGNED, - MPI_ANY_SOURCE, - 32766, - mpi_comm, - MPI_STATUS_IGNORE); + { + const int ierr = MPI_Recv(&el, + 1, + MPI_UNSIGNED, + MPI_ANY_SOURCE, + 32766, + mpi_comm, + MPI_STATUS_IGNORE); + AssertThrowMPI(ierr); + } + + + { + const int ierr = MPI_Waitall(destinations.size(), + send_requests.data(), + MPI_STATUSES_IGNORE); + AssertThrowMPI(ierr); + } - MPI_Waitall(destinations.size(), - send_requests.data(), - MPI_STATUSES_IGNORE); return origins; # else // let all processors communicate the maximal number of destinations