QMCPACK
UniformCommunicateError.h
Go to the documentation of this file.
1 //////////////////////////////////////////////////////////////////////////////////////
2 // This file is distributed under the University of Illinois/NCSA Open Source License.
3 // See LICENSE file in top directory for details.
4 //
5 // Copyright (c) 2020 QMCPACK developers.
6 //
7 // File developed by: Peter Doak, doakpw@ornl.gov, Oak Ridge National Lab
8 //
9 // File created by: Peter Doak, doakpw@ornl.gov, Oak Ridge National Lab
10 //////////////////////////////////////////////////////////////////////////////////////
11 #ifndef QMCPLUSPLUS_UNIFORMCOMMUNICATEERROR_H
12 #define QMCPLUSPLUS_UNIFORMCOMMUNICATEERROR_H
13 #include <stdexcept>
14 
15 namespace qmcplusplus
16 {
17 /** This a subclass for runtime errors that will occur on all ranks.
18  *
19  * This is intended to be thrown and caught within a single Communicate context.
20  *
21  * Intended use is with a catch block like this:
22  *
23  * catch (const UniformMPIerror& ue)
24  * {
25  * my_local_comm->barrier_and_abort(ue.what());
26  * }
27  *
28  * Which insures that the error message actually makes it out on the head
29  * rank before the MPI processes are aborted.
30  *
31  * If even one member of the comm i.e. my_local_comm does not experience the issue
32  * you will HANG the job until the walltime expires. When in doubt it is better
33  * to lose the error message until the crash is examined in a debugger.
34  *
35  * Because of this you should catch the exception as soon as you have access to a Communicate
36  * instance. However unlike the unit test hostile `comm->barrier_and_abort` you can and
37  * should check that an exception is emitted so don't catch it in the same method/function.
38  */
39 class UniformCommunicateError : public std::runtime_error
40 {
41 public:
42  UniformCommunicateError(const std::string& what_arg) : std::runtime_error(what_arg) {}
43  UniformCommunicateError(const char* what_arg) : std::runtime_error(what_arg) {}
44 };
45 
46 } // namespace qmcplusplus
47 
48 #endif
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
UniformCommunicateError(const std::string &what_arg)
This a subclass for runtime errors that will occur on all ranks.