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
14#include "sparta/utils/Utils.hpp"
15
16namespace sparta {
17
18class StatisticInstance;
19
24{
25public:
26
30
35 typedef uint32_t visibility_t;
36
48
53 VIS_SUPPORT = 1000000, // 1M
54
59 VIS_DETAIL = 10000000, // 10M
60
64 VIS_NORMAL = 100000000, // 100M
65
76 VIS_SUMMARY = VIS_NORMAL * 2, // 100M * 2
77
78 /*
79 * If needed, more levels of visibility can be inserted here: VIS_SUMMARY_L2 - VIS_SUMMARY_L9
80 */
81
89 VIS_CRITICAL = 1000000000, // 1B
90
95
96 };
97
103
109
114
119 typedef uint32_t class_t;
120
127 enum Class {
132
137
142
143 CLASS_MAX = ~(class_t)0
144
145 };
146
152
158
163
196
199
203
206
211
222 TreeNode::TreeNode(std::move(rhp)),
223 visibility_(rhp.visibility_),
224 class_(rhp.class_),
225 instrument_type_(rhp.instrument_type_)
226 {
227 }
228
231
236 const std::string& name,
237 const std::string& group,
238 group_idx_type group_idx,
239 const std::string& desc,
240 Type type,
241 visibility_t visibility,
242 class_t n_class) :
243 TreeNode::TreeNode(parent, name, group, group_idx, desc),
244 visibility_(visibility),
245 class_(n_class),
246 instrument_type_(type)
247 { }
248
253 const std::string& name,
254 const std::string& group,
255 group_idx_type group_idx,
256 const std::string& desc,
257 Type type,
258 visibility_t visibility) :
259 TreeNode::TreeNode(parent, name, group, group_idx, desc),
260 visibility_(visibility),
261 class_(DEFAULT_CLASS),
262 instrument_type_(type)
263 { }
264
269 const std::string& name,
270 const std::string& group,
271 group_idx_type group_idx,
272 const std::string& desc,
273 Type type) :
274 InstrumentationNode(parent,
275 name,
276 group,
277 group_idx,
278 desc,
279 type,
282 {
283 // Delegated constructor
284 }
285
290 InstrumentationNode(const std::string& name,
291 const std::string& group,
292 group_idx_type group_idx,
293 const std::string& desc,
294 Type type) :
295 InstrumentationNode(nullptr,
296 name,
297 group,
298 group_idx,
299 desc,
300 type,
303 {
304 // Delegated constructor
305 }
306
311 InstrumentationNode(const std::string& name,
312 const std::string& group,
313 group_idx_type group_idx,
314 const std::string& desc,
315 Type type,
316 visibility_t visibility,
317 class_t n_class) :
318 InstrumentationNode(nullptr,
319 name,
320 group,
321 group_idx,
322 desc,
323 type,
324 visibility,
325 n_class)
326 {
327 // Delegated constructor
328 }
329
334 InstrumentationNode(const std::string& name,
335 const std::string& group,
336 group_idx_type group_idx,
337 const std::string& desc,
338 Type type,
339 visibility_t visibility):
340 InstrumentationNode(nullptr,
341 name,
342 group,
343 group_idx,
344 desc,
345 type,
346 visibility,
348 {
349 // Delegated constructor
350 }
351
356 const std::string& name,
357 const std::string& desc,
358 Type type) :
360 name,
363 desc,
364 type,
367 {
368 // Delegated constructor
369 }
370
375 const std::string& name,
376 const std::string& desc,
377 Type type,
378 visibility_t visibility,
379 class_t n_class) :
381 name,
384 desc,
385 type,
386 visibility,
387 n_class)
388 {
389 // Delegated constructor
390 }
391
396 const std::string& name,
397 const std::string& desc,
398 Type type,
399 visibility_t visibility):
401 name,
404 desc,
405 type,
406 visibility,
408 {
409 // Delegated constructor
410 }
411
412
417 InstrumentationNode(const std::string& name,
418 const std::string& desc,
419 Type type) :
421 name,
424 desc,
425 type,
428 {
429 // Delegated constructor
430 }
431
436 InstrumentationNode(const std::string& name,
437 const std::string& desc,
438 Type type,
439 visibility_t visibility,
440 class_t n_class) :
442 name,
445 desc,
446 type,
447 visibility,
448 n_class)
449 {
450 // Delegated constructor
451 }
452
457 InstrumentationNode(const std::string& name,
458 const std::string& desc,
459 Type type,
460 visibility_t visibility):
462 name,
465 desc,
466 type,
467 visibility,
469 {
470 // Delegated constructor
471 }
472
477 {
478 }
479
482
486
492 return visibility_;
493 }
494
500 return class_;
501 }
502
508 return instrument_type_;
509 }
510
513
517
518 virtual bool groupedPrinting(const std::vector<const StatisticInstance*> & sub_stats,
519 std::set<const void*> & dont_print_these,
520 void * grouped_json,
521 void * doc) const {
522 (void) sub_stats;
523 (void) dont_print_these;
524 (void) grouped_json;
525 (void) doc;
526 return false;
527 }
528
529 virtual bool groupedPrintingReduced(const std::vector<const StatisticInstance*> & sub_stats,
530 std::set<const void*> & dont_print_these,
531 void * grouped_json,
532 void * doc) const {
533 (void) sub_stats;
534 (void) dont_print_these;
535 (void) grouped_json;
536 (void) doc;
537 return false;
538 }
539
540 virtual bool groupedPrintingDetail(const std::vector<const StatisticInstance*> & sub_stats,
541 std::set<const void*> & dont_print_these,
542 void * grouped_json,
543 void * doc) const {
544 (void) sub_stats;
545 (void) dont_print_these;
546 (void) grouped_json;
547 (void) doc;
548 return false;
549 }
550
551 using StringPair = std::pair<std::string, std::string>;
552 const std::vector<StringPair> & getMetadata() const {
553 return metadata_;
554 }
555
558
559protected:
560
565 void addMetadata_(const std::string & key, const std::string & value){
566 metadata_.emplace_back(std::make_pair(key, value));
567 }
568
569private:
570
574 visibility_t visibility_;
575
579 class_t class_;
580
584 Type instrument_type_;
585
589 std::vector<StringPair> metadata_;
590};
591
592} // namespace sparta
593
594// __INSTRUMENTATION_NODE__
Set of macros for Sparta assertions. Caught by the framework.
Exception class for all of Sparta.
Basic Node framework in sparta device tree composite pattern.
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.
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.
uint32_t visibility_t
Continuous visibility level. Several key points along continum are indicated within Visibility.
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)
uint32_t class_t
Continuous Class level. Several key points along continum are indicated within Class.
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.
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.