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

Generated on Tue Sep 21 2021 12:25:25 for gem5 by doxygen 1.8.17