The Sparta Modeling Framework
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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}
13
14namespace sparta { namespace trigger { class ExpressionTrigger; } }
15namespace core_example{ class CPUFactory; }
16
21{
22public:
23
33 ExampleSimulator(const std::string& topology,
34 sparta::Scheduler & scheduler,
35 uint32_t num_cores=1, uint64_t instruction_limit=0,
36 bool show_factories = false);
37
38 // Tear it down
39 virtual ~ExampleSimulator();
40
41private:
42
44 // Setup
45
48 void registerStatCalculationFcns_();
49
52 void buildTree_() override;
53
55 void configureTree_() override;
56
59 void bindTree_() override;
60
62 void reportGenerationStarted_(const uint64_t &);
63 bool report_generation_fired_ = false;
64
66 std::unique_ptr<sparta::Baz> dispatch_baz_;
67 std::unique_ptr<sparta::Baz> fpu_baz_;
68
70 const sparta::CounterBase* findSemanticCounter_(CounterSemantic sem) const override;
71
73 // Runtime
74
76 class ExampleController : public sparta::app::Simulation::SimulationController
77 {
78 public:
79 explicit ExampleController(const sparta::app::Simulation * sim);
80
81 private:
82 virtual void pause_ (const sparta::app::Simulation * sim) override;
83 virtual void resume_ (const sparta::app::Simulation * sim) override;
84 virtual void terminate_(const sparta::app::Simulation * sim) override;
85
86 void customEatCallback_();
87 void customSleepCallback_();
88 };
89
91 std::string cpu_topology_;
92
94 const uint32_t num_cores_;
95
97 const uint64_t instruction_limit_;
98
99 std::vector<sparta::TreeNode*> tlb_nodes_;
100
104 std::unique_ptr<sparta::NotificationSource<uint64_t>> testing_notification_source_;
105 std::unique_ptr<sparta::trigger::ExpressionTrigger> random_number_trigger_;
106 void postRandomNumber_();
107
111 std::unique_ptr<sparta::NotificationSource<uint64_t>> toggle_trigger_notification_source_;
112 std::unique_ptr<sparta::trigger::ExpressionTrigger> toggle_notif_trigger_;
113 void postToToggleTrigger_();
114
119 std::unique_ptr<sparta::NotificationSource<uint64_t>> legacy_warmup_report_starter_;
120 std::vector<std::unique_ptr<sparta::trigger::ExpressionTrigger>> core_warmup_listeners_;
121 uint32_t num_cores_still_warming_up_ = 0;
122 void onLegacyWarmupNotification_();
123
127 void onTriggered_(const std::string & msg);
128 bool on_triggered_notifier_registered_ = false;
129
133 void validateTreeNodeExtensions_();
134
139 auto getCPUFactory_() -> core_example::CPUFactory*;
140
144 bool show_factories_;
145};
Simulation setup base class.
ExampleSimulator which builds the model and configures it.
ExampleSimulator(const std::string &topology, sparta::Scheduler &scheduler, uint32_t num_cores=1, uint64_t instruction_limit=0, bool show_factories=false)
Construct ExampleSimulator.
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.