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::NBX< RequestType, AnswerType > Class Template Reference

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

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

Public Member Functions

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

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 intrequesting_processes
 
Process< RequestType, AnswerType > * process
 
MPI_Comm comm
 

Detailed Description

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

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.

Note
This class closely follows [98], but our implementation also deals with payloads.
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 357 of file mpi_consensus_algorithms.h.

Constructor & Destructor Documentation

◆ NBX() [1/2]

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

Default constructor.

◆ NBX() [2/2]

template<typename RequestType , typename AnswerType >
Utilities::MPI::ConsensusAlgorithms::NBX< RequestType, AnswerType >::NBX ( 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.

◆ ~NBX()

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

Destructor.

Member Function Documentation

◆ run() [1/3]

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

◆ all_locally_originated_receives_are_completed()

template<typename RequestType , typename AnswerType >
bool Utilities::MPI::ConsensusAlgorithms::NBX< RequestType, AnswerType >::all_locally_originated_receives_are_completed ( const std::function< void(const unsigned int, const AnswerType &)> &  process_answer,
const MPI_Comm  comm 
)
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.

◆ signal_finish()

template<typename RequestType , typename AnswerType >
void Utilities::MPI::ConsensusAlgorithms::NBX< RequestType, AnswerType >::signal_finish ( const MPI_Comm  comm)
private

Signal to all other ranks that this rank has received all request answers via entering IBarrier.

◆ all_remotely_originated_receives_are_completed()

template<typename RequestType , typename AnswerType >
bool Utilities::MPI::ConsensusAlgorithms::NBX< RequestType, AnswerType >::all_remotely_originated_receives_are_completed ( )
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.

◆ maybe_answer_one_request()

template<typename RequestType , typename AnswerType >
void Utilities::MPI::ConsensusAlgorithms::NBX< RequestType, AnswerType >::maybe_answer_one_request ( const std::function< AnswerType(const unsigned int, const RequestType &)> &  answer_request,
const MPI_Comm  comm 
)
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.

◆ start_communication()

template<typename RequestType , typename AnswerType >
void Utilities::MPI::ConsensusAlgorithms::NBX< 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.

◆ clean_up_and_end_communication()

template<typename RequestType , typename AnswerType >
void Utilities::MPI::ConsensusAlgorithms::NBX< RequestType, AnswerType >::clean_up_and_end_communication ( const MPI_Comm  comm)
private

After all rank has received all answers, 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::NBX< RequestType, AnswerType >::send_buffers
private

Buffers for sending requests.

Definition at line 406 of file mpi_consensus_algorithms.h.

◆ send_requests

template<typename RequestType , typename AnswerType >
std::vector<MPI_Request> Utilities::MPI::ConsensusAlgorithms::NBX< RequestType, AnswerType >::send_requests
private

Requests for sending requests.

Definition at line 411 of file mpi_consensus_algorithms.h.

◆ request_buffers

template<typename RequestType , typename AnswerType >
std::vector<std::unique_ptr<std::vector<char> > > Utilities::MPI::ConsensusAlgorithms::NBX< RequestType, AnswerType >::request_buffers
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 420 of file mpi_consensus_algorithms.h.

◆ request_requests

template<typename RequestType , typename AnswerType >
std::vector<std::unique_ptr<MPI_Request> > Utilities::MPI::ConsensusAlgorithms::NBX< RequestType, AnswerType >::request_requests
private

Requests for sending answers to requests.

Definition at line 425 of file mpi_consensus_algorithms.h.

◆ n_outstanding_answers

template<typename RequestType , typename AnswerType >
unsigned int Utilities::MPI::ConsensusAlgorithms::NBX< RequestType, AnswerType >::n_outstanding_answers
private

The number of processes from which we are still expecting answers.

Definition at line 430 of file mpi_consensus_algorithms.h.

◆ barrier_request

template<typename RequestType , typename AnswerType >
MPI_Request Utilities::MPI::ConsensusAlgorithms::NBX< RequestType, AnswerType >::barrier_request
private

Definition at line 433 of file mpi_consensus_algorithms.h.

◆ requesting_processes

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

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

Definition at line 439 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: