The Sparta Modeling Framework
Loading...
Searching...
No Matches
ExampleSimulator Class Reference

ExampleSimulator which builds the model and configures it. More...

#include <ExampleSimulation.hpp>

Inheritance diagram for ExampleSimulator:
Collaboration diagram for ExampleSimulator:

Public Member Functions

 ExampleSimulator (const std::string &topology, sparta::Scheduler &scheduler, uint32_t num_cores=1, uint64_t instruction_limit=0, bool show_factories=false)
 Construct ExampleSimulator.
 
- Public Member Functions inherited from sparta::app::Simulation
 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.
 

Additional Inherited Members

- Public Types inherited from sparta::app::Simulation
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...
 
- Protected Member Functions inherited from sparta::app::Simulation
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".
 
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:
 
- Protected Attributes inherited from sparta::app::Simulation
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

ExampleSimulator which builds the model and configures it.

Definition at line 23 of file ExampleSimulation.hpp.

Constructor & Destructor Documentation

◆ ExampleSimulator()

ExampleSimulator::ExampleSimulator ( const std::string &  topology,
sparta::Scheduler scheduler,
uint32_t  num_cores = 1,
uint64_t  instruction_limit = 0,
bool  show_factories = false 
)

Construct ExampleSimulator.

Parameters
num_coresNumber of cores to instantiate any nodes created which match the description as they are created
instruction_limitThe maximum number of instructions to run. 0 means no limit
show_factoriesPrint the registered factories to stdout

Definition at line 460 of file ExampleSimulation.cpp.

Here is the call graph for this function:

◆ ~ExampleSimulator()

ExampleSimulator::~ExampleSimulator ( )
virtual

Definition at line 525 of file ExampleSimulation.cpp.


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