21#include "sparta/sparta.hpp"
22#include "sparta/simulation/ParameterTree.hpp"
24#include "sparta/log/Tap.hpp"
31#include "sparta/report/format/DetailInfoData.hpp"
36constexpr char NoPipelineCollectionStr[] =
"NOPREFIX_";
103 std::pair<std::string, RetiredInstPathStrictness> path_to_retired_inst_counter =
104 std::make_pair(
"rob.stats.total_number_retired",
105 RetiredInstPathStrictness::Relaxed);
138 bool optional =
false);
145 bool is_final =
false);
150 const std::string & filename);
155 const std::string & category,
156 const std::string & destination);
178 const std::string & value);
217 const std::set<utils::lowercase_string> &
267 return extensions_ptree_;
276 return extensions_ptree_;
287 os << arch_applicator_->stringize();
290 os <<
"<not provided>";
299 arch_search_paths_.emplace(arch_search_paths_.begin(), dir);
307 return arch_search_paths_;
315 config_search_paths_.emplace(config_search_paths_.begin(), dir);
323 return config_search_paths_;
331 report_defn_search_paths_.emplace(report_defn_search_paths_.begin(), dir);
339 return report_defn_search_paths_;
344 for(
auto & cp : config_applicators_) {
345 os <<
" " << cp->stringize() <<
'\n';
354 DISABLE_BACKTRACE_SIGNALS,
355 ENABLE_BACKTRACE_SIGNALS
372 DEBUG_DUMP_EVERYTHING,
374 DEBUG_DUMP_BACKTRACE_ONLY
394 TRIGGER_ON_INSTRUCTION,
505 void setGlobalDatabaseFile(
const std::string & db_file)
507 global_simdb_file_ = db_file;
510 void disableLegacyReports()
512 if (!appEnabled(
"simdb-reports")) {
514 <<
"Cannot disable legacy reports when simdb-reports app is not enabled";
516 legacy_reports_enabled_ =
false;
519 bool legacyReportsEnabled()
const
521 return legacy_reports_enabled_;
524 void enableApp(
const std::string & app_name,
const std::string & db_file,
size_t num_instances = 1)
526 enabled_apps_[db_file].insert(app_name);
527 app_db_files_[app_name].insert(db_file);
528 enabled_app_counts_[std::make_pair(app_name, db_file)] = num_instances;
531 bool appEnabled(
const std::string & app_name)
const
533 return app_db_files_.count(app_name) > 0;
536 std::vector<std::string> getEnabledApps()
const
538 std::vector<std::string> apps;
539 for (
const auto& [app_name, db_files] : app_db_files_)
541 apps.emplace_back(app_name);
546 size_t getAppInstances(
const std::string & app_name,
const std::string & db_file)
const
548 auto key = std::make_pair(app_name, db_file);
549 auto it = enabled_app_counts_.find(key);
550 if (it == enabled_app_counts_.end()) {
556 std::vector<std::string> getAppDatabases(
const std::string & app_name)
const
558 auto it = app_db_files_.find(app_name);
559 if (it != app_db_files_.end()) {
560 return {it->second.begin(), it->second.end()};
569 if (global_simdb_file_.empty())
585 std::ostringstream errors;
586 for (
const auto & [app_name, db_files] : app_db_files_) {
587 if (db_files.size() > 1) {
588 if (errors.str().empty()) {
589 errors <<
"Cannot use --simdb-file if any app is sent to two "
590 <<
"different databases:\n";
592 errors <<
" " << app_name <<
" is sent to:\n";
593 for (
const auto & db_file : db_files) {
594 errors <<
" " << db_file <<
"\n";
599 const auto error = errors.str();
600 if (!error.empty()) {
604 for (
const auto & [app_name, db_files] : app_db_files_) {
605 for (
const auto & db_file : db_files) {
606 auto key = std::make_pair(app_name, db_file);
607 const auto num_instances = enabled_app_counts_.at(key);
608 if (db_file != global_simdb_file_) {
609 std::cout <<
"Redirecting " << num_instances <<
" instance"
610 << (num_instances == 1 ?
"" :
"s") <<
" of the '"
611 << app_name <<
"' app from " << db_file <<
" to "
612 << global_simdb_file_ <<
"\n";
613 enableApp(app_name, global_simdb_file_, num_instances);
618 std::vector<std::string> old_db_files;
619 for (
const auto & [db_file, _] : enabled_apps_) {
620 if (db_file != global_simdb_file_) {
621 old_db_files.push_back(db_file);
625 for (
const auto & db_file : old_db_files) {
626 enabled_apps_.erase(db_file);
629 for (
auto & [app_name, db_files] : app_db_files_) {
631 db_files.insert(global_simdb_file_);
634 std::vector<std::pair<std::string, std::string>> old_counts_kvps;
635 for (
const auto & [key, num_instances] : enabled_app_counts_) {
636 if (key.second != global_simdb_file_) {
637 old_counts_kvps.push_back(key);
641 for (
const auto & key : old_counts_kvps) {
642 enabled_app_counts_.erase(key);
648 void addPragmaOnOpen(
const std::string& name,
const std::string& val)
650 dbmgr_pragmas_[name] = val;
653 std::vector<std::pair<std::string, std::string>> getPragmas()
const
655 std::vector<std::pair<std::string, std::string>> pragmas;
656 for (
const auto & [name, val] : dbmgr_pragmas_)
658 pragmas.emplace_back(name, val);
664 std::string global_simdb_file_;
665 std::map<std::string, std::set<std::string>> enabled_apps_;
666 std::map<std::string, std::set<std::string>> app_db_files_;
667 std::unordered_map<std::pair<std::string, std::string>,
size_t> enabled_app_counts_;
668 bool legacy_reports_enabled_ =
true;
669 std::map<std::string, std::string> dbmgr_pragmas_;
698 std::pair<std::string, app::DefaultValues::RetiredInstPathStrictness> path_to_retired_inst_counter =
699 std::make_pair(defaults_.path_to_retired_inst_counter.first,
700 app::DefaultValues::RetiredInstPathStrictness::Relaxed);
706 const log::TapDescVec &
getTaps()
const {
return taps_; }
716 mutable bool is_consumed_ =
false;
722 std::string final_config_file_ =
"";
725 std::string memory_usage_def_file_;
729 bool generate_stats_mapping_ =
false;
733 std::set<std::string> disabled_pretty_print_report_formats_;
737 std::set<utils::lowercase_string> zero_values_omitted_report_formats_;
749 std::vector<std::string> arch_search_paths_;
752 std::vector<std::string> config_search_paths_ = {
"./"};
755 std::vector<std::string> report_defn_search_paths_;
758 std::set<std::string> simulation_control_filenames_;
761 std::vector<std::pair<std::string, std::string>> run_metadata_;
764 std::unique_ptr<ArchNodeConfigFileApplicator> arch_applicator_;
767 ConfigVec config_applicators_;
777 log::TapDescVec taps_;
780 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.
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
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)
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 an extension (.yaml) file.
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.
bool hasTreeNodeExtensions() const
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.
const ParameterTree & getExtensionsUnboundParameterTree() const
Returns a ParameterTree (const version) containing an unbound set of named tree node extensions and t...
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)
ParameterTree & getExtensionsUnboundParameterTree()
Returns a ParameterTree containing an unbound set of named tree node extensions and their parameter v...
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.