Reference documentation for deal.II version 9.5.0
\(\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 >:
[legend]

Public Member Functions

 PEX ()=default
 
 PEX (Process< RequestType, AnswerType > &process, const MPI_Comm comm)
 
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 ()
 
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
 
Process< RequestType, AnswerType > * process
 
MPI_Comm comm
 

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 [98] 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 622 of file mpi_consensus_algorithms.h.

Constructor & Destructor Documentation

◆ PEX() [1/2]

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

Default constructor.

◆ PEX() [2/2]

template<typename RequestType , typename AnswerType >
Utilities::MPI::ConsensusAlgorithms::PEX< RequestType, AnswerType >::PEX ( Process< RequestType, AnswerType > &  process,
const MPI_Comm  comm 
)

Constructor.

Parameters
processProcess to be run during consensus algorithm.
commMPI Communicator
Deprecated:
This constructor stores the Process object and the communicator so that one can later call the run() function without arguments. This approach is deprecated. Instead, use the default constructor of this class along with the run() function that takes an argument.

◆ ~PEX()

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

Destructor.

Member Function Documentation

◆ run() [1/3]

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.

Deprecated:
This function is deprecated. It can be called if the Process object and communicator to be used have previously been provided to the non-default constructor. Use the run() functions taking arguments instead.

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/3]

template<typename RequestType , typename AnswerType >
std::vector< unsigned int > Utilities::MPI::ConsensusAlgorithms::Interface< RequestType, AnswerType >::run ( )
inherited

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

Deprecated:
This function is deprecated. It can be called if the Process object and communicator to be used have previously been provided to the non-default constructor. Use the run() functions taking arguments instead.

◆ run() [3/3]

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.

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 672 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 677 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 682 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 687 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 692 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 697 of file mpi_consensus_algorithms.h.

◆ process

template<typename RequestType , typename AnswerType >
Process<RequestType, AnswerType>* Utilities::MPI::ConsensusAlgorithms::Interface< RequestType, AnswerType >::process
privateinherited

Reference to the process provided by the user.

This member variable is only used in the deprecated constructor and the run() function without argument. It is a nullptr otherwise

Definition at line 330 of file mpi_consensus_algorithms.h.

◆ comm

template<typename RequestType , typename AnswerType >
MPI_Comm Utilities::MPI::ConsensusAlgorithms::Interface< RequestType, AnswerType >::comm
privateinherited

MPI communicator.

This member variable is only used in the deprecated constructor and the run() function without argument.

Definition at line 339 of file mpi_consensus_algorithms.h.


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