deal.II version GIT relicensing-2289-g1e5549a87a 2024-12-21 21:30:00+00:00
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Private Attributes | List of all members
Utilities::MPI::ConsensusAlgorithms::PEX< RequestType, AnswerType > Class Template Reference

#include <deal.II/base/mpi_consensus_algorithms.h>

Inheritance diagram for Utilities::MPI::ConsensusAlgorithms::PEX< RequestType, AnswerType >:
Inheritance graph
[legend]

Public Member Functions

 PEX ()=default
 
virtual ~PEX ()=default
 
virtual std::vector< unsigned intrun (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
 
std::vector< unsigned intrun (Process< RequestType, AnswerType > &process, const MPI_Comm comm)
 

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 intrequesting_processes
 

Detailed Description

template<typename RequestType, typename AnswerType>
class Utilities::MPI::ConsensusAlgorithms::PEX< RequestType, AnswerType >

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.

Note
In contrast to NBX, this class splits the same task into two distinct steps. In the first step, all processes are identified who want to send a request to this process. In the second step, the data is exchanged. However, since - in the second step - now it is clear how many requests have to be answered, i.e. when this process can stop waiting for requests, no IBarrier is needed.
Under the hood, this function uses Utilities::MPI::compute_point_to_point_communication_pattern() to determine the source processes, which itself is based on the NBX-algorithm from [119] that is implemented in the ConsensusAlgorithms::NBX class (a sister class to the current one).
Template Parameters
RequestTypeThe type of the elements of the vector to be sent.
AnswerTypeThe type of the elements of the vector to be received.

Definition at line 566 of file mpi_consensus_algorithms.h.

Constructor & Destructor Documentation

◆ PEX()

template<typename RequestType , typename AnswerType >
Utilities::MPI::ConsensusAlgorithms::PEX< RequestType, AnswerType >::PEX ( )
default

Default constructor.

◆ ~PEX()

template<typename RequestType , typename AnswerType >
virtual Utilities::MPI::ConsensusAlgorithms::PEX< RequestType, AnswerType >::~PEX ( )
virtualdefault

Destructor.

Member Function Documentation

◆ run() [1/2]

template<typename RequestType , typename AnswerType >
virtual std::vector< unsigned int > Utilities::MPI::ConsensusAlgorithms::PEX< RequestType, AnswerType >::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 
)
overridevirtual

Run the consensus algorithm and return a vector of process ranks that have requested answers from the current process.

This version of the run() function simply unpacks the functions packaged in process and calls the version of the run() function that takes a number of std::function arguments.

Deprecated:
Instead of deriving a class from the Process base class and providing a corresponding object to this function, use the other run() function in this class that takes function objects as arguments.

Implements Utilities::MPI::ConsensusAlgorithms::Interface< RequestType, AnswerType >.

◆ start_communication()

template<typename RequestType , typename AnswerType >
unsigned int Utilities::MPI::ConsensusAlgorithms::PEX< RequestType, AnswerType >::start_communication ( const std::vector< unsigned int > &  targets,
const std::function< RequestType(const unsigned int)> &  create_request,
const MPI_Comm  comm 
)
private

Start to send all requests via ISend and post IRecvs for the incoming answer messages.

◆ answer_one_request()

template<typename RequestType , typename AnswerType >
void Utilities::MPI::ConsensusAlgorithms::PEX< RequestType, AnswerType >::answer_one_request ( const unsigned int  index,
const std::function< AnswerType(const unsigned int, const RequestType &)> &  answer_request,
const MPI_Comm  comm 
)
private

The indexth request message from another rank has been received: process the request and send an answer.

◆ process_incoming_answers()

template<typename RequestType , typename AnswerType >
void Utilities::MPI::ConsensusAlgorithms::PEX< RequestType, AnswerType >::process_incoming_answers ( const unsigned int  n_targets,
const std::function< void(const unsigned int, const AnswerType &)> &  process_answer,
const MPI_Comm  comm 
)
private

Receive and process all of the incoming responses to the requests we sent.

◆ clean_up_and_end_communication()

template<typename RequestType , typename AnswerType >
void Utilities::MPI::ConsensusAlgorithms::PEX< RequestType, AnswerType >::clean_up_and_end_communication ( )
private

After all answers have been exchanged, the MPI data structures can be freed and the received answers can be processed.

◆ run() [2/2]

template<typename RequestType , typename AnswerType >
std::vector< unsigned int > Utilities::MPI::ConsensusAlgorithms::Interface< RequestType, AnswerType >::run ( Process< RequestType, AnswerType > &  process,
const MPI_Comm  comm 
)
inherited

Run the consensus algorithm and return a vector of process ranks that have requested answers from the current process.

This version of the run() function simply unpacks the functions packaged in process and calls the version of the run() function that takes a number of std::function arguments.

Deprecated:
Instead of deriving a class from the Process base class and providing a corresponding object to this function, use the other run() function in this class that takes function objects as arguments.

Member Data Documentation

◆ send_buffers

template<typename RequestType , typename AnswerType >
std::vector<std::vector<char> > Utilities::MPI::ConsensusAlgorithms::PEX< RequestType, AnswerType >::send_buffers
private

Buffers for sending requests.

Definition at line 600 of file mpi_consensus_algorithms.h.

◆ recv_buffers

template<typename RequestType , typename AnswerType >
std::vector<std::vector<char> > Utilities::MPI::ConsensusAlgorithms::PEX< RequestType, AnswerType >::recv_buffers
private

Buffers for receiving answers to requests.

Definition at line 605 of file mpi_consensus_algorithms.h.

◆ send_request_requests

template<typename RequestType , typename AnswerType >
std::vector<MPI_Request> Utilities::MPI::ConsensusAlgorithms::PEX< RequestType, AnswerType >::send_request_requests
private

MPI request objects for sending request messages.

Definition at line 610 of file mpi_consensus_algorithms.h.

◆ requests_buffers

template<typename RequestType , typename AnswerType >
std::vector<std::vector<char> > Utilities::MPI::ConsensusAlgorithms::PEX< RequestType, AnswerType >::requests_buffers
private

Buffers for sending answers to requests.

Definition at line 615 of file mpi_consensus_algorithms.h.

◆ send_answer_requests

template<typename RequestType , typename AnswerType >
std::vector<MPI_Request> Utilities::MPI::ConsensusAlgorithms::PEX< RequestType, AnswerType >::send_answer_requests
private

Requests for sending answers to requests.

Definition at line 620 of file mpi_consensus_algorithms.h.

◆ requesting_processes

template<typename RequestType , typename AnswerType >
std::set<unsigned int> Utilities::MPI::ConsensusAlgorithms::PEX< RequestType, AnswerType >::requesting_processes
private

List of processes who have made a request to this process.

Definition at line 625 of file mpi_consensus_algorithms.h.


The documentation for this class was generated from the following file: