Sierra Toolkit  Version of the Day
RuntimeMessage.hpp
Go to the documentation of this file.
1 /*------------------------------------------------------------------------*/
2 /* Copyright 2010 Sandia Corporation. */
3 /* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */
4 /* license for use of this work by or on behalf of the U.S. Government. */
5 /* Export of this program may require a license from the */
6 /* United States Government. */
7 /*------------------------------------------------------------------------*/
8 
9 #ifndef STK_UTIL_ENVIRONMENT_RUNTIMEMESSAGE_HPP
10 #define STK_UTIL_ENVIRONMENT_RUNTIMEMESSAGE_HPP
11 
12 #include <iosfwd>
13 #include <vector>
14 #include <cstddef>
15 
16 #include <stk_util/parallel/Parallel.hpp>
17 
18 namespace stk_classic {
19 
24 
42 typedef ptrdiff_t MessageId;
43 // typedef std::vector<void *>::difference_type MessageId;
44 
55  MSG_DOOMED = 1,
58 
59  MSG_TYPE_MASK = 0x0FFFFFFF,
60  MSG_SYMMETRIC = 0x80000000,
61  MSG_DEFERRED = 0x40000000,
62  MSG_UNUSED0 = 0x20000000,
63  MSG_UNUSED1 = 0x10000000
64 };
65 
76  MSG_APPLICATION = 0,
77  MSG_TIME_STEP = 1
78 };
79 
84 struct Throttle
85 {
96  Throttle(size_t cutoff, int group)
97  : m_cutoff(cutoff),
98  m_group(group),
99  m_count(0)
100  {}
101 
102  size_t m_cutoff;
103  int m_group;
104  size_t m_count;
105 };
106 
125 {
136  MessageCode(size_t throttle_cutoff = 5, int throttle_group = MSG_APPLICATION)
137  : m_id(&m_id - (MessageId *) 0),
138  m_throttle(throttle_cutoff, throttle_group)
139  {}
140 
156  MessageCode(MessageId message_id, size_t throttle_cutoff, int throttle_group)
157  : m_id(message_id),
158  m_throttle(throttle_cutoff, throttle_group)
159  {}
160 
162 
165 };
166 
174 unsigned get_message_count(unsigned message_type);
175 
182 void reset_message_count(unsigned message_type);
183 
192 void set_max_message_count(unsigned message_type, unsigned max_count);
193 
201 unsigned get_max_message_count(unsigned message_type);
202 
210 const std::string &get_message_name(unsigned message_type);
211 
222 void register_message_type(unsigned message_type, unsigned max_count, const char *name);
223 
231 void reset_throttle_group(int throttle_group);
232 
244 void report_message(const char *message, unsigned message_type, const MessageCode &message_code);
245 
264 void add_deferred_message(int message_type, MessageId message_id, size_t throttle_cutoff, int throttle_group, const char *header, const char *aggegrate);
265 
274 
288 void aggregate_messages(ParallelMachine comm, std::ostringstream &os, const char *separator = ", ");
289 
300 std::ostream &operator<<(std::ostream &os, const MessageType &message_type);
301 
305 
306 } // namespace stk_classic
307 
308 #endif // STK_UTIL_ENVIRONMENT_RUNTIMEMESSAGE_HPP
stk_classic::reset_throttle_group
void reset_throttle_group(int throttle_group)
Function reset_message_group sets the count to zero of all messages in the specified throttle group.
Definition: RuntimeMessage.cpp:257
stk_classic::Throttle::m_count
size_t m_count
Number which have been displayed.
Definition: RuntimeMessage.hpp:104
stk_classic::MessageCode::MessageCode
MessageCode(size_t throttle_cutoff=5, int throttle_group=MSG_APPLICATION)
Definition: RuntimeMessage.hpp:136
stk_classic::aggregate_messages
void aggregate_messages(ParallelMachine comm, std::ostringstream &os, const char *separator)
Function aggregate_messages writes a message message to the output string by joining the messages fro...
Definition: RuntimeMessage.cpp:398
stk_classic::MessageId
ptrdiff_t MessageId
Typedef MessageId defines a message identifier.
Definition: RuntimeMessage.hpp:42
stk_classic::ThrottleGroup
ThrottleGroup
Enumeration ThrottleGroup lists defined throttling groups.
Definition: RuntimeMessage.hpp:75
stk_classic::Throttle::m_group
int m_group
Throttle group of message.
Definition: RuntimeMessage.hpp:103
stk_classic::MessageCode::m_throttle
Throttle m_throttle
Throttle characteristics.
Definition: RuntimeMessage.hpp:164
stk_classic::MessageType
MessageType
Enumeration MessageType declares the global message types.
Definition: RuntimeMessage.hpp:53
stk_classic::reset_message_count
void reset_message_count(unsigned message_type)
Member function reset_message_count ...
Definition: RuntimeMessage.cpp:185
stk_classic::MessageCode::MessageCode
MessageCode(MessageId message_id, size_t throttle_cutoff, int throttle_group)
Definition: RuntimeMessage.hpp:156
stk_classic::ParallelMachine
MPI_Comm ParallelMachine
Definition: Parallel.hpp:32
stk_classic::MSG_INFORMATION
Message is informational.
Definition: RuntimeMessage.hpp:57
stk_classic::Throttle::m_cutoff
size_t m_cutoff
Maximum number to display.
Definition: RuntimeMessage.hpp:102
stk_classic::register_message_type
void register_message_type(unsigned message_type, unsigned max_count, const char *name)
Member function set_message_name ...
Definition: RuntimeMessage.cpp:156
stk_classic::get_message_name
const std::string & get_message_name(unsigned message_type)
Member function get_message_name ...
Definition: RuntimeMessage.cpp:193
stk_classic::report_deferred_messages
void report_deferred_messages(ParallelMachine comm)
Function report_deferred_messages aggregates and reports the message on the root processor.
Definition: RuntimeMessage.cpp:291
stk_classic
Sierra Toolkit.
Definition: AlgorithmRunner.cpp:16
stk_classic::Throttle
Class Throttle describes the cutoff limits for a message throttle.
Definition: RuntimeMessage.hpp:84
stk_classic::add_deferred_message
void add_deferred_message(int message_type, MessageId message_id, size_t throttle_cutoff, int throttle_group, const char *header, const char *aggegrate)
Function add_deferred_message adds a message to the deferred message queue.
Definition: RuntimeMessage.cpp:267
stk_classic::MessageCode
Class MessageCode declares a message identifier and throttle characteristics for a message....
Definition: RuntimeMessage.hpp:124
stk_classic::report_message
void report_message(const char *message, unsigned message_type, const MessageCode &message_code)
Member function report_message ...
Definition: RuntimeMessage.cpp:218
stk_classic::get_message_count
unsigned get_message_count(unsigned message_type)
Member function get_message_count ...
Definition: RuntimeMessage.cpp:169
stk_classic::MSG_SYMMETRIC
Message is symmetrical.
Definition: RuntimeMessage.hpp:60
stk_classic::MSG_EXCEPTION
Message is an exception.
Definition: RuntimeMessage.hpp:56
stk_classic::MessageCode::s_defaultMessageCode
static MessageCode s_defaultMessageCode
Default message code.
Definition: RuntimeMessage.hpp:161
stk_classic::Throttle::Throttle
Throttle(size_t cutoff, int group)
Definition: RuntimeMessage.hpp:96
stk_classic::set_max_message_count
void set_max_message_count(unsigned message_type, unsigned max_count)
Member function set_max_message_count ...
Definition: RuntimeMessage.cpp:201
stk_classic::MSG_DEFERRED
Message is deferred.
Definition: RuntimeMessage.hpp:61
stk_classic::MSG_WARNING
Message is a warning.
Definition: RuntimeMessage.hpp:54
stk_classic::MessageCode::m_id
MessageId m_id
Message identifier.
Definition: RuntimeMessage.hpp:163
stk_classic::get_max_message_count
unsigned get_max_message_count(unsigned message_type)
Member function get_max_message_count ...
Definition: RuntimeMessage.cpp:210
stk_classic::MSG_DOOMED
Message is a fatal error.
Definition: RuntimeMessage.hpp:55
stk_classic::MSG_TYPE_MASK
Mask of levels.
Definition: RuntimeMessage.hpp:59