gem5  v21.1.0.2
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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 #include "sim/system.hh"
59 
60 #define MAX_PF_INFLIGHT 8
61 
62 namespace gem5
63 {
64 
65 namespace ruby
66 {
67 
69 {
70  public:
73  {
74  // default: 1 cache-line stride
76  m_use_time = Cycles(0);
77  m_is_valid = false;
78  }
79 
82 
84  int m_stride;
85 
88 
90  bool m_is_valid;
91 
93  RubyRequestType m_type;
94 
97  std::bitset<MAX_PF_INFLIGHT> requestIssued;
98  std::bitset<MAX_PF_INFLIGHT> requestCompleted;
99 };
100 
101 class RubyPrefetcher : public SimObject
102 {
103  public:
104  typedef RubyPrefetcherParams Params;
105  RubyPrefetcher(const Params &p);
106  ~RubyPrefetcher() = default;
107 
108  void issueNextPrefetch(Addr address, PrefetchEntry *stream);
115  void observePfHit(Addr address);
116  void observePfMiss(Addr address);
117 
123  void observeMiss(Addr address, const RubyRequestType& type);
124 
128  void print(std::ostream& out) const;
130  { m_controller = _ctrl; }
131 
132  private:
134  {
138  uint32_t hits;
139 
141  : addr(_addr), hits(0)
142  {
143  }
144  };
145 
147  {
149  int stride;
150 
152  : UnitFilterEntry(_addr), stride(0)
153  {
154  }
155 
156  void
158  {
159  addr = 0;
160  stride = 0;
161  hits = 0;
162  }
163  };
164 
170  uint32_t getLRUindex(void);
171 
173  void initializeStream(Addr address, int stride,
174  uint32_t index, const RubyRequestType& type);
175 
179  uint32_t &index);
180 
192  Addr line_addr, int stride, const RubyRequestType& type);
193 
203  bool accessNonunitFilter(Addr line_addr, const RubyRequestType& type);
204 
206  Addr pageAddress(Addr addr) const;
207 
209  uint32_t m_num_streams;
212 
214  uint32_t m_train_misses;
217 
223 
229 
235 
238 
240 
242 
244  {
246 
262 };
263 
264 } // namespace ruby
265 } // namespace gem5
266 
267 #endif // __MEM_RUBY_STRUCTURES_PREFETCHER_HH__
gem5::statistics::Scalar
This is a simple scalar statistic, like a counter.
Definition: statistics.hh:1927
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:81
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:138
gem5::ruby::RubyPrefetcher::observePfMiss
void observePfMiss(Addr address)
Definition: RubyPrefetcher.cc:136
system.hh
gem5::ruby::PrefetchEntry::requestCompleted
std::bitset< MAX_PF_INFLIGHT > requestCompleted
Definition: RubyPrefetcher.hh:98
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:84
AbstractController.hh
gem5::ruby::RubyPrefetcher::m_num_streams
uint32_t m_num_streams
number of prefetch streams available
Definition: RubyPrefetcher.hh:209
gem5::ruby::PrefetchEntry::PrefetchEntry
PrefetchEntry()
constructor
Definition: RubyPrefetcher.hh:72
RubyRequest.hh
gem5::ruby::PrefetchEntry::m_type
RubyRequestType m_type
L1D prefetches loads and stores.
Definition: RubyPrefetcher.hh:93
gem5::ruby::RubyPrefetcher
Definition: RubyPrefetcher.hh:101
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:216
gem5::ruby::PrefetchEntry::m_is_valid
bool m_is_valid
valid bit for each stream
Definition: RubyPrefetcher.hh:90
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:149
gem5::ruby::RubyPrefetcher::m_train_misses
uint32_t m_train_misses
number of misses I must see before allocating a stream
Definition: RubyPrefetcher.hh:214
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:211
gem5::ruby::RubyPrefetcher::RubyPrefetcherStats::numHits
statistics::Scalar numHits
Count of successful prefetches.
Definition: RubyPrefetcher.hh:254
gem5::ruby::RubyPrefetcher::nonUnitFilter
CircularQueue< NonUnitFilterEntry > nonUnitFilter
A non-unit stride filter array: helps reduce BW requirement of prefetching.
Definition: RubyPrefetcher.hh:234
gem5::ruby::RubyPrefetcher::RubyPrefetcherStats
Definition: RubyPrefetcher.hh:243
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:140
gem5::ruby::RubyPrefetcher::m_page_shift
const Addr m_page_shift
Definition: RubyPrefetcher.hh:241
gem5::ruby::RubyPrefetcher::pageAddress
Addr pageAddress(Addr addr) const
determine the page aligned address
Definition: RubyPrefetcher.cc:379
circular_queue.hh
sim_object.hh
gem5::ruby::RubyPrefetcher::setController
void setController(AbstractController *_ctrl)
Definition: RubyPrefetcher.hh:129
gem5::ruby::RubyPrefetcher::RubyPrefetcherStats::numPagesCrossed
statistics::Scalar numPagesCrossed
Count of pages crossed.
Definition: RubyPrefetcher.hh:258
gem5::MipsISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:326
statistics.hh
gem5::ruby::PrefetchEntry::m_use_time
Cycles m_use_time
the last time that any prefetched request was used
Definition: RubyPrefetcher.hh:87
gem5::ruby::RubyPrefetcher::NonUnitFilterEntry::NonUnitFilterEntry
NonUnitFilterEntry(Addr _addr=0)
Definition: RubyPrefetcher.hh:151
gem5::X86ISA::type
type
Definition: misc.hh:733
gem5::ruby::RubyPrefetcher::UnitFilterEntry::addr
Addr addr
Address to which this filter entry refers.
Definition: RubyPrefetcher.hh:136
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:97
gem5::ruby::RubyPrefetcher::RubyPrefetcherStats::numMissObserved
statistics::Scalar numMissObserved
Count of accesses to the prefetcher.
Definition: RubyPrefetcher.hh:248
gem5::ruby::RubyPrefetcher::unitFilter
CircularQueue< UnitFilterEntry > unitFilter
A unit stride filter array: helps reduce BW requirement of prefetching.
Definition: RubyPrefetcher.hh:222
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:260
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:237
gem5::ruby::RubyPrefetcher::UnitFilterEntry
Definition: RubyPrefetcher.hh:133
Address.hh
gem5::ruby::RubyPrefetcher::RubyPrefetcherStats::numAllocatedStreams
statistics::Scalar numAllocatedStreams
Count of prefetch streams allocated.
Definition: RubyPrefetcher.hh:250
gem5::ruby::RubyPrefetcher::RubyPrefetcherStats::numPartialHits
statistics::Scalar numPartialHits
Count of partial successful prefetches.
Definition: RubyPrefetcher.hh:256
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:228
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:157
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: decoder.cc:40
gem5::ArmISA::stride
Bitfield< 21, 20 > stride
Definition: misc_types.hh:446
gem5::CircularQueue
Circular queue.
Definition: circular_queue.hh:69
gem5::ruby::PrefetchEntry
Definition: RubyPrefetcher.hh:68
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:252
gem5::ruby::RubyPrefetcher::m_controller
AbstractController * m_controller
Definition: RubyPrefetcher.hh:239
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:146
gem5::ruby::RubyPrefetcher::Params
RubyPrefetcherParams Params
Definition: RubyPrefetcher.hh:104
gem5::ruby::RubyPrefetcher::RubyPrefetcher
RubyPrefetcher(const Params &p)
Definition: RubyPrefetcher.cc:57

Generated on Tue Sep 21 2021 12:25:41 for gem5 by doxygen 1.8.17