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);
160 const std::string & category,
161 const std::string & destination);
180 const std::string & value);
219 const std::set<utils::lowercase_string> &
267 os << arch_applicator_->stringize();
270 os <<
"<not provided>";
279 arch_search_paths_.emplace(arch_search_paths_.begin(), dir);
287 return arch_search_paths_;
295 config_search_paths_.emplace(config_search_paths_.begin(), dir);
303 return config_search_paths_;
311 report_defn_search_paths_.emplace(report_defn_search_paths_.begin(), dir);
319 return report_defn_search_paths_;
324 for(
auto & cp : config_applicators_) {
325 os <<
" " << cp->stringize() <<
'\n';
334 DISABLE_BACKTRACE_SIGNALS,
335 ENABLE_BACKTRACE_SIGNALS
352 DEBUG_DUMP_EVERYTHING,
354 DEBUG_DUMP_BACKTRACE_ONLY
374 TRIGGER_ON_INSTRUCTION,
491 sim_exec_db_filename_ = exe_name +
".db";
501 app_file_logger_filename_ = filename;
509 return app_file_logger_filename_;
524 enabled_apps_.insert(app_name);
534 return enabled_apps_.count(app_name) > 0;
542 return {enabled_apps_.begin(), enabled_apps_.end()};
552 concrete_app_counts_[app_name] = count;
553 inferred_app_counts_.erase(app_name);
566 concrete_app_counts_.erase(app_name);
567 inferred_app_counts_[app_name] = pattern;
580 auto it = inferred_app_counts_.find(app_name);
581 if (it != inferred_app_counts_.end()) {
597 auto it = concrete_app_counts_.find(app_name);
598 if (it == concrete_app_counts_.end()) {
599 throw SpartaException(
"We do not know the app count yet. Has the tree been built?");
610 app_databases_[app_name] = db_file;
619 return app_databases_.at(app_name);
627 reused_db_files_.insert(db_file);
635 return reused_db_files_.count(db_file) == 0;
649 <<
"Cannot disable legacy reports when simdb-reports app is not enabled";
651 legacy_reports_enabled_ =
false;
661 return legacy_reports_enabled_;
670 dbmgr_pragmas_[name] = val;
677 std::vector<std::pair<std::string, std::string>>
getPragmas()
const
679 std::vector<std::pair<std::string, std::string>> pragmas;
680 for (
const auto & [name, val] : dbmgr_pragmas_)
682 pragmas.emplace_back(name, val);
688 std::string sim_exec_db_filename_;
689 std::string app_file_logger_filename_;
690 std::set<std::string> enabled_apps_;
691 std::map<std::string, size_t> concrete_app_counts_;
692 std::map<std::string, std::string> inferred_app_counts_;
693 std::map<std::string, std::string> app_databases_;
694 std::set<std::string> reused_db_files_;
695 std::map<std::string, std::string> dbmgr_pragmas_;
696 bool legacy_reports_enabled_ =
true;
733 std::pair<std::string, app::DefaultValues::RetiredInstPathStrictness> path_to_retired_inst_counter =
734 std::make_pair(defaults_.path_to_retired_inst_counter.first,
735 app::DefaultValues::RetiredInstPathStrictness::Relaxed);
741 const log::TapDescVec &
getTaps()
const {
return taps_; }
751 mutable bool is_consumed_ =
false;
757 std::string final_config_file_ =
"";
760 std::string memory_usage_def_file_;
764 bool generate_stats_mapping_ =
false;
768 std::set<std::string> disabled_pretty_print_report_formats_;
772 std::set<utils::lowercase_string> zero_values_omitted_report_formats_;
786 enum ExtensionsOrderOfOps : uint32_t
788 FROM_ARCH_YAML_WITH_WILDCARDS = 0,
789 FROM_CONFIG_YAML_OR_PARAM_WITH_WILDCARDS,
790 FROM_EXT_YAML_WITH_WILDCARDS,
791 FROM_ARCH_YAML_WITHOUT_WILDCARDS,
792 FROM_CONFIG_YAML_OR_PARAM_WITHOUT_WILDCARDS,
793 FROM_EXT_YAML_WITHOUT_WILDCARDS,
799 std::array<ParameterTree, ExtensionsOrderOfOps::__N> extension_ptrees_;
803 static void extractPTreeExtensions_(
811 static void splitExtensionPTree_(
817 std::vector<std::string> arch_search_paths_;
820 std::vector<std::string> config_search_paths_ = {
"./"};
823 std::vector<std::string> report_defn_search_paths_;
826 std::set<std::string> simulation_control_filenames_;
829 std::vector<std::pair<std::string, std::string>> run_metadata_;
832 std::unique_ptr<ArchNodeConfigFileApplicator> arch_applicator_;
835 ConfigVec config_applicators_;
845 log::TapDescVec taps_;
848 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 processExtensionFile(const std::string &filename)
Consume a yaml file with extensions (–extension-file(s))
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.