From: Wolfgang Bangerth Date: Wed, 19 Jan 2022 19:51:34 +0000 (-0700) Subject: Remove the prepare_for_answer() callback in consensus algorithms. X-Git-Tag: v9.4.0-rc1~571^2~1 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1d955978ea390a2b095f22c0c980b31a39dbea18;p=dealii.git Remove the prepare_for_answer() callback in consensus algorithms. The implementations of the two current algorithms no longer use this callback. Remove it from the Process class. --- 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 b697c56aed..2ab4bebbd1 100644 --- a/include/deal.II/base/mpi_compute_index_owner_internal.h +++ b/include/deal.II/base/mpi_compute_index_owner_internal.h @@ -766,18 +766,6 @@ namespace Utilities interval->last() + 1); } - /** - * Implementation of - * Utilities::MPI::ConsensusAlgorithms::Process::prepare_buffer_for_answer(). - */ - virtual void - prepare_buffer_for_answer( - const unsigned int other_rank, - std::vector &recv_buffer) override - { - recv_buffer.resize(recv_indices[other_rank].size()); - } - /** * Implementation of * Utilities::MPI::ConsensusAlgorithms::Process::read_answer(). @@ -786,6 +774,8 @@ namespace Utilities read_answer(const unsigned int other_rank, const std::vector &recv_buffer) override { + Assert(recv_buffer.size() == recv_indices[other_rank].size(), + ExcInternalError()); Assert(recv_indices[other_rank].size() == recv_buffer.size(), ExcMessage("Sizes do not match!")); diff --git a/include/deal.II/base/mpi_consensus_algorithms.h b/include/deal.II/base/mpi_consensus_algorithms.h index 997e1e55b6..6a41ac2146 100644 --- a/include/deal.II/base/mpi_consensus_algorithms.h +++ b/include/deal.II/base/mpi_consensus_algorithms.h @@ -92,20 +92,6 @@ namespace Utilities create_request(const unsigned int other_rank, std::vector & send_buffer); - /** - * Prepare the buffer where the payload of the answer of the request to - * the process with the specified rank is saved in. The most obvious - * task is to resize the buffer, since it is empty when the function is - * called. - * - * @param[in] other_rank Rank of the process. - * @param[out] recv_buffer Data to be sent as part of the request - * (optional). - */ - virtual void - prepare_buffer_for_answer(const unsigned int other_rank, - std::vector & recv_buffer); - /** * Prepare the buffer where the payload of the answer of the request to * the process with the specified rank is saved in. @@ -572,8 +558,6 @@ namespace Utilities * @param function_compute_targets called during `compute_targets`. * @param function_create_request called during `create_request`. * @param function_answer_request called during `answer_request`. - * @param function_prepare_buffer_for_answer called during - * `prepare_buffer_for_answer`. * @param function_read_answer called during `read_answer`. */ AnonymousProcess( @@ -585,8 +569,6 @@ namespace Utilities const std::vector &, std::vector &)> &function_answer_request = {}, - const std::function &)> - &function_prepare_buffer_for_answer = {}, const std::function &)> &function_read_answer = {}); @@ -611,13 +593,6 @@ namespace Utilities const std::vector &buffer_recv, std::vector & request_buffer) override; - /** - * @copydoc Process::prepare_buffer_for_answer() - */ - void - prepare_buffer_for_answer(const unsigned int other_rank, - std::vector & recv_buffer) override; - /** * @copydoc Process::read_answer() */ @@ -633,8 +608,6 @@ namespace Utilities const std::function< void(const unsigned int, const std::vector &, std::vector &)> function_answer_request; - const std::function &)> - function_prepare_buffer_for_answer; const std::function &)> function_read_answer; }; @@ -650,14 +623,11 @@ namespace Utilities const std::function &, std::vector &)> &function_answer_request, - const std::function &)> - &function_prepare_buffer_for_answer, const std::function &)> &function_read_answer) : function_compute_targets(function_compute_targets) , function_create_request(function_create_request) , function_answer_request(function_answer_request) - , function_prepare_buffer_for_answer(function_prepare_buffer_for_answer) , function_read_answer(function_read_answer) {} @@ -696,18 +666,6 @@ namespace Utilities - template - void - AnonymousProcess::prepare_buffer_for_answer( - const unsigned int other_rank, - std::vector & recv_buffer) - { - if (function_prepare_buffer_for_answer) - function_prepare_buffer_for_answer(other_rank, recv_buffer); - } - - - template void AnonymousProcess::read_answer(const unsigned int other_rank, diff --git a/include/deal.II/base/mpi_consensus_algorithms.templates.h b/include/deal.II/base/mpi_consensus_algorithms.templates.h index 18cdf49226..174465c933 100644 --- a/include/deal.II/base/mpi_consensus_algorithms.templates.h +++ b/include/deal.II/base/mpi_consensus_algorithms.templates.h @@ -92,16 +92,6 @@ namespace Utilities - template - void - Process::prepare_buffer_for_answer(const unsigned int, - std::vector &) - { - // nothing to do - } - - - template void Process::read_answer(const unsigned int, const std::vector &) @@ -737,7 +727,6 @@ namespace Utilities std::vector request_buffer; this->process.create_request(0, send_buffer); - this->process.prepare_buffer_for_answer(0, recv_buffer); this->process.answer_request(0, send_buffer, request_buffer); recv_buffer = request_buffer; this->process.read_answer(0, recv_buffer); diff --git a/include/deal.II/fe/fe_tools_extrapolate.templates.h b/include/deal.II/fe/fe_tools_extrapolate.templates.h index cf49dcfc66..aa58ae5411 100644 --- a/include/deal.II/fe/fe_tools_extrapolate.templates.h +++ b/include/deal.II/fe/fe_tools_extrapolate.templates.h @@ -1152,12 +1152,6 @@ namespace FETools send_buffer = Utilities::pack(cells_for_this_destination, false); }; - const auto prepare_buffer_for_answer = - [](const unsigned int /*other_rank*/, std::vector &recv_buffer) { - // Nothing to do here, we don't actually want to send an answer - recv_buffer.clear(); - }; - const auto answer_request = [&received_cells](const unsigned int other_rank, const std::vector &buffer_recv, @@ -1191,7 +1185,6 @@ namespace FETools operations(get_destinations, create_request, answer_request, - prepare_buffer_for_answer, read_answer); Utilities::MPI::ConsensusAlgorithms::Selector(operations, diff --git a/include/deal.II/matrix_free/matrix_free.templates.h b/include/deal.II/matrix_free/matrix_free.templates.h index 3b5c7dc046..253f141f7f 100644 --- a/include/deal.II/matrix_free/matrix_free.templates.h +++ b/include/deal.II/matrix_free/matrix_free.templates.h @@ -2138,10 +2138,10 @@ MatrixFree::initialize_indices( AssertDimension(request_buffer.size(), buffer_recv.size()); }, - [&](const auto other_rank, auto &recv_buffer) { - recv_buffer.resize(cells_shared_ghosts[other_rank].size()); - }, [&](const auto other_rank, const auto &recv_buffer) { + Assert(recv_buffer.size() == + cells_shared_ghosts[other_rank].size(), + ExcInternalError()); for (unsigned int i = 0; i < recv_buffer.size(); ++i) { cells[cells_shared_ghosts[other_rank][i].first] = { diff --git a/source/grid/grid_tools.cc b/source/grid/grid_tools.cc index 2448a8dc8c..620ae281d1 100644 --- a/source/grid/grid_tools.cc +++ b/source/grid/grid_tools.cc @@ -5998,18 +5998,6 @@ namespace GridTools if (perform_handshake) request_buffer = Utilities::pack(request_buffer_temp, false); }, - [&](const unsigned int other_rank, std::vector &recv_buffer) { - if (perform_handshake) - { - const auto other_rank_index = translate(other_rank); - - recv_buffer = - Utilities::pack(std::vector( - potential_owners_ptrs[other_rank_index + 1] - - potential_owners_ptrs[other_rank_index]), - false); - } - }, [&](const unsigned int other_rank, const std::vector &recv_buffer) { if (perform_handshake) diff --git a/tests/base/consensus_algorithm_01.cc b/tests/base/consensus_algorithm_01.cc index bdbe93f616..0cdb1d35e4 100644 --- a/tests/base/consensus_algorithm_01.cc +++ b/tests/base/consensus_algorithm_01.cc @@ -46,9 +46,6 @@ test(const MPI_Comm &comm) << std::endl; request_buffer.push_back(my_rank); }, - [&](const unsigned int other_rank, std::vector &recv_buffer) { - recv_buffer.resize(1); - }, [&](const unsigned int other_rank, const std::vector &recv_buffer) { AssertDimension(other_rank, recv_buffer.front()); deallog << "ConsensusAlgorithmProcess::function_read_answer() passed!"