gem5  v20.0.0.3
RubyPrefetcher.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2020 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) 1999-2012 Mark D. Hill and David A. Wood
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 
41 #ifndef __MEM_RUBY_STRUCTURES_PREFETCHER_HH__
42 #define __MEM_RUBY_STRUCTURES_PREFETCHER_HH__
43 
44 // Implements Power 4 like prefetching
45 
46 #include <bitset>
47 
48 #include "base/statistics.hh"
54 #include "params/RubyPrefetcher.hh"
55 #include "sim/sim_object.hh"
56 #include "sim/system.hh"
57 
58 #define MAX_PF_INFLIGHT 8
59 
61 {
62  public:
65  {
66  // default: 1 cache-line stride
68  m_use_time = Cycles(0);
69  m_is_valid = false;
70  }
71 
74 
76  int m_stride;
77 
80 
82  bool m_is_valid;
83 
85  RubyRequestType m_type;
86 
89  std::bitset<MAX_PF_INFLIGHT> requestIssued;
90  std::bitset<MAX_PF_INFLIGHT> requestCompleted;
91 };
92 
93 class RubyPrefetcher : public SimObject
94 {
95  public:
96  typedef RubyPrefetcherParams Params;
97  RubyPrefetcher(const Params *p);
98  ~RubyPrefetcher();
99 
100  void issueNextPrefetch(Addr address, PrefetchEntry *stream);
107  void observePfHit(Addr address);
108  void observePfMiss(Addr address);
109 
115  void observeMiss(Addr address, const RubyRequestType& type);
116 
120  void print(std::ostream& out) const;
122  { m_controller = _ctrl; }
123 
124  void regStats();
125 
126  private:
132  uint32_t getLRUindex(void);
133 
135  void clearNonunitEntry(uint32_t index);
136 
138  void initializeStream(Addr address, int stride,
139  uint32_t index, const RubyRequestType& type);
140 
143  PrefetchEntry* getPrefetchEntry(Addr address,
144  uint32_t &index);
145 
147  bool accessUnitFilter(std::vector<Addr>& filter_table,
148  uint32_t *hit_table, uint32_t &index, Addr address,
149  int stride, bool &alloc);
150 
152  bool accessNonunitFilter(Addr address, int *stride,
153  bool &alloc);
154 
156  Addr pageAddress(Addr addr) const;
157 
159  uint32_t m_num_streams;
162 
164  uint32_t m_train_misses;
171 
179  uint32_t *m_unit_filter_hit;
180 
189 
197  uint32_t *m_nonunit_hit;
199  uint32_t m_nonunit_index;
200 
203 
205 
207 
222 };
223 
224 #endif // __MEM_RUBY_STRUCTURES_PREFETCHER_HH__
uint32_t m_num_startup_pfs
number of initial prefetches to startup a stream
Bitfield< 30, 0 > index
uint32_t m_num_unit_filters
number of stride filters
Cycles is a wrapper class for representing cycle counts, i.e.
Definition: types.hh:81
std::bitset< MAX_PF_INFLIGHT > requestIssued
Bitset for tracking prefetches for which addresses have been issued, which ones have completed...
bool m_prefetch_cross_pages
Used for allowing prefetches across pages.
uint32_t * m_negative_filter_hit
An array used to count the of times particular filter entries have been hit.
Bitfield< 21, 20 > stride
uint32_t m_num_nonunit_filters
number of non-stride filters
ip6_addr_t addr
Definition: inet.hh:330
void setController(AbstractController *_ctrl)
RubyRequestType m_type
L1D prefetches loads and stores.
int m_stride
stride distance to get next address from
Declaration of Statistics objects.
This is a simple scalar statistic, like a counter.
Definition: statistics.hh:2505
int * m_nonunit_stride
An array of strides (in # of cache lines) for the filter entries.
uint32_t m_negative_filter_index
a round robin pointer into the negative filter group
Stats::Scalar numHits
Count of successful prefetches.
uint8_t type
Definition: inet.hh:328
bool m_is_valid
valid bit for each stream
Stats::Scalar numPagesCrossed
Count of pages crossed.
Stats::Scalar numAllocatedStreams
Count of prefetch streams allocated.
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:140
uint32_t * m_nonunit_hit
An array used to count the of times particular filter entries have been hit.
AbstractController * m_controller
Stats::Scalar numPrefetchRequested
Count of prefetch requests made.
Addr m_address
The base address for the stream prefetch.
uint32_t m_train_misses
number of misses I must see before allocating a stream
std::vector< Addr > m_negative_filter
a negative unit stride filter array: helps reduce BW requirement of prefetching
PrefetchEntry()
constructor
std::bitset< MAX_PF_INFLIGHT > requestCompleted
RubyPrefetcherParams Params
std::vector< PrefetchEntry > m_array
an array of the active prefetch streams
std::vector< Addr > m_unit_filter
a unit stride filter array: helps reduce BW requirement of prefetching
uint32_t m_nonunit_index
a round robin pointer into the unit filter group
std::vector< Addr > m_nonunit_filter
a non-unit stride filter array: helps reduce BW requirement of prefetching
Stats::Scalar numMissedPrefetchedBlocks
Count of misses incurred for blocks that were prefetched.
Stats::Scalar numMissObserved
Count of accesses to the prefetcher.
uint32_t * m_unit_filter_hit
An array used to count the of times particular filter entries have been hit.
uint32_t m_unit_filter_index
a round robin pointer into the unit filter group
Bitfield< 0 > p
static uint32_t getBlockSizeBits()
Definition: RubySystem.hh:60
Abstract superclass for simulation objects.
Definition: sim_object.hh:93
Stats::Scalar numPartialHits
Count of partial successful prefetches.
uint32_t m_num_streams
number of prefetch streams available
const Addr m_page_shift
Cycles m_use_time
the last time that any prefetched request was used

Generated on Fri Jul 3 2020 15:53:04 for gem5 by doxygen 1.8.13