The Sparta Modeling Framework
Loading...
Searching...
No Matches
ExampleSimulation.hpp
1// <Simulation.h> -*- C++ -*-
2
3
4#pragma once
5
7#include "sparta/trigger/ExpiringExpressionTrigger.hpp"
8
9namespace sparta {
10 class Baz;
11 class ParameterSet;
12}
13namespace sparta_simdb {
14 class DatabaseTester;
15}
16
17namespace sparta { namespace trigger { class ExpressionTrigger; } }
18namespace core_example{ class CPUFactory; }
19
24{
25public:
26
36 ExampleSimulator(const std::string& topology,
37 sparta::Scheduler & scheduler,
38 uint32_t num_cores=1, uint64_t instruction_limit=0,
39 bool show_factories = false);
40
41 // Tear it down
42 virtual ~ExampleSimulator();
43
44private:
45
47 // Setup
48
51 void registerStatCalculationFcns_();
52
55 void buildTree_() override;
56
58 void configureTree_() override;
59
62 void bindTree_() override;
63
65 void reportGenerationStarted_(const uint64_t &);
66 bool report_generation_fired_ = false;
67
69 std::unique_ptr<sparta::Baz> dispatch_baz_;
70 std::unique_ptr<sparta::Baz> fpu_baz_;
71
73 const sparta::CounterBase* findSemanticCounter_(CounterSemantic sem) const override;
74
76 // Runtime
77
79 class ExampleController : public sparta::app::Simulation::SimulationController
80 {
81 public:
82 explicit ExampleController(const sparta::app::Simulation * sim);
83
84 private:
85 virtual void pause_ (const sparta::app::Simulation * sim) override;
86 virtual void resume_ (const sparta::app::Simulation * sim) override;
87 virtual void terminate_(const sparta::app::Simulation * sim) override;
88
89 void customEatCallback_();
90 void customSleepCallback_();
91 };
92
94 std::string cpu_topology_;
95
97 const uint32_t num_cores_;
98
100 const uint64_t instruction_limit_;
101
102 std::vector<sparta::TreeNode*> tlb_nodes_;
103
107 std::unique_ptr<sparta::NotificationSource<uint64_t>> testing_notification_source_;
108 std::unique_ptr<sparta::trigger::ExpressionTrigger> random_number_trigger_;
109 void postRandomNumber_();
110
114 std::unique_ptr<sparta::NotificationSource<uint64_t>> toggle_trigger_notification_source_;
115 std::unique_ptr<sparta::trigger::ExpressionTrigger> toggle_notif_trigger_;
116 void postToToggleTrigger_();
117
123 sparta::trigger::ExpiringExpressionTrigger lazy_table_create_trigger_;
124 simdb::TableProxy * lazy_table_proxy_ = nullptr;
125 void addToStatsSchema_();
126 void addToLazySchemaTable_();
127
132 std::unique_ptr<sparta::NotificationSource<uint64_t>> legacy_warmup_report_starter_;
133 std::vector<std::unique_ptr<sparta::trigger::ExpressionTrigger>> core_warmup_listeners_;
134 uint32_t num_cores_still_warming_up_ = 0;
135 void onLegacyWarmupNotification_();
136
140 void onTriggered_(const std::string & msg);
141 bool on_triggered_notifier_registered_ = false;
142
146 void validateTreeNodeExtensions_();
147
152 auto getCPUFactory_() -> core_example::CPUFactory*;
153
157 bool show_factories_;
158
159 /* \brief Flag which enables SimDB-related code to run for
160 * interactive performance benchmarks / comparison. False
161 * by default so that we don't impact unit testing / smoke
162 * testing times for all regression test runs.
163 */
164 bool simdb_perf_async_ctrl_enabled_ = false;
165
172 std::shared_ptr<sparta_simdb::DatabaseTester> simdb_tester_;
173};
Simulation setup base class.
ExampleSimulator which builds the model and configures it.
The base class for all Counters.
A class that lets you schedule events now and in the future.
This class is used for simulation control callbacks.
Simulator which builds a sparta DeviceTree.
void pause_()
Triggered simulation pause callback.
CounterSemantic
Types of semantics attached to certain counters. It is the responsibility of subclasses to implement ...
void terminate_()
Triggered simulation terminate callback.
void resume_()
Triggered simulation resume callback.
Macros for handling exponential backoff.