gem5 v24.0.0.0
Loading...
Searching...
No Matches
tlb.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_HH__
33#define __ARCH_AMDGPU_VEGA_TLB_HH__
34
35#include <list>
36#include <queue>
37#include <string>
38#include <vector>
39
41#include "arch/generic/mmu.hh"
42#include "base/statistics.hh"
43#include "base/trace.hh"
44#include "mem/packet.hh"
45#include "mem/port.hh"
46#include "params/VegaGPUTLB.hh"
47#include "sim/clocked_object.hh"
48
49namespace gem5
50{
51
52class BaseMMU;
53class Packet;
54class AMDGPUDevice;
55class ThreadContext;
56
57namespace VegaISA
58{
59
60class Walker;
61
62class GpuTLB : public ClockedObject
63{
64 public:
65 GpuTLB(const VegaGPUTLBParams &p);
66 ~GpuTLB();
67
68 typedef enum BaseMMU::Mode Mode;
69
71 {
72 public:
73 virtual ~Translation() { }
74
79 virtual void markDelayed() = 0;
80
86 virtual void finish(Fault fault, const RequestPtr &req,
87 Mode mode) = 0;
88
95 virtual bool squashed() const { return false; }
96 };
97
99 void dumpAll();
100 VegaTlbEntry *lookup(Addr va, bool update_lru=true);
101
102 Walker *getWalker();
103 void invalidateAll();
104 void demapPage(Addr va, uint64_t asn);
105
106 protected:
108 EntryList::iterator lookupIt(Addr va, bool update_lru=true);
111
112 int size;
113 int assoc;
115
119 bool FA;
121
127
132
134
135 /*
136 * It's a per-set list. As long as we have not reached
137 * the full capacity of the given set, grab an entry from
138 * the freeList.
139 */
141
150
151 public:
152 // latencies for a TLB hit, miss and page fault
156
187
188
189 VegaTlbEntry *insert(Addr vpn, VegaTlbEntry &entry);
190
191 // Checkpointing
192 virtual void serialize(CheckpointOut& cp) const override;
193 virtual void unserialize(CheckpointIn& cp) override;
196 VegaTlbEntry *tlbLookup(const RequestPtr &req, bool update_stats);
197
198 void walkerResponse(VegaTlbEntry& entry, PacketPtr pkt);
200 PacketPtr pkt);
201
203
205 VegaTlbEntry *tlb_entry, Mode mode);
206
207 void updatePhysAddresses(Addr virt_page_addr, VegaTlbEntry *tlb_entry,
208 Addr phys_page_addr);
209
210 void issueTLBLookup(PacketPtr pkt);
211
212 // CpuSidePort is the TLB Port closer to the CPU/CU side
214 {
215 public:
216 CpuSidePort(const std::string &_name, GpuTLB * gpu_TLB,
217 PortID _index)
218 : ResponsePort(_name), tlb(gpu_TLB), index(_index) { }
219
220 protected:
222 int index;
223
224 virtual bool recvTimingReq(PacketPtr pkt);
225 virtual Tick recvAtomic(PacketPtr pkt) { return 0; }
226 virtual void recvFunctional(PacketPtr pkt);
227 virtual void recvRangeChange() { }
228 virtual void recvReqRetry();
229 virtual void recvRespRetry() { panic("recvRespRetry called"); }
230 virtual AddrRangeList getAddrRanges() const;
231 };
232
241 {
242 public:
243 MemSidePort(const std::string &_name, GpuTLB * gpu_TLB,
244 PortID _index)
245 : RequestPort(_name), tlb(gpu_TLB), index(_index) { }
246
248
249 protected:
251 int index;
252
253 virtual bool recvTimingResp(PacketPtr pkt);
254 virtual Tick recvAtomic(PacketPtr pkt) { return 0; }
255 virtual void recvFunctional(PacketPtr pkt) { }
256 virtual void recvRangeChange() { }
257 virtual void recvReqRetry();
258 };
259
260 // TLB ports on the cpu Side
262 // TLB ports on the memory side
264
265 Port &getPort(const std::string &if_name,
266 PortID idx=InvalidPortID) override;
267
269
270 // maximum number of permitted coalesced requests per cycle
272
273 // Current number of outstandings coalesced requests.
274 // Should be <= maxCoalescedReqs
276
284 void translationReturn(Addr virtPageAddr, tlbOutcome outcome,
285 PacketPtr pkt);
286
287 class TLBEvent : public Event
288 {
289 private:
297
298 public:
299 TLBEvent(GpuTLB *_tlb, Addr _addr, tlbOutcome outcome,
300 PacketPtr _pkt);
301
302 void process();
303 const char *description() const;
304
305 // updateOutcome updates the tlbOutcome of a TLBEvent
306 void updateOutcome(tlbOutcome _outcome);
308 };
309
310 std::unordered_map<Addr, TLBEvent*> translationReturnEvent;
311
312 // this FIFO queue keeps track of the virt. page addresses
313 // that are pending cleanup
314 std::queue<Addr> cleanupQueue;
315
316 // the cleanupEvent is scheduled after a TLBEvent triggers in order to
317 // free memory and do the required clean-up
318 void cleanup();
319
321};
322
323} // namespace VegaISA
324
325} // namespace gem5
326
327#endif // __ARCH_AMDGPU_VEGA_TLB_HH__
Device model for an AMD GPU.
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
virtual void recvRangeChange()
Definition tlb.hh:227
virtual bool recvTimingReq(PacketPtr pkt)
recvTiming receives a coalesced timing request from a TLBCoalescer and it calls issueTLBLookup() It o...
Definition tlb.cc:660
virtual void recvRespRetry()
Called by the peer if sendTimingResp was called on this protocol (causing recvTimingResp to be called...
Definition tlb.hh:229
virtual AddrRangeList getAddrRanges() const
Get a list of the non-overlapping address ranges the owner is responsible for.
Definition tlb.cc:892
CpuSidePort(const std::string &_name, GpuTLB *gpu_TLB, PortID _index)
Definition tlb.hh:216
virtual void recvFunctional(PacketPtr pkt)
Receive a functional request packet from the peer.
Definition tlb.cc:766
virtual Tick recvAtomic(PacketPtr pkt)
Receive an atomic request packet from the peer.
Definition tlb.hh:225
MemSidePort is the TLB Port closer to the memory side If this is a last level TLB then this port will...
Definition tlb.hh:241
virtual void recvFunctional(PacketPtr pkt)
Definition tlb.hh:255
std::deque< PacketPtr > retries
Definition tlb.hh:247
virtual Tick recvAtomic(PacketPtr pkt)
Definition tlb.hh:254
MemSidePort(const std::string &_name, GpuTLB *gpu_TLB, PortID _index)
Definition tlb.hh:243
virtual bool recvTimingResp(PacketPtr pkt)
MemSidePort receives the packet back.
Definition tlb.cc:906
virtual void recvReqRetry()
Called by the peer if sendTimingReq was called on this peer (causing recvTimingReq to be called on th...
Definition tlb.cc:925
virtual void recvRangeChange()
Called to receive an address range change from the peer response port.
Definition tlb.hh:256
const char * description() const
Return a C string describing the event.
Definition tlb.cc:636
void updateOutcome(tlbOutcome _outcome)
Definition tlb.cc:642
tlbOutcome outcome
outcome can be TLB_HIT, TLB_MISS, or PAGE_WALK
Definition tlb.hh:295
TLBEvent(GpuTLB *_tlb, Addr _addr, tlbOutcome outcome, PacketPtr _pkt)
Definition tlb.cc:397
virtual bool squashed() const
This function is used by the page table walker to determine if it should translate the a pending requ...
Definition tlb.hh:95
virtual void markDelayed()=0
Signal that the translation has been delayed due to a hw page table walk.
virtual void finish(Fault fault, const RequestPtr &req, Mode mode)=0
The memory for this object may be dynamically allocated, and it may be responsible for cleaning itsle...
VegaTlbEntry * lookup(Addr va, bool update_lru=true)
Definition tlb.cc:211
EntryList::iterator lookupIt(Addr va, bool update_lru=true)
Definition tlb.cc:181
void walkerResponse(VegaTlbEntry &entry, PacketPtr pkt)
Definition tlb.cc:425
std::vector< CpuSidePort * > cpuSidePort
Definition tlb.hh:261
virtual void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition tlb.cc:295
virtual void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition tlb.cc:300
void issueTLBLookup(PacketPtr pkt)
Do the TLB lookup for this coalesced request and schedule another event <TLB access latency> cycles l...
Definition tlb.cc:310
VegaTlbEntry * insert(Addr vpn, VegaTlbEntry &entry)
Definition tlb.cc:157
void translationReturn(Addr virtPageAddr, tlbOutcome outcome, PacketPtr pkt)
A TLBEvent is scheduled after the TLB lookup and helps us take the appropriate actions: (e....
Definition tlb.cc:548
void pagingProtectionChecks(PacketPtr pkt, VegaTlbEntry *tlb_entry, Mode mode)
Do Paging protection checks.
Definition tlb.cc:409
void handleFuncTranslationReturn(PacketPtr pkt, tlbOutcome outcome)
handleFuncTranslationReturn is called on a TLB hit, when a TLB miss returns or when a page fault retu...
Definition tlb.cc:695
enum BaseMMU::Mode Mode
Definition tlb.hh:68
std::unordered_map< Addr, TLBEvent * > translationReturnEvent
Definition tlb.hh:310
std::list< VegaTlbEntry * > EntryList
Definition tlb.hh:107
std::vector< MemSidePort * > memSidePort
Definition tlb.hh:263
Walker * getWalker()
Definition tlb.cc:288
std::vector< EntryList > freeList
Definition tlb.hh:140
void invalidateAll()
Definition tlb.cc:224
Walker * walker
Definition tlb.hh:109
Port & getPort(const std::string &if_name, PortID idx=InvalidPortID) override
Get a port with a given name and index.
Definition tlb.cc:114
AMDGPUDevice * gpuDevice
Definition tlb.hh:110
Addr pageAlign(Addr vaddr)
Definition tlb.cc:150
void handleTranslationReturn(Addr addr, tlbOutcome outcome, PacketPtr pkt)
handleTranslationReturn is called on a TLB hit, when a TLB miss returns or when a page fault returns.
Definition tlb.cc:451
std::queue< Addr > cleanupQueue
Definition tlb.hh:314
bool FA
true if this is a fully-associative TLB
Definition tlb.hh:119
bool allocationPolicy
Allocation Policy: true if we always allocate on a hit, false otherwise.
Definition tlb.hh:126
EventFunctionWrapper cleanupEvent
Definition tlb.hh:320
gem5::VegaISA::GpuTLB::VegaTLBStats stats
VegaTlbEntry * tlbLookup(const RequestPtr &req, bool update_stats)
TLB_lookup will only perform a TLB lookup returning the TLB entry on a TLB hit and nullptr on a TLB m...
Definition tlb.cc:260
std::vector< EntryList > entryList
An entryList per set is the equivalent of an LRU stack; it's used to guide replacement decisions.
Definition tlb.hh:149
void demapPage(Addr va, uint64_t asn)
Definition tlb.cc:238
GpuTLB(const VegaGPUTLBParams &p)
Definition tlb.cc:52
std::vector< VegaTlbEntry > tlb
Definition tlb.hh:133
Fault createPagefault(Addr vaddr, Mode mode)
Definition tlb.cc:136
void updatePhysAddresses(Addr virt_page_addr, VegaTlbEntry *tlb_entry, Addr phys_page_addr)
bool hasMemSidePort
if true, then this is not the last level TLB
Definition tlb.hh:131
A formula for statistics that is calculated when printed.
Statistics container.
Definition group.hh:93
This is a simple scalar statistic, like a counter.
STL deque class.
Definition stl.hh:44
STL list class.
Definition stl.hh:51
STL vector class.
Definition stl.hh:37
ClockedObject declaration and implementation.
#define panic(...)
This implements a cprintf based panic() function.
Definition logging.hh:188
Port Object Declaration.
Bitfield< 4, 0 > mode
Definition misc_types.hh:74
Bitfield< 8 > va
Bitfield< 54 > p
Definition pagetable.hh:70
Bitfield< 3 > addr
Definition types.hh:84
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
std::shared_ptr< FaultBase > Fault
Definition types.hh:249
std::shared_ptr< Request > RequestPtr
Definition request.hh:94
const PortID InvalidPortID
Definition types.hh:246
std::ostream CheckpointOut
Definition serialize.hh:66
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition types.hh:147
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 the Packet class.
Declaration of Statistics objects.
statistics::Scalar outstandingReqsMax
Definition tlb.hh:162
statistics::Scalar localNumTLBMisses
Definition tlb.hh:168
statistics::Formula localLatency
Definition tlb.hh:185
statistics::Formula localTLBMissRate
Definition tlb.hh:169
statistics::Scalar localCycles
Definition tlb.hh:184
statistics::Scalar globalNumTLBAccesses
Definition tlb.hh:174
statistics::Scalar accessCycles
Definition tlb.hh:180
statistics::Scalar localNumTLBAccesses
Definition tlb.hh:166
VegaTLBStats(statistics::Group *parent)
Definition tlb.cc:958
statistics::Formula globalTLBMissRate
Definition tlb.hh:177
statistics::Scalar globalNumTLBMisses
Definition tlb.hh:176
statistics::Scalar localNumTLBHits
Definition tlb.hh:167
statistics::Scalar pageTableCycles
Definition tlb.hh:181
statistics::Scalar globalNumTLBHits
Definition tlb.hh:175
statistics::Scalar maxDownstreamReached
Definition tlb.hh:161

Generated on Tue Jun 18 2024 16:24:00 for gem5 by doxygen 1.11.0