gem5  v22.0.0.1
RubyPrefetcher.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2020 Inria
3  * Copyright (c) 2020 ARM Limited
4  * All rights reserved
5  *
6  * The license below extends only to copyright in the software and shall
7  * not be construed as granting a license to any other intellectual
8  * property including but not limited to intellectual property relating
9  * to a hardware implementation of the functionality of the software
10  * licensed hereunder. You may use the software subject to the license
11  * terms below provided that you ensure that this notice is replicated
12  * unmodified and in its entirety in all distributions of the software,
13  * modified or unmodified, in source code or in binary form.
14  *
15  * Copyright (c) 1999-2012 Mark D. Hill and David A. Wood
16  * All rights reserved.
17  *
18  * Redistribution and use in source and binary forms, with or without
19  * modification, are permitted provided that the following conditions are
20  * met: redistributions of source code must retain the above copyright
21  * notice, this list of conditions and the following disclaimer;
22  * redistributions in binary form must reproduce the above copyright
23  * notice, this list of conditions and the following disclaimer in the
24  * documentation and/or other materials provided with the distribution;
25  * neither the name of the copyright holders nor the names of its
26  * contributors may be used to endorse or promote products derived from
27  * this software without specific prior written permission.
28  *
29  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
30  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
31  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
32  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
33  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
34  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
35  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
36  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
37  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
38  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
39  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40  */
41 
42 #ifndef __MEM_RUBY_STRUCTURES_PREFETCHER_HH__
43 #define __MEM_RUBY_STRUCTURES_PREFETCHER_HH__
44 
45 // Implements Power 4 like prefetching
46 
47 #include <bitset>
48 
49 #include "base/circular_queue.hh"
50 #include "base/statistics.hh"
56 #include "params/RubyPrefetcher.hh"
57 #include "sim/sim_object.hh"
58 
59 #define MAX_PF_INFLIGHT 8
60 
61 namespace gem5
62 {
63 
64 namespace ruby
65 {
66 
68 {
69  public:
72  {
73  // default: 1 cache-line stride
75  m_use_time = Cycles(0);
76  m_is_valid = false;
77  }
78 
81 
83  int m_stride;
84 
87 
89  bool m_is_valid;
90 
92  RubyRequestType m_type;
93 
96  std::bitset<MAX_PF_INFLIGHT> requestIssued;
97  std::bitset<MAX_PF_INFLIGHT> requestCompleted;
98 };
99 
100 class RubyPrefetcher : public SimObject
101 {
102  public:
103  typedef RubyPrefetcherParams Params;
104  RubyPrefetcher(const Params &p);
105  ~RubyPrefetcher() = default;
106 
107  void issueNextPrefetch(Addr address, PrefetchEntry *stream);
114  void observePfHit(Addr address);
115  void observePfMiss(Addr address);
116 
122  void observeMiss(Addr address, const RubyRequestType& type);
123 
127  void print(std::ostream& out) const;
129  { m_controller = _ctrl; }
130 
131  private:
133  {
137  uint32_t hits;
138 
140  : addr(_addr), hits(0)
141  {
142  }
143  };
144 
146  {
148  int stride;
149 
151  : UnitFilterEntry(_addr), stride(0)
152  {
153  }
154 
155  void
157  {
158  addr = 0;
159  stride = 0;
160  hits = 0;
161  }
162  };
163 
169  uint32_t getLRUindex(void);
170 
172  void initializeStream(Addr address, int stride,
173  uint32_t index, const RubyRequestType& type);
174 
178  uint32_t &index);
179 
191  Addr line_addr, int stride, const RubyRequestType& type);
192 
202  bool accessNonunitFilter(Addr line_addr, const RubyRequestType& type);
203 
205  Addr pageAddress(Addr addr) const;
206 
208  uint32_t m_num_streams;
211 
213  uint32_t m_train_misses;
216 
222 
228 
234 
237 
239 
240  const unsigned pageShift;
241 
243  {
245 
261 };
262 
263 } // namespace ruby
264 } // namespace gem5
265 
266 #endif // __MEM_RUBY_STRUCTURES_PREFETCHER_HH__
gem5::statistics::Scalar
This is a simple scalar statistic, like a counter.
Definition: statistics.hh:1930
gem5::ruby::RubyPrefetcher::observePfHit
void observePfHit(Addr address)
Implement the prefetch hit(miss) callback interface.
Definition: RubyPrefetcher.cc:144
gem5::ruby::PrefetchEntry::m_address
Addr m_address
The base address for the stream prefetch.
Definition: RubyPrefetcher.hh:80
gem5::ruby::RubyPrefetcher::getPrefetchEntry
PrefetchEntry * getPrefetchEntry(Addr address, uint32_t &index)
get pointer to the matching stream entry, returns NULL if not found index holds the multiple of the s...
Definition: RubyPrefetcher.cc:251
gem5::ruby::RubyPrefetcher::UnitFilterEntry::hits
uint32_t hits
Counter of the number of times this entry has been hit.
Definition: RubyPrefetcher.hh:137
gem5::ruby::RubyPrefetcher::observePfMiss
void observePfMiss(Addr address)
Definition: RubyPrefetcher.cc:136
gem5::ruby::PrefetchEntry::requestCompleted
std::bitset< MAX_PF_INFLIGHT > requestCompleted
Definition: RubyPrefetcher.hh:97
gem5::MipsISA::index
Bitfield< 30, 0 > index
Definition: pra_constants.hh:47
gem5::ruby::RubyPrefetcher::getLRUindex
uint32_t getLRUindex(void)
Returns an unused stream buffer (or if all are used, returns the least recently used (accessed) strea...
Definition: RubyPrefetcher.cc:191
gem5::ruby::PrefetchEntry::m_stride
int m_stride
stride distance to get next address from
Definition: RubyPrefetcher.hh:83
AbstractController.hh
gem5::ruby::RubyPrefetcher::m_num_streams
uint32_t m_num_streams
number of prefetch streams available
Definition: RubyPrefetcher.hh:208
gem5::ruby::PrefetchEntry::PrefetchEntry
PrefetchEntry()
constructor
Definition: RubyPrefetcher.hh:71
RubyRequest.hh
gem5::ruby::PrefetchEntry::m_type
RubyRequestType m_type
L1D prefetches loads and stores.
Definition: RubyPrefetcher.hh:92
gem5::ruby::RubyPrefetcher
Definition: RubyPrefetcher.hh:100
std::vector
STL vector class.
Definition: stl.hh:37
gem5::ruby::RubyPrefetcher::m_num_startup_pfs
uint32_t m_num_startup_pfs
number of initial prefetches to startup a stream
Definition: RubyPrefetcher.hh:215
gem5::ruby::PrefetchEntry::m_is_valid
bool m_is_valid
valid bit for each stream
Definition: RubyPrefetcher.hh:89
gem5::ruby::RubyPrefetcher::initializeStream
void initializeStream(Addr address, int stride, uint32_t index, const RubyRequestType &type)
allocate a new stream buffer at a specific index
Definition: RubyPrefetcher.cc:210
gem5::ruby::AbstractController
Definition: AbstractController.hh:82
gem5::ruby::RubyPrefetcher::NonUnitFilterEntry::stride
int stride
Stride (in # of cache lines).
Definition: RubyPrefetcher.hh:148
gem5::ruby::RubyPrefetcher::m_train_misses
uint32_t m_train_misses
number of misses I must see before allocating a stream
Definition: RubyPrefetcher.hh:213
gem5::ruby::RubyPrefetcher::pageShift
const unsigned pageShift
Definition: RubyPrefetcher.hh:240
gem5::Cycles
Cycles is a wrapper class for representing cycle counts, i.e.
Definition: types.hh:78
gem5::ruby::RubyPrefetcher::accessNonunitFilter
bool accessNonunitFilter(Addr line_addr, const RubyRequestType &type)
Access a non-unit stride filter to determine if there is a hit, and update it otherwise.
Definition: RubyPrefetcher.cc:292
gem5::ruby::RubyPrefetcher::m_array
std::vector< PrefetchEntry > m_array
an array of the active prefetch streams
Definition: RubyPrefetcher.hh:210
gem5::ruby::RubyPrefetcher::RubyPrefetcherStats::numHits
statistics::Scalar numHits
Count of successful prefetches.
Definition: RubyPrefetcher.hh:253
gem5::ruby::RubyPrefetcher::nonUnitFilter
CircularQueue< NonUnitFilterEntry > nonUnitFilter
A non-unit stride filter array: helps reduce BW requirement of prefetching.
Definition: RubyPrefetcher.hh:233
gem5::ruby::RubyPrefetcher::RubyPrefetcherStats
Definition: RubyPrefetcher.hh:242
gem5::ruby::RubyPrefetcher::observeMiss
void observeMiss(Addr address, const RubyRequestType &type)
Observe a memory miss from the cache.
Definition: RubyPrefetcher.cc:90
gem5::ruby::RubyPrefetcher::UnitFilterEntry::UnitFilterEntry
UnitFilterEntry(Addr _addr=0)
Definition: RubyPrefetcher.hh:139
gem5::ruby::RubyPrefetcher::pageAddress
Addr pageAddress(Addr addr) const
determine the page aligned address
Definition: RubyPrefetcher.cc:379
circular_queue.hh
gem5::VegaISA::p
Bitfield< 54 > p
Definition: pagetable.hh:70
sim_object.hh
gem5::ruby::RubyPrefetcher::setController
void setController(AbstractController *_ctrl)
Definition: RubyPrefetcher.hh:128
gem5::ruby::RubyPrefetcher::RubyPrefetcherStats::numPagesCrossed
statistics::Scalar numPagesCrossed
Count of pages crossed.
Definition: RubyPrefetcher.hh:257
statistics.hh
gem5::ruby::PrefetchEntry::m_use_time
Cycles m_use_time
the last time that any prefetched request was used
Definition: RubyPrefetcher.hh:86
gem5::ruby::RubyPrefetcher::NonUnitFilterEntry::NonUnitFilterEntry
NonUnitFilterEntry(Addr _addr=0)
Definition: RubyPrefetcher.hh:150
gem5::X86ISA::type
type
Definition: misc.hh:727
gem5::ruby::RubyPrefetcher::UnitFilterEntry::addr
Addr addr
Address to which this filter entry refers.
Definition: RubyPrefetcher.hh:135
gem5::ruby::RubySystem::getBlockSizeBits
static uint32_t getBlockSizeBits()
Definition: RubySystem.hh:73
gem5::ruby::PrefetchEntry::requestIssued
std::bitset< MAX_PF_INFLIGHT > requestIssued
Bitset for tracking prefetches for which addresses have been issued, which ones have completed.
Definition: RubyPrefetcher.hh:96
gem5::ruby::RubyPrefetcher::RubyPrefetcherStats::numMissObserved
statistics::Scalar numMissObserved
Count of accesses to the prefetcher.
Definition: RubyPrefetcher.hh:247
gem5::ruby::RubyPrefetcher::unitFilter
CircularQueue< UnitFilterEntry > unitFilter
A unit stride filter array: helps reduce BW requirement of prefetching.
Definition: RubyPrefetcher.hh:221
gem5::SimObject
Abstract superclass for simulation objects.
Definition: sim_object.hh:146
RubySystem.hh
gem5::Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:147
gem5::ruby::RubyPrefetcher::issueNextPrefetch
void issueNextPrefetch(Addr address, PrefetchEntry *stream)
Definition: RubyPrefetcher.cc:152
gem5::ruby::RubyPrefetcher::RubyPrefetcherStats::numMissedPrefetchedBlocks
statistics::Scalar numMissedPrefetchedBlocks
Count of misses incurred for blocks that were prefetched.
Definition: RubyPrefetcher.hh:259
gem5::ruby::RubyPrefetcher::RubyPrefetcherStats::RubyPrefetcherStats
RubyPrefetcherStats(statistics::Group *parent)
Definition: RubyPrefetcher.cc:73
MessageBuffer.hh
gem5::ruby::RubyPrefetcher::m_prefetch_cross_pages
bool m_prefetch_cross_pages
Used for allowing prefetches across pages.
Definition: RubyPrefetcher.hh:236
gem5::ruby::RubyPrefetcher::UnitFilterEntry
Definition: RubyPrefetcher.hh:132
Address.hh
gem5::ruby::RubyPrefetcher::RubyPrefetcherStats::numAllocatedStreams
statistics::Scalar numAllocatedStreams
Count of prefetch streams allocated.
Definition: RubyPrefetcher.hh:249
gem5::ruby::RubyPrefetcher::RubyPrefetcherStats::numPartialHits
statistics::Scalar numPartialHits
Count of partial successful prefetches.
Definition: RubyPrefetcher.hh:255
gem5::statistics::Group
Statistics container.
Definition: group.hh:93
gem5::ruby::RubyPrefetcher::negativeFilter
CircularQueue< UnitFilterEntry > negativeFilter
A negative unit stride filter array: helps reduce BW requirement of prefetching.
Definition: RubyPrefetcher.hh:227
gem5::ruby::RubyPrefetcher::~RubyPrefetcher
~RubyPrefetcher()=default
gem5::ruby::RubyPrefetcher::accessUnitFilter
bool accessUnitFilter(CircularQueue< UnitFilterEntry > *const filter, Addr line_addr, int stride, const RubyRequestType &type)
Access a unit stride filter to determine if there is a hit, and update it otherwise.
Definition: RubyPrefetcher.cc:269
gem5::ruby::RubyPrefetcher::NonUnitFilterEntry::clear
void clear()
Definition: RubyPrefetcher.hh:156
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: gpu_translation_state.hh:37
gem5::ArmISA::stride
Bitfield< 21, 20 > stride
Definition: misc_types.hh:447
gem5::CircularQueue
Circular queue.
Definition: circular_queue.hh:69
gem5::ruby::PrefetchEntry
Definition: RubyPrefetcher.hh:67
gem5::ruby::RubyPrefetcher::rubyPrefetcherStats
gem5::ruby::RubyPrefetcher::RubyPrefetcherStats rubyPrefetcherStats
gem5::ruby::RubyPrefetcher::RubyPrefetcherStats::numPrefetchRequested
statistics::Scalar numPrefetchRequested
Count of prefetch requests made.
Definition: RubyPrefetcher.hh:251
gem5::ruby::RubyPrefetcher::m_controller
AbstractController * m_controller
Definition: RubyPrefetcher.hh:238
gem5::ruby::RubyPrefetcher::print
void print(std::ostream &out) const
Print out some statistics.
Definition: RubyPrefetcher.cc:346
gem5::X86ISA::addr
Bitfield< 3 > addr
Definition: types.hh:84
gem5::ruby::RubyPrefetcher::NonUnitFilterEntry
Definition: RubyPrefetcher.hh:145
gem5::ruby::RubyPrefetcher::Params
RubyPrefetcherParams Params
Definition: RubyPrefetcher.hh:103
gem5::ruby::RubyPrefetcher::RubyPrefetcher
RubyPrefetcher(const Params &p)
Definition: RubyPrefetcher.cc:57

Generated on Sat Jun 18 2022 08:12:30 for gem5 by doxygen 1.8.17