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<unsigned int> &recv_buffer) override
- {
- recv_buffer.resize(recv_indices[other_rank].size());
- }
-
/**
* Implementation of
* Utilities::MPI::ConsensusAlgorithms::Process::read_answer().
read_answer(const unsigned int other_rank,
const std::vector<unsigned int> &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!"));
create_request(const unsigned int other_rank,
std::vector<T1> & 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<T2> & recv_buffer);
-
/**
* Prepare the buffer where the payload of the answer of the request to
* the process with the specified rank is saved in.
* @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(
const std::vector<T1> &,
std::vector<T2> &)>
&function_answer_request = {},
- const std::function<void(const unsigned int, std::vector<T2> &)>
- &function_prepare_buffer_for_answer = {},
const std::function<void(const unsigned int, const std::vector<T2> &)>
&function_read_answer = {});
const std::vector<T1> &buffer_recv,
std::vector<T2> & request_buffer) override;
- /**
- * @copydoc Process::prepare_buffer_for_answer()
- */
- void
- prepare_buffer_for_answer(const unsigned int other_rank,
- std::vector<T2> & recv_buffer) override;
-
/**
* @copydoc Process::read_answer()
*/
const std::function<
void(const unsigned int, const std::vector<T1> &, std::vector<T2> &)>
function_answer_request;
- const std::function<void(const int, std::vector<T2> &)>
- function_prepare_buffer_for_answer;
const std::function<void(const int, const std::vector<T2> &)>
function_read_answer;
};
const std::function<void(const unsigned int,
const std::vector<T1> &,
std::vector<T2> &)> &function_answer_request,
- const std::function<void(const unsigned int, std::vector<T2> &)>
- &function_prepare_buffer_for_answer,
const std::function<void(const unsigned int, const std::vector<T2> &)>
&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)
{}
- template <typename T1, typename T2>
- void
- AnonymousProcess<T1, T2>::prepare_buffer_for_answer(
- const unsigned int other_rank,
- std::vector<T2> & recv_buffer)
- {
- if (function_prepare_buffer_for_answer)
- function_prepare_buffer_for_answer(other_rank, recv_buffer);
- }
-
-
-
template <typename T1, typename T2>
void
AnonymousProcess<T1, T2>::read_answer(const unsigned int other_rank,
- template <typename T1, typename T2>
- void
- Process<T1, T2>::prepare_buffer_for_answer(const unsigned int,
- std::vector<T2> &)
- {
- // nothing to do
- }
-
-
-
template <typename T1, typename T2>
void
Process<T1, T2>::read_answer(const unsigned int, const std::vector<T2> &)
std::vector<T2> 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);
send_buffer = Utilities::pack(cells_for_this_destination, false);
};
- const auto prepare_buffer_for_answer =
- [](const unsigned int /*other_rank*/, std::vector<char> &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<char> &buffer_recv,
operations(get_destinations,
create_request,
answer_request,
- prepare_buffer_for_answer,
read_answer);
Utilities::MPI::ConsensusAlgorithms::Selector<char, char>(operations,