![]() |
deal.II version GIT relicensing-6834-g5b78e6bcdf 2026-10-01 11:20:01+00:00
|
#include <deal.II/base/mpi_consensus_algorithms.h>
This class implements a concrete algorithm for the ConsensusAlgorithms::Interface base class, using only point-to-point communications and a single IBarrier. This algorithm is suitable for very large process counts because it does not require the allocation of arrays with size proportional to the number of processes.
| RequestType | The type of the elements of the vector to be sent. |
| AnswerType | The type of the elements of the vector to be received. |
Definition at line 209 of file mpi_consensus_algorithms.h.
Public Member Functions | |
| NBX ()=default | |
| virtual | ~NBX ()=default |
| virtual std::vector< unsigned int > | run (const std::vector< unsigned int > &targets, const std::function< RequestType(const unsigned int)> &create_request, const std::function< AnswerType(const unsigned int, const RequestType &)> &answer_request, const std::function< void(const unsigned int, const AnswerType &)> &process_answer, const MPI_Comm comm) override |
Private Member Functions | |
| bool | all_locally_originated_receives_are_completed (const std::function< void(const unsigned int, const AnswerType &)> &process_answer, const MPI_Comm comm) |
| void | signal_finish (const MPI_Comm comm) |
| bool | all_remotely_originated_receives_are_completed () |
| void | maybe_answer_one_request (const std::function< AnswerType(const unsigned int, const RequestType &)> &answer_request, const MPI_Comm comm) |
| void | start_communication (const std::vector< unsigned int > &targets, const std::function< RequestType(const unsigned int)> &create_request, const MPI_Comm comm) |
| void | clean_up_and_end_communication (const MPI_Comm comm) |
Private Attributes | |
| std::vector< std::vector< char > > | send_buffers |
| std::vector< MPI_Request > | send_requests |
| std::vector< std::unique_ptr< std::vector< char > > > | request_buffers |
| std::vector< std::unique_ptr< MPI_Request > > | request_requests |
| unsigned int | n_outstanding_answers |
| MPI_Request | barrier_request |
| std::set< unsigned int > | requesting_processes |
|
default |
Default constructor.
|
virtualdefault |
Destructor.
|
overridevirtual |
Run the consensus algorithm and return a vector of process ranks that have requested answers from the current process.
| [in] | targets | A vector that contains the ranks of processes to which requests should be sent and from which answers need to be received. |
| [in] | create_request | A function object that takes the rank of a target process as argument and returns the message that forms the request to this target. |
| [in] | answer_request | A function that takes as arguments the rank of the process that has sent a request to us, along with the message of the request, and returns the message that forms the answer that should be sent back to the requesting process. |
| [in] | process_answer | A function object that takes as argument the rank of a process from which we have received an answer to a previously sent request, along with the message that forms this answer. This function is used to describe what the caller of the consensus algorithm wants to do with the received answer. |
| [in] | comm | The MPI communicator on which the whole algorithm is to be performed. |
Implements Utilities::MPI::ConsensusAlgorithms::Interface< RequestType, AnswerType >.
|
private |
Check whether all of the requests for answers that were created by the communication posted from the current process to other ranks have been satisfied.
|
private |
Signal to all other ranks that this rank has received all request answers via entering IBarrier.
|
private |
Check whether all of the requests for answers that were created by communication posted from other processes to the current rank have been satisfied.
|
private |
Check whether a request message from another rank has been received, and if so, process the request by storing the data and sending an answer.
|
private |
Start to send all requests via ISend and post IRecvs for the incoming answer messages.
|
private |
After all rank has received all answers, the MPI data structures can be freed and the received answers can be processed.
|
private |
Buffers for sending requests.
Definition at line 240 of file mpi_consensus_algorithms.h.
|
private |
Requests for sending requests.
Definition at line 245 of file mpi_consensus_algorithms.h.
|
private |
Buffers for sending answers to requests. We use a vector of pointers because that guarantees that the buffers themselves are newer moved around in memory, even if the vector is resized and consequently its elements (the pointers) are moved around.
Definition at line 254 of file mpi_consensus_algorithms.h.
|
private |
Requests for sending answers to requests.
Definition at line 259 of file mpi_consensus_algorithms.h.
|
private |
The number of processes from which we are still expecting answers.
Definition at line 264 of file mpi_consensus_algorithms.h.
|
private |
Definition at line 267 of file mpi_consensus_algorithms.h.
|
private |
List of processes who have made a request to this process.
Definition at line 273 of file mpi_consensus_algorithms.h.