gem5  v22.1.0.0
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__
Circular queue.
Cycles is a wrapper class for representing cycle counts, i.e.
Definition: types.hh:79
Abstract superclass for simulation objects.
Definition: sim_object.hh:148
RubyRequestType m_type
L1D prefetches loads and stores.
int m_stride
stride distance to get next address from
std::bitset< MAX_PF_INFLIGHT > requestIssued
Bitset for tracking prefetches for which addresses have been issued, which ones have completed.
bool m_is_valid
valid bit for each stream
std::bitset< MAX_PF_INFLIGHT > requestCompleted
Cycles m_use_time
the last time that any prefetched request was used
Addr m_address
The base address for the stream prefetch.
CircularQueue< UnitFilterEntry > negativeFilter
A negative unit stride filter array: helps reduce BW requirement of prefetching.
void initializeStream(Addr address, int stride, uint32_t index, const RubyRequestType &type)
allocate a new stream buffer at a specific index
uint32_t m_num_streams
number of prefetch streams available
gem5::ruby::RubyPrefetcher::RubyPrefetcherStats rubyPrefetcherStats
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.
RubyPrefetcher(const Params &p)
void setController(AbstractController *_ctrl)
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...
CircularQueue< UnitFilterEntry > unitFilter
A unit stride filter array: helps reduce BW requirement of prefetching.
void observeMiss(Addr address, const RubyRequestType &type)
Observe a memory miss from the cache.
AbstractController * m_controller
void observePfHit(Addr address)
Implement the prefetch hit(miss) callback interface.
uint32_t m_num_startup_pfs
number of initial prefetches to startup a stream
void print(std::ostream &out) const
Print out some statistics.
std::vector< PrefetchEntry > m_array
an array of the active prefetch streams
CircularQueue< NonUnitFilterEntry > nonUnitFilter
A non-unit stride filter array: helps reduce BW requirement of prefetching.
uint32_t getLRUindex(void)
Returns an unused stream buffer (or if all are used, returns the least recently used (accessed) strea...
RubyPrefetcherParams Params
void issueNextPrefetch(Addr address, PrefetchEntry *stream)
void observePfMiss(Addr address)
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.
uint32_t m_train_misses
number of misses I must see before allocating a stream
bool m_prefetch_cross_pages
Used for allowing prefetches across pages.
Addr pageAddress(Addr addr) const
determine the page aligned address
static uint32_t getBlockSizeBits()
Definition: RubySystem.hh:73
Statistics container.
Definition: group.hh:94
This is a simple scalar statistic, like a counter.
Definition: statistics.hh:1931
STL vector class.
Definition: stl.hh:37
Bitfield< 21, 20 > stride
Definition: misc_types.hh:453
Bitfield< 30, 0 > index
Bitfield< 54 > p
Definition: pagetable.hh:70
Bitfield< 3 > addr
Definition: types.hh:84
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:147
Declaration of Statistics objects.
int stride
Stride (in # of cache lines).
statistics::Scalar numPartialHits
Count of partial successful prefetches.
statistics::Scalar numPagesCrossed
Count of pages crossed.
statistics::Scalar numMissObserved
Count of accesses to the prefetcher.
statistics::Scalar numHits
Count of successful prefetches.
statistics::Scalar numAllocatedStreams
Count of prefetch streams allocated.
statistics::Scalar numPrefetchRequested
Count of prefetch requests made.
statistics::Scalar numMissedPrefetchedBlocks
Count of misses incurred for blocks that were prefetched.
uint32_t hits
Counter of the number of times this entry has been hit.
Addr addr
Address to which this filter entry refers.

Generated on Wed Dec 21 2022 10:22:38 for gem5 by doxygen 1.9.1