The Sparta Modeling Framework
Loading...
Searching...
No Matches
sparta::app::Simulation Class Referenceabstract

Simulator which builds a sparta DeviceTree. More...

#include <Simulation.hpp>

Inheritance diagram for sparta::app::Simulation:
Collaboration diagram for sparta::app::Simulation:

Classes

class  SimulationController
 This class is used for simulation control callbacks. More...
 

Public Types

enum  CounterSemantic { CSEM_INSTRUCTIONS = 0 }
 Types of semantics attached to certain counters. It is the responsibility of subclasses to implement findSemanticCounter such taht it can satisfy requests for counters having these semantics. More...
 

Public Member Functions

 Simulation ()=delete
 Not default-constructable.
 
 Simulation (const Simulation &)=delete
 Not copy-constructable.
 
 Simulation (Simulation &&)=delete
 Not move-constructable.
 
Simulationoperator= (const Simulation &)=delete
 Not assignable.
 
 Simulation (const std::string &sim_name, Scheduler *scheduler)
 Deferred configuration constructor. Subsequent call to configure must be made before building/configuring/finalizing.
 
virtual ~Simulation ()
 Virtual destructor.
 
void setFeatureConfig (const FeatureConfiguration *feature_config)
 Set a collection of feature name-value pairs.
 
simdb::DatabaseRoot * getDatabaseRoot () const
 Get the database root for this simulation.
 
const DatabaseAccessor * getSimulationDatabaseAccessor () const
 There is a 1-to-1 mapping between a running simulation and the database it is using. Some components in the simulator may have database access, while others are not intended to use the database. This is controlled via command line arguments, and the simulation's DatabaseAccessor knows which components are DB- enabled, and which are not.
 
void configure (const int argc, char **argv, SimulationConfiguration *configuration, const bool use_pyshell=false)
 Configures the simulator after construction. Necessary only when using the simple constructor.
 
void addReport (const ReportDescriptor &rep)
 Add a report.
 
void installTaps (const log::TapDescVec &taps)
 Add new taps the the simulation immediately IF possible.
 
sparta::RootTreeNodegetRoot () noexcept
 Returns the tree root.
 
sparta::app::MetaTreeNodegetMetaParamRoot () const noexcept
 Returns the Meta TreeNode root.
 
const sparta::RootTreeNodegetRoot () const noexcept
 Returns the tree root (const)
 
sparta::SchedulergetScheduler ()
 Returns the simulation's scheduler.
 
const sparta::SchedulergetScheduler () const
 Returns the simulation's scheduler.
 
bool usingFinalConfig () const
 Returns whether or not the simulator was configured using a final configuration option, likely via the –read-final-config cml option.
 
bool readyToRun () const
 Is the framework ready to run.
 
sparta::ClockgetRootClock () noexcept
 Returns the root clock.
 
const sparta::ClockgetRootClock () const noexcept
 Returns the root clock (const)
 
sparta::ClockManagergetClockManager () noexcept
 Returns the clock manager.
 
sparta::ResourceSetgetResourceSet () noexcept
 Returns the resource set for this Simulation.
 
const std::string & getSimName () const noexcept
 Returns this simulator's name.
 
SimulationConfigurationgetSimulationConfiguration () const
 Returns this simulator's configuration.
 
const FeatureConfigurationgetFeatureConfiguration () const
 Returns this simulator's feature configuration.
 
ReportConfigurationgetReportConfiguration () const
 Get this simulator's report configuration.
 
void buildTree ()
 Builds hard-coded device tree.
 
void configureTree ()
 Configure the tree with some node-local config files, params, and node-specific parameters.
 
void finalizeTree ()
 Finalizes the device tree.
 
void finalizeFramework ()
 Finalize framework before running.
 
virtual void run (uint64_t run_time)
 Run for specified "time" or less.
 
virtual void runRaw (uint64_t run_time)
 Runs the simulation for a limited run time, returning when done.
 
virtual void asyncStop ()
 Asynchronously stop the run.
 
void dumpDebugContentIfAllowed (std::exception_ptr eptr, bool forcec=false) noexcept
 Determine if debug content needs to be dumped and dump if so. Uses dumpDebugContent to dump.
 
void saveReports ()
 Writes all reports to their respective files.
 
void postProcessingLastCall ()
 After CommandLineSimulator runs the simulation and calls all post-processing APIs, this method will be called. It is the only thing left before our destructor gets called. Do any last- minute final wrap up work if needed in this method.
 
const CounterBasefindSemanticCounter (CounterSemantic sem) const
 Get a counter by its semantic (if such a counter exists).
 
bool simulationSuccessful () const
 Was simulation successful?
 
uint64_t numFired ()
 return the number of events fired on the scheduler during simulation.
 
void enablePostRunValidation ()
 Enable post-run validation explicity.
 
std::string getPipelineCollectionPrefix () const
 Gets the pipeline collection path.
 
bool usingPyshell () const
 Was this simulation configured with a Python shell?
 
virtual sparta::control::TemporaryRunControl * getRunControlInterface ()
 Get the run control interface for this simulation. This must exist for the lifetime of this simulation.
 
void dumpMetaParameterTable (std::ostream &out) const
 Write meta-data tree parameters to given ostream.
 

Protected Member Functions

void setSimulationController_ (std::shared_ptr< SimulationController > controller)
 Set a controller to handle custom simulation events.
 
void pause_ ()
 Triggered simulation pause callback.
 
void resume_ ()
 Triggered simulation resume callback.
 
void terminate_ ()
 Triggered simulation terminate callback.
 
void customEvent_ (const std::string &event_name)
 Triggered simulation custom named event.
 
void setupControllerTriggers_ ()
 Initialization of custom simulation event triggers.
 
uint32_t dumpNonDefaultParameters_ (TreeNode *root, std::ostream &out)
 Print and count the number of Parameters which have had their values changed to something different than the default.
 
uint32_t countNonDefaultParameters_ (TreeNode *root)
 Same counting behavior as dumpNonDefaultParameters_ but does not print.
 
uint32_t reapplyVolatileParameters_ (TreeNode *root)
 Re-read volatile parameter values from the virtual tree and write them to the parmeters. This is used by simulators if special parmeter application ordering is required.
 
uint32_t reapplyAllParameters_ (TreeNode *root)
 Re-read all parameter values from the virtual tree.
 
void addTreeNodeExtensionFactory_ (const std::string &extension_name, std::function< TreeNode::ExtensionsBase *()> creator)
 Include an extension factory for this simulation's device tree nodes. They will be given to specific tree nodes right after they are instantiated. Which extension(s) go to which tree node(s) is determined by configuration files.
 
virtual void runControlLoop_ (uint64_t run_time)
 Enter run-control loop causing the simulator to run or give control to an interactive shell.
 
virtual void runRaw_ (uint64_t run_time)
 Run for specified "time".
 
virtual const CounterBasefindSemanticCounter_ (CounterSemantic sem) const
 Implements findSemanticCounter.
 
bool dumpDebugContent_ (std::string &filename, const std::string &exception, const std::string &backtrace) noexcept
 Dump debug content to a timestamped file regardless of debug-dumping control flags.
 
void delayedPeventStart_ ()
 a Callback that officially starts pevent collection.
 
void rootDescendantAdded_ (const sparta::TreeNode &node_added)
 Notification callback invoked when a new node is attached as a descendant of this simulator's root node.
 
void attachTapTo_ (const log::TapDescriptor &td, sparta::TreeNode *n)
 Creates and attaches a tap to a node based on its descriptor.
 
void attachReportTo_ (sparta::ReportRepository::DirectoryHandle directoryH, const ReportDescriptor &rd, sparta::TreeNode *n, const std::vector< std::string > &replacements)
 Creates and attaches a report to a node based on its descriptor.
 
void checkAllVirtualParamsRead_ (const ParameterTree &pt)
 Check that all virtual parameters have been read from a given tree.
 
void validateDescriptorCanBeAdded_ (const ReportDescriptor &rd, const bool using_pyshell) const
 Verify that the given report descriptor can be added to this simulation.
 
void setupReports_ ()
 Sets up all reports in this simulation. This can be called during finalization or deferred until later.
 
void setupDatabaseTriggers_ ()
 Right before the main sim loop, this method is called in order to create any SimDB triggers the simulation was configured to use. These triggers dictate when database namespace(s) are opened and closed for reads and writes via the simdb::TableProxy class.
 
ReportDescVec expandReportDescriptor_ (const ReportDescriptor &rd) const
 In the case where a comma-separated list of file formats was used to specify the output file format (i.e. 'csv, csv_cumulative'), this method will expand the report descriptors given to this simulation appropriately.
 
void setupProfilers_ ()
 Sets up any heap profiler(s) used in this simulation.
 
void setupStreamControllers_ ()
 If report statistics are being streamed out of this simulation, share the run controllers's stream controller object with each of the statistics stream root nodes. To illustrate:
 
Virtual Setup Interface
virtual void buildTree_ ()=0
 Allows implementer to create new nodes in the tree.
 
virtual void configureTree_ ()=0
 Allows implementer to manually configure the tree if required.
 
virtual void bindTree_ ()=0
 Allows implementer to bind ports to gether.
 

Protected Attributes

std::shared_ptr< SimulationControllercontroller_
 Custom controller to handle various simulation events.
 
std::vector< std::shared_ptr< trigger::ExpressionTrigger > > controller_triggers_
 Expression triggers to invoke custom simulation events via the SimulationController object.
 
sparta::ClockManager clk_manager_
 Clock manager for all clocks in simulation.
 
std::shared_ptr< sparta::MemoryProfilermemory_profiler_
 Heap profiler(s), if any.
 
std::unique_ptr< sparta::ReportRepository > report_repository_
 Repository of all reports for this simulation.
 
Backtrace backtrace_
 Backtracing utility for error signals.
 
const std::string sim_name_
 Simulation name.
 
std::vector< std::unique_ptr< sparta::log::Tap > > taps_to_del_
 User-specified Taps to delete at teardown. These should outlast the entire tree so that they can intercept destruction log messages.
 
sparta::ResourceSet res_list_
 Map of of resources available to this simulation. This must outlast destruction of the tree root_ and its children.
 
Scheduler *const scheduler_
 Scheduler this simulation will use.
 
std::unique_ptr< Report > auto_summary_report_
 Default automaticly generated report containing the entire simulation.
 
std::unique_ptr< sparta::RootTreeNodeclk_root_node_
 Root node containing the clock tree (called "clocks")
 
Clock::Handle root_clk_
 Root of clock tree (direct child of clk_root_node_). Represents hypercycles. Destruct after all nodes.
 
sparta::RootTreeNode root_
 Root of device tree: "top". Destruct after all non-root nodes (see to_delete_)
 
std::unique_ptr< MetaTreeNodemeta_
 Meta-tree containing simulation meta-information in parameters in "meta.params.fizbin". Destruct after all non-root nodes (see to_delete_)
 
std::unordered_map< std::string, std::function< TreeNode::ExtensionsBase *()> > tree_node_extension_factories_
 Tree node extension factories by name.
 
bool framework_finalized_ = false
 Has the framework been finalized.
 
std::vector< std::unique_ptr< sparta::TreeNode > > to_delete_
 Vector of TreeNodes to delete automatically at destruction. Add any nodes allocated to this list to automatically manage them.
 
SimulationConfigurationsim_config_ {nullptr}
 
const FeatureConfigurationfeature_config_ {nullptr}
 
sparta::log::Tap warn_to_cerr_
 Tap which warns to cerr.
 
std::unique_ptr< sparta::log::Tapwarn_to_file_
 Tap which, if constructed, will write all warnings to a file.
 
uint64_t num_fired_
 Total number of scheduler events firerd.
 
bool print_dag_ = false
 Should the DAG be printed after it is built.
 
bool validate_post_run_ = false
 Validate after running.
 
std::string pipeline_collection_prefix_
 Pipeline collection prefix.
 
ReportDescriptorCollection rep_descs_
 Vector of Report descriptors applicable to the simulation. These descriptors are used as the tree is built to find nodes on which to instantiate them. These are still used following building of the device tree in order to determine where the completed reports should be saved. This must be destroyed or no longer accessed once the reports_ vector is destroyed.
 
std::unique_ptr< ReportConfigurationreport_config_
 Report configuration object which wraps the simulation's ReportDescriptorCollection.
 
ExtensionDescriptorVec extension_descs_
 Keep the extension descriptors alive for the entire simulation. The Simulation base class is meant to actually allocate and own this memory (named parameter sets) even though simulation subclasses are the only ones who use these extended parameters sets.
 
std::set< std::string > nodes_given_extensions_
 
std::vector< ConfigApplicator * > user_configs_
 User configuration vector stored at "preprocessParameters".
 
bool using_final_config_ = false
 tells the simulator that we are using the final config option and need to prevent parameter set callbacks and the simulator itself cannot change parameters.
 
uint64_t pevent_warmup_icount_ = 0
 Warmup period in instructions before logging pevents.
 
SpartaHandler pevent_start_handler_
 Callback for pevent startup.
 
std::unique_ptr< trigger::CounterTrigger > pevent_start_trigger_
 An instruction trigger for observing pevent warmup.
 
std::unique_ptr< LoggingTriggerlog_trigger_
 Trigger for starting logging.
 
std::unique_ptr< trigger::Trigger > debug_trigger_
 A trigger used to turn on debug useful options at a given cycle, right now this only turns on pipeline collection.
 
bool simulation_successful_ = true
 Was simulation successful? I.e. no exceptions were thrown.
 

Detailed Description

Simulator which builds a sparta DeviceTree.

Definition at line 64 of file Simulation.hpp.

Member Enumeration Documentation

◆ CounterSemantic

Types of semantics attached to certain counters. It is the responsibility of subclasses to implement findSemanticCounter such taht it can satisfy requests for counters having these semantics.

Enumerator
CSEM_INSTRUCTIONS 

Instruction count semantic (usually core0)

Definition at line 74 of file Simulation.hpp.

Constructor & Destructor Documentation

◆ Simulation()

sparta::app::Simulation::Simulation ( const std::string &  sim_name,
Scheduler scheduler 
)

Deferred configuration constructor. Subsequent call to configure must be made before building/configuring/finalizing.

Parameters
sim_nameName of the simulator
schedulerPointer to the Scheduler that this Simulation operates with

Member Function Documentation

◆ addReport()

void sparta::app::Simulation::addReport ( const ReportDescriptor rep)

Add a report.

Precondition
Must be done before root is finalized or finalizing
Parameters
repDescriptor of report to add

◆ asyncStop()

virtual void sparta::app::Simulation::asyncStop ( )
virtual

Asynchronously stop the run.

Warning
This is not thread safe. This is just a call that can come from a signal handler or within the simulator model code to stop at the next tick boundary.

◆ attachReportTo_()

void sparta::app::Simulation::attachReportTo_ ( sparta::ReportRepository::DirectoryHandle  directoryH,
const ReportDescriptor rd,
sparta::TreeNode n,
const std::vector< std::string > &  replacements 
)
protected

Creates and attaches a report to a node based on its descriptor.

Parameters
directoryHRepository directory where the new report goes
def_fileReport definition file (.yaml)
nNode to which report should be attached
replacementsSet of replacements to give to the report definition parser as substitutions in the report name or report's local stat names
Postcondition
The report will be created and appended to the repository

◆ attachTapTo_()

void sparta::app::Simulation::attachTapTo_ ( const log::TapDescriptor td,
sparta::TreeNode n 
)
protected

Creates and attaches a tap to a node based on its descriptor.

Parameters
tdDescriptor of tap to create and attach
nNode to which tap should be attached
Postcondition
The tap will be created and appended to the taps_to_del_ list.
td will have its usage count incremented

◆ bindTree_()

virtual void sparta::app::Simulation::bindTree_ ( )
protectedpure virtual

Allows implementer to bind ports to gether.

Precondition
Tree will be finalized
Logging taps specified on the command line will be attached to appropriate nodes

◆ buildTree()

void sparta::app::Simulation::buildTree ( )

Builds hard-coded device tree.

Note
Result can be dumped with getRoot()->renderSubtree(-1, true); to show everything in the device tree.

Root will be in the TreeNode::TREE_BUILDING phase

◆ checkAllVirtualParamsRead_()

void sparta::app::Simulation::checkAllVirtualParamsRead_ ( const ParameterTree pt)
protected

Check that all virtual parameters have been read from a given tree.

Parameters
[out]ptParameterTree to inspect
Exceptions
SpartaExceptionif any parameters are unread. Exception will explain which parameter is a problem and where it came from (e.g. which file)

◆ configure()

void sparta::app::Simulation::configure ( const int  argc,
char **  argv,
SimulationConfiguration configuration,
const bool  use_pyshell = false 
)

Configures the simulator after construction. Necessary only when using the simple constructor.

Parameters
argccommand line argc (used by the python shell)
argvcommand line argv (used by the python shell)
configurationThe SimulationConfiguration object to initialize this Simulation object
use_pyshellEnable the python shell (experimental)

◆ configureTree()

void sparta::app::Simulation::configureTree ( )

Configure the tree with some node-local config files, params, and node-specific parameters.

Precondition
Tree must be in building phase. Check getRoot()->isBuilding()

Root will be in the TreeNode::TREE_CONFIGURING phase

◆ configureTree_()

virtual void sparta::app::Simulation::configureTree_ ( )
protectedpure virtual

Allows implementer to manually configure the tree if required.

Precondition
Tree will be built
Tree will have all command-line parameters applied

◆ dumpDebugContent_()

bool sparta::app::Simulation::dumpDebugContent_ ( std::string &  filename,
const std::string &  exception,
const std::string &  backtrace 
)
protectednoexcept

Dump debug content to a timestamped file regardless of debug-dumping control flags.

Parameters
filenameFilename of output or "" if output was written to cerr. Updated by this method even if the are errors
exceptionException to write at top of tile
backtraceString describing backtrace at the time the exception was thrown
Returns
true if there were no issues. False if output is possible truncated due to an internal exception

◆ dumpDebugContentIfAllowed()

void sparta::app::Simulation::dumpDebugContentIfAllowed ( std::exception_ptr  eptr,
bool  forcec = false 
)
noexcept

Determine if debug content needs to be dumped and dump if so. Uses dumpDebugContent to dump.

Parameters
[in]eptrException pointer to inspect
[in]forceForce the dump regardless of configuration

◆ dumpMetaParameterTable()

void sparta::app::Simulation::dumpMetaParameterTable ( std::ostream &  out) const

Write meta-data tree parameters to given ostream.

Parameters
[in]outosteam to which meta parameter values will be written

◆ dumpNonDefaultParameters_()

uint32_t sparta::app::Simulation::dumpNonDefaultParameters_ ( TreeNode root,
std::ostream &  out 
)
protected

Print and count the number of Parameters which have had their values changed to something different than the default.

Note
"default" refers to the parameter default OR the architecture (–arch) "default" override.
uses sparta::ParameterBase::isDefault
Returns
Number of non-default parameters

◆ enablePostRunValidation()

void sparta::app::Simulation::enablePostRunValidation ( )
inline

Enable post-run validation explicity.

Definition at line 388 of file Simulation.hpp.

◆ finalizeFramework()

void sparta::app::Simulation::finalizeFramework ( )

Finalize framework before running.

Precondition
Tree will be in the TreeNode::TREE_FINALIZED phase. Check getRoot()->isFinalized()

◆ finalizeTree()

void sparta::app::Simulation::finalizeTree ( )

Finalizes the device tree.

Precondition
Tree must be in configuring phase. Check getRoot()->isConfiguring()
Postcondition
Tree will be finalized. Check getRoot()->isFinalized()
Root will be in the TreeNode::TREE_FINALIZED phase

◆ findSemanticCounter()

const CounterBase * sparta::app::Simulation::findSemanticCounter ( CounterSemantic  sem) const
inline

Get a counter by its semantic (if such a counter exists).

Parameters
semSemantic of counter to return
Note
uses virtual findSemanticCounter_
Precondition
Simulation must be finalized and not in teardown

Definition at line 362 of file Simulation.hpp.

Here is the call graph for this function:

◆ findSemanticCounter_()

virtual const CounterBase * sparta::app::Simulation::findSemanticCounter_ ( CounterSemantic  sem) const
inlineprotectedvirtual

Implements findSemanticCounter.

Parameters
semSemantic of counter to return
Precondition
Simulation must be finalized and not in teardown
Returns
Pointer to counter with this semantic of nullptr if none. This method must return the same pointer each call.

Definition at line 656 of file Simulation.hpp.

◆ getClockManager()

sparta::ClockManager & sparta::app::Simulation::getClockManager ( )
inlinenoexcept

Returns the clock manager.

Definition at line 225 of file Simulation.hpp.

◆ getDatabaseRoot()

simdb::DatabaseRoot * sparta::app::Simulation::getDatabaseRoot ( ) const

Get the database root for this simulation.

Returns
Pointer to the DatabaseRoot

This is a container that holds all databases the simulation is using. The underlying ObjectManager methods such as getTable() and findObject() can be accessed indirectly using the ObjectDatabase class (nested class inside ObjectManager). For example, say that we ran a simulation using the –report command line option, and we want to go through the DatabaseRoot to get the StatisticInstance / reports database records:

simdb::DatabaseRoot * db_root = sim->getDatabaseRoot();
simdb::DatabaseNamespace * stats_namespace = db_root->
getNamespace("Stats");
simdb::ObjectManager::ObjectDatabase * stats_db =
stats_namespace->getDatabase();

Once you have the ObjectDatabase for the desired namespace, access the table wrappers like so:

std::unique_ptr<simdb::TableRef> ts_table =
stats_db->getTable("Timeseries");

See "simdb/include/simdb/schema/DatabaseRoot.hpp" and "simdb/include/simdb/ObjectManager.hpp" for more info about using these other classes to read and write database records in a SimDB namespace.

◆ getFeatureConfiguration()

const FeatureConfiguration * sparta::app::Simulation::getFeatureConfiguration ( ) const
inline

Returns this simulator's feature configuration.

Definition at line 247 of file Simulation.hpp.

◆ getMetaParamRoot()

sparta::app::MetaTreeNode * sparta::app::Simulation::getMetaParamRoot ( ) const
inlinenoexcept

Returns the Meta TreeNode root.

Definition at line 198 of file Simulation.hpp.

◆ getPipelineCollectionPrefix()

std::string sparta::app::Simulation::getPipelineCollectionPrefix ( ) const
inline

Gets the pipeline collection path.

Definition at line 394 of file Simulation.hpp.

◆ getReportConfiguration()

ReportConfiguration * sparta::app::Simulation::getReportConfiguration ( ) const
inline

Get this simulator's report configuration.

Definition at line 254 of file Simulation.hpp.

◆ getResourceSet()

sparta::ResourceSet * sparta::app::Simulation::getResourceSet ( )
inlinenoexcept

Returns the resource set for this Simulation.

Definition at line 228 of file Simulation.hpp.

◆ getRoot() [1/2]

const sparta::RootTreeNode * sparta::app::Simulation::getRoot ( ) const
inlinenoexcept

Returns the tree root (const)

Definition at line 201 of file Simulation.hpp.

◆ getRoot() [2/2]

sparta::RootTreeNode * sparta::app::Simulation::getRoot ( )
inlinenoexcept

Returns the tree root.

Definition at line 195 of file Simulation.hpp.

◆ getRootClock() [1/2]

const sparta::Clock * sparta::app::Simulation::getRootClock ( ) const
inlinenoexcept

Returns the root clock (const)

Definition at line 222 of file Simulation.hpp.

◆ getRootClock() [2/2]

sparta::Clock * sparta::app::Simulation::getRootClock ( )
inlinenoexcept

Returns the root clock.

Definition at line 219 of file Simulation.hpp.

◆ getRunControlInterface()

virtual sparta::control::TemporaryRunControl * sparta::app::Simulation::getRunControlInterface ( )
inlinevirtual

Get the run control interface for this simulation. This must exist for the lifetime of this simulation.

This is overridable so that simulators can instantiate and return their own run control implementation.

Definition at line 420 of file Simulation.hpp.

◆ getScheduler() [1/2]

sparta::Scheduler * sparta::app::Simulation::getScheduler ( )
inline

Returns the simulation's scheduler.

Definition at line 204 of file Simulation.hpp.

◆ getScheduler() [2/2]

const sparta::Scheduler * sparta::app::Simulation::getScheduler ( ) const
inline

Returns the simulation's scheduler.

Definition at line 207 of file Simulation.hpp.

◆ getSimName()

const std::string & sparta::app::Simulation::getSimName ( ) const
inlinenoexcept

Returns this simulator's name.

Definition at line 233 of file Simulation.hpp.

◆ getSimulationConfiguration()

SimulationConfiguration * sparta::app::Simulation::getSimulationConfiguration ( ) const
inline

Returns this simulator's configuration.

Definition at line 240 of file Simulation.hpp.

◆ installTaps()

void sparta::app::Simulation::installTaps ( const log::TapDescVec &  taps)

Add new taps the the simulation immediately IF possible.

Postcondition
Warnings will be printed directly to cerr if any taps cannot be added.
Note
These taps cannot be removed and are not tracked like those added through configure() or the constructor.

This method exists mainly to allow delayed starting of logging

◆ numFired()

uint64_t sparta::app::Simulation::numFired ( )
inline

return the number of events fired on the scheduler during simulation.

Definition at line 383 of file Simulation.hpp.

◆ readyToRun()

bool sparta::app::Simulation::readyToRun ( ) const
inline

Is the framework ready to run.

Definition at line 216 of file Simulation.hpp.

◆ reapplyAllParameters_()

uint32_t sparta::app::Simulation::reapplyAllParameters_ ( TreeNode root)
protected

Re-read all parameter values from the virtual tree.

See also
reapplyVolatileParameters_ for precondition, return, and params

◆ reapplyVolatileParameters_()

uint32_t sparta::app::Simulation::reapplyVolatileParameters_ ( TreeNode root)
protected

Re-read volatile parameter values from the virtual tree and write them to the parmeters. This is used by simulators if special parmeter application ordering is required.

Parameters
[in]rootNode at which a search for ParameterSets is started. Each ParameterSet found as an ancestor of this node will have its volatile params updated
Warning
Do not pass a Parameter node directly as it will not be updated.

◆ run()

virtual void sparta::app::Simulation::run ( uint64_t  run_time)
virtual

Run for specified "time" or less.

Precondition
Device tree and framework must be finalized. and ensure finalizeFramework is called. Check readyToRun().
Parameters
run_timescheduler run_time argument
Note
Invokes runRaw_after setting up the dag. Catches exceptions from runRaw_ and outputs summary or debug dumps as necessary

◆ runControlLoop_()

virtual void sparta::app::Simulation::runControlLoop_ ( uint64_t  run_time)
protectedvirtual

Enter run-control loop causing the simulator to run or give control to an interactive shell.

Note
Subclasses may override this method to provide custom state/setup or exception handling. This is called once per simulation lifetime.
Exceptions generated within the model should be re-thrown up to the caller of this function so that SPARTA can properly log failures and quit with a proper exit.

◆ runRaw()

virtual void sparta::app::Simulation::runRaw ( uint64_t  run_time)
virtual

Runs the simulation for a limited run time, returning when done.

This can be called multiple times for a simulator's lifetime and indicates a run of the simulator which can be interrupted by components within the simulator.

This should include no simulator-level setup code since it may be called multiple (unknown number of) times (never recursively) throughout the lifetime of the simulation.

By default, this is done through the SPARTA Scheduler. This method has no exception handling or setup. It should be overridden if the scheduler is not being used to run the simulation (e.g. simulation is functional-only and purely trace-driven).

◆ runRaw_()

virtual void sparta::app::Simulation::runRaw_ ( uint64_t  run_time)
protectedvirtual

Run for specified "time".

Precondition
Device tree and framework must be finalized. and ensure finalizeFramework is called. Check readyToRun().
Parameters
run_timescheduler run_time argument
Note
Invokes runRaw_() after setting up the dag. Catches exceptions from runRaw_() and outputs summary or debug dumps as necessary.

◆ setFeatureConfig()

void sparta::app::Simulation::setFeatureConfig ( const FeatureConfiguration feature_config)
inline

Set a collection of feature name-value pairs.

Parameters
feature_configPointer to a feature configuration class

Typically given to us by the CommandLineSimulator who populates the feature values using a command-line "feature" option.

Definition at line 110 of file Simulation.hpp.

◆ setupStreamControllers_()

void sparta::app::Simulation::setupStreamControllers_ ( )
protected

If report statistics are being streamed out of this simulation, share the run controllers's stream controller object with each of the statistics stream root nodes. To illustrate:

Simulation

  • owns a RunController
    • shares a stream controller <–|
  • owns a ReportRepository |
    • owns report / SI hierarchies |- make this connection
      • each has a root StreamNode |
        • shares a stream controller <–|

◆ simulationSuccessful()

bool sparta::app::Simulation::simulationSuccessful ( ) const
inline

Was simulation successful?

Returns
true if no exceptions were thrown; false otherwise

Definition at line 377 of file Simulation.hpp.

◆ usingFinalConfig()

bool sparta::app::Simulation::usingFinalConfig ( ) const
inline

Returns whether or not the simulator was configured using a final configuration option, likely via the –read-final-config cml option.

Definition at line 213 of file Simulation.hpp.

◆ usingPyshell()

bool sparta::app::Simulation::usingPyshell ( ) const
inline

Was this simulation configured with a Python shell?

Note
Query this after finalizeFramework() is true. Configuration of the simulator can happen after construction but always before the simulation is built (buildTree_). While finalizeFramework() becomes true much later, it is a safe place to query.

Definition at line 405 of file Simulation.hpp.

Member Data Documentation

◆ auto_summary_report_

std::unique_ptr<Report> sparta::app::Simulation::auto_summary_report_
protected

Default automaticly generated report containing the entire simulation.

Definition at line 815 of file Simulation.hpp.

◆ backtrace_

Backtrace sparta::app::Simulation::backtrace_
protected

Backtracing utility for error signals.

Definition at line 787 of file Simulation.hpp.

◆ clk_manager_

sparta::ClockManager sparta::app::Simulation::clk_manager_
protected

Clock manager for all clocks in simulation.

This can be created first and destroyed last in case there are resources/reports that still need use of the clocks

Definition at line 772 of file Simulation.hpp.

◆ clk_root_node_

std::unique_ptr<sparta::RootTreeNode> sparta::app::Simulation::clk_root_node_
protected

Root node containing the clock tree (called "clocks")

Definition at line 820 of file Simulation.hpp.

◆ controller_

std::shared_ptr<SimulationController> sparta::app::Simulation::controller_
protected

Custom controller to handle various simulation events.

Definition at line 548 of file Simulation.hpp.

◆ controller_triggers_

std::vector<std::shared_ptr<trigger::ExpressionTrigger> > sparta::app::Simulation::controller_triggers_
protected

Expression triggers to invoke custom simulation events via the SimulationController object.

Definition at line 554 of file Simulation.hpp.

◆ debug_trigger_

std::unique_ptr<trigger::Trigger> sparta::app::Simulation::debug_trigger_
protected

A trigger used to turn on debug useful options at a given cycle, right now this only turns on pipeline collection.

Definition at line 955 of file Simulation.hpp.

◆ extension_descs_

ExtensionDescriptorVec sparta::app::Simulation::extension_descs_
protected

Keep the extension descriptors alive for the entire simulation. The Simulation base class is meant to actually allocate and own this memory (named parameter sets) even though simulation subclasses are the only ones who use these extended parameters sets.

Definition at line 914 of file Simulation.hpp.

◆ feature_config_

const FeatureConfiguration* sparta::app::Simulation::feature_config_ {nullptr}
protected

Definition at line 866 of file Simulation.hpp.

◆ framework_finalized_

bool sparta::app::Simulation::framework_finalized_ = false
protected

Has the framework been finalized.

Definition at line 853 of file Simulation.hpp.

◆ log_trigger_

std::unique_ptr<LoggingTrigger> sparta::app::Simulation::log_trigger_
protected

Trigger for starting logging.

Definition at line 948 of file Simulation.hpp.

◆ memory_profiler_

std::shared_ptr<sparta::MemoryProfiler> sparta::app::Simulation::memory_profiler_
protected

Heap profiler(s), if any.

Definition at line 777 of file Simulation.hpp.

◆ meta_

std::unique_ptr<MetaTreeNode> sparta::app::Simulation::meta_
protected

Meta-tree containing simulation meta-information in parameters in "meta.params.fizbin". Destruct after all non-root nodes (see to_delete_)

Note
Created after parameter preprocessing since it has some parameters of its own.

Definition at line 841 of file Simulation.hpp.

◆ nodes_given_extensions_

std::set<std::string> sparta::app::Simulation::nodes_given_extensions_
protected

Definition at line 915 of file Simulation.hpp.

◆ num_fired_

uint64_t sparta::app::Simulation::num_fired_
protected

Total number of scheduler events firerd.

Definition at line 878 of file Simulation.hpp.

◆ pevent_start_handler_

SpartaHandler sparta::app::Simulation::pevent_start_handler_
protected

Callback for pevent startup.

Definition at line 938 of file Simulation.hpp.

◆ pevent_start_trigger_

std::unique_ptr<trigger::CounterTrigger> sparta::app::Simulation::pevent_start_trigger_
protected

An instruction trigger for observing pevent warmup.

Definition at line 943 of file Simulation.hpp.

◆ pevent_warmup_icount_

uint64_t sparta::app::Simulation::pevent_warmup_icount_ = 0
protected

Warmup period in instructions before logging pevents.

Definition at line 933 of file Simulation.hpp.

◆ pipeline_collection_prefix_

std::string sparta::app::Simulation::pipeline_collection_prefix_
protected

Pipeline collection prefix.

Definition at line 890 of file Simulation.hpp.

◆ print_dag_

bool sparta::app::Simulation::print_dag_ = false
protected

Should the DAG be printed after it is built.

Definition at line 880 of file Simulation.hpp.

◆ rep_descs_

ReportDescriptorCollection sparta::app::Simulation::rep_descs_
protected

Vector of Report descriptors applicable to the simulation. These descriptors are used as the tree is built to find nodes on which to instantiate them. These are still used following building of the device tree in order to determine where the completed reports should be saved. This must be destroyed or no longer accessed once the reports_ vector is destroyed.

Definition at line 900 of file Simulation.hpp.

◆ report_config_

std::unique_ptr<ReportConfiguration> sparta::app::Simulation::report_config_
protected

Report configuration object which wraps the simulation's ReportDescriptorCollection.

Definition at line 906 of file Simulation.hpp.

◆ report_repository_

std::unique_ptr<sparta::ReportRepository> sparta::app::Simulation::report_repository_
protected

Repository of all reports for this simulation.

Definition at line 782 of file Simulation.hpp.

◆ res_list_

sparta::ResourceSet sparta::app::Simulation::res_list_
protected

Map of of resources available to this simulation. This must outlast destruction of the tree root_ and its children.

Definition at line 804 of file Simulation.hpp.

◆ root_

sparta::RootTreeNode sparta::app::Simulation::root_
protected

Root of device tree: "top". Destruct after all non-root nodes (see to_delete_)

Definition at line 832 of file Simulation.hpp.

◆ root_clk_

Clock::Handle sparta::app::Simulation::root_clk_
protected

Root of clock tree (direct child of clk_root_node_). Represents hypercycles. Destruct after all nodes.

Definition at line 826 of file Simulation.hpp.

◆ scheduler_

Scheduler* const sparta::app::Simulation::scheduler_
protected

Scheduler this simulation will use.

Definition at line 809 of file Simulation.hpp.

◆ sim_config_

SimulationConfiguration* sparta::app::Simulation::sim_config_ {nullptr}
protected

Definition at line 863 of file Simulation.hpp.

◆ sim_name_

const std::string sparta::app::Simulation::sim_name_
protected

Simulation name.

Definition at line 792 of file Simulation.hpp.

◆ simulation_successful_

bool sparta::app::Simulation::simulation_successful_ = true
protected

Was simulation successful? I.e. no exceptions were thrown.

Definition at line 960 of file Simulation.hpp.

◆ taps_to_del_

std::vector<std::unique_ptr<sparta::log::Tap> > sparta::app::Simulation::taps_to_del_
protected

User-specified Taps to delete at teardown. These should outlast the entire tree so that they can intercept destruction log messages.

Definition at line 798 of file Simulation.hpp.

◆ to_delete_

std::vector<std::unique_ptr<sparta::TreeNode> > sparta::app::Simulation::to_delete_
protected

Vector of TreeNodes to delete automatically at destruction. Add any nodes allocated to this list to automatically manage them.

Definition at line 859 of file Simulation.hpp.

◆ tree_node_extension_factories_

std::unordered_map< std::string, std::function<TreeNode::ExtensionsBase*()> > sparta::app::Simulation::tree_node_extension_factories_
protected

Tree node extension factories by name.

Definition at line 848 of file Simulation.hpp.

◆ user_configs_

std::vector<ConfigApplicator*> sparta::app::Simulation::user_configs_
protected

User configuration vector stored at "preprocessParameters".

Note
Does not own memory.

Definition at line 921 of file Simulation.hpp.

◆ using_final_config_

bool sparta::app::Simulation::using_final_config_ = false
protected

tells the simulator that we are using the final config option and need to prevent parameter set callbacks and the simulator itself cannot change parameters.

Definition at line 928 of file Simulation.hpp.

◆ validate_post_run_

bool sparta::app::Simulation::validate_post_run_ = false
protected

Validate after running.

Definition at line 885 of file Simulation.hpp.

◆ warn_to_cerr_

sparta::log::Tap sparta::app::Simulation::warn_to_cerr_
protected

Tap which warns to cerr.

Definition at line 871 of file Simulation.hpp.

◆ warn_to_file_

std::unique_ptr<sparta::log::Tap> sparta::app::Simulation::warn_to_file_
protected

Tap which, if constructed, will write all warnings to a file.

Definition at line 876 of file Simulation.hpp.


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