gem5  v22.0.0.1
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) 2021 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 __ARCH_AMDGPU_VEGA_TLB_COALESCER_HH__
33 #define __ARCH_AMDGPU_VEGA_TLB_COALESCER_HH__
34 
35 #include <list>
36 #include <queue>
37 #include <string>
38 #include <vector>
39 
40 #include "arch/amdgpu/vega/tlb.hh"
41 #include "arch/isa.hh"
42 #include "base/statistics.hh"
43 #include "mem/port.hh"
44 #include "mem/request.hh"
45 #include "params/VegaTLBCoalescer.hh"
46 #include "sim/clocked_object.hh"
47 
48 namespace gem5
49 {
50 
51 class Packet;
52 class ThreadContext;
53 
62 {
63  public:
64  VegaTLBCoalescer(const VegaTLBCoalescerParams &p);
66 
67  // Number of TLB probes per cycle. Parameterizable - default 2.
69 
70  // Consider coalescing across that many ticks.
71  // Paraemterizable - default 1.
73 
74  // Each coalesced request consists of multiple packets
75  // that all fall within the same virtual page
77 
78  // disables coalescing when true
80 
81  /*
82  * This is a hash map with <tick_index> as a key.
83  * It contains a vector of coalescedReqs per <tick_index>.
84  * Requests are buffered here until they can be issued to
85  * the TLB, at which point they are copied to the
86  * issuedTranslationsTable hash map.
87  *
88  * In terms of coalescing, we coalesce requests in a given
89  * window of x cycles by using tick_index = issueTime/x as a
90  * key, where x = coalescingWindow. issueTime is the issueTime
91  * of the pkt from the ComputeUnit's perspective, but another
92  * option is to change it to curTick(), so we coalesce based
93  * on the receive time.
94  */
95  typedef std::map<Tick, std::vector<coalescedReq>> CoalescingFIFO;
96 
98 
99  /*
100  * issuedTranslationsTable: a hash_map indexed by virtual page
101  * address. Each hash_map entry has a vector of PacketPtr associated
102  * with it denoting the different packets that share an outstanding
103  * coalesced translation request for the same virtual page.
104  *
105  * The rules that determine which requests we can coalesce are
106  * specified in the canCoalesce() method.
107  */
108  typedef std::unordered_map<Addr, coalescedReq> CoalescingTable;
109 
111 
112  // number of packets the coalescer receives
114  // number packets the coalescer send to the TLB
116 
117  // Number of cycles the coalesced requests spend waiting in
118  // coalescerFIFO. For each packet the coalescer receives we take into
119  // account the number of all uncoalesced requests this pkt "represents"
121 
122  // On average how much time a request from the
123  // uncoalescedAccesses that reaches the TLB
124  // spends waiting?
127  // localqueuingCycles/uncoalescedAccesses
129  // latency of a request to be completed
131 
132  bool canCoalesce(PacketPtr pkt1, PacketPtr pkt2);
133  void updatePhysAddresses(PacketPtr pkt);
134  void regStats() override;
135 
136  class CpuSidePort : public ResponsePort
137  {
138  public:
139  CpuSidePort(const std::string &_name, VegaTLBCoalescer *tlb_coalescer,
140  PortID _index)
141  : ResponsePort(_name, tlb_coalescer), coalescer(tlb_coalescer),
142  index(_index) { }
143 
144  protected:
146  int index;
147 
148  virtual bool recvTimingReq(PacketPtr pkt);
149  virtual Tick recvAtomic(PacketPtr pkt) { return 0; }
150  virtual void recvFunctional(PacketPtr pkt);
151  virtual void recvRangeChange() { }
152  virtual void recvReqRetry();
153 
154  virtual void
156  {
157  fatal("recvRespRetry() is not implemented in the TLB "
158  "coalescer.\n");
159  }
160 
161  virtual AddrRangeList getAddrRanges() const;
162  };
163 
164  class MemSidePort : public RequestPort
165  {
166  public:
167  MemSidePort(const std::string &_name, VegaTLBCoalescer *tlb_coalescer,
168  PortID _index)
169  : RequestPort(_name, tlb_coalescer), coalescer(tlb_coalescer),
170  index(_index) { }
171 
173 
174  protected:
176  int index;
177 
178  virtual bool recvTimingResp(PacketPtr pkt);
179  virtual Tick recvAtomic(PacketPtr pkt) { return 0; }
180  virtual void recvFunctional(PacketPtr pkt);
181  virtual void recvRangeChange() { }
182  virtual void recvReqRetry();
183 
184  virtual void
186  {
187  fatal("recvRespRetry() not implemented in TLB coalescer");
188  }
189  };
190 
191  // Coalescer response ports on the cpu Side
193  // Coalescer request ports on the memory side
195 
196  Port &getPort(const std::string &if_name,
197  PortID idx=InvalidPortID) override;
198 
199  void processProbeTLBEvent();
202 
203  void processCleanupEvent();
207 
210  unsigned int numDownstream;
212  std::queue<CpuSidePort *> stalledPortsQueue;
213  // enforce uniqueness in queue
214  std::map<CpuSidePort *, CpuSidePort *> stalledPortsMap;
215 
216  unsigned int availDownstreamSlots() {
217  assert(tlb_level == 1);
218  return maxDownstream - numDownstream;
219  }
220 
221  void insertStalledPortIfNotMapped(CpuSidePort *);
222  bool mustStallCUPort(CpuSidePort *);
223 
224  bool stalledPorts() {
225  assert(tlb_level == 1);
226  return stalledPortsQueue.size() > 0;
227  }
228 
230  assert(tlb_level == 1);
231  assert(numDownstream > 0);
232  numDownstream--;
233  }
234 
236  assert(tlb_level == 1);
237  assert(maxDownstream >= numDownstream);
238  numDownstream++;
239  }
240 
241  void unstallPorts();
242 
243 
244  // this FIFO queue keeps track of the virt. page
245  // addresses that are pending cleanup
246  std::queue<Addr> cleanupQueue;
247 };
248 
249 } // namespace gem5
250 
251 #endif // __ARCH_AMDGPU_VEGA_TLB_COALESCER_HH__
gem5::statistics::Scalar
This is a simple scalar statistic, like a counter.
Definition: statistics.hh:1930
gem5::VegaTLBCoalescer::mustStallCUPort
bool mustStallCUPort(CpuSidePort *)
Definition: tlb_coalescer.cc:642
gem5::VegaTLBCoalescer::regStats
void regStats() override
Callback to set stat parameters.
Definition: tlb_coalescer.cc:584
fatal
#define fatal(...)
This implements a cprintf based fatal() function.
Definition: logging.hh:190
gem5::PortID
int16_t PortID
Port index/ID type, and a symbolic name for an invalid port id.
Definition: types.hh:245
gem5::VegaTLBCoalescer::queuingCycles
statistics::Scalar queuingCycles
Definition: tlb_coalescer.hh:120
gem5::VegaTLBCoalescer::stalledPortsMap
std::map< CpuSidePort *, CpuSidePort * > stalledPortsMap
Definition: tlb_coalescer.hh:214
gem5::VegaTLBCoalescer::stalledPort
CpuSidePort * stalledPort
Definition: tlb_coalescer.hh:211
gem5::VegaTLBCoalescer::CpuSidePort::CpuSidePort
CpuSidePort(const std::string &_name, VegaTLBCoalescer *tlb_coalescer, PortID _index)
Definition: tlb_coalescer.hh:139
gem5::VegaTLBCoalescer::decrementNumDownstream
void decrementNumDownstream()
Definition: tlb_coalescer.hh:229
gem5::VegaTLBCoalescer::coalescedReq
std::vector< PacketPtr > coalescedReq
Definition: tlb_coalescer.hh:76
gem5::VegaTLBCoalescer::CoalescingFIFO
std::map< Tick, std::vector< coalescedReq > > CoalescingFIFO
Definition: tlb_coalescer.hh:95
gem5::VegaTLBCoalescer::tlb_level
int tlb_level
Definition: tlb_coalescer.hh:208
gem5::VegaTLBCoalescer::VegaTLBCoalescer
VegaTLBCoalescer(const VegaTLBCoalescerParams &p)
Definition: tlb_coalescer.cc:46
gem5::VegaTLBCoalescer::processCleanupEvent
void processCleanupEvent()
Definition: tlb_coalescer.cc:571
gem5::VegaTLBCoalescer::coalescedAccesses
statistics::Scalar coalescedAccesses
Definition: tlb_coalescer.hh:115
gem5::VegaTLBCoalescer::MemSidePort
Definition: tlb_coalescer.hh:164
gem5::VegaTLBCoalescer::issuedTranslationsTable
CoalescingTable issuedTranslationsTable
Definition: tlb_coalescer.hh:110
gem5::VegaTLBCoalescer::stalledPorts
bool stalledPorts()
Definition: tlb_coalescer.hh:224
gem5::VegaTLBCoalescer::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:75
gem5::VegaTLBCoalescer::stalledPortsQueue
std::queue< CpuSidePort * > stalledPortsQueue
Definition: tlb_coalescer.hh:212
gem5::VegaTLBCoalescer::localqueuingCycles
statistics::Scalar localqueuingCycles
Definition: tlb_coalescer.hh:125
gem5::statistics::Formula
A formula for statistics that is calculated when printed.
Definition: statistics.hh:2539
std::vector
STL vector class.
Definition: stl.hh:37
gem5::VegaTLBCoalescer::TLBProbesPerCycle
int TLBProbesPerCycle
Definition: tlb_coalescer.hh:68
gem5::VegaTLBCoalescer::MemSidePort::index
int index
Definition: tlb_coalescer.hh:176
gem5::VegaTLBCoalescer::MemSidePort::coalescer
VegaTLBCoalescer * coalescer
Definition: tlb_coalescer.hh:175
gem5::VegaTLBCoalescer::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:155
gem5::InvalidPortID
const PortID InvalidPortID
Definition: types.hh:246
tlb.hh
request.hh
gem5::VegaTLBCoalescer::CpuSidePort::recvRangeChange
virtual void recvRangeChange()
Definition: tlb_coalescer.hh:151
gem5::VegaTLBCoalescer::CpuSidePort::coalescer
VegaTLBCoalescer * coalescer
Definition: tlb_coalescer.hh:145
gem5::RequestPort
A RequestPort is a specialisation of a Port, which implements the default protocol for the three diff...
Definition: port.hh:77
gem5::VegaTLBCoalescer::incrementNumDownstream
void incrementNumDownstream()
Definition: tlb_coalescer.hh:235
gem5::VegaTLBCoalescer::availDownstreamSlots
unsigned int availDownstreamSlots()
Definition: tlb_coalescer.hh:216
gem5::VegaISA::p
Bitfield< 54 > p
Definition: pagetable.hh:70
gem5::VegaTLBCoalescer::disableCoalescing
bool disableCoalescing
Definition: tlb_coalescer.hh:79
gem5::Packet
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:291
gem5::VegaTLBCoalescer
The VegaTLBCoalescer is a ClockedObject sitting on the front side (CPUSide) of each TLB.
Definition: tlb_coalescer.hh:61
gem5::VegaTLBCoalescer::CpuSidePort::getAddrRanges
virtual AddrRangeList getAddrRanges() const
Get a list of the non-overlapping address ranges the owner is responsible for.
Definition: tlb_coalescer.cc:377
gem5::probing::Packet
ProbePointArg< PacketInfo > Packet
Packet probe point.
Definition: mem.hh:109
statistics.hh
gem5::Tick
uint64_t Tick
Tick count type.
Definition: types.hh:58
gem5::VegaTLBCoalescer::MemSidePort::MemSidePort
MemSidePort(const std::string &_name, VegaTLBCoalescer *tlb_coalescer, PortID _index)
Definition: tlb_coalescer.hh:167
gem5::VegaTLBCoalescer::insertStalledPortIfNotMapped
void insertStalledPortIfNotMapped(CpuSidePort *)
Definition: tlb_coalescer.cc:628
gem5::VegaTLBCoalescer::CpuSidePort::recvAtomic
virtual Tick recvAtomic(PacketPtr pkt)
Receive an atomic request packet from the peer.
Definition: tlb_coalescer.hh:149
port.hh
gem5::VegaTLBCoalescer::MemSidePort::recvFunctional
virtual void recvFunctional(PacketPtr pkt)
Definition: tlb_coalescer.cc:417
gem5::VegaTLBCoalescer::probeTLBEvent
EventFunctionWrapper probeTLBEvent
This event issues the TLB probes.
Definition: tlb_coalescer.hh:201
gem5::VegaTLBCoalescer::coalescerFIFO
CoalescingFIFO coalescerFIFO
Definition: tlb_coalescer.hh:97
gem5::VegaTLBCoalescer::CpuSidePort::recvReqRetry
virtual void recvReqRetry()
Definition: tlb_coalescer.cc:348
gem5::ClockedObject
The ClockedObject class extends the SimObject with a clock and accessor functions to relate ticks to ...
Definition: clocked_object.hh:234
gem5::VegaTLBCoalescer::MemSidePort::retries
std::deque< PacketPtr > retries
Definition: tlb_coalescer.hh:172
gem5::VegaTLBCoalescer::MemSidePort::recvAtomic
virtual Tick recvAtomic(PacketPtr pkt)
Definition: tlb_coalescer.hh:179
gem5::VegaTLBCoalescer::canCoalesce
bool canCoalesce(PacketPtr pkt1, PacketPtr pkt2)
Definition: tlb_coalescer.cc:101
gem5::EventFunctionWrapper
Definition: eventq.hh:1115
gem5::VegaTLBCoalescer::unstallPorts
void unstallPorts()
Definition: tlb_coalescer.cc:659
gem5::ResponsePort
A ResponsePort is a specialization of a port.
Definition: port.hh:268
gem5::VegaTLBCoalescer::uncoalescedAccesses
statistics::Scalar uncoalescedAccesses
Definition: tlb_coalescer.hh:113
gem5::VegaTLBCoalescer::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:408
gem5::VegaTLBCoalescer::MemSidePort::recvRespRetry
virtual void recvRespRetry()
Definition: tlb_coalescer.hh:185
gem5::VegaTLBCoalescer::localCycles
statistics::Scalar localCycles
Definition: tlb_coalescer.hh:126
gem5::VegaTLBCoalescer::numDownstream
unsigned int numDownstream
Definition: tlb_coalescer.hh:210
gem5::Port
Ports are used to interface objects to each other.
Definition: port.hh:61
clocked_object.hh
std::deque
STL deque class.
Definition: stl.hh:44
gem5::VegaTLBCoalescer::cleanupQueue
std::queue< Addr > cleanupQueue
Definition: tlb_coalescer.hh:246
gem5::VegaTLBCoalescer::maxDownstream
int maxDownstream
Definition: tlb_coalescer.hh:209
gem5::VegaTLBCoalescer::~VegaTLBCoalescer
~VegaTLBCoalescer()
Definition: tlb_coalescer.hh:65
gem5::VegaTLBCoalescer::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:206
gem5::VegaTLBCoalescer::CpuSidePort::recvFunctional
virtual void recvFunctional(PacketPtr pkt)
Receive a functional request packet from the peer.
Definition: tlb_coalescer.cc:354
gem5::VegaTLBCoalescer::CpuSidePort::index
int index
Definition: tlb_coalescer.hh:146
gem5::VegaTLBCoalescer::CpuSidePort
Definition: tlb_coalescer.hh:136
gem5::VegaTLBCoalescer::CoalescingTable
std::unordered_map< Addr, coalescedReq > CoalescingTable
Definition: tlb_coalescer.hh:108
std::list< AddrRange >
gem5::VegaTLBCoalescer::localLatency
statistics::Formula localLatency
Definition: tlb_coalescer.hh:128
gem5::VegaTLBCoalescer::latency
statistics::Formula latency
Definition: tlb_coalescer.hh:130
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: gpu_translation_state.hh:37
gem5::VegaTLBCoalescer::MemSidePort::recvRangeChange
virtual void recvRangeChange()
Called to receive an address range change from the peer response port.
Definition: tlb_coalescer.hh:181
gem5::VegaTLBCoalescer::cpuSidePort
std::vector< CpuSidePort * > cpuSidePort
Definition: tlb_coalescer.hh:192
gem5::VegaTLBCoalescer::MemSidePort::recvTimingResp
virtual bool recvTimingResp(PacketPtr pkt)
Receive a timing response from the peer.
Definition: tlb_coalescer.cc:389
gem5::VegaTLBCoalescer::processProbeTLBEvent
void processProbeTLBEvent()
Definition: tlb_coalescer.cc:435
gem5::Named::_name
const std::string _name
Definition: named.hh:41
gem5::VegaTLBCoalescer::coalescingWindow
int coalescingWindow
Definition: tlb_coalescer.hh:72
gem5::VegaTLBCoalescer::CpuSidePort::recvTimingReq
virtual bool recvTimingReq(PacketPtr pkt)
Receive a timing request from the peer.
Definition: tlb_coalescer.cc:249
gem5::VegaTLBCoalescer::updatePhysAddresses
void updatePhysAddresses(PacketPtr pkt)
Definition: tlb_coalescer.cc:146
gem5::VegaTLBCoalescer::memSidePort
std::vector< MemSidePort * > memSidePort
Definition: tlb_coalescer.hh:194

Generated on Wed Jul 13 2022 10:38:55 for gem5 by doxygen 1.8.17