gem5  v22.1.0.0
RubySystem.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 1999-2012 Mark D. Hill and David A. Wood
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are
7  * met: redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer;
9  * redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution;
12  * neither the name of the copyright holders nor the names of its
13  * contributors may be used to endorse or promote products derived from
14  * this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  */
28 
29 /*
30  * Contains all of the various parts of the system we are simulating.
31  * Performs allocation, deallocation, and setup of all the major
32  * components of the system
33  */
34 
35 #ifndef __MEM_RUBY_SYSTEM_RUBYSYSTEM_HH__
36 #define __MEM_RUBY_SYSTEM_RUBYSYSTEM_HH__
37 
38 #include <unordered_map>
39 
40 #include "base/callback.hh"
41 #include "base/output.hh"
42 #include "mem/packet.hh"
46 #include "params/RubySystem.hh"
47 #include "sim/clocked_object.hh"
48 
49 namespace gem5
50 {
51 
52 namespace memory
53 {
54 class SimpleMemory;
55 } // namespace memory
56 
57 namespace ruby
58 {
59 
60 class Network;
61 class AbstractController;
62 
63 class RubySystem : public ClockedObject
64 {
65  public:
67  RubySystem(const Params &p);
68  ~RubySystem();
69 
70  // config accessors
71  static int getRandomization() { return m_randomization; }
72  static uint32_t getBlockSizeBytes() { return m_block_size_bytes; }
73  static uint32_t getBlockSizeBits() { return m_block_size_bits; }
74  static uint32_t getMemorySizeBits() { return m_memory_size_bits; }
75  static bool getWarmupEnabled() { return m_warmup_enabled; }
76  static bool getCooldownEnabled() { return m_cooldown_enabled; }
77 
81 
82  // Public Methods
83  Profiler*
85  {
86  assert(m_profiler != NULL);
87  return m_profiler;
88  }
89 
90  void regStats() override {
92  }
94  void resetStats() override;
95 
96  void memWriteback() override;
97  void serialize(CheckpointOut &cp) const override;
98  void unserialize(CheckpointIn &cp) override;
99  void drainResume() override;
100  void process();
101  void init() override;
102  void startup() override;
103  bool functionalRead(Packet *ptr);
104  bool functionalWrite(Packet *ptr);
105 
106  void registerNetwork(Network*);
108  void registerMachineID(const MachineID& mach_id, Network* network);
109  void registerRequestorIDs();
110 
111  bool eventQueueEmpty() { return eventq->empty(); }
113  {
114  auto e = new EventFunctionWrapper(
115  [this]{ processRubyEvent(); }, "RubyEvent");
116  schedule(e, tick);
117  }
118 
119  private:
120  // Private copy constructor and assignment operator
121  RubySystem(const RubySystem& obj);
123 
124  void makeCacheRecorder(uint8_t *uncompressed_trace,
125  uint64_t cache_trace_size,
126  uint64_t block_size_bytes);
127 
128  static void readCompressedTrace(std::string filename,
129  uint8_t *&raw_data,
130  uint64_t &uncompressed_trace_size);
131  static void writeCompressedTrace(uint8_t *raw_data, std::string file,
132  uint64_t uncompressed_trace_size);
133 
134  void processRubyEvent();
135  private:
136  // configuration parameters
137  static bool m_randomization;
138  static uint32_t m_block_size_bytes;
139  static uint32_t m_block_size_bits;
140  static uint32_t m_memory_size_bits;
141 
142  static bool m_warmup_enabled;
143  static unsigned m_systems_to_warmup;
144  static bool m_cooldown_enabled;
147 
148  //std::vector<Network *> m_networks;
152 
153  std::unordered_map<MachineID, unsigned> machineToNetwork;
154  std::unordered_map<RequestorID, unsigned> requestorToNetwork;
155  std::unordered_map<unsigned, std::vector<AbstractController*>> netCntrls;
156 
157  public:
161 };
162 
163 } // namespace ruby
164 } // namespace gem5
165 
166 #endif //__MEM_RUBY_SYSTEM_RUBYSYSTEM_HH__
The ClockedObject class extends the SimObject with a clock and accessor functions to relate ticks to ...
ClockedObjectParams Params
Parameters of ClockedObject.
Cycles is a wrapper class for representing cycle counts, i.e.
Definition: types.hh:79
EventQueue * eventq
A pointer to this object's event queue.
Definition: eventq.hh:991
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:294
The simple memory is a basic single-ported memory controller with a configurable throughput and laten...
Definition: simple_mem.hh:68
void enqueueRubyEvent(Tick tick)
Definition: RubySystem.hh:112
static bool m_warmup_enabled
Definition: RubySystem.hh:142
static bool getWarmupEnabled()
Definition: RubySystem.hh:75
bool functionalWrite(Packet *ptr)
Definition: RubySystem.cc:702
static uint32_t getBlockSizeBytes()
Definition: RubySystem.hh:72
RubySystem & operator=(const RubySystem &obj)
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition: RubySystem.cc:380
const bool m_access_backing_store
Definition: RubySystem.hh:146
void init() override
init() is called after all C++ SimObjects have been created and all ports are connected.
Definition: RubySystem.cc:407
static bool m_cooldown_enabled
Definition: RubySystem.hh:144
std::vector< std::map< uint32_t, AbstractController * > > m_abstract_controls
Definition: RubySystem.hh:160
void registerMachineID(const MachineID &mach_id, Network *network)
Definition: RubySystem.cc:116
static bool m_randomization
Definition: RubySystem.hh:137
static unsigned m_systems_to_warmup
Definition: RubySystem.hh:143
std::unordered_map< RequestorID, unsigned > requestorToNetwork
Definition: RubySystem.hh:154
static void writeCompressedTrace(uint8_t *raw_data, std::string file, uint64_t uncompressed_trace_size)
Definition: RubySystem.cc:282
RubySystem(const Params &p)
Definition: RubySystem.cc:79
void registerNetwork(Network *)
Definition: RubySystem.cc:101
void startup() override
startup() is the final initialization call before simulation.
Definition: RubySystem.cc:413
static uint32_t getBlockSizeBits()
Definition: RubySystem.hh:73
std::unordered_map< MachineID, unsigned > machineToNetwork
Definition: RubySystem.hh:153
static void readCompressedTrace(std::string filename, uint8_t *&raw_data, uint64_t &uncompressed_trace_size)
Definition: RubySystem.cc:349
void registerAbstractController(AbstractController *)
Definition: RubySystem.cc:107
CacheRecorder * m_cache_recorder
Definition: RubySystem.hh:159
static uint32_t m_block_size_bits
Definition: RubySystem.hh:139
std::vector< std::unique_ptr< Network > > m_networks
Definition: RubySystem.hh:149
void drainResume() override
Resume execution after a successful drain.
Definition: RubySystem.cc:338
static uint32_t m_block_size_bytes
Definition: RubySystem.hh:138
std::vector< AbstractController * > m_abs_cntrl_vec
Definition: RubySystem.hh:150
Profiler * getProfiler()
Definition: RubySystem.hh:84
void resetStats() override
Callback to reset stats.
Definition: RubySystem.cc:474
memory::SimpleMemory * m_phys_mem
Definition: RubySystem.hh:145
std::unordered_map< unsigned, std::vector< AbstractController * > > netCntrls
Definition: RubySystem.hh:155
static uint32_t m_memory_size_bits
Definition: RubySystem.hh:140
static int getRandomization()
Definition: RubySystem.hh:71
void regStats() override
Callback to set stat parameters.
Definition: RubySystem.hh:90
static uint32_t getMemorySizeBits()
Definition: RubySystem.hh:74
bool functionalRead(Packet *ptr)
Definition: RubySystem.cc:485
void makeCacheRecorder(uint8_t *uncompressed_trace, uint64_t cache_trace_size, uint64_t block_size_bytes)
Definition: RubySystem.cc:176
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition: RubySystem.cc:311
memory::SimpleMemory * getPhysMem()
Definition: RubySystem.hh:78
RubySystem(const RubySystem &obj)
void memWriteback() override
Write back dirty buffers to memory using functional writes.
Definition: RubySystem.cc:209
static bool getCooldownEnabled()
Definition: RubySystem.hh:76
STL vector class.
Definition: stl.hh:37
ClockedObject declaration and implementation.
void schedule(Event &event, Tick when)
Definition: eventq.hh:1019
bool empty() const
Returns true if no events are queued.
Definition: eventq.hh:898
virtual void regStats()
Callback to set stat parameters.
Definition: group.cc:69
Bitfield< 9 > e
Definition: misc_types.hh:65
Bitfield< 54 > p
Definition: pagetable.hh:70
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
std::ostream CheckpointOut
Definition: serialize.hh:66
uint64_t Tick
Tick count type.
Definition: types.hh:58
Declaration of the Packet class.
Definition: mem.h:38

Generated on Wed Dec 21 2022 10:22:39 for gem5 by doxygen 1.9.1