gem5 v24.0.0.0
Loading...
Searching...
No Matches
base.hh
Go to the documentation of this file.
1/*
2 * Copyright (c) 2013-2014, 2023 ARM Limited
3 * All rights reserved.
4 *
5 * The license below extends only to copyright in the software and shall
6 * not be construed as granting a license to any other intellectual
7 * property including but not limited to intellectual property relating
8 * to a hardware implementation of the functionality of the software
9 * licensed hereunder. You may use the software subject to the license
10 * terms below provided that you ensure that this notice is replicated
11 * unmodified and in its entirety in all distributions of the software,
12 * modified or unmodified, in source code or in binary form.
13 *
14 * Copyright (c) 2005 The Regents of The University of Michigan
15 * All rights reserved.
16 *
17 * Redistribution and use in source and binary forms, with or without
18 * modification, are permitted provided that the following conditions are
19 * met: redistributions of source code must retain the above copyright
20 * notice, this list of conditions and the following disclaimer;
21 * redistributions in binary form must reproduce the above copyright
22 * notice, this list of conditions and the following disclaimer in the
23 * documentation and/or other materials provided with the distribution;
24 * neither the name of the copyright holders nor the names of its
25 * contributors may be used to endorse or promote products derived from
26 * this software without specific prior written permission.
27 *
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
31 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
32 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
33 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
34 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
35 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
36 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
38 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39 */
40
46#ifndef __MEM_CACHE_PREFETCH_BASE_HH__
47#define __MEM_CACHE_PREFETCH_BASE_HH__
48
49#include <cstdint>
50
51#include "arch/generic/tlb.hh"
52#include "base/compiler.hh"
53#include "base/statistics.hh"
54#include "base/types.hh"
56#include "mem/packet.hh"
57#include "mem/request.hh"
58#include "sim/byteswap.hh"
59#include "sim/clocked_object.hh"
60#include "sim/probe/probe.hh"
61
62namespace gem5
63{
64
65struct BasePrefetcherParams;
66class ProbeManager;
67class System;
68
69namespace prefetch
70{
71
72class Base : public ClockedObject
73{
74 class PrefetchListener : public ProbeListenerArgBase<CacheAccessProbeArg>
75 {
76 public:
78 const std::string &name, bool _isFill = false,
79 bool _miss = false)
81 parent(_parent), isFill(_isFill), miss(_miss) {}
82 void notify(const CacheAccessProbeArg &arg) override;
83 protected:
85 const bool isFill;
86 const bool miss;
87 };
88
90
91 class PrefetchEvictListener : public ProbeListenerArgBase<EvictionInfo>
92 {
93 public:
95 const std::string &name)
96 : ProbeListenerArgBase(pm, name), parent(_parent) {}
97 void notify(const EvictionInfo &info) override;
98 protected:
100 };
101
103
104 public:
105
111 {
121 bool secure;
123 unsigned int size;
125 bool write;
131 uint8_t *data;
132
133 public:
138 Addr getAddr() const
139 {
140 return address;
141 }
142
147 bool isSecure() const
148 {
149 return secure;
150 }
151
156 Addr getPC() const
157 {
158 assert(hasPC());
159 return pc;
160 }
161
166 bool hasPC() const
167 {
168 return validPC;
169 }
170
176 {
177 return requestorId;
178 }
179
184 unsigned int getSize() const
185 {
186 return size;
187 }
188
194 bool isWrite() const
195 {
196 return write;
197 }
198
204 {
205 return paddress;
206 }
207
212 bool isCacheMiss() const
213 {
214 return cacheMiss;
215 }
216
222 template <typename T>
223 inline T
224 get(ByteOrder endian) const
225 {
226 if (data == nullptr) {
227 panic("PrefetchInfo::get called with a request with no data.");
228 }
229 switch (endian) {
230 case ByteOrder::big:
231 return betoh(*(T*)data);
232
233 case ByteOrder::little:
234 return letoh(*(T*)data);
235
236 default:
237 panic("Illegal byte order in PrefetchInfo::get()\n");
238 };
239 }
240
246 bool sameAddr(PrefetchInfo const &pfi) const
247 {
248 return this->getAddr() == pfi.getAddr() &&
249 this->isSecure() == pfi.isSecure();
250 }
251
259 PrefetchInfo(PacketPtr pkt, Addr addr, bool miss);
260
267 PrefetchInfo(PrefetchInfo const &pfi, Addr addr);
268
270 {
271 delete[] data;
272 }
273 };
274
275 protected:
276
277 // PARAMETERS
278
281
284
286 unsigned blkSize;
287
289 unsigned lBlkSize;
290
292 const bool onMiss;
293
295 const bool onRead;
296
298 const bool onWrite;
299
301 const bool onData;
302
304 const bool onInst;
305
308
310
313
315 const bool prefetchOnPfHit;
316
319
326 bool observeAccess(const PacketPtr &pkt, bool miss, bool prefetched) const;
327
329 bool samePage(Addr a, Addr b) const;
331 Addr blockAddress(Addr a) const;
333 Addr blockIndex(Addr a) const;
335 Addr pageAddress(Addr a) const;
337 Addr pageOffset(Addr a) const;
339 Addr pageIthBlockAddress(Addr page, uint32_t i) const;
370
375
378
379 public:
380 Base(const BasePrefetcherParams &p);
381 virtual ~Base() = default;
382
383 virtual void
384 setParentInfo(System *sys, ProbeManager *pm, unsigned blk_size);
385
390 virtual void
391 notify(const CacheAccessProbeArg &acc, const PrefetchInfo &pfi) = 0;
392
394 virtual void notifyFill(const CacheAccessProbeArg &acc)
395 {}
396
398 virtual void notifyEvict(const EvictionInfo &info)
399 {}
400
401 virtual PacketPtr getPacket() = 0;
402
403 virtual Tick nextPrefetchReadyTime() const = 0;
404
405 void
410
411 void
416
417 void
422
423 void
428
429 void
431 {
433 }
434
438 void regProbeListeners() override;
439
445 void probeNotify(const CacheAccessProbeArg &acc, bool miss);
446
452 void addEventProbe(SimObject *obj, const char *name);
453
460 void addMMU(BaseMMU *mmu);
461};
462
463} // namespace prefetch
464} // namespace gem5
465
466#endif //__MEM_CACHE_PREFETCH_BASE_HH__
Defines global host-dependent types: Counter, Tick, and (indirectly) {int,uint}{8,...
Information provided to probes on a cache event.
The ClockedObject class extends the SimObject with a clock and accessor functions to relate ticks to ...
virtual std::string name() const
Definition named.hh:47
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition packet.hh:295
ProbeListenerArgBase is used to define the base interface to a ProbeListenerArg (i....
Definition probe.hh:212
const std::string name
Definition probe.hh:138
ProbeManager is a conduit class that lives on each SimObject, and is used to match up probe listeners...
Definition probe.hh:164
Abstract superclass for simulation objects.
PrefetchEvictListener(Base &_parent, ProbeManager *pm, const std::string &name)
Definition base.hh:94
void notify(const EvictionInfo &info) override
Definition base.cc:96
Class containing the information needed by the prefetch to train and generate new prefetch requests.
Definition base.hh:111
bool validPC
Validity bit for the PC of this address.
Definition base.hh:119
PrefetchInfo(PacketPtr pkt, Addr addr, bool miss)
Constructs a PrefetchInfo using a PacketPtr.
Definition base.cc:61
Addr getPC() const
Returns the program counter that generated this request.
Definition base.hh:156
bool isSecure() const
Returns true if the address targets the secure memory space.
Definition base.hh:147
unsigned int getSize() const
Gets the size of the request triggering this event.
Definition base.hh:184
Addr getPaddr() const
Gets the physical address of the request.
Definition base.hh:203
bool write
Whether this event comes from a write request.
Definition base.hh:125
bool isWrite() const
Checks if the request that caused this prefetch event was a write request.
Definition base.hh:194
bool isCacheMiss() const
Check if this event comes from a cache miss.
Definition base.hh:212
RequestorID requestorId
The requestor ID that generated this address.
Definition base.hh:117
Addr address
The address used to train and generate prefetches.
Definition base.hh:113
Addr getAddr() const
Obtains the address value of this Prefetcher address.
Definition base.hh:138
bool cacheMiss
Whether this event comes from a cache miss.
Definition base.hh:129
Addr paddress
Physical address, needed because address can be virtual.
Definition base.hh:127
T get(ByteOrder endian) const
Gets the associated data of the request triggering the event.
Definition base.hh:224
bool hasPC() const
Returns true if the associated program counter is valid.
Definition base.hh:166
Addr pc
The program counter that generated this address.
Definition base.hh:115
unsigned int size
Size in bytes of the request triggering this event.
Definition base.hh:123
uint8_t * data
Pointer to the associated request data.
Definition base.hh:131
RequestorID getRequestorId() const
Gets the requestor ID that generated this address.
Definition base.hh:175
bool secure
Whether this address targets the secure memory space.
Definition base.hh:121
bool sameAddr(PrefetchInfo const &pfi) const
Check for equality.
Definition base.hh:246
void notify(const CacheAccessProbeArg &arg) override
Definition base.cc:86
PrefetchListener(Base &_parent, ProbeManager *pm, const std::string &name, bool _isFill=false, bool _miss=false)
Definition base.hh:77
Base(const BasePrefetcherParams &p)
Definition base.cc:102
const bool useVirtualAddresses
Use Virtual Addresses for prefetching.
Definition base.hh:318
const bool prefetchOnAccess
Prefetch on every access, not just misses.
Definition base.hh:312
const bool onRead
Consult prefetcher on reads?
Definition base.hh:295
virtual void notifyFill(const CacheAccessProbeArg &acc)
Notify prefetcher of cache fill.
Definition base.hh:394
unsigned blkSize
The block size of the parent cache.
Definition base.hh:286
uint64_t issuedPrefetches
Total prefetches issued.
Definition base.hh:372
void incrDemandMhsrMisses()
Definition base.hh:412
const RequestorID requestorId
Request id for prefetches.
Definition base.hh:307
void pfHitInCache()
Definition base.hh:418
void addMMU(BaseMMU *mmu)
Add a BaseMMU object to be used whenever a translation is needed.
Definition base.cc:299
void regProbeListeners() override
Register probe points for this object.
Definition base.cc:272
Addr pageAddress(Addr a) const
Determine the address of the page in which a lays.
Definition base.cc:214
ProbeManager * probeManager
Pointer to the parent cache's probe manager.
Definition base.hh:283
virtual void notifyEvict(const EvictionInfo &info)
Notify prefetcher of cache eviction.
Definition base.hh:398
const bool onInst
Consult prefetcher on instruction accesses?
Definition base.hh:304
uint64_t usefulPrefetches
Total prefetches that has been useful.
Definition base.hh:374
gem5::prefetch::Base::StatGroup prefetchStats
virtual void setParentInfo(System *sys, ProbeManager *pm, unsigned blk_size)
Definition base.cc:118
virtual void notify(const CacheAccessProbeArg &acc, const PrefetchInfo &pfi)=0
Notify prefetcher of cache access (may be any access or just misses, depending on cache parameters....
virtual ~Base()=default
Addr pageIthBlockAddress(Addr page, uint32_t i) const
Build the address of the i-th block inside the page.
Definition base.cc:226
Addr pageOffset(Addr a) const
Determine the page-offset of a
Definition base.cc:220
std::vector< ProbeListener * > listeners
Definition base.hh:102
BaseMMU * mmu
Registered mmu for address translations.
Definition base.hh:377
virtual PacketPtr getPacket()=0
const bool onData
Consult prefetcher on data accesses?
Definition base.hh:301
const bool prefetchOnPfHit
Prefetch on hit on prefetched lines.
Definition base.hh:315
System * system
Pointer to the parent system.
Definition base.hh:280
const bool onWrite
Consult prefetcher on reads?
Definition base.hh:298
unsigned lBlkSize
log_2(block size of the parent cache).
Definition base.hh:289
bool observeAccess(const PacketPtr &pkt, bool miss, bool prefetched) const
Determine if this access should be observed.
Definition base.cc:168
const Addr pageBytes
Definition base.hh:309
Addr blockIndex(Addr a) const
Determine the address of a at block granularity.
Definition base.cc:208
void prefetchUnused()
Definition base.hh:406
Addr blockAddress(Addr a) const
Determine the address of the block in which a lays.
Definition base.cc:202
void probeNotify(const CacheAccessProbeArg &acc, bool miss)
Process a notification event from the ProbeListener.
Definition base.cc:232
const bool onMiss
Only consult prefetcher on cache misses?
Definition base.hh:292
bool samePage(Addr a, Addr b) const
Determine if addresses are on the same page.
Definition base.cc:196
virtual Tick nextPrefetchReadyTime() const =0
void addEventProbe(SimObject *obj, const char *name)
Add a SimObject and a probe name to listen events from.
Definition base.cc:292
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 vector class.
Definition stl.hh:37
ClockedObject declaration and implementation.
#define panic(...)
This implements a cprintf based panic() function.
Definition logging.hh:188
Bitfield< 7 > b
Bitfield< 7 > i
Definition misc_types.hh:67
Bitfield< 8 > a
Definition misc_types.hh:66
Bitfield< 0 > p
Bitfield< 3 > addr
Definition types.hh:84
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
Definition binary32.hh:36
T letoh(T value)
Definition byteswap.hh:173
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition types.hh:147
T betoh(T value)
Definition byteswap.hh:175
uint64_t Tick
Tick count type.
Definition types.hh:58
uint16_t RequestorID
Definition request.hh:95
Declaration of the Packet class.
Declaration of a request, the overall memory request consisting of the parts of the request that are ...
Declaration of Statistics objects.
A data contents update is composed of the updated block's address, the old contents,...
statistics::Formula accuracy
Definition base.hh:353
statistics::Scalar pfUsefulButMiss
The number of times there is a hit on prefetch but cache block is not in an usable state.
Definition base.hh:352
statistics::Scalar pfIssued
Definition base.hh:344
statistics::Scalar pfUseful
The number of times a HW-prefetch is useful.
Definition base.hh:349
statistics::Scalar pfHitInWB
The number of times a HW-prefetch hits in the Write Buffer (WB).
Definition base.hh:364
statistics::Scalar pfHitInMSHR
The number of times a HW-prefetch hits in a MSHR.
Definition base.hh:360
statistics::Formula pfLate
The number of times a HW-prefetch is late (hit in cache, MSHR, WB).
Definition base.hh:368
statistics::Scalar pfUnused
The number of times a HW-prefetched block is evicted w/o reference.
Definition base.hh:347
statistics::Scalar pfHitInCache
The number of times a HW-prefetch hits in cache.
Definition base.hh:357
statistics::Scalar demandMshrMisses
Definition base.hh:343
StatGroup(statistics::Group *parent)
Definition base.cc:128
statistics::Formula coverage
Definition base.hh:354

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