The Sparta Modeling Framework
Loading...
Searching...
No Matches
SimulationConfiguration.hpp
Go to the documentation of this file.
1// <SimulationConfiguration> -*- C++ -*-
2
3
9#pragma once
10
11#include <cstdint>
12#include <vector>
13#include <set>
14#include <string>
15#include <memory>
16#include <list>
17#include <ostream>
18#include <type_traits>
19#include <utility>
20
21#include "sparta/sparta.hpp"
22#include "sparta/simulation/ParameterTree.hpp"
24#include "sparta/log/Tap.hpp"
29
30namespace sparta {
31namespace app {
32
33constexpr char NoPipelineCollectionStr[] = "NOPREFIX_";
34
40{
41public:
45 std::vector<std::string> arch_search_dirs = {""};
46
52 std::string arch_arg_default = "";
53
58
63 std::string run_time_clock = "";
64
69 std::string inst_counter = "";
70
75 std::list<ParameterTemplate> other_meta_params = {};
76
84 std::string auto_summary_default = "off";
85
98 Strict, Relaxed
99 };
100 std::pair<std::string, RetiredInstPathStrictness> path_to_retired_inst_counter =
101 std::make_pair("rob.stats.total_number_retired",
102 RetiredInstPathStrictness::Relaxed);
103};
104
119{
120private:
121
123 const DefaultValues defaults_;
124
125public:
126
129
134 void processParameter(const std::string & pattern, const std::string & value,
135 bool optional = false);
136
141 void processConfigFile(const std::string & pattern, const std::string & filename,
142 bool is_final = false);
143
146 void processArch(const std::string & pattern,
147 const std::string & filename);
148
151 void enableLogging(const std::string & pattern,
152 const std::string & category,
153 const std::string & destination);
154
156 bool hasFinalConfig() const { return !final_config_file_.empty(); }
157
159 void processExtensionFile(const std::string & filename);
160
162 void setStateTrackingFile(const std::string & filename);
163
165 const std::string& getStateTrackingFilename() const;
166
168 void addControlFile(const std::string & filename);
169
171 const std::set<std::string> & getControlFiles() const;
172
174 void addRunMetadata(const std::string & name,
175 const std::string & value);
176
178 const std::vector<std::pair<std::string, std::string>> & getRunMetadata() const;
179
181 std::string stringizeRunMetadata() const;
182
184 std::string getFinalConfigFile() const { return final_config_file_; }
185
187 void setMemoryUsageDefFile(const std::string & def_file);
188
190 const std::string & getMemoryUsageDefFile() const;
191
194
197
202 void disablePrettyPrintReports(const std::string & format);
203
205 const std::set<std::string> & getDisabledPrettyPrintFormats() const;
206
211 void omitStatsWithValueZeroForReportFormat(const std::string & format);
212
214 const std::set<utils::lowercase_string> &
216
223
231
238 const ParameterTree& getUnboundParameterTree() const { return ptree_; }
239
246
252 const ParameterTree& getArchUnboundParameterTree() const { return arch_ptree_; }
253
259 return extensions_ptree_;
260 }
261
268 return extensions_ptree_;
269 }
270
274 bool archFileProvided() const { return arch_applicator_ != nullptr; }
275
277 void printArchConfigurations(std::ostream & os) const {
278 if(archFileProvided()) {
279 os << arch_applicator_->stringize();
280 }
281 else {
282 os << "<not provided>";
283 }
284 }
285
290 void addArchSearchPath(const std::string & dir) {
291 arch_search_paths_.emplace(arch_search_paths_.begin(), dir);
292 }
293
298 const std::vector<std::string> &getArchSearchPath() const {
299 return arch_search_paths_;
300 }
301
306 void addConfigSearchPath(const std::string & dir) {
307 config_search_paths_.emplace(config_search_paths_.begin(), dir);
308 }
309
314 const std::vector<std::string> & getConfigSearchPath() const {
315 return config_search_paths_;
316 }
317
322 void addReportDefnSearchPath(const std::string & dir) {
323 report_defn_search_paths_.emplace(report_defn_search_paths_.begin(), dir);
324 }
325
330 const std::vector<std::string> & getReportDefnSearchPaths() const {
331 return report_defn_search_paths_;
332 }
333
335 void printGenericConfigurations(std::ostream & os) const {
336 for(auto & cp : config_applicators_) {
337 os << " " << cp->stringize() << '\n';
338 }
339 }
340
344 void setSimulationDatabaseLocation(const std::string & loc) {
345 simdb_location_ = loc;
346 }
347
404 const std::string & opts_file)
405 {
406 simdb_enabled_components_opts_files_.emplace_back(opts_file);
407 }
408
442 void setLegacyReportsCopyDir(const std::string & reports_root_dir,
443 const std::set<std::string> & collected_formats = {})
444 {
445 simdb_legacy_reports_copy_dir_ = reports_root_dir;
446 for (const auto & fmt : collected_formats) {
447 const utils::lowercase_string lower_fmt = fmt;
448 simdb_legacy_reports_collected_formats_.insert(lower_fmt.getString());
449 }
450 }
451
457 const std::string & getSimulationDatabaseLocation() const {
458 return simdb_location_;
459 }
460
467 const std::vector<std::string> & getDatabaseAccessOptsFiles() const {
468 return simdb_enabled_components_opts_files_;
469 }
470
476 const std::string & getLegacyReportsCopyDir() const {
477 return simdb_legacy_reports_copy_dir_;
478 }
479
486 const std::set<std::string> & getLegacyReportsCollectedFormats() const {
487 return simdb_legacy_reports_collected_formats_;
488 }
489
493 enum class SignalMode
494 {
495 DISABLE_BACKTRACE_SIGNALS,
496 ENABLE_BACKTRACE_SIGNALS
497 };
498
504 DEBUG_DUMP_NEVER = 1,
505 DEBUG_DUMP_ERROR = 2,
506 DEBUG_DUMP_MAX = 3
507 };
508
513 DEBUG_DUMP_EVERYTHING,
514 DEBUG_DUMP_NOTHING,
515 DEBUG_DUMP_BACKTRACE_ONLY
516 };
517
521 enum class AutoSummaryState {
522 AUTO_SUMMARY_OFF = 0,
526 };
527
532 enum class TriggerSource {
533 TRIGGER_ON_NONE = 0,
534 TRIGGER_ON_CYCLE,
535 TRIGGER_ON_INSTRUCTION,
536 TRIGGER_ON_ROI
537 };
538
543 bool warn_stderr = true;
544
549 bool verbose_cfg = false;
550
555
559 bool debug_sim = false;
560
564 bool report_on_error = true;
565
572 SignalMode signal_mode{SignalMode::ENABLE_BACKTRACE_SIGNALS};
573
580
585
589 PostRunDebugDumpOptions debug_dump_options{PostRunDebugDumpOptions::DEBUG_DUMP_EVERYTHING};
590
594 std::string dump_debug_filename{"error-dump.dbg"};
595
599 uint64_t trigger_on_value = 0;
600
603 TriggerSource trigger_on_type{TriggerSource::TRIGGER_ON_NONE};
604
607 std::string trigger_clock;
608
612 bool validate_post_run = false;
613
617 std::string warnings_file{""};
618
622 bool show_dag = false;
623
628
633 std::string pipeline_collection_file_prefix = NoPipelineCollectionStr;
634
638 ReportDescVec reports;
639
654
662
666 std::pair<std::string, app::DefaultValues::RetiredInstPathStrictness> path_to_retired_inst_counter =
667 std::make_pair(defaults_.path_to_retired_inst_counter.first,
668 app::DefaultValues::RetiredInstPathStrictness::Relaxed);
669
671 const DefaultValues & getDefaults() const { return defaults_; }
672
674 const log::TapDescVec & getTaps() const { return taps_; }
675
679 void setConsumed() const { is_consumed_ = true; }
680
681private:
682
684 mutable bool is_consumed_ = false;
685
687 // Simulation configuration, your -c, -p, --arch flags from Command line
688
690 std::string final_config_file_ = "";
691
693 std::string memory_usage_def_file_;
694
697 bool generate_stats_mapping_ = false;
698
701 std::set<std::string> disabled_pretty_print_report_formats_;
702
705 std::set<utils::lowercase_string> zero_values_omitted_report_formats_;
706
708 ParameterTree arch_ptree_;
709
711 ParameterTree ptree_;
712
714 ParameterTree extensions_ptree_;
715
717 std::vector<std::string> arch_search_paths_;
718
720 std::vector<std::string> config_search_paths_ = {"./"};
721
723 std::vector<std::string> report_defn_search_paths_;
724
726 std::set<std::string> simulation_control_filenames_;
727
729 std::vector<std::pair<std::string, std::string>> run_metadata_;
730
732 std::unique_ptr<ArchNodeConfigFileApplicator> arch_applicator_;
733
735 ConfigVec config_applicators_;
736
737 //
739
741 // Simulation logging
745 log::TapDescVec taps_;
746
748 std::string state_tracking_file_;
749
750 //
752
754 // Simulation database
755
757 std::string simdb_location_;
758
763 std::vector<std::string> simdb_enabled_components_opts_files_;
764
767 std::string simdb_legacy_reports_copy_dir_;
768
771 std::set<std::string> simdb_legacy_reports_collected_formats_;
772
773 //
775};
776
777} // namespace app
778} // namespace sparta
Configuration Applicators.
Describes reports to instantiate and tracks their instantiations.
Set of macros for Sparta assertions. Caught by the framework.
Cool string utilities.
Virtual Parameter Tree. This represents a tree of parameters read from some source but does not neces...
Optional default values for the simulator which can be customized and provided by anyone instantiatin...
std::list< ParameterTemplate > other_meta_params
std::vector< std::string > arch_search_dirs
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.
const std::set< std::string > & getLegacyReportsCollectedFormats() const
const std::string & getSimulationDatabaseLocation() const
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)
void addSimulationDatabaseAccessOptsYaml(const std::string &opts_file)
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.
const std::string & getLegacyReportsCopyDir() const
const ParameterTree & getArchUnboundParameterTree() const
const std::set< std::string > & getDisabledPrettyPrintFormats() const
Get all report file extensions which have had their pretty printing disabled.
void printArchConfigurations(std::ostream &os) const
Print the ArchNodeConfigFileApplicator for informative messages.
void processConfigFile(const std::string &pattern, const std::string &filename, bool is_final=false)
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.
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 setMemoryUsageDefFile(const std::string &def_file)
Set filename which contains heap profiler settings.
void addConfigSearchPath(const std::string &dir)
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.
bool shouldGenerateStatsMapping() const
Get statistics mapping "enabled" flag.
std::string stringizeRunMetadata() const
Get run metadata stringized as "name1=value1,name2=value2,...".
const std::vector< std::string > & getDatabaseAccessOptsFiles() const
void setLegacyReportsCopyDir(const std::string &reports_root_dir, const std::set< std::string > &collected_formats={})
void disablePrettyPrintReports(const std::string &format)
const log::TapDescVec & getTaps() const
Get the taps vector.
const ParameterTree & getUnboundParameterTree() const
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)
@ 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.
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...
const std::set< std::string > & getControlFiles() const
Get all control files for this simulation.
void setSimulationDatabaseLocation(const std::string &loc)
void processArch(const std::string &pattern, const std::string &filename)
function LevenshteinDistance()
Macros for handling exponential backoff.