gem5  [DEVELOP-FOR-23.0]
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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"
55 #include "mem/cache/cache_blk.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 
62 namespace gem5
63 {
64 
65 class BaseCache;
66 struct BasePrefetcherParams;
67 
68 namespace prefetch
69 {
70 
71 class 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  {
105  bool validPC;
107  bool secure;
109  unsigned int size;
111  bool write;
115  bool cacheMiss;
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 
189  Addr getPaddr() const
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 
295  const bool prefetchOnAccess;
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;
330  struct StatGroup : public statistics::Group
331  {
332  StatGroup(statistics::Group *parent);
345 
348 
351 
355 
359  } prefetchStats;
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__
gem5::prefetch::Base::PrefetchInfo::getAddr
Addr getAddr() const
Obtains the address value of this Prefetcher address.
Definition: base.hh:124
gem5::statistics::Scalar
This is a simple scalar statistic, like a counter.
Definition: statistics.hh:1929
gem5::prefetch::Base::StatGroup::demandMshrMisses
statistics::Scalar demandMshrMisses
Definition: base.hh:333
gem5::prefetch::Base::prefetchOnAccess
const bool prefetchOnAccess
Prefetch on every access, not just misses.
Definition: base.hh:295
gem5::prefetch::Base::StatGroup::pfUsefulButMiss
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
gem5::prefetch::Base::blockIndex
Addr blockIndex(Addr a) const
Determine the address of a at block granularity.
Definition: base.cc:218
gem5::prefetch::Base::useVirtualAddresses
const bool useVirtualAddresses
Use Virtual Addresses for prefetching.
Definition: base.hh:301
gem5::prefetch::Base::~Base
virtual ~Base()=default
gem5::prefetch::Base::pageOffset
Addr pageOffset(Addr a) const
Determine the page-offset of a
Definition: base.cc:230
gem5::prefetch::Base::addMMU
void addMMU(BaseMMU *mmu)
Add a BaseMMU object to be used whenever a translation is needed.
Definition: base.cc:301
gem5::prefetch::Base::hasBeenPrefetched
bool hasBeenPrefetched(Addr addr, bool is_secure) const
Definition: base.cc:200
gem5::prefetch::Base::PrefetchInfo::write
bool write
Whether this event comes from a write request.
Definition: base.hh:111
gem5::prefetch::Base::StatGroup::StatGroup
StatGroup(statistics::Group *parent)
Definition: base.cc:120
gem5::prefetch::Base::setCache
virtual void setCache(BaseCache *_cache)
Definition: base.cc:110
gem5::prefetch::Base::PrefetchInfo::address
Addr address
The address used to train and generate prefetches.
Definition: base.hh:99
gem5::prefetch::Base::PrefetchInfo::isSecure
bool isSecure() const
Returns true if the address targets the secure memory space.
Definition: base.hh:133
gem5::prefetch::Base::StatGroup::pfIssued
statistics::Scalar pfIssued
Definition: base.hh:334
gem5::prefetch::Base::PrefetchInfo::data
uint8_t * data
Pointer to the associated request data.
Definition: base.hh:117
gem5::prefetch::Base::addEventProbe
void addEventProbe(SimObject *obj, const char *name)
Add a SimObject and a probe name to listen events from.
Definition: base.cc:294
gem5::prefetch::Base::listeners
std::vector< PrefetchListener * > listeners
Definition: base.hh:88
tlb.hh
gem5::betoh
T betoh(T value)
Definition: byteswap.hh:175
gem5::prefetch::Base::prefetchUnused
void prefetchUnused()
Definition: base.hh:390
gem5::ArmISA::a
Bitfield< 8 > a
Definition: misc_types.hh:66
gem5::prefetch::Base::PrefetchInfo::sameAddr
bool sameAddr(PrefetchInfo const &pfi) const
Check for equality.
Definition: base.hh:232
gem5::prefetch::Base::PrefetchInfo::pc
Addr pc
The program counter that generated this address.
Definition: base.hh:101
gem5::prefetch::Base::pageAddress
Addr pageAddress(Addr a) const
Determine the address of the page in which a lays.
Definition: base.cc:224
gem5::prefetch::Base::inMissQueue
bool inMissQueue(Addr addr, bool is_secure) const
Determine if address is in cache miss queue.
Definition: base.cc:194
gem5::prefetch::Base::PrefetchInfo::isCacheMiss
bool isCacheMiss() const
Check if this event comes from a cache miss.
Definition: base.hh:198
gem5::statistics::Formula
A formula for statistics that is calculated when printed.
Definition: statistics.hh:2538
std::vector
STL vector class.
Definition: stl.hh:37
gem5::prefetch::Base::Base
Base(const BasePrefetcherParams &p)
Definition: base.cc:95
gem5::prefetch::Base::blockAddress
Addr blockAddress(Addr a) const
Determine the address of the block in which a lays.
Definition: base.cc:212
gem5::prefetch::Base::notifyFill
virtual void notifyFill(const PacketPtr &pkt)
Notify prefetcher of cache fill.
Definition: base.hh:382
gem5::prefetch::Base::PrefetchInfo::get
T get(ByteOrder endian) const
Gets the associated data of the request triggering the event.
Definition: base.hh:210
gem5::ArmISA::i
Bitfield< 7 > i
Definition: misc_types.hh:67
gem5::prefetch::Base::requestorId
const RequestorID requestorId
Request id for prefetches.
Definition: base.hh:290
gem5::prefetch::Base::PrefetchInfo::size
unsigned int size
Size in bytes of the request triggering this event.
Definition: base.hh:109
gem5::prefetch::Base::PrefetchInfo::getPaddr
Addr getPaddr() const
Gets the physical address of the request.
Definition: base.hh:189
gem5::prefetch::Base::PrefetchListener::miss
const bool miss
Definition: base.hh:85
gem5::prefetch::Base::onRead
const bool onRead
Consult prefetcher on reads?
Definition: base.hh:278
gem5::prefetch::Base::PrefetchInfo::getRequestorId
RequestorID getRequestorId() const
Gets the requestor ID that generated this address.
Definition: base.hh:161
request.hh
gem5::prefetch::Base::mmu
BaseMMU * mmu
Registered mmu for address translations.
Definition: base.hh:367
gem5::prefetch::Base::PrefetchInfo::validPC
bool validPC
Validity bit for the PC of this address.
Definition: base.hh:105
gem5::prefetch::Base::PrefetchListener::isFill
const bool isFill
Definition: base.hh:84
gem5::letoh
T letoh(T value)
Definition: byteswap.hh:173
gem5::BaseMMU
Definition: mmu.hh:53
packet.hh
gem5::prefetch::Base::StatGroup::pfHitInWB
statistics::Scalar pfHitInWB
The number of times a HW-prefetch hits in the Write Buffer (WB).
Definition: base.hh:354
gem5::prefetch::Base::observeAccess
bool observeAccess(const PacketPtr &pkt, bool miss) const
Determine if this access should be observed.
Definition: base.cc:160
gem5::prefetch::Base::onInst
const bool onInst
Consult prefetcher on instruction accesses?
Definition: base.hh:287
gem5::prefetch::Base::PrefetchListener::parent
Base & parent
Definition: base.hh:83
gem5::prefetch::Base::PrefetchInfo::getPC
Addr getPC() const
Returns the program counter that generated this request.
Definition: base.hh:142
gem5::prefetch::Base::StatGroup::pfUnused
statistics::Scalar pfUnused
The number of times a HW-prefetched block is evicted w/o reference.
Definition: base.hh:337
gem5::prefetch::Base::samePage
bool samePage(Addr a, Addr b) const
Determine if addresses are on the same page.
Definition: base.cc:206
gem5::prefetch::Base::PrefetchInfo::requestorId
RequestorID requestorId
The requestor ID that generated this address.
Definition: base.hh:103
gem5::prefetch::Base::onMiss
const bool onMiss
Only consult prefetcher on cache misses?
Definition: base.hh:275
gem5::ArmISA::b
Bitfield< 7 > b
Definition: misc_types.hh:438
gem5::prefetch::Base::pageBytes
const Addr pageBytes
Definition: base.hh:292
gem5::prefetch::Base::pfHitInMSHR
void pfHitInMSHR()
Definition: base.hh:408
gem5::Named::name
virtual std::string name() const
Definition: named.hh:47
gem5::VegaISA::p
Bitfield< 54 > p
Definition: pagetable.hh:70
gem5::BaseCache
A basic cache interface.
Definition: base.hh:94
gem5::Packet
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:294
gem5::prefetch::Base::usefulPrefetches
uint64_t usefulPrefetches
Total prefetches that has been useful.
Definition: base.hh:364
gem5::prefetch::Base::PrefetchInfo::PrefetchInfo
PrefetchInfo(PacketPtr pkt, Addr addr, bool miss)
Constructs a PrefetchInfo using a PacketPtr.
Definition: base.cc:61
statistics.hh
gem5::prefetch::Base::StatGroup::pfLate
statistics::Formula pfLate
The number of times a HW-prefetch is late (hit in cache, MSHR, WB).
Definition: base.hh:358
gem5::Tick
uint64_t Tick
Tick count type.
Definition: types.hh:58
gem5::prefetch::Base::probeNotify
void probeNotify(const PacketPtr &pkt, bool miss)
Process a notification event from the ProbeListener.
Definition: base.cc:242
gem5::prefetch::Base::onData
const bool onData
Consult prefetcher on data accesses?
Definition: base.hh:284
compiler.hh
gem5::prefetch::Base::PrefetchInfo::paddress
Addr paddress
Physical address, needed because address can be virtual.
Definition: base.hh:113
gem5::prefetch::Base::StatGroup::coverage
statistics::Formula coverage
Definition: base.hh:344
gem5::SimObject
Abstract superclass for simulation objects.
Definition: sim_object.hh:146
gem5::prefetch::Base::PrefetchListener::PrefetchListener
PrefetchListener(Base &_parent, ProbeManager *pm, const std::string &name, bool _isFill=false, bool _miss=false)
Definition: base.hh:76
gem5::Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:147
gem5::prefetch::Base::PrefetchInfo::~PrefetchInfo
~PrefetchInfo()
Definition: base.hh:255
gem5::prefetch::Base::pfHitInWB
void pfHitInWB()
Definition: base.hh:414
gem5::prefetch::Base::pfHitInCache
void pfHitInCache()
Definition: base.hh:402
gem5::ClockedObject
The ClockedObject class extends the SimObject with a clock and accessor functions to relate ticks to ...
Definition: clocked_object.hh:234
gem5::prefetch::Base::PrefetchInfo::isWrite
bool isWrite() const
Checks if the request that caused this prefetch event was a write request.
Definition: base.hh:180
gem5::prefetch::Base::nextPrefetchReadyTime
virtual Tick nextPrefetchReadyTime() const =0
gem5::ProbeManager
ProbeManager is a conduit class that lives on each SimObject, and is used to match up probe listeners...
Definition: probe.hh:162
gem5::prefetch::Base::PrefetchInfo::getSize
unsigned int getSize() const
Gets the size of the request triggering this event.
Definition: base.hh:170
gem5::prefetch::Base::PrefetchInfo::cacheMiss
bool cacheMiss
Whether this event comes from a cache miss.
Definition: base.hh:115
gem5::prefetch::Base::PrefetchInfo::secure
bool secure
Whether this address targets the secure memory space.
Definition: base.hh:107
gem5::prefetch::Base::prefetchStats
gem5::prefetch::Base::StatGroup prefetchStats
gem5::prefetch::Base::PrefetchListener::notify
void notify(const PacketPtr &pkt) override
Definition: base.cc:86
gem5::prefetch::Base::issuedPrefetches
uint64_t issuedPrefetches
Total prefetches issued.
Definition: base.hh:362
gem5::prefetch::Base::StatGroup
Definition: base.hh:330
gem5::prefetch::Base::lBlkSize
unsigned lBlkSize
log_2(block size of the parent cache).
Definition: base.hh:272
cache_blk.hh
gem5::prefetch::Base::regProbeListeners
void regProbeListeners() override
Register probe points for this object.
Definition: base.cc:275
gem5::ProbeListenerArgBase
ProbeListenerArgBase is used to define the base interface to a ProbeListenerArg (i....
Definition: probe.hh:210
types.hh
gem5::prefetch::Base::StatGroup::pfUseful
statistics::Scalar pfUseful
The number of times a HW-prefetch is useful.
Definition: base.hh:339
clocked_object.hh
gem5::prefetch::Base::StatGroup::accuracy
statistics::Formula accuracy
Definition: base.hh:343
gem5::statistics::Group
Statistics container.
Definition: group.hh:92
gem5::prefetch::Base::cache
BaseCache * cache
Pointr to the parent cache.
Definition: base.hh:266
gem5::prefetch::Base::prefetchOnPfHit
const bool prefetchOnPfHit
Prefetch on hit on prefetched lines.
Definition: base.hh:298
gem5::prefetch::Base::incrDemandMhsrMisses
void incrDemandMhsrMisses()
Definition: base.hh:396
gem5::ProbeListener::name
const std::string name
Definition: probe.hh:137
gem5::prefetch::Base::blkSize
unsigned blkSize
The block size of the parent cache.
Definition: base.hh:269
gem5::RequestorID
uint16_t RequestorID
Definition: request.hh:95
gem5::prefetch::Base::inCache
bool inCache(Addr addr, bool is_secure) const
Determine if address is in cache.
Definition: base.cc:188
gem5::prefetch::Base::pageIthBlockAddress
Addr pageIthBlockAddress(Addr page, uint32_t i) const
Build the address of the i-th block inside the page.
Definition: base.cc:236
probe.hh
gem5::prefetch::Base::getPacket
virtual PacketPtr getPacket()=0
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: gpu_translation_state.hh:37
gem5::prefetch::Base::StatGroup::pfHitInMSHR
statistics::Scalar pfHitInMSHR
The number of times a HW-prefetch hits in a MSHR.
Definition: base.hh:350
gem5::prefetch::Base
Definition: base.hh:71
gem5::prefetch::Base::PrefetchInfo
Class containing the information needed by the prefetch to train and generate new prefetch requests.
Definition: base.hh:96
gem5::prefetch::Base::onWrite
const bool onWrite
Consult prefetcher on reads?
Definition: base.hh:281
gem5::prefetch::Base::StatGroup::pfHitInCache
statistics::Scalar pfHitInCache
The number of times a HW-prefetch hits in cache.
Definition: base.hh:347
byteswap.hh
panic
#define panic(...)
This implements a cprintf based panic() function.
Definition: logging.hh:188
gem5::X86ISA::addr
Bitfield< 3 > addr
Definition: types.hh:84
gem5::prefetch::Base::PrefetchInfo::hasPC
bool hasPC() const
Returns true if the associated program counter is valid.
Definition: base.hh:152
gem5::prefetch::Base::PrefetchListener
Definition: base.hh:73
gem5::prefetch::Base::notify
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....

Generated on Sun Jul 30 2023 01:56:51 for gem5 by doxygen 1.8.17