The Sparta Modeling Framework
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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 enum class SignalMode
345 {
346 DISABLE_BACKTRACE_SIGNALS,
347 ENABLE_BACKTRACE_SIGNALS
348 };
349
355 DEBUG_DUMP_NEVER = 1,
356 DEBUG_DUMP_ERROR = 2,
357 DEBUG_DUMP_MAX = 3
358 };
359
364 DEBUG_DUMP_EVERYTHING,
365 DEBUG_DUMP_NOTHING,
366 DEBUG_DUMP_BACKTRACE_ONLY
367 };
368
372 enum class AutoSummaryState {
373 AUTO_SUMMARY_OFF = 0,
377 };
378
383 enum class TriggerSource {
384 TRIGGER_ON_NONE = 0,
385 TRIGGER_ON_CYCLE,
386 TRIGGER_ON_INSTRUCTION,
387 TRIGGER_ON_ROI
388 };
389
394 bool warn_stderr = true;
395
400 bool verbose_cfg = false;
401
406
410 bool debug_sim = false;
411
415 bool report_on_error = true;
416
423 SignalMode signal_mode{SignalMode::ENABLE_BACKTRACE_SIGNALS};
424
431
436
440 PostRunDebugDumpOptions debug_dump_options{PostRunDebugDumpOptions::DEBUG_DUMP_EVERYTHING};
441
445 std::string dump_debug_filename{"error-dump.dbg"};
446
450 uint64_t trigger_on_value = 0;
451
454 TriggerSource trigger_on_type{TriggerSource::TRIGGER_ON_NONE};
455
458 std::string trigger_clock;
459
463 bool validate_post_run = false;
464
468 std::string warnings_file{""};
469
473 bool show_dag = false;
474
479
484 std::string pipeline_collection_file_prefix = NoPipelineCollectionStr;
485
489 ReportDescVec reports;
490
505
513
517 std::pair<std::string, app::DefaultValues::RetiredInstPathStrictness> path_to_retired_inst_counter =
518 std::make_pair(defaults_.path_to_retired_inst_counter.first,
519 app::DefaultValues::RetiredInstPathStrictness::Relaxed);
520
522 const DefaultValues & getDefaults() const { return defaults_; }
523
525 const log::TapDescVec & getTaps() const { return taps_; }
526
530 void setConsumed() const { is_consumed_ = true; }
531
532private:
533
535 mutable bool is_consumed_ = false;
536
538 // Simulation configuration, your -c, -p, --arch flags from Command line
539
541 std::string final_config_file_ = "";
542
544 std::string memory_usage_def_file_;
545
548 bool generate_stats_mapping_ = false;
549
552 std::set<std::string> disabled_pretty_print_report_formats_;
553
556 std::set<utils::lowercase_string> zero_values_omitted_report_formats_;
557
559 ParameterTree arch_ptree_;
560
562 ParameterTree ptree_;
563
565 ParameterTree extensions_ptree_;
566
568 std::vector<std::string> arch_search_paths_;
569
571 std::vector<std::string> config_search_paths_ = {"./"};
572
574 std::vector<std::string> report_defn_search_paths_;
575
577 std::set<std::string> simulation_control_filenames_;
578
580 std::vector<std::pair<std::string, std::string>> run_metadata_;
581
583 std::unique_ptr<ArchNodeConfigFileApplicator> arch_applicator_;
584
586 ConfigVec config_applicators_;
587
588 //
590
592 // Simulation logging
596 log::TapDescVec taps_;
597
599 std::string state_tracking_file_;
600
601 //
603};
604
605} // namespace app
606} // 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.
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.
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,...".
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 processArch(const std::string &pattern, const std::string &filename)
Macros for handling exponential backoff.