gem5 v23.0.0.1
Loading...
Searching...
No Matches
base.hh
Go to the documentation of this file.
1/*
2 * Copyright (c) 2013-2014 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
65class BaseCache;
66struct BasePrefetcherParams;
67
68namespace prefetch
69{
70
71class Base : public ClockedObject
72{
73 class PrefetchListener : public ProbeListenerArgBase<PacketPtr>
74 {
75 public:
77 const std::string &name, bool _isFill = false,
78 bool _miss = false)
80 parent(_parent), isFill(_isFill), miss(_miss) {}
81 void notify(const PacketPtr &pkt) override;
82 protected:
84 const bool isFill;
85 const bool miss;
86 };
87
89
90 public:
91
97 {
107 bool secure;
109 unsigned int size;
111 bool write;
117 uint8_t *data;
118
119 public:
124 Addr getAddr() const
125 {
126 return address;
127 }
128
133 bool isSecure() const
134 {
135 return secure;
136 }
137
142 Addr getPC() const
143 {
144 assert(hasPC());
145 return pc;
146 }
147
152 bool hasPC() const
153 {
154 return validPC;
155 }
156
162 {
163 return requestorId;
164 }
165
170 unsigned int getSize() const
171 {
172 return size;
173 }
174
180 bool isWrite() const
181 {
182 return write;
183 }
184
190 {
191 return paddress;
192 }
193
198 bool isCacheMiss() const
199 {
200 return cacheMiss;
201 }
202
208 template <typename T>
209 inline T
210 get(ByteOrder endian) const
211 {
212 if (data == nullptr) {
213 panic("PrefetchInfo::get called with a request with no data.");
214 }
215 switch (endian) {
216 case ByteOrder::big:
217 return betoh(*(T*)data);
218
219 case ByteOrder::little:
220 return letoh(*(T*)data);
221
222 default:
223 panic("Illegal byte order in PrefetchInfo::get()\n");
224 };
225 }
226
232 bool sameAddr(PrefetchInfo const &pfi) const
233 {
234 return this->getAddr() == pfi.getAddr() &&
235 this->isSecure() == pfi.isSecure();
236 }
237
245 PrefetchInfo(PacketPtr pkt, Addr addr, bool miss);
246
253 PrefetchInfo(PrefetchInfo const &pfi, Addr addr);
254
256 {
257 delete[] data;
258 }
259 };
260
261 protected:
262
263 // PARAMETERS
264
267
269 unsigned blkSize;
270
272 unsigned lBlkSize;
273
275 const bool onMiss;
276
278 const bool onRead;
279
281 const bool onWrite;
282
284 const bool onData;
285
287 const bool onInst;
288
291
293
296
298 const bool prefetchOnPfHit;
299
302
308 bool observeAccess(const PacketPtr &pkt, bool miss) const;
309
311 bool inCache(Addr addr, bool is_secure) const;
312
314 bool inMissQueue(Addr addr, bool is_secure) const;
315
316 bool hasBeenPrefetched(Addr addr, bool is_secure) const;
317
319 bool samePage(Addr a, Addr b) const;
321 Addr blockAddress(Addr a) const;
323 Addr blockIndex(Addr a) const;
325 Addr pageAddress(Addr a) const;
327 Addr pageOffset(Addr a) const;
329 Addr pageIthBlockAddress(Addr page, uint32_t i) const;
331 {
345
348
351
355
360
365
368
369 public:
370 Base(const BasePrefetcherParams &p);
371 virtual ~Base() = default;
372
373 virtual void setCache(BaseCache *_cache);
374
379 virtual void notify(const PacketPtr &pkt, const PrefetchInfo &pfi) = 0;
380
382 virtual void notifyFill(const PacketPtr &pkt)
383 {}
384
385 virtual PacketPtr getPacket() = 0;
386
387 virtual Tick nextPrefetchReadyTime() const = 0;
388
389 void
391 {
393 }
394
395 void
397 {
399 }
400
401 void
403 {
405 }
406
407 void
409 {
411 }
412
413 void
415 {
417 }
418
422 void regProbeListeners() override;
423
429 void probeNotify(const PacketPtr &pkt, bool miss);
430
436 void addEventProbe(SimObject *obj, const char *name);
437
444 void addMMU(BaseMMU *mmu);
445};
446
447} // namespace prefetch
448} // namespace gem5
449
450#endif //__MEM_CACHE_PREFETCH_BASE_HH__
Defines global host-dependent types: Counter, Tick, and (indirectly) {int,uint}{8,...
Definitions of a simple cache block class.
A basic cache interface.
Definition base.hh:95
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:211
const std::string name
Definition probe.hh:137
ProbeManager is a conduit class that lives on each SimObject, and is used to match up probe listeners...
Definition probe.hh:163
Abstract superclass for simulation objects.
Class containing the information needed by the prefetch to train and generate new prefetch requests.
Definition base.hh:97
bool validPC
Validity bit for the PC of this address.
Definition base.hh:105
Addr getPC() const
Returns the program counter that generated this request.
Definition base.hh:142
bool isSecure() const
Returns true if the address targets the secure memory space.
Definition base.hh:133
unsigned int getSize() const
Gets the size of the request triggering this event.
Definition base.hh:170
Addr getPaddr() const
Gets the physical address of the request.
Definition base.hh:189
bool write
Whether this event comes from a write request.
Definition base.hh:111
bool isWrite() const
Checks if the request that caused this prefetch event was a write request.
Definition base.hh:180
bool isCacheMiss() const
Check if this event comes from a cache miss.
Definition base.hh:198
RequestorID requestorId
The requestor ID that generated this address.
Definition base.hh:103
Addr address
The address used to train and generate prefetches.
Definition base.hh:99
Addr getAddr() const
Obtains the address value of this Prefetcher address.
Definition base.hh:124
bool cacheMiss
Whether this event comes from a cache miss.
Definition base.hh:115
Addr paddress
Physical address, needed because address can be virtual.
Definition base.hh:113
T get(ByteOrder endian) const
Gets the associated data of the request triggering the event.
Definition base.hh:210
bool hasPC() const
Returns true if the associated program counter is valid.
Definition base.hh:152
Addr pc
The program counter that generated this address.
Definition base.hh:101
unsigned int size
Size in bytes of the request triggering this event.
Definition base.hh:109
uint8_t * data
Pointer to the associated request data.
Definition base.hh:117
RequestorID getRequestorId() const
Gets the requestor ID that generated this address.
Definition base.hh:161
bool secure
Whether this address targets the secure memory space.
Definition base.hh:107
bool sameAddr(PrefetchInfo const &pfi) const
Check for equality.
Definition base.hh:232
void notify(const PacketPtr &pkt) override
Definition base.cc:86
PrefetchListener(Base &_parent, ProbeManager *pm, const std::string &name, bool _isFill=false, bool _miss=false)
Definition base.hh:76
const bool useVirtualAddresses
Use Virtual Addresses for prefetching.
Definition base.hh:301
const bool prefetchOnAccess
Prefetch on every access, not just misses.
Definition base.hh:295
const bool onRead
Consult prefetcher on reads?
Definition base.hh:278
unsigned blkSize
The block size of the parent cache.
Definition base.hh:269
uint64_t issuedPrefetches
Total prefetches issued.
Definition base.hh:362
bool observeAccess(const PacketPtr &pkt, bool miss) const
Determine if this access should be observed.
Definition base.cc:160
bool inCache(Addr addr, bool is_secure) const
Determine if address is in cache.
Definition base.cc:188
void incrDemandMhsrMisses()
Definition base.hh:396
void addEventProbe(SimObject *obj, const char *name)
Add a SimObject and a probe name to listen events from.
Definition base.cc:294
const RequestorID requestorId
Request id for prefetches.
Definition base.hh:290
void pfHitInCache()
Definition base.hh:402
std::vector< PrefetchListener * > listeners
Definition base.hh:88
void addMMU(BaseMMU *mmu)
Add a BaseMMU object to be used whenever a translation is needed.
Definition base.cc:301
void regProbeListeners() override
Register probe points for this object.
Definition base.cc:275
Addr pageAddress(Addr a) const
Determine the address of the page in which a lays.
Definition base.cc:224
bool inMissQueue(Addr addr, bool is_secure) const
Determine if address is in cache miss queue.
Definition base.cc:194
bool hasBeenPrefetched(Addr addr, bool is_secure) const
Definition base.cc:200
const bool onInst
Consult prefetcher on instruction accesses?
Definition base.hh:287
uint64_t usefulPrefetches
Total prefetches that has been useful.
Definition base.hh:364
gem5::prefetch::Base::StatGroup prefetchStats
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:236
BaseCache * cache
Pointr to the parent cache.
Definition base.hh:266
Addr pageOffset(Addr a) const
Determine the page-offset of a
Definition base.cc:230
BaseMMU * mmu
Registered mmu for address translations.
Definition base.hh:367
virtual PacketPtr getPacket()=0
virtual void setCache(BaseCache *_cache)
Definition base.cc:110
const bool onData
Consult prefetcher on data accesses?
Definition base.hh:284
const bool prefetchOnPfHit
Prefetch on hit on prefetched lines.
Definition base.hh:298
void probeNotify(const PacketPtr &pkt, bool miss)
Process a notification event from the ProbeListener.
Definition base.cc:242
virtual void notifyFill(const PacketPtr &pkt)
Notify prefetcher of cache fill.
Definition base.hh:382
const bool onWrite
Consult prefetcher on reads?
Definition base.hh:281
virtual void notify(const PacketPtr &pkt, const PrefetchInfo &pfi)=0
Notify prefetcher of cache access (may be any access or just misses, depending on cache parameters....
unsigned lBlkSize
log_2(block size of the parent cache).
Definition base.hh:272
const Addr pageBytes
Definition base.hh:292
Addr blockIndex(Addr a) const
Determine the address of a at block granularity.
Definition base.cc:218
void prefetchUnused()
Definition base.hh:390
Addr blockAddress(Addr a) const
Determine the address of the block in which a lays.
Definition base.cc:212
const bool onMiss
Only consult prefetcher on cache misses?
Definition base.hh:275
bool samePage(Addr a, Addr b) const
Determine if addresses are on the same page.
Definition base.cc:206
virtual Tick nextPrefetchReadyTime() const =0
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
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
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.
statistics::Formula accuracy
Definition base.hh:343
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:342
statistics::Scalar pfIssued
Definition base.hh:334
statistics::Scalar pfUseful
The number of times a HW-prefetch is useful.
Definition base.hh:339
statistics::Scalar pfHitInWB
The number of times a HW-prefetch hits in the Write Buffer (WB).
Definition base.hh:354
statistics::Scalar pfHitInMSHR
The number of times a HW-prefetch hits in a MSHR.
Definition base.hh:350
statistics::Formula pfLate
The number of times a HW-prefetch is late (hit in cache, MSHR, WB).
Definition base.hh:358
statistics::Scalar pfUnused
The number of times a HW-prefetched block is evicted w/o reference.
Definition base.hh:337
statistics::Scalar pfHitInCache
The number of times a HW-prefetch hits in cache.
Definition base.hh:347
statistics::Scalar demandMshrMisses
Definition base.hh:333
statistics::Formula coverage
Definition base.hh:344

Generated on Mon Jul 10 2023 15:32:02 for gem5 by doxygen 1.9.7