The Sparta Modeling Framework
|
Instance of either a StatisticDef or CounterBase or an Expression. Has a sample window (simulator ticks) over which it will compute the value of the contained expression/counter for that range. More...
#include <StatisticInstance.hpp>
Public Member Functions | |
StatisticInstance & | operator= (const StatisticInstance &rhp) |
Assignment Operator. | |
void | setContext (const TreeNode *context) |
Set the context of this StatisticInstance (sets the scheduler) based on a TreeNode. | |
void | setContext (const Scheduler *scheduler) |
Set the Scheduler context of this StatisticInstance. | |
Construction | |
StatisticInstance (statistics::expression::Expression &&expr) | |
Construction with a predefined expression. | |
StatisticInstance (const TreeNode *node) | |
Construct with a StatisticDef or Counter as a TreeNode*. | |
StatisticInstance (const TreeNode *node, std::vector< const TreeNode * > &used) | |
Construct with a StatisticDef or Counter as a TreeNode*. | |
StatisticInstance (std::shared_ptr< StatInstCalculator > &calculator, std::vector< const TreeNode * > &used) | |
Construct with a StatInstCalculator function (wrapper around a SpartaHandler) | |
StatisticInstance (const StatisticInstance &rhp) | |
Copy Constructor. | |
StatisticInstance (StatisticInstance &&rhp) | |
Move Constructor. | |
StatisticInstance (const std::string &location, const std::string &description, const std::string &expression_str, const StatisticDef::ValueSemantic value_semantic, const InstrumentationNode::visibility_t visibility, const InstrumentationNode::class_t cls, const std::vector< std::pair< std::string, std::string > > &metadata={}) | |
Construct a StatisticInstance with its metadata values set directly, as opposed to this SI asking its underlying counter/parameter/etc. for these values. | |
StatisticInstance (const std::string &location, const std::string &description, const std::shared_ptr< StatInstCalculator > &calculator, const InstrumentationNode::visibility_t visibility=InstrumentationNode::DEFAULT_VISIBILITY, const InstrumentationNode::class_t cls=InstrumentationNode::DEFAULT_CLASS, const std::vector< std::pair< std::string, std::string > > &metadata={}) | |
Construct a StatisticInstance with its location and description set directly, along with a StatInstCalculator which can retrieve the SI value on demand from another source (such as a database file). | |
~StatisticInstance () | |
Non-Virtual destructor. | |
const std::vector< StatisticDef::PendingSubStatCreationInfo > & | getSubStatistics () const |
Get this statistic instance's list of pending substatistic information (TreeNode* and stat name), if any. | |
Computation Window | |
void | start () |
Start the computation window for this instance. | |
void | end () |
Ends the window for this instance. Computes and caches the result of the statistic. | |
Scheduler::Tick | getStart () const |
Returns the time at which this computation window was started. If started multiple times, returns the most recent start tick. | |
Scheduler::Tick | getEnd () const |
Returns the time at which ths computation window was ended. | |
Value | |
void | accumulateStatistic () const |
Tell this statistic to continually accumulate statistic values, always subtracting out the statistic value that was present when the 'start()' method was first called. | |
void | setSIValueDirectLookupPlaceholder (const std::shared_ptr< sparta::StatInstValueLookup > &direct_lookup) |
During SimDB->report generation, there is a notion of "placeholder" objects which get set on StatisticInstance/Report objects temporarily. These placeholders can be cloned into "realized" versions of themselves later on. | |
void | realizeSIValueDirectLookup (const StatInstRowIterator &si_row_iterator) |
Our StatInstValueLookup placeholder object needs to bind itself to a StatInstRowIterator object, since these two classes go hand in hand. Now that we're being given the row iterator, we can use it to "realize" our "SI direct value lookup" object now. | |
bool | isSIValueDirectLookupValid () const |
If this SI is using a StatInstValueLookup object to get its SI values, ask if this direct-lookup object can be used to get the current SI value. | |
double | getValue () const |
Returns the value computed for this statistic instance at the current time. | |
double | getInitial () const |
Returns the initial value of this instance at start_tick_. | |
double | getRawLatest () const |
Returns the Raw latest value of the this instance for whatever statistic or counter it contains. This could fiffer from getValue() since it disregards the computation window. | |
bool | supportsCompression () const |
std::string | stringize (bool show_range=true, bool resolve_subexprs=true) const |
Renders this StatisticInstance to a string containing computation window, source, and current value. | |
std::string | getExpressionString (bool show_range=true, bool resolve_subexprs=true) const |
Returns a string containing the expression that this statistic will evaluate. | |
std::string | getDesc (bool show_stat_node_expressions) const |
Returns a string that describes the statistic instance If this instance points to a TreeNode, result is that node's description. If it points to a free expression, returns the expression. | |
void | dump (std::ostream &o, bool show_range=false) const |
Renders this StatisticInstance to a string containing computation window, source, and current value. | |
void | addSnapshotLogger (statistics::StatisticSnapshot &snapshot) const |
Allow this statistic instance to emit statistic value snapshots for observation purposes. These loggers are given the current SI value with each call to getValue() | |
void | disableSnapshotLogging () const |
Remove any SI value loggers we may have been given. | |
Source Data | |
std::string | getLocation () const |
Get the location associated with this statistic instance. | |
StatisticDef::ValueSemantic | getValueSemantic () const |
Gets the statistic value semantic associated with this statistic instance. | |
InstrumentationNode::visibility_t | getVisibility () const |
Gets the visibility associated with this statistic instance. | |
InstrumentationNode::class_t | getClass () const |
Gets the Class associated with this statistic instance. | |
const std::vector< std::pair< std::string, std::string > > & | getMetadata () const |
Give the reporting infrastructure access to all metadata that has been set. The database report writers need this metadata, and others may need it as well. | |
const StatisticDef * | getStatisticDef () |
Returns the StatisticDef used to compute this statistic. | |
const StatisticDef * | getStatisticDef () const |
const Expression & | getStatisticExpression () const |
Get the underlying expression representing this SI. | |
const CounterBase * | getCounter () |
const CounterBase * | getCounter () const |
const ParameterBase * | getParameter () |
const ParameterBase * | getParameter () const |
void | getClocks (std::vector< const Clock * > &clocks) const |
Gets all clocks associated with this Statistic instance (if any) whether it points to a StatisticDef, a Counter or an anonymous Expression. | |
Instance of either a StatisticDef or CounterBase or an Expression. Has a sample window (simulator ticks) over which it will compute the value of the contained expression/counter for that range.
A StatisticInstance refers to a StatisticDef, CounterBase and uses said definition to determine inputs and evalute it's statistic function.
The overhead of distinguishing between StatisticDef and CounterBase is done here, since it is external to simulation and introduces no overhead unless this StatisticInstance is being evaluated
Internally, a StatisticInstance will store spapshot values of counters such that it can compute deltas for evaluating the statistic over the desired sample range.
Definition at line 96 of file StatisticInstance.hpp.
|
inlineexplicit |
Construction with a predefined expression.
expr | Expression reference to move |
Definition at line 131 of file StatisticInstance.hpp.
|
inlineexplicit |
Construct with a StatisticDef or Counter as a TreeNode*.
node | Must be an interface to a StatisticDef or a Counter |
Definition at line 139 of file StatisticInstance.hpp.
|
inline |
Construct with a StatisticDef or Counter as a TreeNode*.
node | Must be an interface to a StatisticDef or a Counter |
Definition at line 147 of file StatisticInstance.hpp.
sparta::StatisticInstance::StatisticInstance | ( | std::shared_ptr< StatInstCalculator > & | calculator, |
std::vector< const TreeNode * > & | used | ||
) |
Construct with a StatInstCalculator function (wrapper around a SpartaHandler)
calculator | Must be a StatInstCalculator with a non-null tree node attached to it (its 'getNode()' method will be evaluated in this constructor) |
|
inline |
Non-Virtual destructor.
Definition at line 197 of file StatisticInstance.hpp.
|
inline |
Tell this statistic to continually accumulate statistic values, always subtracting out the statistic value that was present when the 'start()' method was first called.
Definition at line 266 of file StatisticInstance.hpp.
|
inline |
Allow this statistic instance to emit statistic value snapshots for observation purposes. These loggers are given the current SI value with each call to getValue()
Definition at line 389 of file StatisticInstance.hpp.
|
inline |
Remove any SI value loggers we may have been given.
Definition at line 397 of file StatisticInstance.hpp.
void sparta::StatisticInstance::dump | ( | std::ostream & | o, |
bool | show_range = false |
||
) | const |
Renders this StatisticInstance to a string containing computation window, source, and current value.
o | ostream to which this stat instance is rendered \oaram show_range Should range information for this instance be written to o? |
void sparta::StatisticInstance::end | ( | ) |
Ends the window for this instance. Computes and caches the result of the statistic.
SpartaException | if node reference is expired (and there is a node reference) |
void sparta::StatisticInstance::getClocks | ( | std::vector< const Clock * > & | clocks | ) | const |
Gets all clocks associated with this Statistic instance (if any) whether it points to a StatisticDef, a Counter or an anonymous Expression.
clocks | Vector of clocks to which all found clocsk will be appended. This vector will not be cleared |
SpartaException | if this StatisticInstance refers to an expired TreeNode. |
|
inline |
\Returns the counter used to compute this statistic
Definition at line 470 of file StatisticInstance.hpp.
|
inline |
Definition at line 473 of file StatisticInstance.hpp.
std::string sparta::StatisticInstance::getDesc | ( | bool | show_stat_node_expressions | ) | const |
Returns a string that describes the statistic instance If this instance points to a TreeNode, result is that node's description. If it points to a free expression, returns the expression.
show_stat_node_expressions | If true, also shows expressions for nodes which are StatisticDefs |
|
inline |
Returns the time at which ths computation window was ended.
If ended once or multiple times, returns the most recent ending tick. If never ended, returns Scheduler::INDEFINITE
Definition at line 250 of file StatisticInstance.hpp.
std::string sparta::StatisticInstance::getExpressionString | ( | bool | show_range = true , |
bool | resolve_subexprs = true |
||
) | const |
Returns a string containing the expression that this statistic will evaluate.
show_range | Should the range be shown in any subexpression nodes. |
resolve_subexprs | Should any referenced statistic defs be expanded to their full expressions so that this becomes an expression containing only counters. |
|
inline |
Returns the initial value of this instance at start_tick_.
Definition at line 322 of file StatisticInstance.hpp.
std::string sparta::StatisticInstance::getLocation | ( | ) | const |
Get the location associated with this statistic instance.
For counters, returns the counter node's location. For statistic defs, returns the stat def node's location. For expression, returns "<expression>". If any referenced node is expired, returns "<expired>".
|
inline |
Give the reporting infrastructure access to all metadata that has been set. The database report writers need this metadata, and others may need it as well.
Definition at line 445 of file StatisticInstance.hpp.
|
inline |
\Returns the parameter used to compute this statistic
Definition at line 480 of file StatisticInstance.hpp.
|
inline |
Definition at line 483 of file StatisticInstance.hpp.
|
inline |
Returns the time at which this computation window was started. If started multiple times, returns the most recent start tick.
Definition at line 241 of file StatisticInstance.hpp.
|
inline |
Returns the StatisticDef used to compute this statistic.
Definition at line 452 of file StatisticInstance.hpp.
|
inline |
Definition at line 455 of file StatisticInstance.hpp.
|
inline |
Get the underlying expression representing this SI.
Definition at line 463 of file StatisticInstance.hpp.
|
inline |
Get this statistic instance's list of pending substatistic information (TreeNode* and stat name), if any.
Definition at line 203 of file StatisticInstance.hpp.
double sparta::StatisticInstance::getValue | ( | ) | const |
Returns the value computed for this statistic instance at the current time.
ReversedStatisticRange | if end tick is less than start tick |
FutureStatisticRange | StatisticRange if the end tick is finite (not Scheduler::INDEFINITE) and it is greater than the current scheduler tick (Scheduler::getCurrentTick) |
StatisticDef::ValueSemantic sparta::StatisticInstance::getValueSemantic | ( | ) | const |
Gets the statistic value semantic associated with this statistic instance.
For counters and expressions, returns StatisticDef::VS_INVALID. For expired node references, returns StatisticDef::VS_INVALID
|
inline |
Set the Scheduler context of this StatisticInstance.
scheduler | The Scheduler this SI should use |
Definition at line 515 of file StatisticInstance.hpp.
|
inline |
Set the context of this StatisticInstance (sets the scheduler) based on a TreeNode.
context | The context of this StatisticInstance based on a TreeNode |
Definition at line 505 of file StatisticInstance.hpp.
void sparta::StatisticInstance::setSIValueDirectLookupPlaceholder | ( | const std::shared_ptr< sparta::StatInstValueLookup > & | direct_lookup | ) |
During SimDB->report generation, there is a notion of "placeholder" objects which get set on StatisticInstance/Report objects temporarily. These placeholders can be cloned into "realized" versions of themselves later on.
This method lets SimDB-recreated Report objects set placeholders this SI will soon use to get SI data values directly from a SimDB blob (not from an actual simulation).
void sparta::StatisticInstance::start | ( | ) |
Start the computation window for this instance.
SpartaException | if node reference is expired (and there is a node reference) |
std::string sparta::StatisticInstance::stringize | ( | bool | show_range = true , |
bool | resolve_subexprs = true |
||
) | const |
Renders this StatisticInstance to a string containing computation window, source, and current value.
show_range | Should the range be shown in any subexpression nodes. |
resolve_subexprs | Should any referenced statistic defs be expanded to their full expressions so that this becomes an expression containing only counters. |
bool sparta::StatisticInstance::supportsCompression | ( | ) | const |
Does this StatisticInstance support compression (database)?