The Sparta Modeling Framework
Loading...
Searching...
No Matches
sparta::collection::PipelineCollector Class Reference

A class that facilitates all universal pipeline collection operations such as outputting finalized records, generating unique transaction Id's, maintaining heartbeat functionality, writing the location file, writing the clock file. More...

#include <PipelineCollector.hpp>

Inheritance diagram for sparta::collection::PipelineCollector:
Collaboration diagram for sparta::collection::PipelineCollector:

Public Member Functions

 PipelineCollector (const std::string &filepath, Scheduler::Tick heartbeat_interval, const sparta::Clock *root_clk, const sparta::TreeNode *root, Scheduler *scheduler=nullptr)
 Instantiate the collector with required parameters before pipeline collection can occur.
 
void destroy ()
 Teardown the pipeline collector.
 
void reactivate (const std::string &filepath)
 
void startCollection (sparta::TreeNode *starting_node)
 Turn on collection for everything below a TreeNode. Recursively transverse the tree and turn on child nodes for pipeline collection.
 
void stopCollection (sparta::TreeNode *starting_node)
 Stop pipeline collection on only those CollectableTreeNodes given.
 
void stopCollection ()
 Stop pipeline collection on only those CollectableTreeNodes that this PipelineCollector was started with.
 
void addToAutoCollection (CollectableTreeNode *ctn, SchedulingPhase collection_phase=SchedulingPhase::Tick)
 Add the CollectableTreeNode to auto collection.
 
void removeFromAutoCollection (CollectableTreeNode *ctn)
 Remove the given CollectableTreeNode from collection.
 
uint64_t getUniqueTransactionId ()
 Return a unique transaction id using a dummy counter.
 
template<class R_Type >
void writeRecord (const R_Type &dat)
 Output a finized transaction to our Outputter class.
 
uint64_t numTransactionsWritten () const
 Return the number of transactions that this singleton has passed to it's output. This is useful for testing purposes.
 
bool isCollectionActive () const
 Return true if the collector is actively collecting.
 
void printMap ()
 
const std::string & getFilePath () const
 
SchedulergetScheduler () const
 
- Public Member Functions inherited from sparta::collection::Collector
 Collector (const std::string &name)
 Construct a collector.
 
virtual ~Collector ()
 Enable polymorphism and also be nice.
 
std::string getName () const
 

Additional Inherited Members

- Protected Attributes inherited from sparta::collection::Collector
std::string name_
 

Detailed Description

A class that facilitates all universal pipeline collection operations such as outputting finalized records, generating unique transaction Id's, maintaining heartbeat functionality, writing the location file, writing the clock file.

The class must be initialized with PipelineCollector::getPipelineCollector()->init(...) before collection is to occure. This method is required to have important parameters required during pipeline collection.

This class operates on a specific scheduler specified at construction. It's implementation should not access the sparta Scheduler singleton directly.

destroy() should also be called at the end of the programs life to perform post collection maintenance. Any transactions alive at this point will have their current data written to disk with the end time as the end time of simulation. If the singleton was never initialized, destroy will have no effect.

Once the singleton is created and initialized with init pipeline collection still needs to be switched on. This can be done via the startCollection() at the treenode level. This method recursively turns on collection at and below the treenode pointer passed in.

Likewise collection can be turned off via stopCollection at any time.

Definition at line 65 of file PipelineCollector.hpp.

Constructor & Destructor Documentation

◆ PipelineCollector()

sparta::collection::PipelineCollector::PipelineCollector ( const std::string &  filepath,
Scheduler::Tick  heartbeat_interval,
const sparta::Clock root_clk,
const sparta::TreeNode root,
Scheduler scheduler = nullptr 
)
inline

Instantiate the collector with required parameters before pipeline collection can occur.

Parameters
filepathThe relative path to the output directory or file prefix.
heartbeat_intervalThe interval offset at which to write an index file (in Ticks). If 0, the heartbeat will be derived from the known clocks in the simulation.
root_clkA pointer to the clock that maintains the hyper cycle time.
rootA pointer to the root sparta::TreeNode during simulation which will be walked when producing a location map file that maps location id numbers with the sparta tree location for collected objects.
schedulerScheduler on which this collector operates. If null, uses the Scheduler belonging to root_clk. This allows us to run different pipeline collectors on different schedulers which is useful for standalone analyzers which run multiple instances of some model in parallel over the same trace data
Warning
If filepath is a directory, the directory must already exist.
Precondition
The sparta tree must be finalized.
Note
This method does NOT start collection. To start collection, call startCollection
Todo:
The multiplier should also be scaled slightly by the number of locations registered in order to better estimate the ideal heartbeat size.

Definition at line 203 of file PipelineCollector.hpp.

Here is the call graph for this function:

◆ ~PipelineCollector()

sparta::collection::PipelineCollector::~PipelineCollector ( )
inline

Definition at line 294 of file PipelineCollector.hpp.

Member Function Documentation

◆ addToAutoCollection()

void sparta::collection::PipelineCollector::addToAutoCollection ( CollectableTreeNode ctn,
SchedulingPhase  collection_phase = SchedulingPhase::Tick 
)
inline

Add the CollectableTreeNode to auto collection.

Parameters
ctnThe CollectableTreeNode that is to be collected
collection_phaseThe phase to collect the object in

Enable collection on the given CollectableTreeNode. This is a runtime call. There are some rules here:

#. The Scheduler must be finialized and simulation started #. The clock that the CollectableTreeNode belongs to must have been registered with the PipelineCollector at init time.

Definition at line 466 of file PipelineCollector.hpp.

Here is the call graph for this function:

◆ destroy()

void sparta::collection::PipelineCollector::destroy ( )
inline

Teardown the pipeline collector.

Tear down the PipelineCollector. Should be called before Tree teardown to close all open transactions.

Definition at line 309 of file PipelineCollector.hpp.

◆ getFilePath()

const std::string & sparta::collection::PipelineCollector::getFilePath ( ) const
inline
Returns
the pipeout file path

Definition at line 570 of file PipelineCollector.hpp.

◆ getScheduler()

Scheduler * sparta::collection::PipelineCollector::getScheduler ( ) const
inline
Returns
the scheduler for this collector

Definition at line 575 of file PipelineCollector.hpp.

◆ getUniqueTransactionId()

uint64_t sparta::collection::PipelineCollector::getUniqueTransactionId ( )
inline

Return a unique transaction id using a dummy counter.

Definition at line 497 of file PipelineCollector.hpp.

◆ isCollectionActive()

bool sparta::collection::PipelineCollector::isCollectionActive ( ) const
inline

Return true if the collector is actively collecting.

Will be true if there are any registered collectables that are being collected on any clock.

Note
This method should not be used to determine whether pipeline collection is running at a specific tree node location.

Definition at line 556 of file PipelineCollector.hpp.

◆ numTransactionsWritten()

uint64_t sparta::collection::PipelineCollector::numTransactionsWritten ( ) const
inline

Return the number of transactions that this singleton has passed to it's output. This is useful for testing purposes.

Definition at line 541 of file PipelineCollector.hpp.

◆ printMap()

void sparta::collection::PipelineCollector::printMap ( )
inline

Definition at line 560 of file PipelineCollector.hpp.

◆ reactivate()

void sparta::collection::PipelineCollector::reactivate ( const std::string &  filepath)
inline

Definition at line 324 of file PipelineCollector.hpp.

◆ removeFromAutoCollection()

void sparta::collection::PipelineCollector::removeFromAutoCollection ( CollectableTreeNode ctn)
inline

Remove the given CollectableTreeNode from collection.

Parameters
ctnThe CollectableTreeNode that is to be removed from collection

Disable collection on the given CollectableTreeNode. This is a runtime call. There are some rules here:

#. The Scheduler must be finialized and simulation started #. The clock that the CollectableTreeNode belongs to must have been registered with the PipelineCollector at init time.

Definition at line 485 of file PipelineCollector.hpp.

Here is the call graph for this function:

◆ startCollection()

void sparta::collection::PipelineCollector::startCollection ( sparta::TreeNode starting_node)
inline

Turn on collection for everything below a TreeNode. Recursively transverse the tree and turn on child nodes for pipeline collection.

Parameters
starting_nodeTreeNode to start collection on. This TreeNode will try to start collection as well as any node below it.
Note
The Scheduler MUST be finalized before this method is called

Definition at line 343 of file PipelineCollector.hpp.

Here is the call graph for this function:

◆ stopCollection() [1/2]

void sparta::collection::PipelineCollector::stopCollection ( )
inline

Stop pipeline collection on only those CollectableTreeNodes that this PipelineCollector was started with.

Definition at line 447 of file PipelineCollector.hpp.

◆ stopCollection() [2/2]

void sparta::collection::PipelineCollector::stopCollection ( sparta::TreeNode starting_node)
inline

Stop pipeline collection on only those CollectableTreeNodes given.

Parameters
starting_nodeThe node to shut collection down on

Definition at line 412 of file PipelineCollector.hpp.

Here is the call graph for this function:

◆ writeRecord()

template<class R_Type >
void sparta::collection::PipelineCollector::writeRecord ( const R_Type &  dat)
inline

Output a finized transaction to our Outputter class.

Parameters
datThe transaction to be outputted.
R_Typethe type of transaction struct

Definition at line 511 of file PipelineCollector.hpp.


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