detects a thrown exception and communicates to all other processes
More...
#include <dune/common/parallel/mpiguard.hh>
detects a thrown exception and communicates to all other processes
{
do_something();
guard.finalize();
guard.reactivate();
int result = do_something_else();
guard.finalize(result == success);
}
detects a thrown exception and communicates to all other processes
Definition mpiguard.hh:134
You create a MPIGuard object. If an exception is risen on a process the MPIGuard detects the exception, because the finalize method was not called. When reaching the finalize call all other processes are informed that an error occurred and the MPIGuard throws an exception of type MPIGuardError.
- Note
- You can initialize the MPIGuard from different types of communication objects:
◆ MPIGuard() [1/4]
Dune::MPIGuard::MPIGuard |
( |
bool |
active = true | ) |
|
|
inline |
◆ MPIGuard() [2/4]
Dune::MPIGuard::MPIGuard |
( |
MPIHelper & |
m, |
|
|
bool |
active = true |
|
) |
| |
|
inline |
◆ MPIGuard() [3/4]
template<class C >
Dune::MPIGuard::MPIGuard |
( |
const C & |
comm, |
|
|
bool |
active = true |
|
) |
| |
|
inline |
create an MPIGuard operating on an arbitrary communicator.
Supported types for the communication object are:
- Parameters
-
comm | reference to a communication object |
active | should the MPIGuard be active upon creation? |
◆ MPIGuard() [4/4]
Dune::MPIGuard::MPIGuard |
( |
const MPI_Comm & |
comm, |
|
|
bool |
active = true |
|
) |
| |
|
inline |
◆ ~MPIGuard()
Dune::MPIGuard::~MPIGuard |
( |
| ) |
|
|
inline |
destroy the guard and check for undetected exceptions
◆ finalize()
void Dune::MPIGuard::finalize |
( |
bool |
success = true | ) |
|
|
inline |
stop the guard.
If no success parameter is passed, the guard assumes that everything worked as planned. All errors are communicated and an exception of type MPIGuardError is thrown if an error (or exception) occurred on any of the processors in the communicator.
- Parameters
-
success | inform the guard about possible errors |
◆ reactivate()
void Dune::MPIGuard::reactivate |
( |
| ) |
|
|
inline |
reactivate the guard.
If the guard is still active finalize(true) is called first.
The documentation for this class was generated from the following file: