The Sparta Modeling Framework
Loading...
Searching...
No Matches
ReportStatisticsAggregator.hpp
1// <ReportStatisticsAggregator> -*- C++ -*-
2
3#pragma once
4
5#include "sparta/statistics/dispatch/archives/ArchiveNode.hpp"
6#include "sparta/statistics/dispatch/archives/RootArchiveNode.hpp"
7#include "sparta/statistics/dispatch/archives/ArchiveSource.hpp"
8#include "sparta/statistics/dispatch/StatisticSnapshot.hpp"
9#include "sparta/report/Report.hpp"
10
11namespace sparta {
12namespace statistics {
13
21{
22public:
23 explicit ReportStatisticsAggregator(const Report & r) :
24 report_(r)
25 {}
26
27 //One-time initialization of this source
28 void initialize() override;
29
30 //Return the flattened StatisticInstance's that
31 //belong to this report SI aggregator. This is
32 //populated from the root Report node down to
33 //all the leaves in a depth-first traversal.
34 const std::vector<const StatisticInstance*> & getAggregatedSIs() const {
35 return aggregated_sis_;
36 }
37
38 //Get a list of all the SI's locations in this timeseries report.
39 //This is equivalent to the first row of SI information in the
40 //CSV file (dest_file: out.csv) which looks something like this:
41 //
42 // "scheduler.ticks,scheduler.picoseconds,scheduler.seconds,..."
43 const std::vector<std::string> & getStatInstLocations() const {
44 return si_locations_;
45 }
46
47 std::shared_ptr<RootArchiveNode> getRoot() {
48 return root_;
49 }
50
51 //All of this report's StatisticInstance's are copying
52 //their stat values to a fixed location in our own double
53 //vector. This occurs whenever anybody calls the SI::getValue()
54 //method, which is called for every report output/update.
55 //Our aggregated values vector is always up to date, and
56 //we can just return a reference to it.
57 const std::vector<double> & readFromSource() override {
58 return aggregated_values_;
59 }
60
61private:
62 //Create a 1-to-1 mapping between all StatisticInstance's
63 //in this report and a reference to a double value in our
64 //aggregated values vector.
65 void createSnapshotLoggers_(
66 const std::vector<const StatisticInstance*> & flattened_stat_insts);
67
68 const Report & report_;
69 std::shared_ptr<RootArchiveNode> root_;
70 std::vector<double> aggregated_values_;
71 std::vector<const StatisticInstance*> aggregated_sis_;
72 std::vector<std::string> si_locations_;
73};
74
75} // namespace statistics
76} // namespace sparta
77
Generic statistic source base class for report archives.
This class is a source of statistics values used by SPARTA simulators. It takes a sparta::Report obje...
Macros for handling exponential backoff.