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
11#include <vector>
12#include <utility>
13
17#include "sparta/utils/Utils.hpp"
18
19namespace sparta {
20
21class StatisticInstance;
22
27{
28public:
29
33
38 typedef uint32_t visibility_t;
39
51
56 VIS_SUPPORT = 1000000, // 1M
57
62 VIS_DETAIL = 10000000, // 10M
63
67 VIS_NORMAL = 100000000, // 100M
68
79 VIS_SUMMARY = VIS_NORMAL * 2, // 100M * 2
80
81 /*
82 * If needed, more levels of visibility can be inserted here: VIS_SUMMARY_L2 - VIS_SUMMARY_L9
83 */
84
92 VIS_CRITICAL = 1000000000, // 1B
93
98
99 };
100
106
112
117
122 typedef uint32_t class_t;
123
130 enum Class {
135
140
145
146 CLASS_MAX = ~(class_t)0
147
148 };
149
155
161
166
199
205 using StringPair = std::pair<std::string, std::string>;
206 using MetadataPairs = std::vector<StringPair>;
207
210
214
217
222
233 TreeNode::TreeNode(std::move(rhp)),
234 meta_data_(std::move(rhp.meta_data_)),
235 visibility_(rhp.visibility_),
236 class_(rhp.class_),
237 instrument_type_(rhp.instrument_type_)
238 {
239 }
240
243
248 const std::string& name,
249 const std::string& group,
250 group_idx_type group_idx,
251 const std::string& desc,
252 Type type,
253 visibility_t visibility,
254 class_t n_class) :
255 TreeNode::TreeNode(parent, name, group, group_idx, desc),
256 visibility_(visibility),
257 class_(n_class),
258 instrument_type_(type)
259 { }
260
265 const std::string& name,
266 const std::string& group,
267 group_idx_type group_idx,
268 const std::string& desc,
269 Type type,
270 visibility_t visibility) :
271 TreeNode::TreeNode(parent, name, group, group_idx, desc),
272 visibility_(visibility),
273 class_(DEFAULT_CLASS),
274 instrument_type_(type)
275 { }
276
281 const std::string& name,
282 const std::string& group,
283 group_idx_type group_idx,
284 const std::string& desc,
285 Type type) :
286 InstrumentationNode(parent,
287 name,
288 group,
289 group_idx,
290 desc,
291 type,
294 {
295 // Delegated constructor
296 }
297
302 InstrumentationNode(const std::string& name,
303 const std::string& group,
304 group_idx_type group_idx,
305 const std::string& desc,
306 Type type) :
307 InstrumentationNode(nullptr,
308 name,
309 group,
310 group_idx,
311 desc,
312 type,
315 {
316 // Delegated constructor
317 }
318
323 InstrumentationNode(const std::string& name,
324 const std::string& group,
325 group_idx_type group_idx,
326 const std::string& desc,
327 Type type,
328 visibility_t visibility,
329 class_t n_class) :
330 InstrumentationNode(nullptr,
331 name,
332 group,
333 group_idx,
334 desc,
335 type,
336 visibility,
337 n_class)
338 {
339 // Delegated constructor
340 }
341
346 InstrumentationNode(const std::string& name,
347 const std::string& group,
348 group_idx_type group_idx,
349 const std::string& desc,
350 Type type,
351 visibility_t visibility):
352 InstrumentationNode(nullptr,
353 name,
354 group,
355 group_idx,
356 desc,
357 type,
358 visibility,
360 {
361 // Delegated constructor
362 }
363
368 const std::string& name,
369 const std::string& desc,
370 Type type) :
372 name,
375 desc,
376 type,
379 {
380 // Delegated constructor
381 }
382
387 const std::string& name,
388 const std::string& desc,
389 Type type,
390 visibility_t visibility,
391 class_t n_class) :
393 name,
396 desc,
397 type,
398 visibility,
399 n_class)
400 {
401 // Delegated constructor
402 }
403
408 const std::string& name,
409 const std::string& desc,
410 Type type,
411 visibility_t visibility):
413 name,
416 desc,
417 type,
418 visibility,
420 {
421 // Delegated constructor
422 }
423
424
429 InstrumentationNode(const std::string& name,
430 const std::string& desc,
431 Type type) :
433 name,
436 desc,
437 type,
440 {
441 // Delegated constructor
442 }
443
448 InstrumentationNode(const std::string& name,
449 const std::string& desc,
450 Type type,
451 visibility_t visibility,
452 class_t n_class) :
454 name,
457 desc,
458 type,
459 visibility,
460 n_class)
461 {
462 // Delegated constructor
463 }
464
469 InstrumentationNode(const std::string& name,
470 const std::string& desc,
471 Type type,
472 visibility_t visibility):
474 name,
477 desc,
478 type,
479 visibility,
481 {
482 // Delegated constructor
483 }
484
489 {
490 }
491
494
498
504 return visibility_;
505 }
506
512 return class_;
513 }
514
520 return instrument_type_;
521 }
522
525
529
530 virtual bool groupedPrinting(const std::vector<const StatisticInstance*> & sub_stats,
531 std::set<const void*> & dont_print_these,
532 void * grouped_json,
533 void * doc) const {
534 (void) sub_stats;
535 (void) dont_print_these;
536 (void) grouped_json;
537 (void) doc;
538 return false;
539 }
540
541 virtual bool groupedPrintingReduced(const std::vector<const StatisticInstance*> & sub_stats,
542 std::set<const void*> & dont_print_these,
543 void * grouped_json,
544 void * doc) const {
545 (void) sub_stats;
546 (void) dont_print_these;
547 (void) grouped_json;
548 (void) doc;
549 return false;
550 }
551
552 virtual bool groupedPrintingDetail(const std::vector<const StatisticInstance*> & sub_stats,
553 std::set<const void*> & dont_print_these,
554 void * grouped_json,
555 void * doc) const {
556 (void) sub_stats;
557 (void) dont_print_these;
558 (void) grouped_json;
559 (void) doc;
560 return false;
561 }
562
563 const MetadataPairs & getMetadata() const {
564 return meta_data_;
565 }
566
569
570protected:
571
576 MetadataPairs meta_data_;
577
578private:
579
583 visibility_t visibility_;
584
588 class_t class_;
589
593 Type instrument_type_;
594};
595
596} // namespace sparta
597
598// __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.
MetadataPairs meta_data_
Add any arbitrary metadata as strings to this object. Used to add extra information to statistics rep...
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.
std::pair< std::string, std::string > StringPair
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...
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:204
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:302
static constexpr char GROUP_NAME_NONE[]
Group name indicating that a node belongs to no group.
Definition TreeNode.hpp:313
uint32_t group_idx_type
Index within a group.
Definition TreeNode.hpp:260
Macros for handling exponential backoff.