TRIQS/mpi 1.3.0
C++ interface to MPI
Loading...
Searching...
No Matches
mpi::monitor

#include <mpi/monitor.hpp>

Detailed Description

Constructed on top of an MPI communicator, this class helps to monitor and communicate events across multiple processes.

The root process (rank == 0) monitors all other processes. If a process encounters an event, it sends a message to the root process by calling monitor::report_local_event. The root process then broadcasts this information to all other processes.

It can be used to check

It uses a duplicate communicator to not interfere with other MPI communications. The communicator is freed in the finalize_communications function (which is called in the destructor if not called before).

All functions that make direct calls to the MPI C library throw an exception in case the call fails.

Definition at line 53 of file monitor.hpp.

Public Member Functions

 monitor (monitor const &)=delete
 Deleted copy constructor.
 
 monitor (mpi::communicator c)
 Construct a monitor on top of a given mpi::communicator.
 
 ~monitor ()
 Destructor calls finalize_communications().
 
bool event_on_all_ranks ()
 Check if an event has occurred on all processes.
 
bool event_on_any_rank ()
 Check if an event has occurred on any process.
 
void finalize_communications ()
 Finalize all pending communications.
 
monitoroperator= (monitor const &)=delete
 Deleted copy assignment operator.
 
void report_local_event ()
 Report a local event to the root process (rank == 0).
 

Constructor & Destructor Documentation

◆ monitor()

mpi::monitor::monitor ( mpi::communicator c)
inline

Construct a monitor on top of a given mpi::communicator.

The communicator is duplicated to not interfere with other MPI communications.

The root process (rank == 0) performs a non-blocking receive for every non-root process and waits for a non-root process to send a message that an event has occurred.

Non-root processes make two non-blocking broadcast calls and wait for the root process to broadcast a message in case an event has occurred on any or on all processes.

Parameters
cmpi::communicator.

Definition at line 104 of file monitor.hpp.

Member Function Documentation

◆ event_on_all_ranks()

bool mpi::monitor::event_on_all_ranks ( )
inlinenodiscard

Check if an event has occurred on all processes.

This function can be called on any process to check if an event has occurred on all processes.

It returns true, if an event has occurred on all processes which has already been reported to the root process and broadcasted to all other processes.

On the root process (rank == 0), it checks the status of all non-root processes and performs the necessary broadcasts in case it has not been done yet.

Returns
True, if an event has occurred on all processes.

Definition at line 202 of file monitor.hpp.

◆ event_on_any_rank()

bool mpi::monitor::event_on_any_rank ( )
inlinenodiscard

Check if an event has occurred on any process.

This function can be called on any process to check if an event has occurred somewhere.

It returns true, if

  • a local event has occurred or
  • if an event has occurred on some other process which has already been reported to the root process and broadcasted to all other processes.

On the root process (rank == 0), it checks the status of all non-root processes and performs the necessary broadcasts in case they have not been done yet.

Returns
True, if an event has occurred on any process.

Definition at line 167 of file monitor.hpp.

◆ finalize_communications()

void mpi::monitor::finalize_communications ( )
inline

Finalize all pending communications.

At the end of this function, all MPI communications have been completed and the values of the member variables will not change anymore due to some member function calls.

Furthermore, it frees the used communicator.

Definition at line 230 of file monitor.hpp.

◆ report_local_event()

void mpi::monitor::report_local_event ( )
inline

Report a local event to the root process (rank == 0).

This function can be called on any process in case a local event has occurred.

On the root process, it immediately broadcasts to all other processes that an event has occurred and further checks if all other processes have reported an event as well. If so, it additionally broadcasts to all processes that an event has occurred on all processes.

On non-root processes, it sends a message to the root process that a local event has occurred.

Definition at line 137 of file monitor.hpp.


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