The Sparta Modeling Framework
Loading...
Searching...
No Matches
sparta::statistics::ArchiveNode Class Reference

When a simulation is configured to archive its statistics values, it will build a subset of its device tree to organize the statistics. The analogy is that a TreeNode is loosely the same as an ArchiveNode: More...

#include <ArchiveNode.hpp>

Inheritance diagram for sparta::statistics::ArchiveNode:

Public Member Functions

 ArchiveNode ()=default
 
 ArchiveNode (const std::string &name)
 Construct a named node.
 
 ArchiveNode (const std::string &name, const StatisticInstance *)
 
 ArchiveNode (const std::string &name, const Report *)
 
const std::string & getName () const
 Return the name that this node was originally created with.
 
void setLeafIndex (const size_t index)
 
std::vector< std::shared_ptr< ArchiveNode > > & getChildren ()
 
const std::vector< std::shared_ptr< ArchiveNode > > & getChildren () const
 
void setParent (std::shared_ptr< ArchiveNode > &parent)
 
void setParent (ArchiveNode *parent)
 
RootArchiveNodegetRoot ()
 
bool isLeaf () const
 
bool canAccessDataSeries () const
 
ArchiveDataSeriescreateDataSeries ()
 
size_t getTotalNumLeaves () const
 

Protected Attributes

std::string name_
 
std::vector< std::shared_ptr< ArchiveNode > > children_
 

Friends

class boost::serialization::access
 

Detailed Description

When a simulation is configured to archive its statistics values, it will build a subset of its device tree to organize the statistics. The analogy is that a TreeNode is loosely the same as an ArchiveNode:

top.core0.rob.stats.total_number_retired  (device tree)
top.core0.rob.total_number_retired (archive tree)
...

The archive tree will strictly be a subset of the full device tree.

Definition at line 29 of file ArchiveNode.hpp.

Constructor & Destructor Documentation

◆ ArchiveNode() [1/3]

sparta::statistics::ArchiveNode::ArchiveNode ( )
default

Default constructor should only be used by Boost serialization code. Boost will build up the archive tree from a metadata file piecemeal. First it will create an ArchiveNode with no ctor arguments, then it will fill in the rest (name, children, ...)

◆ ArchiveNode() [2/3]

sparta::statistics::ArchiveNode::ArchiveNode ( const std::string &  name,
const StatisticInstance  
)
inline

Archive trees are built with the help of the ReportStatisticsHierTree class. That class is templated on ArchiveNode, and needs a constructor that takes a name and an SI. For our case, we don't use the SI for anything, but we still have this constructor to make ReportStatisticsHierTree happy.

Definition at line 48 of file ArchiveNode.hpp.

◆ ArchiveNode() [3/3]

sparta::statistics::ArchiveNode::ArchiveNode ( const std::string &  name,
const Report *   
)
inline

See the comment above for the ArchiveNode(string, SI*) constructor. This constructor is here just to make the ArchiveNode class conform to the ReportStatisticsHierTree template code so we can reuse that tree builder class.

Definition at line 57 of file ArchiveNode.hpp.

Member Function Documentation

◆ canAccessDataSeries()

bool sparta::statistics::ArchiveNode::canAccessDataSeries ( ) const
inline

Only nodes that are both leaves, and that have had their leaf index assigned to them, are able to access SI data.

Definition at line 133 of file ArchiveNode.hpp.

Here is the call graph for this function:

◆ createDataSeries()

ArchiveDataSeries * sparta::statistics::ArchiveNode::createDataSeries ( )

Ask a leaf node to create an ArchiveDataSeries object. This object can be used to get individual SI values out of the archive. This method will throw if canAccessDataSeries() is FALSE.

◆ getChildren() [1/2]

std::vector< std::shared_ptr< ArchiveNode > > & sparta::statistics::ArchiveNode::getChildren ( )
inline

Definition at line 96 of file ArchiveNode.hpp.

◆ getChildren() [2/2]

const std::vector< std::shared_ptr< ArchiveNode > > & sparta::statistics::ArchiveNode::getChildren ( ) const
inline

Definition at line 100 of file ArchiveNode.hpp.

◆ getName()

const std::string & sparta::statistics::ArchiveNode::getName ( ) const
inline

Return the name that this node was originally created with.

Definition at line 65 of file ArchiveNode.hpp.

◆ getRoot()

RootArchiveNode * sparta::statistics::ArchiveNode::getRoot ( )

All archive trees have a root node. This is different than a regular ArchiveNode in that the RootArchiveNode:

  • Holds onto all shared metadata that is common to the tree nodes
  • Holds an ArchiveController object which can be used to synchronize the archive sources/sinks and save the archives to a specific directory

This is lazily evaluated and then cached.

◆ getTotalNumLeaves()

size_t sparta::statistics::ArchiveNode::getTotalNumLeaves ( ) const
inline

Returns the total number of leaf nodes from this node on down. For example:

          A
    -------------
     |         |
     B         C
            -------
             |   |
             D   E

 Node:        Num leaves:
 ------       ------------
 A            3
 B            1
 C            2
 D            1
 E            1 

Definition at line 161 of file ArchiveNode.hpp.

◆ isLeaf()

bool sparta::statistics::ArchiveNode::isLeaf ( ) const
inline

Only leaf nodes have any data. Ask this node if it is a leaf. This is different from "do you have any data?" - leaves can have no data if the simulation hasn't even logged one report update yet.

Definition at line 127 of file ArchiveNode.hpp.

◆ setLeafIndex()

void sparta::statistics::ArchiveNode::setLeafIndex ( const size_t  index)
inline

In every archive tree, all leaf nodes need to know their "leaf index", which is a 0-based index assigned in depth- first traversal of the tree. For example:

          A
    -------------
     |         |
     B         C
            -------
             |   |
             D   E

Here, nodes A/C would not have a leaf index, because they are not leaves. But the others would have:

 Node:        Leaf index:
 ------       ------------
 B            0
 D            1
 E            2

Leaves use this index to figure out their byte offset in the underlying contiguous array of SI values.

Definition at line 92 of file ArchiveNode.hpp.

◆ setParent() [1/2]

void sparta::statistics::ArchiveNode::setParent ( ArchiveNode parent)
inline

Definition at line 108 of file ArchiveNode.hpp.

◆ setParent() [2/2]

void sparta::statistics::ArchiveNode::setParent ( std::shared_ptr< ArchiveNode > &  parent)
inline

Definition at line 104 of file ArchiveNode.hpp.

Friends And Related Symbol Documentation

◆ boost::serialization::access

friend class boost::serialization::access
friend

The archive directories contain the following structure:

  • ArchiveDir
    • archive_tree.bin
    • values.bin
  • AnotherArchiveDir
    • archive_tree.bin
    • values.bin

We let Boost call this same serialize() method whether we are writing to disk or reading from disk.

Definition at line 204 of file ArchiveNode.hpp.

Member Data Documentation

◆ children_

std::vector<std::shared_ptr<ArchiveNode> > sparta::statistics::ArchiveNode::children_
protected

Same as 'name_', the children_ vector is protected to make the subclass Boost serialization routines easier to manage.

Definition at line 179 of file ArchiveNode.hpp.

◆ name_

std::string sparta::statistics::ArchiveNode::name_
protected

This property is protected so that subclasses can write their Boost serialization routines as simply as "archive & name_" and not fuss with setter and getter methods.

Definition at line 174 of file ArchiveNode.hpp.


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