ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
|
Handle exceptions thrown in MPI parallel code. More...
#include <ParallelExceptionHandler.hpp>
Public Member Functions | |
ParallelExceptionHandler (boost::mpi::communicator comm) | |
template<typename T > | |
void | parallel_try_catch (std::function< void()> const &callback) const |
Handle exceptions in synchronous code. | |
Handle exceptions thrown in MPI parallel code.
Instantiate this class inside the catch block and after the catch block, like so:
Exceptions are handled as follows:
std::runtime_error
, throw Exception on all other ranksThrowing a Exception guarantees that the partially initialized script interface object won't be registered in the GlobalContext dictionary; this is the only side-effect on worker nodes, since the exception itself is otherwise silently ignored. On the main rank, the thrown exception is converted to a Python exception.
Definition at line 58 of file ParallelExceptionHandler.hpp.
|
inline |
Definition at line 60 of file ParallelExceptionHandler.hpp.
|
inline |
Handle exceptions in synchronous code.
Error messages queued in the runtime error collector are flushed to standard error if the code throws on any rank.
callback
cannot invoke remote functions from the Communication::MpiCallbacks framework due to blocking communication (risk of MPI deadlock on worker nodes). [in] | callback | Callback to execute synchronously on all ranks. |
Definition at line 74 of file ParallelExceptionHandler.hpp.
References ScriptInterface::get_value().
Referenced by ScriptInterface::GlobalContext::parallel_try_catch(), and ScriptInterface::LocalContext::parallel_try_catch().