![]() |
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 a two step approach. In the first step the source ranks are determined and in the second step a static sparse data exchange is performed. This algorithm is most suitable for relatively small process counts – say, less than 100.
| 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 456 of file mpi_consensus_algorithms.h.
Public Member Functions | |
| PEX ()=default | |
| virtual | ~PEX ()=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 | |
| unsigned int | start_communication (const std::vector< unsigned int > &targets, const std::function< RequestType(const unsigned int)> &create_request, const MPI_Comm comm) |
| void | answer_one_request (const unsigned int index, const std::function< AnswerType(const unsigned int, const RequestType &)> &answer_request, const MPI_Comm comm) |
| void | process_incoming_answers (const unsigned int n_targets, const std::function< void(const unsigned int, const AnswerType &)> &process_answer, const MPI_Comm comm) |
| void | clean_up_and_end_communication () |
Private Attributes | |
| std::vector< std::vector< char > > | send_buffers |
| std::vector< std::vector< char > > | recv_buffers |
| std::vector< MPI_Request > | send_request_requests |
| std::vector< std::vector< char > > | requests_buffers |
| std::vector< MPI_Request > | send_answer_requests |
| 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 |
Start to send all requests via ISend and post IRecvs for the incoming answer messages.
|
private |
The indexth request message from another rank has been received: process the request and send an answer.
|
private |
Receive and process all of the incoming responses to the requests we sent.
|
private |
After all answers have been exchanged, the MPI data structures can be freed and the received answers can be processed.
|
private |
Buffers for sending requests.
Definition at line 487 of file mpi_consensus_algorithms.h.
|
private |
Buffers for receiving answers to requests.
Definition at line 492 of file mpi_consensus_algorithms.h.
|
private |
MPI request objects for sending request messages.
Definition at line 497 of file mpi_consensus_algorithms.h.
|
private |
Buffers for sending answers to requests.
Definition at line 502 of file mpi_consensus_algorithms.h.
|
private |
Requests for sending answers to requests.
Definition at line 507 of file mpi_consensus_algorithms.h.
|
private |
List of processes who have made a request to this process.
Definition at line 512 of file mpi_consensus_algorithms.h.