From c88f3d770131756d7f4ed4fc751e10d97946b9df Mon Sep 17 00:00:00 2001 From: Peter Munch Date: Fri, 17 Jan 2020 07:17:34 +0100 Subject: [PATCH] Rename methods in ConsensusAlgorithmProcess --- include/deal.II/base/mpi.h | 18 +++--- .../base/mpi_compute_index_owner_internal.h | 42 ++++++------- include/deal.II/base/mpi_tags.h | 4 +- source/base/mpi.cc | 62 +++++++++---------- 4 files changed, 62 insertions(+), 64 deletions(-) diff --git a/include/deal.II/base/mpi.h b/include/deal.II/base/mpi.h index 37557429b3..0ea19a9eb6 100644 --- a/include/deal.II/base/mpi.h +++ b/include/deal.II/base/mpi.h @@ -993,7 +993,7 @@ namespace Utilities * @note The buffer is empty. Before using it, you have to set its size. */ virtual void - pack_recv_buffer(const int other_rank, std::vector &send_buffer); + create_request(const int other_rank, std::vector &send_buffer); /** * Prepare the buffer where the payload of the answer of the request to @@ -1004,7 +1004,8 @@ namespace Utilities * @param[out] recv_buffer data to be sent part of the request (optional) */ virtual void - prepare_recv_buffer(const int other_rank, std::vector &recv_buffer); + prepare_buffer_for_answer(const int other_rank, + std::vector &recv_buffer); /** * Prepare the buffer where the payload of the answer of the request to @@ -1019,9 +1020,9 @@ namespace Utilities * its size. */ virtual void - process_request(const unsigned int other_rank, - const std::vector &buffer_recv, - std::vector & request_buffer); + answer_request(const unsigned int other_rank, + const std::vector &buffer_recv, + std::vector & request_buffer); /** * Process the payload of the answer of the request to the process with @@ -1031,8 +1032,7 @@ namespace Utilities * @param[in] recv_buffer data to be sent part of the request (optional) */ virtual void - unpack_recv_buffer(const int other_rank, - const std::vector &recv_buffer); + read_answer(const int other_rank, const std::vector &recv_buffer); }; /** @@ -1222,7 +1222,7 @@ namespace Utilities * request and send an answer. */ void - process_requests(); + answer_requests(); /** * Start to send all requests via ISend and post IRecvs for the incoming @@ -1333,7 +1333,7 @@ namespace Utilities * the request and send an answer. */ void - process_requests(int index); + answer_requests(int index); /** * Start to send all requests via ISend and post IRecvs for the incoming diff --git a/include/deal.II/base/mpi_compute_index_owner_internal.h b/include/deal.II/base/mpi_compute_index_owner_internal.h index ba3b542c25..66f4c272b1 100644 --- a/include/deal.II/base/mpi_compute_index_owner_internal.h +++ b/include/deal.II/base/mpi_compute_index_owner_internal.h @@ -81,23 +81,23 @@ namespace Utilities /** * Implementation of - * Utilities::MPI::ConsensusAlgorithmProcess::pack_recv_buffer(). + * Utilities::MPI::ConsensusAlgorithmProcess::create_request(). */ virtual void - pack_recv_buffer(const int other_rank, - std::vector> - &send_buffer) override + create_request(const int other_rank, + std::vector> + &send_buffer) override { send_buffer = this->buffers.at(other_rank); } /** * Implementation of - * Utilities::MPI::ConsensusAlgorithmProcess::process_request(). + * Utilities::MPI::ConsensusAlgorithmProcess::answer_request(). */ virtual void - process_request( + answer_request( const unsigned int other_rank, const std::vector> &buffer_recv, @@ -632,13 +632,13 @@ namespace Utilities /** * Implementation of - * Utilities::MPI::ConsensusAlgorithmProcess::process_request(), + * Utilities::MPI::ConsensusAlgorithmProcess::answer_request(), * adding the owner of a particular index in request_buffer (and * keeping track of who requested a particular index in case that * information is also desired). */ virtual void - process_request( + answer_request( const unsigned int other_rank, const std::vector> &buffer_recv, @@ -717,13 +717,13 @@ namespace Utilities /** * Implementation of - * Utilities::MPI::ConsensusAlgorithmProcess::pack_recv_buffer(). + * Utilities::MPI::ConsensusAlgorithmProcess::create_request(). */ virtual void - pack_recv_buffer(const int other_rank, - std::vector> - &send_buffer) override + create_request(const int other_rank, + std::vector> + &send_buffer) override { // create index set and compress data to be sent auto & indices_i = indices_to_look_up_by_dict_rank[other_rank]; @@ -740,23 +740,23 @@ namespace Utilities /** * Implementation of - * Utilities::MPI::ConsensusAlgorithmProcess::prepare_recv_buffer(). + * Utilities::MPI::ConsensusAlgorithmProcess::prepare_buffer_for_answer(). */ virtual void - prepare_recv_buffer(const int other_rank, - std::vector &recv_buffer) override + prepare_buffer_for_answer( + const int other_rank, + std::vector &recv_buffer) override { recv_buffer.resize(recv_indices[other_rank].size()); } /** * Implementation of - * Utilities::MPI::ConsensusAlgorithmProcess::unpack_recv_buffer(). + * Utilities::MPI::ConsensusAlgorithmProcess::read_answer(). */ virtual void - unpack_recv_buffer( - const int other_rank, - const std::vector &recv_buffer) override + read_answer(const int other_rank, + const std::vector &recv_buffer) override { Assert(recv_indices[other_rank].size() == recv_buffer.size(), ExcMessage("Sizes do not match!")); diff --git a/include/deal.II/base/mpi_tags.h b/include/deal.II/base/mpi_tags.h index 51fa10b714..38dd155189 100644 --- a/include/deal.II/base/mpi_tags.h +++ b/include/deal.II/base/mpi_tags.h @@ -86,12 +86,12 @@ namespace Utilities fe_tools_extrapolate_end = fe_tools_extrapolate + 10, /// ConsensusAlgorithm_NBX::process - consensus_algorithm_nbx_process_request, + consensus_algorithm_nbx_answer_request, /// ConsensusAlgorithm_NBX::process consensus_algorithm_nbx_process_deliver, /// ConsensusAlgorithm_PEX::process - consensus_algorithm_pex_process_request, + consensus_algorithm_pex_answer_request, /// ConsensusAlgorithm_PEX::process consensus_algorithm_pex_process_deliver, diff --git a/source/base/mpi.cc b/source/base/mpi.cc index 6b363f65a0..e9b71e0e46 100644 --- a/source/base/mpi.cc +++ b/source/base/mpi.cc @@ -236,9 +236,9 @@ namespace Utilities using T2 = int; virtual void - process_request(const unsigned int other_rank, - const std::vector &, - std::vector &) override + answer_request(const unsigned int other_rank, + const std::vector &, + std::vector &) override { this->sources.push_back(other_rank); } @@ -961,9 +961,9 @@ namespace Utilities template void - ConsensusAlgorithmProcess::process_request(const unsigned int, - const std::vector &, - std::vector &) + ConsensusAlgorithmProcess::answer_request(const unsigned int, + const std::vector &, + std::vector &) { // nothing to do } @@ -972,8 +972,8 @@ namespace Utilities template void - ConsensusAlgorithmProcess::pack_recv_buffer(const int, - std::vector &) + ConsensusAlgorithmProcess::create_request(const int, + std::vector &) { // nothing to do } @@ -982,8 +982,9 @@ namespace Utilities template void - ConsensusAlgorithmProcess::prepare_recv_buffer(const int, - std::vector &) + ConsensusAlgorithmProcess::prepare_buffer_for_answer( + const int, + std::vector &) { // nothing to do } @@ -992,9 +993,8 @@ namespace Utilities template void - ConsensusAlgorithmProcess::unpack_recv_buffer( - const int, - const std::vector &) + ConsensusAlgorithmProcess::read_answer(const int, + const std::vector &) { // nothing to do } @@ -1035,7 +1035,7 @@ namespace Utilities // 2) answer requests and check if all requests of this process have been // answered while (!check_own_state()) - process_requests(); + answer_requests(); // 3) signal to all other processes that all requests of this process have // been answered @@ -1045,7 +1045,7 @@ namespace Utilities // incoming requests until all processes have received the // answer to all requests while (!check_global_state()) - process_requests(); + answer_requests(); // 5) process the answer to all requests clean_up_and_end_communication(); @@ -1112,12 +1112,12 @@ namespace Utilities template void - ConsensusAlgorithm_NBX::process_requests() + ConsensusAlgorithm_NBX::answer_requests() { #ifdef DEAL_II_WITH_MPI const int tag_request = - Utilities::MPI::internal::Tags::consensus_algorithm_nbx_process_request; + Utilities::MPI::internal::Tags::consensus_algorithm_nbx_answer_request; const int tag_deliver = Utilities::MPI::internal::Tags::consensus_algorithm_nbx_process_deliver; @@ -1165,9 +1165,7 @@ namespace Utilities // process request auto &request_buffer = *request_buffers.back(); - this->process.process_request(other_rank, - buffer_recv, - request_buffer); + this->process.answer_request(other_rank, buffer_recv, request_buffer); // start to send answer back ierr = MPI_Isend(request_buffer.data(), @@ -1194,7 +1192,7 @@ namespace Utilities const auto n_targets = targets.size(); const int tag_request = - Utilities::MPI::internal::Tags::consensus_algorithm_nbx_process_request; + Utilities::MPI::internal::Tags::consensus_algorithm_nbx_answer_request; const int tag_deliver = Utilities::MPI::internal::Tags::consensus_algorithm_nbx_process_deliver; @@ -1213,7 +1211,7 @@ namespace Utilities // translate index set to a list of pairs auto &send_buffer = send_buffers[index]; - this->process.pack_recv_buffer(rank, send_buffer); + this->process.create_request(rank, send_buffer); // start to send data auto ierr = MPI_Isend(send_buffer.data(), @@ -1227,7 +1225,7 @@ namespace Utilities // start to receive data auto &recv_buffer = recv_buffers[index]; - this->process.prepare_recv_buffer(rank, recv_buffer); + this->process.prepare_buffer_for_answer(rank, recv_buffer); ierr = MPI_Irecv(recv_buffer.data(), recv_buffer.size() * sizeof(T2), MPI_BYTE, @@ -1286,7 +1284,7 @@ namespace Utilities // unpack data { for (unsigned int i = 0; i < targets.size(); i++) - this->process.unpack_recv_buffer(targets[i], recv_buffers[i]); + this->process.read_answer(targets[i], recv_buffers[i]); } #endif } @@ -1315,7 +1313,7 @@ namespace Utilities // 2) answer requests for (unsigned int request = 0; request < n_requests; request++) - process_requests(request); + answer_requests(request); // 3) process answers clean_up_and_end_communication(); @@ -1325,11 +1323,11 @@ namespace Utilities template void - ConsensusAlgorithm_PEX::process_requests(int index) + ConsensusAlgorithm_PEX::answer_requests(int index) { #ifdef DEAL_II_WITH_MPI const int tag_request = - Utilities::MPI::internal::Tags::consensus_algorithm_pex_process_request; + Utilities::MPI::internal::Tags::consensus_algorithm_pex_answer_request; const int tag_deliver = Utilities::MPI::internal::Tags::consensus_algorithm_pex_process_deliver; @@ -1360,7 +1358,7 @@ namespace Utilities // process request auto &request_buffer = requests_buffers[index]; - this->process.process_request(other_rank, buffer_recv, request_buffer); + this->process.answer_request(other_rank, buffer_recv, request_buffer); // start to send answer back ierr = MPI_Isend(request_buffer.data(), @@ -1387,7 +1385,7 @@ namespace Utilities targets = this->process.compute_targets(); const int tag_request = - Utilities::MPI::internal::Tags::consensus_algorithm_pex_process_request; + Utilities::MPI::internal::Tags::consensus_algorithm_pex_answer_request; const int tag_deliver = Utilities::MPI::internal::Tags::consensus_algorithm_pex_process_deliver; @@ -1413,7 +1411,7 @@ namespace Utilities // pack data which should be sent auto &send_buffer = send_buffers[i]; - this->process.pack_recv_buffer(rank, send_buffer); + this->process.create_request(rank, send_buffer); // start to send data auto ierr = MPI_Isend(send_buffer.data(), @@ -1427,7 +1425,7 @@ namespace Utilities // start to receive data auto &recv_buffer = recv_buffers[i]; - this->process.prepare_recv_buffer(rank, recv_buffer); + this->process.prepare_buffer_for_answer(rank, recv_buffer); ierr = MPI_Irecv(recv_buffer.data(), recv_buffer.size() * sizeof(T2), MPI_BYTE, @@ -1470,7 +1468,7 @@ namespace Utilities // unpack received data for (unsigned int i = 0; i < targets.size(); i++) - this->process.unpack_recv_buffer(targets[i], recv_buffers[i]); + this->process.read_answer(targets[i], recv_buffers[i]); #endif } -- 2.39.5