21#include "sparta/sparta.hpp"
22#include "sparta/simulation/ParameterTree.hpp"
24#include "sparta/log/Tap.hpp"
29#include "sparta/utils/Utils.hpp"
30#include "sparta/extensions/TreeNodeExtensionManager.hpp"
33#include "sparta/report/format/DetailInfoData.hpp"
38constexpr char NoPipelineCollectionStr[] =
"NOPREFIX_";
105 std::pair<std::string, RetiredInstPathStrictness> path_to_retired_inst_counter =
106 std::make_pair(
"rob.stats.total_number_retired",
107 RetiredInstPathStrictness::Relaxed);
140 bool optional =
false);
147 bool is_final =
false);
152 const std::string & filename);
157 const std::string & category,
158 const std::string & destination);
177 const std::string & value);
216 const std::set<utils::lowercase_string> &
264 os << arch_applicator_->stringize();
267 os <<
"<not provided>";
276 arch_search_paths_.emplace(arch_search_paths_.begin(), dir);
284 return arch_search_paths_;
292 config_search_paths_.emplace(config_search_paths_.begin(), dir);
300 return config_search_paths_;
308 report_defn_search_paths_.emplace(report_defn_search_paths_.begin(), dir);
316 return report_defn_search_paths_;
321 for(
auto & cp : config_applicators_) {
322 os <<
" " << cp->stringize() <<
'\n';
331 DISABLE_BACKTRACE_SIGNALS,
332 ENABLE_BACKTRACE_SIGNALS
349 DEBUG_DUMP_EVERYTHING,
351 DEBUG_DUMP_BACKTRACE_ONLY
371 TRIGGER_ON_INSTRUCTION,
488 sim_exec_db_filename_ = exe_name +
".db";
498 app_file_logger_filename_ = filename;
506 return app_file_logger_filename_;
521 enabled_apps_.insert(app_name);
531 return enabled_apps_.count(app_name) > 0;
539 return {enabled_apps_.begin(), enabled_apps_.end()};
549 concrete_app_counts_[app_name] = count;
550 inferred_app_counts_.erase(app_name);
563 concrete_app_counts_.erase(app_name);
564 inferred_app_counts_[app_name] = pattern;
577 auto it = inferred_app_counts_.find(app_name);
578 if (it != inferred_app_counts_.end()) {
594 auto it = concrete_app_counts_.find(app_name);
595 if (it == concrete_app_counts_.end()) {
596 throw SpartaException(
"We do not know the app count yet. Has the tree been built?");
607 app_databases_[app_name] = db_file;
616 return app_databases_.at(app_name);
624 reused_db_files_.insert(db_file);
632 return reused_db_files_.count(db_file) == 0;
646 <<
"Cannot disable legacy reports when simdb-reports app is not enabled";
648 legacy_reports_enabled_ =
false;
658 return legacy_reports_enabled_;
667 dbmgr_pragmas_[name] = val;
674 std::vector<std::pair<std::string, std::string>>
getPragmas()
const
676 std::vector<std::pair<std::string, std::string>> pragmas;
677 for (
const auto & [name, val] : dbmgr_pragmas_)
679 pragmas.emplace_back(name, val);
685 std::string sim_exec_db_filename_;
686 std::string app_file_logger_filename_;
687 std::set<std::string> enabled_apps_;
688 std::map<std::string, size_t> concrete_app_counts_;
689 std::map<std::string, std::string> inferred_app_counts_;
690 std::map<std::string, std::string> app_databases_;
691 std::set<std::string> reused_db_files_;
692 std::map<std::string, std::string> dbmgr_pragmas_;
693 bool legacy_reports_enabled_ =
true;
730 std::pair<std::string, app::DefaultValues::RetiredInstPathStrictness> path_to_retired_inst_counter =
731 std::make_pair(defaults_.path_to_retired_inst_counter.first,
732 app::DefaultValues::RetiredInstPathStrictness::Relaxed);
738 const log::TapDescVec &
getTaps()
const {
return taps_; }
748 mutable bool is_consumed_ =
false;
754 std::string final_config_file_ =
"";
757 std::string memory_usage_def_file_;
761 bool generate_stats_mapping_ =
false;
765 std::set<std::string> disabled_pretty_print_report_formats_;
769 std::set<utils::lowercase_string> zero_values_omitted_report_formats_;
778 std::vector<std::string> arch_search_paths_;
781 std::vector<std::string> config_search_paths_ = {
"./"};
784 std::vector<std::string> report_defn_search_paths_;
787 std::set<std::string> simulation_control_filenames_;
790 std::vector<std::pair<std::string, std::string>> run_metadata_;
793 std::unique_ptr<ArchNodeConfigFileApplicator> arch_applicator_;
796 ConfigVec config_applicators_;
806 log::TapDescVec taps_;
809 std::string state_tracking_file_;
Configuration Applicators.
Describes reports to instantiate and tracks their instantiations.
Set of macros for Sparta assertions. Caught by the framework.
#define sparta_assert(...)
Simple variadic assertion that will throw a sparta_exception if the condition fails.
Virtual Parameter Tree. This represents a tree of parameters read from some source but does not neces...
Used to construct and throw a standard C++ exception. Inherits from std::exception.
Optional default values for the simulator which can be customized and provided by anyone instantiatin...
std::string arch_arg_default
bool non_empty_arch_arg_required
std::string run_time_clock
RetiredInstPathStrictness
std::list< ParameterTemplate > other_meta_params
std::vector< std::string > arch_search_dirs
std::string auto_summary_default
size_t getAppCount(const std::string &app_name) const
Return the number of instances we should create for the given app.
void setAppDatabase(const std::string &app_name, const std::string &db_file)
Direct the given app to go to the provided database file.
void setAppCount(const std::string &app_name, size_t count)
Set the number of instances that should be available for the given app.
void disableLegacyReports()
When used together with –enable-simdb-reports, the option –disable-legacy-reports results in stats re...
std::vector< std::pair< std::string, std::string > > getPragmas() const
Get a list of name-value pairs for SQLite PRAGMA's to execute on database creation.
void useAppFileLogger(const std::string &filename)
Before creating any apps, call this method to enable all apps to have access to a single thread-safe ...
std::string getAppDatabase(const std::string &app_name) const
Get the database file for the given app.
void reuseDatabase(const std::string &db_file)
Tell SimDB to open the given file without overwriting it.
bool shouldOverwriteDatabase(const std::string &db_file) const
See if the given database should be overwritten or reused.
void inferAppCountFromTreePattern(const std::string &app_name, const std::string &pattern)
Set the number of instances that should be available for the given app using a device tree wildcard p...
void addPragmaOnOpen(const std::string &name, const std::string &val)
Add a SQLite PRAGMA to execute on database creation.
bool appEnabled(const std::string &app_name) const
Check if the given app is enabled.
void setSimExecutable(const std::string &exe_name)
Set the simulation executable. This will be used as the default database filename (with a ....
std::vector< std::string > getEnabledApps() const
Return a list of all enabled apps.
bool legacyReportsEnabled() const
See if legacy stats reports are enabled or not.
void enableApp(const std::string &app_name)
Tell the simulation to enable the given app. Unless otherwise specified, the database will be the exe...
std::string getAppLoggerFilename() const
Get the filename of the apps' shared file logger, if enabled.
std::string getTreePatternForInferredAppCount(const std::string &app_name) const
Get the device tree pattern from which to infer the number of instances of the given app we should cr...
Configuration applicator class that is used for configuring a simulator. Works in conjunction with sp...
const DefaultValues & getDefaults() const
Get the defaults this configuration was made with.
const std::vector< std::string > & getArchSearchPath() const
Get the arch search paths.
std::string parsed_path_to_retired_inst_counter_
PostRunDebugDumpOptions debug_dump_options
std::string getFinalConfigFile() const
Get the final config file name.
const std::vector< std::string > & getReportDefnSearchPaths() const
bool hasFinalConfig() const
Was a final configuration file provided?
void omitStatsWithValueZeroForReportFormat(const std::string &format)
TreeNodeExtensionManager extension_mgr
const std::vector< std::pair< std::string, std::string > > & getRunMetadata() const
Get run metadata as key-value pairs.
void addReportDefnSearchPath(const std::string &dir)
const std::string & getStateTrackingFilename() const
Get the State Tracking filename.
ParameterTree & getUnboundParameterTree()
const ParameterTree & getArchUnboundParameterTree() const
const std::set< std::string > & getDisabledPrettyPrintFormats() const
Get all report file extensions which have had their pretty printing disabled.
bool scheduler_exacting_run
void printArchConfigurations(std::ostream &os) const
Print the ArchNodeConfigFileApplicator for informative messages.
bool suppress_unread_parameter_warnings
void processConfigFile(const std::string &pattern, const std::string &filename, bool is_final=false)
bool verbose_report_triggers
void addRunMetadata(const std::string &name, const std::string &value)
Add run metadata as a string.
const std::vector< std::string > & getConfigSearchPath() const
Get the search paths for the configure files.
std::string dump_debug_filename
void printGenericConfigurations(std::ostream &os) const
Print the generic configurations for informative messages.
const std::set< utils::lowercase_string > & getReportFormatsWhoOmitStatsWithValueZero() const
Get all report formats which are to omit all SI values that are zero.
void copyTreeNodeExtensionsFromArchAndConfigPTrees()
void setMemoryUsageDefFile(const std::string &def_file)
Set filename which contains heap profiler settings.
void addConfigSearchPath(const std::string &dir)
bool archFileProvided() const
SignalMode
Controls installation of signal handlers.
void addControlFile(const std::string &filename)
Consume a simulation control file.
const std::string & getMemoryUsageDefFile() const
Get filename for heap profiler configuration.
SimulationConfiguration(const DefaultValues &defaults=DefaultValues())
Create a SimulationConfiguration.
PostRunDebugDumpPolicy debug_dump_policy
bool shouldGenerateStatsMapping() const
Get statistics mapping "enabled" flag.
std::string stringizeRunMetadata() const
Get run metadata stringized as "name1=value1,name2=value2,...".
ParameterTree & getArchUnboundParameterTree()
void addArchSearchPath(const std::string &dir)
TriggerSource trigger_on_type
void disablePrettyPrintReports(const std::string &format)
const log::TapDescVec & getTaps() const
Get the taps vector.
const ParameterTree & getUnboundParameterTree() const
AutoSummaryState auto_summary_state
std::string pipeline_collection_file_prefix
std::string trigger_clock
void setStateTrackingFile(const std::string &filename)
Set the filename for the State Tracking file.
void enableLogging(const std::string &pattern, const std::string &category, const std::string &destination)
@ AUTO_SUMMARY_VERBOSE
Write verbose summary.
@ AUTO_SUMMARY_OFF
Do not write summary.
@ AUTO_SUMMARY_NORMAL
Write normal summary.
@ AUTO_SUMMARY_MAX
Invalid enum value.
@ DEBUG_DUMP_NEVER
Never dump debug data after running.
@ DEBUG_DUMP_ERROR
Dump debug data only if there is an error while running.
@ DEBUG_DUMP_ALWAYS
Dump debug data in all cases after running.
@ DEBUG_DUMP_MAX
Invalid enum value.
void generateStatsMapping()
Auto-generate mappings from report column headers to statistic names.
void processParameter(const std::string &pattern, const std::string &value, bool optional=false)
bool scheduler_measure_run_time
const std::set< std::string > & getControlFiles() const
Get all control files for this simulation.
std::string warnings_file
uint64_t trigger_on_value
void processArch(const std::string &pattern, const std::string &filename)
Macros for handling exponential backoff.