gem5  v21.0.1.0
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 
63 {
64  public:
67  {
68  // default: 1 cache-line stride
70  m_use_time = Cycles(0);
71  m_is_valid = false;
72  }
73 
76 
78  int m_stride;
79 
82 
84  bool m_is_valid;
85 
87  RubyRequestType m_type;
88 
91  std::bitset<MAX_PF_INFLIGHT> requestIssued;
92  std::bitset<MAX_PF_INFLIGHT> requestCompleted;
93 };
94 
95 class RubyPrefetcher : public SimObject
96 {
97  public:
98  typedef RubyPrefetcherParams Params;
99  RubyPrefetcher(const Params &p);
100  ~RubyPrefetcher() = default;
101 
102  void issueNextPrefetch(Addr address, PrefetchEntry *stream);
109  void observePfHit(Addr address);
110  void observePfMiss(Addr address);
111 
117  void observeMiss(Addr address, const RubyRequestType& type);
118 
122  void print(std::ostream& out) const;
124  { m_controller = _ctrl; }
125 
126  private:
128  {
132  uint32_t hits;
133 
135  : addr(_addr), hits(0)
136  {
137  }
138  };
139 
141  {
143  int stride;
144 
146  : UnitFilterEntry(_addr), stride(0)
147  {
148  }
149 
150  void
152  {
153  addr = 0;
154  stride = 0;
155  hits = 0;
156  }
157  };
158 
164  uint32_t getLRUindex(void);
165 
167  void initializeStream(Addr address, int stride,
168  uint32_t index, const RubyRequestType& type);
169 
173  uint32_t &index);
174 
186  Addr line_addr, int stride, const RubyRequestType& type);
187 
197  bool accessNonunitFilter(Addr line_addr, const RubyRequestType& type);
198 
200  Addr pageAddress(Addr addr) const;
201 
203  uint32_t m_num_streams;
206 
208  uint32_t m_train_misses;
211 
217 
223 
229 
232 
234 
236 
238  {
240 
256 };
257 
258 #endif // __MEM_RUBY_STRUCTURES_PREFETCHER_HH__
PrefetchEntry::m_type
RubyRequestType m_type
L1D prefetches loads and stores.
Definition: RubyPrefetcher.hh:87
RubyPrefetcher::pageAddress
Addr pageAddress(Addr addr) const
determine the page aligned address
Definition: RubyPrefetcher.cc:373
RubyPrefetcher::NonUnitFilterEntry::stride
int stride
Stride (in # of cache lines).
Definition: RubyPrefetcher.hh:143
system.hh
RubyPrefetcher::print
void print(std::ostream &out) const
Print out some statistics.
Definition: RubyPrefetcher.cc:340
RubyPrefetcher::m_num_startup_pfs
uint32_t m_num_startup_pfs
number of initial prefetches to startup a stream
Definition: RubyPrefetcher.hh:210
RubyPrefetcher::setController
void setController(AbstractController *_ctrl)
Definition: RubyPrefetcher.hh:123
MipsISA::index
Bitfield< 30, 0 > index
Definition: pra_constants.hh:44
RubyPrefetcher::NonUnitFilterEntry
Definition: RubyPrefetcher.hh:140
RubyPrefetcher::unitFilter
CircularQueue< UnitFilterEntry > unitFilter
A unit stride filter array: helps reduce BW requirement of prefetching.
Definition: RubyPrefetcher.hh:216
PrefetchEntry::m_use_time
Cycles m_use_time
the last time that any prefetched request was used
Definition: RubyPrefetcher.hh:81
RubyPrefetcher::NonUnitFilterEntry::clear
void clear()
Definition: RubyPrefetcher.hh:151
RubyPrefetcher::issueNextPrefetch
void issueNextPrefetch(Addr address, PrefetchEntry *stream)
Definition: RubyPrefetcher.cc:146
PrefetchEntry::m_stride
int m_stride
stride distance to get next address from
Definition: RubyPrefetcher.hh:78
RubyPrefetcher::RubyPrefetcherStats::numPartialHits
Stats::Scalar numPartialHits
Count of partial successful prefetches.
Definition: RubyPrefetcher.hh:250
RubyPrefetcher::UnitFilterEntry
Definition: RubyPrefetcher.hh:127
RubyPrefetcher::m_num_streams
uint32_t m_num_streams
number of prefetch streams available
Definition: RubyPrefetcher.hh:203
CircularQueue
Circular queue.
Definition: circular_queue.hh:66
PrefetchEntry::requestCompleted
std::bitset< MAX_PF_INFLIGHT > requestCompleted
Definition: RubyPrefetcher.hh:92
AbstractController.hh
RubyPrefetcher::observeMiss
void observeMiss(Addr address, const RubyRequestType &type)
Observe a memory miss from the cache.
Definition: RubyPrefetcher.cc:84
RubyPrefetcher::RubyPrefetcherStats::numPrefetchRequested
Stats::Scalar numPrefetchRequested
Count of prefetch requests made.
Definition: RubyPrefetcher.hh:246
RubyPrefetcher::~RubyPrefetcher
~RubyPrefetcher()=default
RubyRequest.hh
RubyPrefetcher::UnitFilterEntry::addr
Addr addr
Address to which this filter entry refers.
Definition: RubyPrefetcher.hh:130
std::vector< PrefetchEntry >
PrefetchEntry::PrefetchEntry
PrefetchEntry()
constructor
Definition: RubyPrefetcher.hh:66
AbstractController
Definition: AbstractController.hh:76
RubyPrefetcher::UnitFilterEntry::UnitFilterEntry
UnitFilterEntry(Addr _addr=0)
Definition: RubyPrefetcher.hh:134
RubyPrefetcher
Definition: RubyPrefetcher.hh:95
PrefetchEntry::m_is_valid
bool m_is_valid
valid bit for each stream
Definition: RubyPrefetcher.hh:84
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:91
RubyPrefetcher::RubyPrefetcherStats::RubyPrefetcherStats
RubyPrefetcherStats(Stats::Group *parent)
Definition: RubyPrefetcher.cc:67
RubyPrefetcher::observePfHit
void observePfHit(Addr address)
Implement the prefetch hit(miss) callback interface.
Definition: RubyPrefetcher.cc:138
Stats::Scalar
This is a simple scalar statistic, like a counter.
Definition: statistics.hh:1933
RubyPrefetcher::RubyPrefetcherStats::numPagesCrossed
Stats::Scalar numPagesCrossed
Count of pages crossed.
Definition: RubyPrefetcher.hh:252
circular_queue.hh
sim_object.hh
statistics.hh
RubyPrefetcher::m_controller
AbstractController * m_controller
Definition: RubyPrefetcher.hh:233
RubySystem.hh
RubyPrefetcher::RubyPrefetcherStats::numHits
Stats::Scalar numHits
Count of successful prefetches.
Definition: RubyPrefetcher.hh:248
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:185
Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:148
RubyPrefetcher::RubyPrefetcherStats::numAllocatedStreams
Stats::Scalar numAllocatedStreams
Count of prefetch streams allocated.
Definition: RubyPrefetcher.hh:244
RubyPrefetcher::RubyPrefetcherStats::numMissedPrefetchedBlocks
Stats::Scalar numMissedPrefetchedBlocks
Count of misses incurred for blocks that were prefetched.
Definition: RubyPrefetcher.hh:254
PrefetchEntry
Definition: RubyPrefetcher.hh:62
X86ISA::addr
Bitfield< 3 > addr
Definition: types.hh:80
MessageBuffer.hh
RubyPrefetcher::negativeFilter
CircularQueue< UnitFilterEntry > negativeFilter
A negative unit stride filter array: helps reduce BW requirement of prefetching.
Definition: RubyPrefetcher.hh:222
RubyPrefetcher::NonUnitFilterEntry::NonUnitFilterEntry
NonUnitFilterEntry(Addr _addr=0)
Definition: RubyPrefetcher.hh:145
RubyPrefetcher::observePfMiss
void observePfMiss(Addr address)
Definition: RubyPrefetcher.cc:130
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:204
Address.hh
RubyPrefetcher::m_page_shift
const Addr m_page_shift
Definition: RubyPrefetcher.hh:235
Stats::Group
Statistics container.
Definition: group.hh:87
RubyPrefetcher::m_array
std::vector< PrefetchEntry > m_array
an array of the active prefetch streams
Definition: RubyPrefetcher.hh:205
RubyPrefetcher::rubyPrefetcherStats
RubyPrefetcher::RubyPrefetcherStats rubyPrefetcherStats
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:286
PrefetchEntry::m_address
Addr m_address
The base address for the stream prefetch.
Definition: RubyPrefetcher.hh:75
ArmISA::stride
Bitfield< 21, 20 > stride
Definition: miscregs_types.hh:441
RubyPrefetcher::Params
RubyPrefetcherParams Params
Definition: RubyPrefetcher.hh:98
Cycles
Cycles is a wrapper class for representing cycle counts, i.e.
Definition: types.hh:79
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:245
RubyPrefetcher::m_train_misses
uint32_t m_train_misses
number of misses I must see before allocating a stream
Definition: RubyPrefetcher.hh:208
X86ISA::type
type
Definition: misc.hh:727
RubyPrefetcher::RubyPrefetcherStats::numMissObserved
Stats::Scalar numMissObserved
Count of accesses to the prefetcher.
Definition: RubyPrefetcher.hh:242
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:263
RubyPrefetcher::m_prefetch_cross_pages
bool m_prefetch_cross_pages
Used for allowing prefetches across pages.
Definition: RubyPrefetcher.hh:231
MipsISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:323
RubyPrefetcher::UnitFilterEntry::hits
uint32_t hits
Counter of the number of times this entry has been hit.
Definition: RubyPrefetcher.hh:132
RubyPrefetcher::RubyPrefetcher
RubyPrefetcher(const Params &p)
Definition: RubyPrefetcher.cc:51
RubySystem::getBlockSizeBits
static uint32_t getBlockSizeBits()
Definition: RubySystem.hh:62
RubyPrefetcher::nonUnitFilter
CircularQueue< NonUnitFilterEntry > nonUnitFilter
A non-unit stride filter array: helps reduce BW requirement of prefetching.
Definition: RubyPrefetcher.hh:228
RubyPrefetcher::RubyPrefetcherStats
Definition: RubyPrefetcher.hh:237
SimObject
Abstract superclass for simulation objects.
Definition: sim_object.hh:141

Generated on Tue Jun 22 2021 15:28:30 for gem5 by doxygen 1.8.17