gem5  v22.1.0.0
tlb_coalescer.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011-2015 Advanced Micro Devices, Inc.
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 met:
7  *
8  * 1. Redistributions of source code must retain the above copyright notice,
9  * this list of conditions and the following disclaimer.
10  *
11  * 2. Redistributions in binary form must reproduce the above copyright notice,
12  * this list of conditions and the following disclaimer in the documentation
13  * and/or other materials provided with the distribution.
14  *
15  * 3. Neither the name of the copyright holder nor the names of its
16  * contributors may be used to endorse or promote products derived from this
17  * software without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29  * POSSIBILITY OF SUCH DAMAGE.
30  */
31 
32 #ifndef __TLB_COALESCER_HH__
33 #define __TLB_COALESCER_HH__
34 
35 #include <list>
36 #include <queue>
37 #include <string>
38 #include <vector>
39 
41 #include "arch/generic/tlb.hh"
42 #include "arch/x86/isa.hh"
43 #include "arch/x86/pagetable.hh"
44 #include "arch/x86/regs/segment.hh"
45 #include "base/logging.hh"
46 #include "base/statistics.hh"
47 #include "mem/port.hh"
48 #include "mem/request.hh"
49 #include "params/TLBCoalescer.hh"
50 #include "sim/clocked_object.hh"
51 
52 namespace gem5
53 {
54 
55 class BaseTLB;
56 class Packet;
57 class ThreadContext;
58 
67 {
68  public:
69  typedef TLBCoalescerParams Params;
70  TLBCoalescer(const Params &p);
72 
73  // Number of TLB probes per cycle. Parameterizable - default 2.
75 
76  // Consider coalescing across that many ticks.
77  // Paraemterizable - default 1.
79 
80  // Each coalesced request consists of multiple packets
81  // that all fall within the same virtual page
83 
84  // disables coalescing when true
86 
87  /*
88  * This is a hash map with <tick_index> as a key.
89  * It contains a vector of coalescedReqs per <tick_index>.
90  * Requests are buffered here until they can be issued to
91  * the TLB, at which point they are copied to the
92  * issuedTranslationsTable hash map.
93  *
94  * In terms of coalescing, we coalesce requests in a given
95  * window of x cycles by using tick_index = issueTime/x as a
96  * key, where x = coalescingWindow. issueTime is the issueTime
97  * of the pkt from the ComputeUnit's perspective, but another
98  * option is to change it to curTick(), so we coalesce based
99  * on the receive time.
100  */
101  typedef std::map<int64_t, std::vector<coalescedReq>>
103 
105 
106  /*
107  * issuedTranslationsTabler: a hash_map indexed by virtual page
108  * address. Each hash_map entry has a vector of PacketPtr associated
109  * with it denoting the different packets that share an outstanding
110  * coalesced translation request for the same virtual page.
111  *
112  * The rules that determine which requests we can coalesce are
113  * specified in the canCoalesce() method.
114  */
115  typedef std::unordered_map<Addr, coalescedReq> CoalescingTable;
116 
118 
119  bool canCoalesce(PacketPtr pkt1, PacketPtr pkt2);
120  void updatePhysAddresses(PacketPtr pkt);
121 
122  class CpuSidePort : public ResponsePort
123  {
124  public:
125  CpuSidePort(const std::string &_name, TLBCoalescer *tlb_coalescer,
126  PortID _index)
127  : ResponsePort(_name, tlb_coalescer), coalescer(tlb_coalescer),
128  index(_index) { }
129 
130  protected:
132  int index;
133 
134  virtual bool recvTimingReq(PacketPtr pkt);
135  virtual Tick recvAtomic(PacketPtr pkt) { return 0; }
136  virtual void recvFunctional(PacketPtr pkt);
137  virtual void recvRangeChange() { }
138  virtual void recvReqRetry();
139 
140  virtual void
142  {
143  fatal("recvRespRetry() is not implemented in the TLB "
144  "coalescer.\n");
145  }
146 
147  virtual AddrRangeList getAddrRanges() const;
148  };
149 
150  class MemSidePort : public RequestPort
151  {
152  public:
153  MemSidePort(const std::string &_name, TLBCoalescer *tlb_coalescer,
154  PortID _index)
155  : RequestPort(_name, tlb_coalescer), coalescer(tlb_coalescer),
156  index(_index) { }
157 
159 
160  protected:
162  int index;
163 
164  virtual bool recvTimingResp(PacketPtr pkt);
165  virtual Tick recvAtomic(PacketPtr pkt) { return 0; }
166  virtual void recvFunctional(PacketPtr pkt);
167  virtual void recvRangeChange() { }
168  virtual void recvReqRetry();
169 
170  virtual void
172  {
173  fatal("recvRespRetry() not implemented in TLB coalescer");
174  }
175  };
176 
177  // Coalescer response ports on the cpu Side
179  // Coalescer request ports on the memory side
181 
182  Port &getPort(const std::string &if_name,
183  PortID idx=InvalidPortID) override;
184 
185  void processProbeTLBEvent();
188 
189  void processCleanupEvent();
193 
194  // this FIFO queue keeps track of the virt. page
195  // addresses that are pending cleanup
196  std::queue<Addr> cleanupQueue;
197 
198  protected:
200  {
202 
203  // number of packets the coalescer receives
205  // number packets the coalescer send to the TLB
207 
208  // Number of cycles the coalesced requests spend waiting in
209  // coalescerFIFO. For each packet the coalescer receives we take into
210  // account the number of all uncoalesced requests this pkt "represents"
212 
213  // On average how much time a request from the
214  // uncoalescedAccesses that reaches the TLB
215  // spends waiting?
217  // localqueuingCycles/uncoalescedAccesses
219  } stats;
220 };
221 
222 } // namespace gem5
223 
224 #endif // __TLB_COALESCER_HH__
The ClockedObject class extends the SimObject with a clock and accessor functions to relate ticks to ...
const std::string _name
Definition: named.hh:41
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:294
Ports are used to interface objects to each other.
Definition: port.hh:62
A RequestPort is a specialisation of a Port, which implements the default protocol for the three diff...
Definition: port.hh:79
A ResponsePort is a specialization of a port.
Definition: port.hh:270
virtual Tick recvAtomic(PacketPtr pkt)
Receive an atomic request packet from the peer.
virtual void recvRespRetry()
Called by the peer if sendTimingResp was called on this protocol (causing recvTimingResp to be called...
virtual AddrRangeList getAddrRanges() const
Get a list of the non-overlapping address ranges the owner is responsible for.
virtual void recvFunctional(PacketPtr pkt)
Receive a functional request packet from the peer.
CpuSidePort(const std::string &_name, TLBCoalescer *tlb_coalescer, PortID _index)
virtual bool recvTimingReq(PacketPtr pkt)
Receive a timing request from the peer.
virtual void recvFunctional(PacketPtr pkt)
virtual void recvRangeChange()
Called to receive an address range change from the peer response port.
std::deque< PacketPtr > retries
virtual bool recvTimingResp(PacketPtr pkt)
Receive a timing response from the peer.
virtual Tick recvAtomic(PacketPtr pkt)
virtual void recvReqRetry()
Called by the peer if sendTimingReq was called on this peer (causing recvTimingReq to be called on th...
MemSidePort(const std::string &_name, TLBCoalescer *tlb_coalescer, PortID _index)
The TLBCoalescer is a ClockedObject sitting on the front side (CPUSide) of each TLB.
TLBCoalescerParams Params
std::queue< Addr > cleanupQueue
gem5::TLBCoalescer::TLBCoalescerStats stats
CoalescingTable issuedTranslationsTable
std::vector< MemSidePort * > memSidePort
void updatePhysAddresses(PacketPtr pkt)
EventFunctionWrapper cleanupEvent
The cleanupEvent is scheduled after a TLBEvent triggers in order to free memory and do the required c...
EventFunctionWrapper probeTLBEvent
This event issues the TLB probes.
Port & getPort(const std::string &if_name, PortID idx=InvalidPortID) override
Get a port with a given name and index.
std::map< int64_t, std::vector< coalescedReq > > CoalescingFIFO
std::vector< PacketPtr > coalescedReq
CoalescingFIFO coalescerFIFO
TLBCoalescer(const Params &p)
bool canCoalesce(PacketPtr pkt1, PacketPtr pkt2)
std::vector< CpuSidePort * > cpuSidePort
std::unordered_map< Addr, coalescedReq > CoalescingTable
A formula for statistics that is calculated when printed.
Definition: statistics.hh:2540
Statistics container.
Definition: group.hh:94
This is a simple scalar statistic, like a counter.
Definition: statistics.hh:1931
STL deque class.
Definition: stl.hh:44
STL vector class.
Definition: stl.hh:37
ClockedObject declaration and implementation.
#define fatal(...)
This implements a cprintf based fatal() function.
Definition: logging.hh:190
Port Object Declaration.
Bitfield< 54 > p
Definition: pagetable.hh:70
ProbePointArg< PacketInfo > Packet
Packet probe point.
Definition: mem.hh:109
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
const PortID InvalidPortID
Definition: types.hh:246
int16_t PortID
Port index/ID type, and a symbolic name for an invalid port id.
Definition: types.hh:245
uint64_t Tick
Tick count type.
Definition: types.hh:58
Declaration of a request, the overall memory request consisting of the parts of the request that are ...
Declaration of Statistics objects.
TLBCoalescerStats(statistics::Group *parent)

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