The Sparta Modeling Framework
Loading...
Searching...
No Matches
InstrumentationNode.hpp
Go to the documentation of this file.
1// <InstrumentationNode> -*- C++ -*-
2
9#pragma once
10
13#include "sparta/utils/Utils.hpp"
14
15namespace sparta {
16
17class StatisticInstance;
18
23{
24public:
25
29
34 typedef uint32_t visibility_t;
35
47
52 VIS_SUPPORT = 1000000, // 1M
53
58 VIS_DETAIL = 10000000, // 10M
59
63 VIS_NORMAL = 100000000, // 100M
64
75 VIS_SUMMARY = VIS_NORMAL * 2, // 100M * 2
76
77 /*
78 * If needed, more levels of visibility can be inserted here: VIS_SUMMARY_L2 - VIS_SUMMARY_L9
79 */
80
88 VIS_CRITICAL = 1000000000, // 1B
89
94
95 };
96
102
108
113
118 typedef uint32_t class_t;
119
126 enum Class {
131
136
141
142 CLASS_MAX = ~(class_t)0
143
144 };
145
151
157
162
195
198
202
205
210
221 TreeNode::TreeNode(std::move(rhp)),
222 visibility_(rhp.visibility_),
223 class_(rhp.class_),
224 instrument_type_(rhp.instrument_type_)
225 {
226 }
227
230
235 const std::string& name,
236 const std::string& group,
237 group_idx_type group_idx,
238 const std::string& desc,
239 Type type,
240 visibility_t visibility,
241 class_t n_class) :
242 TreeNode::TreeNode(parent, name, group, group_idx, desc),
243 visibility_(visibility),
244 class_(n_class),
245 instrument_type_(type)
246 { }
247
252 const std::string& name,
253 const std::string& group,
254 group_idx_type group_idx,
255 const std::string& desc,
256 Type type,
257 visibility_t visibility) :
258 TreeNode::TreeNode(parent, name, group, group_idx, desc),
259 visibility_(visibility),
260 class_(DEFAULT_CLASS),
261 instrument_type_(type)
262 { }
263
268 const std::string& name,
269 const std::string& group,
270 group_idx_type group_idx,
271 const std::string& desc,
272 Type type) :
273 InstrumentationNode(parent,
274 name,
275 group,
276 group_idx,
277 desc,
278 type,
281 {
282 // Delegated constructor
283 }
284
289 InstrumentationNode(const std::string& name,
290 const std::string& group,
291 group_idx_type group_idx,
292 const std::string& desc,
293 Type type) :
294 InstrumentationNode(nullptr,
295 name,
296 group,
297 group_idx,
298 desc,
299 type,
302 {
303 // Delegated constructor
304 }
305
310 InstrumentationNode(const std::string& name,
311 const std::string& group,
312 group_idx_type group_idx,
313 const std::string& desc,
314 Type type,
315 visibility_t visibility,
316 class_t n_class) :
317 InstrumentationNode(nullptr,
318 name,
319 group,
320 group_idx,
321 desc,
322 type,
323 visibility,
324 n_class)
325 {
326 // Delegated constructor
327 }
328
333 InstrumentationNode(const std::string& name,
334 const std::string& group,
335 group_idx_type group_idx,
336 const std::string& desc,
337 Type type,
338 visibility_t visibility):
339 InstrumentationNode(nullptr,
340 name,
341 group,
342 group_idx,
343 desc,
344 type,
345 visibility,
347 {
348 // Delegated constructor
349 }
350
355 const std::string& name,
356 const std::string& desc,
357 Type type) :
359 name,
362 desc,
363 type,
366 {
367 // Delegated constructor
368 }
369
374 const std::string& name,
375 const std::string& desc,
376 Type type,
377 visibility_t visibility,
378 class_t n_class) :
380 name,
383 desc,
384 type,
385 visibility,
386 n_class)
387 {
388 // Delegated constructor
389 }
390
395 const std::string& name,
396 const std::string& desc,
397 Type type,
398 visibility_t visibility):
400 name,
403 desc,
404 type,
405 visibility,
407 {
408 // Delegated constructor
409 }
410
411
416 InstrumentationNode(const std::string& name,
417 const std::string& desc,
418 Type type) :
420 name,
423 desc,
424 type,
427 {
428 // Delegated constructor
429 }
430
435 InstrumentationNode(const std::string& name,
436 const std::string& desc,
437 Type type,
438 visibility_t visibility,
439 class_t n_class) :
441 name,
444 desc,
445 type,
446 visibility,
447 n_class)
448 {
449 // Delegated constructor
450 }
451
456 InstrumentationNode(const std::string& name,
457 const std::string& desc,
458 Type type,
459 visibility_t visibility):
461 name,
464 desc,
465 type,
466 visibility,
468 {
469 // Delegated constructor
470 }
471
476 {
477 }
478
481
485
491 return visibility_;
492 }
493
499 return class_;
500 }
501
507 return instrument_type_;
508 }
509
512
516
517 virtual bool groupedPrinting(const std::vector<const StatisticInstance*> & sub_stats,
518 std::set<const void*> & dont_print_these,
519 void * grouped_json,
520 void * doc) const {
521 (void) sub_stats;
522 (void) dont_print_these;
523 (void) grouped_json;
524 (void) doc;
525 return false;
526 }
527
528 virtual bool groupedPrintingReduced(const std::vector<const StatisticInstance*> & sub_stats,
529 std::set<const void*> & dont_print_these,
530 void * grouped_json,
531 void * doc) const {
532 (void) sub_stats;
533 (void) dont_print_these;
534 (void) grouped_json;
535 (void) doc;
536 return false;
537 }
538
539 virtual bool groupedPrintingDetail(const std::vector<const StatisticInstance*> & sub_stats,
540 std::set<const void*> & dont_print_these,
541 void * grouped_json,
542 void * doc) const {
543 (void) sub_stats;
544 (void) dont_print_these;
545 (void) grouped_json;
546 (void) doc;
547 return false;
548 }
549
550 using StringPair = std::pair<std::string, std::string>;
551 const std::vector<StringPair> & getMetadata() const {
552 return metadata_;
553 }
554
557
558protected:
559
564 void addMetadata_(const std::string & key, const std::string & value){
565 metadata_.emplace_back(std::make_pair(key, value));
566 }
567
568private:
569
573 visibility_t visibility_;
574
578 class_t class_;
579
583 Type instrument_type_;
584
588 std::vector<StringPair> metadata_;
589};
590
591} // namespace sparta
592
593// __INSTRUMENTATION_NODE__
Set of macros for Sparta assertions. Caught by the framework.
Exception class for all of Sparta.
InstrumentationNode(const std::string &name, const std::string &group, group_idx_type group_idx, const std::string &desc, Type type, visibility_t visibility)
InstrumentationNode constructor with no parent Node.
InstrumentationNode()=delete
Not default-constructable.
static constexpr visibility_t CONTAINER_DEFAULT_VISIBILITY
the actual visibility that the sparta containers such as buffer, queue, and array will use when VIS_S...
Type
Instrumentation types. All subclasses will provide this type.
@ TYPE_STATISTICDEF
Statisitic definition.
@ NUM_TYPES
Maximum Type value (illegal)
@ TYPE_COUNTER
Counter (of any subclass)
@ TYPE_HISTOGRAM
Histogram Node, which should have relevant stats and counters as (indirect) children.
uint32_t visibility_t
Continuous visibility level. Several key points along continum are indicated within Visibility.
static constexpr visibility_t DEFAULT_VISIBILITY
Default node visibility.
InstrumentationNode(const std::string &name, const std::string &group, group_idx_type group_idx, const std::string &desc, Type type, visibility_t visibility, class_t n_class)
InstrumentationNode constructor with no parent Node.
visibility_t getVisibility() const
Gets the visibility hint of this node. This is invariant after construction.
InstrumentationNode(TreeNode *parent, const std::string &name, const std::string &desc, Type type, visibility_t visibility)
InstrumentationNode constructor with no group information.
InstrumentationNode(const std::string &name, const std::string &desc, Type type, visibility_t visibility)
InstrumentationNode constructor with no parent node or information.
static constexpr class_t DEFAULT_CLASS
Default node class.
InstrumentationNode(TreeNode *parent, const std::string &name, const std::string &group, group_idx_type group_idx, const std::string &desc, Type type, visibility_t visibility)
InstrumentationNode full constructor.
Visibility
Common visibility levels. Visibility is a continum (visibility can be anywhere in [0 to MAX_VISIBILIT...
@ VIS_HIDDEN
Hidden hint. Lowest possible visibility.
@ VIS_CRITICAL
2) High-importance data that end-users should always see.
@ VIS_MAX
Maximum possible visibility.
@ VIS_SUPPORT
Supporting data. Used mainly for counters which contain an intermediate value for the sole purpose of...
@ VIS_DETAIL
Detailed data. Might be confusing or esoteric for end-users.
@ VIS_SUMMARY
The next two visibility levels are for High-importance data. These are split up in the (100M,...
@ VIS_NORMAL
Normal visibility (default)
Class
Common Class levels. Class is a continum (class can be anywhere in [0 to MAX_CLASS])
@ CLASS_OTHER
Other hint. Lowest possible class.
@ CLASS_CRITICAL
important class (default)
@ CLASS_IMPORTANT
important class (default)
static constexpr visibility_t AUTO_VISIBILITY
The default sparta resource visibility value that should be used. This is an alias of VIS_MAX at the ...
InstrumentationNode(const std::string &name, const std::string &group, group_idx_type group_idx, const std::string &desc, Type type)
InstrumentationNode constructor with no parent Node.
InstrumentationNode(const InstrumentationNode &)=delete
Not copy-constructable.
InstrumentationNode & operator=(const InstrumentationNode &)=delete
Not assign-constructable.
InstrumentationNode(TreeNode *parent, const std::string &name, const std::string &desc, Type type, visibility_t visibility, class_t n_class)
InstrumentationNode constructor with no group information.
Type getInstrumentationType() const
Gets the instrumentaiton type hint of this node. This is invariant after construction.
InstrumentationNode(TreeNode *parent, const std::string &name, const std::string &group, group_idx_type group_idx, const std::string &desc, Type type, visibility_t visibility, class_t n_class)
InstrumentationNode full constructor.
static constexpr class_t CONTAINER_DEFAULT_CLASS
the actual class that the sparta containers such as buffer, queue, and array will use when CLASS_SPAR...
void addMetadata_(const std::string &key, const std::string &value)
Add any arbitrary metadata as strings to this object. Used to add extra information to statistics rep...
class_t getClass() const
Gets the class hint of this node. This is invariant after construction.
InstrumentationNode(InstrumentationNode &&rhp)
Move constructor.
virtual ~InstrumentationNode()
Virtual destructor.
InstrumentationNode(TreeNode *parent, const std::string &name, const std::string &desc, Type type)
InstrumentationNode constructor with no group information.
static constexpr class_t AUTO_CLASS
The default sparta resource class value that should be used. This is an alias of CLASS_IMPORTANT at t...
InstrumentationNode(const std::string &name, const std::string &desc, Type type, visibility_t visibility, class_t n_class)
InstrumentationNode constructor with no parent node or information.
uint32_t class_t
Continuous Class level. Several key points along continum are indicated within Class.
InstrumentationNode(const std::string &name, const std::string &desc, Type type)
InstrumentationNode constructor with no parent node or information.
InstrumentationNode(TreeNode *parent, const std::string &name, const std::string &group, group_idx_type group_idx, const std::string &desc, Type type)
InstrumentationNode full constructor.
Node in a composite tree representing a sparta Tree item.
Definition TreeNode.hpp:205
static const group_idx_type GROUP_IDX_NONE
GroupIndex indicating that a node has no group index because it belongs to no group.
Definition TreeNode.hpp:303
static constexpr char GROUP_NAME_NONE[]
Group name indicating that a node belongs to no group.
Definition TreeNode.hpp:314
uint32_t group_idx_type
Index within a group.
Definition TreeNode.hpp:261
Macros for handling exponential backoff.