The Sparta Modeling Framework
|
Command line simulator front-end class with argument parsing Works in conjunction with sparta::app::Simulation. More...
#include <CommandLineSimulator.hpp>
Public Member Functions | |
CommandLineSimulator ()=delete | |
Not default constructable. | |
CommandLineSimulator (const std::string &usage, const DefaultValues &defs=DEFAULTS) | |
Construct. | |
virtual | ~CommandLineSimulator () |
Destructor. | |
bool | isParsed () const |
Has this simulator parsed the command line yet Being parsed is required to call for populateSimulation. | |
bool | isSetup () const |
Has this simulator been setup yet? Being set up is required to call runSimulator. | |
const std::string & | getUsage () const |
Gets the usage string specified for this simulator at construction. This string is printed when usage errors are encountered. | |
const MultiDetailOptions & | getSpartaOptions () const |
Gets the sparta-specific options for this simulator. | |
MultiDetailOptions & | getApplicationOptions () |
Gets the application-specific options for this simulator. | |
MultiDetailOptions & | getAdvancedOptions () |
Gets the advanced options for this simulator. | |
po::positional_options_description & | getPositionalOptions () |
Gets the boost positional options for the parser owned by this simulator. | |
const po::variables_map & | getVariablesMap () const |
Variables map populated by command-line parsing. This map is populated within the parse() method. | |
bool | parse (int argc, char **argv, int &err_code) |
Parse command line options. | |
int | parse (int argc, char **argv) |
DEPRECATED Shorthand version of other parse method,. | |
void | populateSimulation (Simulation *sim) |
Builds the content of the simulator making it ready to run. | |
void | runSimulator (Simulation *sim) |
Run the simulator. | |
void | runSimulator (Simulation *sim, uint64_t ticks) |
Run the simulator for the specified number of ticks. | |
void | postProcess (Simulation *sim) |
Post-process the results of the simulation if applicable. | |
bool | isRuntimeFinite () const |
SimulationConfiguration & | getSimulationConfiguration () |
const SimulationConfiguration & | getSimulationConfiguration () const |
Static Public Attributes | |
static DefaultValues | DEFAULTS |
Static DefaultValues for a SPARTA CommandLineSimulator. | |
Protected Member Functions | |
void | populateSimulation_ (Simulation *sim) |
Implements populateSimulation. | |
void | runSimulator_ (Simulation *sim, uint64_t ticks) |
Implements runSimulator. | |
void | postProcess_ (Simulation *sim) |
Implements postProcess. | |
virtual void | postParse_ (po::basic_parsed_options< char > &opts) |
Callback before interpreting command parsed command line tokens. | |
Protected Attributes | |
SimulationConfiguration | sim_config_ |
Simulation configuration including default values. | |
FeatureConfiguration | feature_config_ |
Simulation feature configuration. | |
const std::string | usage_ |
Usage string specified at construction. | |
int | argc_ = 0 |
argc from main | |
char ** | argv_ = nullptr |
argv from main | |
ReportDescVec | reports_ |
Vector of Report descriptors to instantiate on the simulator. | |
std::vector< std::string > | report_descriptor_def_files_ |
Vector of report descriptor definition files (YAML) | |
app::ReportYamlReplacements | report_yaml_placeholder_replacements_ |
Vector of yaml placeholder key-value pairs. These will be applied to the yamls given by "--report my_report_info.yaml". | |
std::unordered_map< std::string, app::ReportYamlReplacements > | report_specific_yaml_placeholder_replacements_ |
Map to hold report-specific yaml placeholder key-value pairs. An example usage might be: <sim> –report foo.yaml rep1.yaml –report bar.yaml rep2.yaml Where 'rep1.yaml' contains key-value replacements specifically for descriptor file 'foo.yaml', and 'rep2.yaml' contains those specifically for descriptor file 'bar.yaml'. | |
bool | is_parsed_ = false |
Have the command line options been parsed yet by this class through the parse method. | |
bool | is_setup_ = false |
Has the simulator been setup through the populateSimulation method. | |
uint64_t | run_time_cycles_ = sparta::Scheduler::INDEFINITE |
Run-time user parameter. | |
uint64_t | run_time_ticks_ = sparta::Scheduler::INDEFINITE |
bool | no_run_mode_ = false |
Is this simulator in no-run mode where it quits just before finalization. | |
std::string | final_config_file_ |
Destination to which final configuration (before running) will be written ("" if not written) | |
std::string | read_final_config_ = "" |
The file to read from for reading in a final config file. | |
uint32_t | config_applicators_used_ = 0 |
number of non-final configuration applications used to modify parameters. A tally of all -p, –arch, –config-file. Does not include –read-final-config | |
std::string | power_config_file_ |
Destination to which power configuration (to be read by power model) will be written ("" if not written) | |
std::string | final_config_file_verbose_ |
Destination to which final configuration (before running) will be written ("" if not written). This file will also include descriptions of each parameter preceeding them with extra newlines. | |
bool | no_show_config_ = false |
Should the trivialities of simulator configuration (e.g what command line options were specified) be hidden? | |
bool | show_tree_ = false |
Display the device tree at every opportunity. | |
bool | show_parameters_ = false |
Display all parameters in the device tree after building. | |
bool | show_ports_ = false |
Display all ports in the device tree after finalization. | |
bool | show_counters_ = false |
Display all counters and stats in the device tree after finalization. | |
bool | show_clocks_ = false |
Display all the clocks in the tree. | |
bool | show_pevents_ = false |
Display all the pevent types in the tree. | |
bool | show_notifications_ = false |
Display all notifications in the device tree after finalization excluding log messages. | |
bool | show_loggers_ = false |
Display all notifications in the device tree after finalization excluding log messages. | |
bool | show_hidden_ = false |
Show hidden treenodes when displaying the device tree. | |
bool | disable_colors_ = false |
Show hidden treenodes when displaying the device tree. | |
std::string | dump_debug_type_ {"error"} |
Under what conditions should the debug content be dumped at simulator destruction. {always,never,error}. | |
std::string | debug_dump_options_ {"all"} |
When a simulation error occurs and error logging is enabled, what content should the error log contain? | |
std::unique_ptr< sparta::trigger::Triggerable > | pipeline_collection_triggerable_ |
Instance of the pipeline collector if collection enabled. | |
std::unique_ptr< sparta::trigger::Trigger > | pipeline_trigger_ |
std::unique_ptr< sparta::InformationWriter > | info_out_ |
std::string | pipeline_heartbeat_ = DefaultHeartbeat |
Heartbeat period of pipeline collection file (before lexical cast or validation) | |
std::set< std::string > | pipeline_enabled_node_names_ |
The names of the nodes to be enabled. | |
std::unique_ptr< sparta::trigger::Triggerable > | pevent_trigger_ |
The filename to log pevents too. | |
pevents::PeventCollectorController | pevent_controller_ |
a pevent controller is used to parse in pevent on and off commands, and prepare collection for the specified pevent types, this is different than pevent trigger because the controller only preps collectors, the trigger actually starts the trigger | |
bool | run_pevents_ = false |
std::string | runtime_clock_ |
The runtime clock to use for -r option. | |
std::string | auto_summary_ |
Automatic summary state. Determines what to do with the automatic summary after running. | |
std::string | help_topic_ |
Help topic to show. | |
Command line simulator front-end class with argument parsing Works in conjunction with sparta::app::Simulation.
This class is extensible by clients by adding to its construction options before parsing (see parse) or by subclassing.
This class is intended to contain redundant sparta-enabled simulator code into a single set of classes to reduce the work necessary when implementing new simulators or maintaining a set of simulators and tests.
Additionally, this class helps ensure that the command-line look and feel of simulators and tests is consistent by providing the same argument names and documentation as other simulators
This class should mainly contain code relevant to setting up a simulator based on command-line options. Generic simulator setup code that might be invoked from a Python shell, remote interface, or something else does NOT belong in this class. Such common code should be in sparta::app::Simulation. If another simulation interface is desired, the functionality here should not need to be re-implemented.
Definition at line 84 of file CommandLineSimulator.hpp.
sparta::app::CommandLineSimulator::CommandLineSimulator | ( | const std::string & | usage, |
const DefaultValues & | defs = DEFAULTS |
||
) |
Construct.
usage | String describing usage of the simulator. Example: * "Usage: ./sim_bin -r NUM_CYCLES [--other-args]" * |
|
inline |
Gets the advanced options for this simulator.
Definition at line 157 of file CommandLineSimulator.hpp.
|
inline |
Gets the application-specific options for this simulator.
Definition at line 150 of file CommandLineSimulator.hpp.
|
inline |
Gets the boost positional options for the parser owned by this simulator.
Definition at line 165 of file CommandLineSimulator.hpp.
|
inline |
Get the internal SimulationConfiguration this CommandLineSimulator uses
Definition at line 246 of file CommandLineSimulator.hpp.
|
inline |
Get the internal SimulationConfiguration this CommandLineSimulator uses
Definition at line 253 of file CommandLineSimulator.hpp.
|
inline |
Gets the sparta-specific options for this simulator.
Definition at line 143 of file CommandLineSimulator.hpp.
|
inline |
Gets the usage string specified for this simulator at construction. This string is printed when usage errors are encountered.
Definition at line 133 of file CommandLineSimulator.hpp.
|
inline |
Variables map populated by command-line parsing. This map is populated within the parse() method.
Definition at line 173 of file CommandLineSimulator.hpp.
|
inline |
Has this simulator parsed the command line yet Being parsed is required to call for populateSimulation.
Definition at line 116 of file CommandLineSimulator.hpp.
|
inline |
Return whether this object is trying to run simulation for a finite amount of time via some command line argument.
Definition at line 236 of file CommandLineSimulator.hpp.
|
inline |
Has this simulator been setup yet? Being set up is required to call runSimulator.
Definition at line 125 of file CommandLineSimulator.hpp.
int sparta::app::CommandLineSimulator::parse | ( | int | argc, |
char ** | argv | ||
) |
DEPRECATED Shorthand version of other parse method,.
bool sparta::app::CommandLineSimulator::parse | ( | int | argc, |
char ** | argv, | ||
int & | err_code | ||
) |
Parse command line options.
sim | Simulation to configure after parsing |
argc | command line arg count |
argv | command line parameter string vector |
err_code | Reference to value where parsing will store and error code. This is because this method could want the application to exit, but to use a zero error code. |
SpartaException | if anything cannot be parsed |
void sparta::app::CommandLineSimulator::populateSimulation | ( | Simulation * | sim | ) |
Builds the content of the simulator making it ready to run.
|
inlineprotectedvirtual |
Callback before interpreting command parsed command line tokens.
opts | Parsed options with order information |
Definition at line 278 of file CommandLineSimulator.hpp.
void sparta::app::CommandLineSimulator::postProcess | ( | Simulation * | sim | ) |
Post-process the results of the simulation if applicable.
|
protected |
argc from main
Definition at line 296 of file CommandLineSimulator.hpp.
|
protected |
argv from main
Definition at line 301 of file CommandLineSimulator.hpp.
|
protected |
Automatic summary state. Determines what to do with the automatic summary after running.
Definition at line 492 of file CommandLineSimulator.hpp.
|
protected |
number of non-final configuration applications used to modify parameters. A tally of all -p, –arch, –config-file. Does not include –read-final-config
Definition at line 367 of file CommandLineSimulator.hpp.
|
protected |
When a simulation error occurs and error logging is enabled, what content should the error log contain?
Definition at line 453 of file CommandLineSimulator.hpp.
|
static |
Static DefaultValues for a SPARTA CommandLineSimulator.
Definition at line 91 of file CommandLineSimulator.hpp.
|
protected |
Show hidden treenodes when displaying the device tree.
Definition at line 438 of file CommandLineSimulator.hpp.
|
protected |
Under what conditions should the debug content be dumped at simulator destruction. {always,never,error}.
Definition at line 444 of file CommandLineSimulator.hpp.
|
protected |
Simulation feature configuration.
Definition at line 286 of file CommandLineSimulator.hpp.
|
protected |
Destination to which final configuration (before running) will be written ("" if not written)
Definition at line 357 of file CommandLineSimulator.hpp.
|
protected |
Destination to which final configuration (before running) will be written ("" if not written). This file will also include descriptions of each parameter preceeding them with extra newlines.
Definition at line 380 of file CommandLineSimulator.hpp.
|
protected |
Help topic to show.
Definition at line 497 of file CommandLineSimulator.hpp.
|
protected |
Definition at line 460 of file CommandLineSimulator.hpp.
|
protected |
Have the command line options been parsed yet by this class through the parse method.
Definition at line 334 of file CommandLineSimulator.hpp.
|
protected |
Has the simulator been setup through the populateSimulation method.
Definition at line 339 of file CommandLineSimulator.hpp.
|
protected |
Is this simulator in no-run mode where it quits just before finalization.
Definition at line 351 of file CommandLineSimulator.hpp.
|
protected |
Should the trivialities of simulator configuration (e.g what command line options were specified) be hidden?
Definition at line 386 of file CommandLineSimulator.hpp.
|
protected |
a pevent controller is used to parse in pevent on and off commands, and prepare collection for the specified pevent types, this is different than pevent trigger because the controller only preps collectors, the trigger actually starts the trigger
Definition at line 482 of file CommandLineSimulator.hpp.
|
protected |
The filename to log pevents too.
Definition at line 474 of file CommandLineSimulator.hpp.
|
protected |
Instance of the pipeline collector if collection enabled.
Definition at line 458 of file CommandLineSimulator.hpp.
|
protected |
The names of the nodes to be enabled.
Definition at line 469 of file CommandLineSimulator.hpp.
|
protected |
Heartbeat period of pipeline collection file (before lexical cast or validation)
Definition at line 466 of file CommandLineSimulator.hpp.
|
protected |
Definition at line 459 of file CommandLineSimulator.hpp.
|
protected |
Destination to which power configuration (to be read by power model) will be written ("" if not written)
Definition at line 373 of file CommandLineSimulator.hpp.
|
protected |
The file to read from for reading in a final config file.
Definition at line 362 of file CommandLineSimulator.hpp.
|
protected |
Vector of report descriptor definition files (YAML)
Definition at line 311 of file CommandLineSimulator.hpp.
|
protected |
Map to hold report-specific yaml placeholder key-value pairs. An example usage might be: <sim> –report foo.yaml rep1.yaml –report bar.yaml rep2.yaml Where 'rep1.yaml' contains key-value replacements specifically for descriptor file 'foo.yaml', and 'rep2.yaml' contains those specifically for descriptor file 'bar.yaml'.
Definition at line 328 of file CommandLineSimulator.hpp.
|
protected |
Vector of yaml placeholder key-value pairs. These will be applied to the yamls given by "--report my_report_info.yaml".
Definition at line 317 of file CommandLineSimulator.hpp.
|
protected |
Vector of Report descriptors to instantiate on the simulator.
Definition at line 306 of file CommandLineSimulator.hpp.
|
protected |
Definition at line 483 of file CommandLineSimulator.hpp.
|
protected |
Run-time user parameter.
Definition at line 344 of file CommandLineSimulator.hpp.
|
protected |
Definition at line 345 of file CommandLineSimulator.hpp.
|
protected |
The runtime clock to use for -r option.
Definition at line 486 of file CommandLineSimulator.hpp.
|
protected |
Display all the clocks in the tree.
Definition at line 412 of file CommandLineSimulator.hpp.
|
protected |
Display all counters and stats in the device tree after finalization.
Definition at line 407 of file CommandLineSimulator.hpp.
|
protected |
Show hidden treenodes when displaying the device tree.
Definition at line 433 of file CommandLineSimulator.hpp.
|
protected |
Display all notifications in the device tree after finalization excluding log messages.
Definition at line 428 of file CommandLineSimulator.hpp.
|
protected |
Display all notifications in the device tree after finalization excluding log messages.
Definition at line 422 of file CommandLineSimulator.hpp.
|
protected |
Display all parameters in the device tree after building.
Definition at line 396 of file CommandLineSimulator.hpp.
|
protected |
Display all the pevent types in the tree.
Definition at line 417 of file CommandLineSimulator.hpp.
|
protected |
Display all ports in the device tree after finalization.
Definition at line 401 of file CommandLineSimulator.hpp.
|
protected |
Display the device tree at every opportunity.
Definition at line 391 of file CommandLineSimulator.hpp.
|
protected |
Simulation configuration including default values.
Definition at line 283 of file CommandLineSimulator.hpp.
|
protected |
Usage string specified at construction.
Definition at line 291 of file CommandLineSimulator.hpp.