gem5 v24.0.0.0
Loading...
Searching...
No Matches
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
41#include "base/statistics.hh"
42#include "mem/port.hh"
43#include "mem/request.hh"
44#include "params/VegaTLBCoalescer.hh"
45#include "sim/clocked_object.hh"
46
47namespace gem5
48{
49
50class Packet;
51class ThreadContext;
52
61{
62 public:
63 VegaTLBCoalescer(const VegaTLBCoalescerParams &p);
65
66 // Number of TLB probes per cycle. Parameterizable - default 2.
68
69 // Consider coalescing across that many ticks.
70 // Paraemterizable - default 1.
72
73 // Each coalesced request consists of multiple packets
74 // that all fall within the same virtual page
76
77 // disables coalescing when true
79
80 /*
81 * This is a hash map with <tick_index> as a key.
82 * It contains a vector of coalescedReqs per <tick_index>.
83 * Requests are buffered here until they can be issued to
84 * the TLB, at which point they are copied to the
85 * issuedTranslationsTable hash map.
86 *
87 * In terms of coalescing, we coalesce requests in a given
88 * window of x cycles by using tick_index = issueTime/x as a
89 * key, where x = coalescingWindow. issueTime is the issueTime
90 * of the pkt from the ComputeUnit's perspective, but another
91 * option is to change it to curTick(), so we coalesce based
92 * on the receive time.
93 */
94 typedef std::map<Tick, std::vector<coalescedReq>> CoalescingFIFO;
95
97
98 /*
99 * issuedTranslationsTable: a hash_map indexed by virtual page
100 * address. Each hash_map entry has a vector of PacketPtr associated
101 * with it denoting the different packets that share an outstanding
102 * coalesced translation request for the same virtual page.
103 *
104 * The rules that determine which requests we can coalesce are
105 * specified in the canCoalesce() method.
106 */
107 typedef std::unordered_map<Addr, coalescedReq> CoalescingTable;
108
110
111 // number of packets the coalescer receives
113 // number packets the coalescer send to the TLB
115
116 // Number of cycles the coalesced requests spend waiting in
117 // coalescerFIFO. For each packet the coalescer receives we take into
118 // account the number of all uncoalesced requests this pkt "represents"
120
121 // On average how much time a request from the
122 // uncoalescedAccesses that reaches the TLB
123 // spends waiting?
126 // localqueuingCycles/uncoalescedAccesses
128 // latency of a request to be completed
130
131 bool canCoalesce(PacketPtr pkt1, PacketPtr pkt2);
133 void regStats() override;
134
136 {
137 public:
138 CpuSidePort(const std::string &_name, VegaTLBCoalescer *tlb_coalescer,
139 PortID _index)
140 : ResponsePort(_name), coalescer(tlb_coalescer),
141 index(_index) { }
142
143 protected:
145 int index;
146
147 virtual bool recvTimingReq(PacketPtr pkt);
148 virtual Tick recvAtomic(PacketPtr pkt) { return 0; }
149 virtual void recvFunctional(PacketPtr pkt);
150 virtual void recvRangeChange() { }
151 virtual void recvReqRetry();
152
153 virtual void
155 {
156 fatal("recvRespRetry() is not implemented in the TLB "
157 "coalescer.\n");
158 }
159
160 virtual AddrRangeList getAddrRanges() const;
161 };
162
164 {
165 public:
166 MemSidePort(const std::string &_name, VegaTLBCoalescer *tlb_coalescer,
167 PortID _index)
168 : RequestPort(_name), coalescer(tlb_coalescer),
169 index(_index) { }
170
172
173 protected:
175 int index;
176
177 virtual bool recvTimingResp(PacketPtr pkt);
178 virtual Tick recvAtomic(PacketPtr pkt) { return 0; }
179 virtual void recvFunctional(PacketPtr pkt);
180 virtual void recvRangeChange() { }
181 virtual void recvReqRetry();
182
183 virtual void
185 {
186 fatal("recvRespRetry() not implemented in TLB coalescer");
187 }
188 };
189
190 // Coalescer response ports on the cpu Side
192 // Coalescer request ports on the memory side
194
195 Port &getPort(const std::string &if_name,
196 PortID idx=InvalidPortID) override;
197
201
202 void processCleanupEvent();
206
209 unsigned int numDownstream;
211 std::queue<CpuSidePort *> stalledPortsQueue;
212 // enforce uniqueness in queue
213 std::map<CpuSidePort *, CpuSidePort *> stalledPortsMap;
214
215 unsigned int availDownstreamSlots() {
216 assert(tlb_level == 1);
218 }
219
220 void insertStalledPortIfNotMapped(CpuSidePort *);
221 bool mustStallCUPort(CpuSidePort *);
222
224 assert(tlb_level == 1);
225 return stalledPortsQueue.size() > 0;
226 }
227
229 assert(tlb_level == 1);
230 assert(numDownstream > 0);
232 }
233
235 assert(tlb_level == 1);
236 assert(maxDownstream >= numDownstream);
238 }
239
240 void unstallPorts();
241
242
243 // this FIFO queue keeps track of the virt. page
244 // addresses that are pending cleanup
245 std::queue<Addr> cleanupQueue;
246};
247
248} // namespace gem5
249
250#endif // __ARCH_AMDGPU_VEGA_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:295
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:136
A ResponsePort is a specialization of a port.
Definition port.hh:349
CpuSidePort(const std::string &_name, VegaTLBCoalescer *tlb_coalescer, PortID _index)
virtual Tick recvAtomic(PacketPtr pkt)
Receive an atomic request packet from the peer.
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.
virtual void recvRespRetry()
Called by the peer if sendTimingResp was called on this protocol (causing recvTimingResp to be called...
virtual bool recvTimingReq(PacketPtr pkt)
Receive a timing request from the peer.
virtual void recvRangeChange()
Called to receive an address range change from the peer response port.
virtual void recvReqRetry()
Called by the peer if sendTimingReq was called on this peer (causing recvTimingReq to be called on th...
virtual void recvFunctional(PacketPtr pkt)
virtual bool recvTimingResp(PacketPtr pkt)
Receive a timing response from the peer.
MemSidePort(const std::string &_name, VegaTLBCoalescer *tlb_coalescer, PortID _index)
virtual Tick recvAtomic(PacketPtr pkt)
The VegaTLBCoalescer is a ClockedObject sitting on the front side (CPUSide) of each TLB.
std::map< Tick, std::vector< coalescedReq > > CoalescingFIFO
statistics::Scalar localqueuingCycles
statistics::Scalar coalescedAccesses
CoalescingTable issuedTranslationsTable
void updatePhysAddresses(PacketPtr pkt)
statistics::Scalar queuingCycles
EventFunctionWrapper cleanupEvent
The cleanupEvent is scheduled after a TLBEvent triggers in order to free memory and do the required c...
std::queue< CpuSidePort * > stalledPortsQueue
statistics::Scalar uncoalescedAccesses
std::vector< PacketPtr > coalescedReq
Port & getPort(const std::string &if_name, PortID idx=InvalidPortID) override
Get a port with a given name and index.
std::vector< CpuSidePort * > cpuSidePort
std::vector< MemSidePort * > memSidePort
EventFunctionWrapper probeTLBEvent
This event issues the TLB probes.
VegaTLBCoalescer(const VegaTLBCoalescerParams &p)
void insertStalledPortIfNotMapped(CpuSidePort *)
CoalescingFIFO coalescerFIFO
std::unordered_map< Addr, coalescedReq > CoalescingTable
std::map< CpuSidePort *, CpuSidePort * > stalledPortsMap
bool canCoalesce(PacketPtr pkt1, PacketPtr pkt2)
void regStats() override
Callback to set stat parameters.
statistics::Formula localLatency
unsigned int availDownstreamSlots()
std::queue< Addr > cleanupQueue
bool mustStallCUPort(CpuSidePort *)
statistics::Scalar localCycles
statistics::Formula latency
A formula for statistics that is calculated when printed.
This is a simple scalar statistic, like a counter.
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:200
Port Object Declaration.
Bitfield< 0 > p
ProbePointArg< PacketInfo > Packet
Packet probe point.
Definition mem.hh:108
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
Definition binary32.hh:36
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.

Generated on Tue Jun 18 2024 16:23:55 for gem5 by doxygen 1.11.0