The Sparta Modeling Framework
Loading...
Searching...
No Matches
sparta::statistics::expression::Operation Struct Reference

Operation Node (e.g. +,-,*,/) More...

#include <ExpressionNodeTypes.hpp>

Inheritance diagram for sparta::statistics::expression::Operation:
Collaboration diagram for sparta::statistics::expression::Operation:

Public Member Functions

 Operation ()
 Default constructor with null operations and no type.
 
 Operation (const Operation &rhp)
 Copy constructor. Deep copies the operands of the operation.
 
 Operation (operation_t type, ExpressionNode *op1, ExpressionNode *op2=nullptr, ExpressionNode *op3=nullptr)
 Contruct with operation type and operands.
 
virtual Operationclone_ () const override
 Deep copy of the content of this item.
 
void addOperand (ExpressionNode *op)
 Manually add an operand.
 
virtual double evaluate_ () const override
 Compute value of this item in simulation.
 
virtual bool supportsCompression () const override
 
virtual void start () override
 
virtual void end () override
 
virtual void dump (std::ostream &o, bool show_range=true, bool resolve_subexprs=true) const override
 Dump the content of this expression item.
 
virtual void getClocks (std::vector< const Clock * > &clocks) const override
 Populates a vector with the clocks found in this subexpression node.
 
- Public Member Functions inherited from sparta::statistics::expression::ExpressionNode
 ExpressionNode (const ExpressionNode &)=delete
 No copy-constructable.
 
ExpressionNodeclone () const
 
uint32_t getStats (std::vector< const StatisticInstance * > &results) const
 Gets the statistics present in this expression.
 
double evaluate ()
 Compute value of this item in simulation. Must be implemented by subclass.
 

Public Attributes

operation_t type_
 Type of operation to perform.
 
std::vector< std::unique_ptr< ExpressionNode > > operands_
 All operands (subexpressions) in this node.
 

Detailed Description

Operation Node (e.g. +,-,*,/)

Definition at line 20 of file ExpressionNodeTypes.hpp.

Constructor & Destructor Documentation

◆ Operation() [1/3]

sparta::statistics::expression::Operation::Operation ( )
inline

Default constructor with null operations and no type.

Definition at line 35 of file ExpressionNodeTypes.hpp.

◆ Operation() [2/3]

sparta::statistics::expression::Operation::Operation ( const Operation rhp)
inline

Copy constructor. Deep copies the operands of the operation.

Definition at line 42 of file ExpressionNodeTypes.hpp.

◆ Operation() [3/3]

sparta::statistics::expression::Operation::Operation ( operation_t  type,
ExpressionNode op1,
ExpressionNode op2 = nullptr,
ExpressionNode op3 = nullptr 
)
inline

Contruct with operation type and operands.

Parameters
typeType of operation
op1Operand 1 (required). Must not be nullptr
op2Optional operand 2
op3Optional operand 3

Definition at line 59 of file ExpressionNodeTypes.hpp.

◆ ~Operation()

virtual sparta::statistics::expression::Operation::~Operation ( )
inlinevirtual

Definition at line 76 of file ExpressionNodeTypes.hpp.

Member Function Documentation

◆ addOperand()

void sparta::statistics::expression::Operation::addOperand ( ExpressionNode op)
inline

Manually add an operand.

Definition at line 86 of file ExpressionNodeTypes.hpp.

◆ clone_()

virtual Operation * sparta::statistics::expression::Operation::clone_ ( ) const
inlineoverridevirtual

Deep copy of the content of this item.

To be overridden by subclasses

Implements sparta::statistics::expression::ExpressionNode.

Definition at line 79 of file ExpressionNodeTypes.hpp.

Here is the call graph for this function:

◆ dump()

virtual void sparta::statistics::expression::Operation::dump ( std::ostream &  o,
bool  show_range = true,
bool  resolve_subexprs = true 
) const
inlineoverridevirtual

Dump the content of this expression item.

Note
Must not evaluate the expression
Parameters
oOstream to write to
show_rangeShould the range be shown in any subexpression nodes.
resolve_subexprsShould any referenced statistic defs be expanded to their full expressions so that this becomes an expression containing only counters.

Implements sparta::statistics::expression::ExpressionNode.

Definition at line 180 of file ExpressionNodeTypes.hpp.

◆ end()

virtual void sparta::statistics::expression::Operation::end ( )
inlineoverridevirtual

◆ evaluate_()

virtual double sparta::statistics::expression::Operation::evaluate_ ( ) const
inlineoverridevirtual

Compute value of this item in simulation.

Implements sparta::statistics::expression::ExpressionNode.

Definition at line 90 of file ExpressionNodeTypes.hpp.

◆ getClocks()

virtual void sparta::statistics::expression::Operation::getClocks ( std::vector< const Clock * > &  clocks) const
inlineoverridevirtual

Populates a vector with the clocks found in this subexpression node.

Parameters
clocksVector of clocks to which any found clocks will be appended. This vector is not cleared.

Implements sparta::statistics::expression::ExpressionNode.

Definition at line 209 of file ExpressionNodeTypes.hpp.

◆ start()

virtual void sparta::statistics::expression::Operation::start ( )
inlineoverridevirtual

◆ supportsCompression()

virtual bool sparta::statistics::expression::Operation::supportsCompression ( ) const
inlineoverridevirtual

Every SI needs to make an estimation (ahead of simulation) whether it's a good candidate for compression or not. There are some obvious good choices such as integral counters and constants. As for generic StatisticDef expressions, we make an estimation that we are a good candidate for compression if all of our operands say that they support compression, and this SI expression does NOT have a divide anywhere in it.

                                          Compress it?

"counterA + counterB" yes

"counterA * counterB" yes

"statdefA - statdefB" depends on what those statdef's are going to do

"counterA / counterB" NO

The rational for not trying to compress an SI with a divide in its expression is that double-precision values tend to compress less than integral values do. The zlib compression library supports a small variety of compression algorithms however, and we should try them all. If RLE is used, doubles may not be worth the performance hit. But this is under design / up in the air at the moment, and is implementation detail to the outside world either way.

Implements sparta::statistics::expression::ExpressionNode.

Definition at line 142 of file ExpressionNodeTypes.hpp.

Member Data Documentation

◆ operands_

std::vector<std::unique_ptr<ExpressionNode> > sparta::statistics::expression::Operation::operands_

All operands (subexpressions) in this node.

Definition at line 30 of file ExpressionNodeTypes.hpp.

◆ type_

operation_t sparta::statistics::expression::Operation::type_

Type of operation to perform.

Definition at line 25 of file ExpressionNodeTypes.hpp.


The documentation for this struct was generated from the following file: