ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
RuntimeErrorCollector.hpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2014-2022 The ESPResSo project
3 *
4 * This file is part of ESPResSo.
5 *
6 * ESPResSo is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * ESPResSo is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#pragma once
21
23
24#include <boost/mpi/communicator.hpp>
25
26#include <mutex>
27#include <sstream>
28#include <string>
29#include <vector>
30
31namespace ErrorHandling {
32
34public:
35 explicit RuntimeErrorCollector(boost::mpi::communicator comm);
37
38 void message(RuntimeError::ErrorLevel level, const std::string &msg,
39 const char *function, const char *file, int line);
40
41 void warning(const std::string &msg, const char *function, const char *file,
42 int line);
43
44 void error(const std::string &msg, const char *function, const char *file,
45 int line);
46
47 /**
48 * \brief Get the number of all flying messages on all nodes.
49 *
50 * @return Total number of messages.
51 */
52 int count() const;
53
54 /**
55 * \brief Get the number of messages that have at least severity
56 * @p level on this node.
57 *
58 * @param level Severity filter.
59 * @return Number of messages that match the filter.
60 */
62
63 /**
64 * @brief Reset error messages.
65 */
66 void clear();
67
68 /**
69 * @brief Flush error messages to standard error.
70 */
71 void flush();
72
73 std::vector<RuntimeError> gather();
74 void gather_local();
75
76 const boost::mpi::communicator &comm() const { return m_comm; }
77
78private:
79 mutable std::mutex mutex;
80 std::vector<RuntimeError> m_errors;
81 boost::mpi::communicator m_comm;
82};
83
84} // namespace ErrorHandling
void flush()
Flush error messages to standard error.
int count() const
Get the number of all flying messages on all nodes.
void error(const std::string &msg, const char *function, const char *file, int line)
void warning(const std::string &msg, const char *function, const char *file, int line)
const boost::mpi::communicator & comm() const
void message(RuntimeError::ErrorLevel level, const std::string &msg, const char *function, const char *file, int line)
cudaStream_t stream[1]
CUDA streams for parallel computing on CPU and GPU.