gem5  v20.1.0.0
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);
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 
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__
PrefetchEntry::m_type
RubyRequestType m_type
L1D prefetches loads and stores.
Definition: RubyPrefetcher.hh:85
RubyPrefetcher::pageAddress
Addr pageAddress(Addr addr) const
determine the page aligned address
Definition: RubyPrefetcher.cc:480
RubyPrefetcher::numPartialHits
Stats::Scalar numPartialHits
Count of partial successful prefetches.
Definition: RubyPrefetcher.hh:217
system.hh
RubyPrefetcher::print
void print(std::ostream &out) const
Print out some statistics.
Definition: RubyPrefetcher.cc:447
RubyPrefetcher::m_num_startup_pfs
uint32_t m_num_startup_pfs
number of initial prefetches to startup a stream
Definition: RubyPrefetcher.hh:166
RubyPrefetcher::setController
void setController(AbstractController *_ctrl)
Definition: RubyPrefetcher.hh:121
MipsISA::index
Bitfield< 30, 0 > index
Definition: pra_constants.hh:44
RubyPrefetcher::m_nonunit_stride
int * m_nonunit_stride
An array of strides (in # of cache lines) for the filter entries.
Definition: RubyPrefetcher.hh:194
PrefetchEntry::m_use_time
Cycles m_use_time
the last time that any prefetched request was used
Definition: RubyPrefetcher.hh:79
RubyPrefetcher::issueNextPrefetch
void issueNextPrefetch(Addr address, PrefetchEntry *stream)
Definition: RubyPrefetcher.cc:226
PrefetchEntry::m_stride
int m_stride
stride distance to get next address from
Definition: RubyPrefetcher.hh:76
RubyPrefetcher::numHits
Stats::Scalar numHits
Count of successful prefetches.
Definition: RubyPrefetcher.hh:215
RubyPrefetcher::m_num_streams
uint32_t m_num_streams
number of prefetch streams available
Definition: RubyPrefetcher.hh:159
type
uint8_t type
Definition: inet.hh:421
PrefetchEntry::requestCompleted
std::bitset< MAX_PF_INFLIGHT > requestCompleted
Definition: RubyPrefetcher.hh:90
AbstractController.hh
RubyPrefetcher::observeMiss
void observeMiss(Addr address, const RubyRequestType &type)
Observe a memory miss from the cache.
Definition: RubyPrefetcher.cc:142
RubyRequest.hh
std::vector< Addr >
PrefetchEntry::PrefetchEntry
PrefetchEntry()
constructor
Definition: RubyPrefetcher.hh:64
RubyPrefetcher::accessUnitFilter
bool accessUnitFilter(std::vector< Addr > &filter_table, uint32_t *hit_table, uint32_t &index, Addr address, int stride, bool &alloc)
access a unit stride filter to determine if there is a hit
Definition: RubyPrefetcher.cc:351
AbstractController
Definition: AbstractController.hh:74
RubyPrefetcher
Definition: RubyPrefetcher.hh:93
PrefetchEntry::m_is_valid
bool m_is_valid
valid bit for each stream
Definition: RubyPrefetcher.hh:82
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:89
RubyPrefetcher::observePfHit
void observePfHit(Addr address)
Implement the prefetch hit(miss) callback interface.
Definition: RubyPrefetcher.cc:218
RubyPrefetcher::m_negative_filter_index
uint32_t m_negative_filter_index
a round robin pointer into the negative filter group
Definition: RubyPrefetcher.hh:185
Stats::Scalar
This is a simple scalar statistic, like a counter.
Definition: statistics.hh:2533
RubyPrefetcher::m_num_nonunit_filters
uint32_t m_num_nonunit_filters
number of non-stride filters
Definition: RubyPrefetcher.hh:170
sim_object.hh
statistics.hh
RubyPrefetcher::RubyPrefetcher
RubyPrefetcher(const Params *p)
Definition: RubyPrefetcher.cc:54
RubyPrefetcher::m_controller
AbstractController * m_controller
Definition: RubyPrefetcher.hh:204
RubySystem.hh
RubyPrefetcher::numPagesCrossed
Stats::Scalar numPagesCrossed
Count of pages crossed.
Definition: RubyPrefetcher.hh:219
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:265
Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
RubyPrefetcher::accessNonunitFilter
bool accessNonunitFilter(Addr address, int *stride, bool &alloc)
access a unit stride filter to determine if there is a hit
Definition: RubyPrefetcher.cc:384
PrefetchEntry
Definition: RubyPrefetcher.hh:60
RubyPrefetcher::m_nonunit_hit
uint32_t * m_nonunit_hit
An array used to count the of times particular filter entries have been hit.
Definition: RubyPrefetcher.hh:197
RubyPrefetcher::m_unit_filter
std::vector< Addr > m_unit_filter
a unit stride filter array: helps reduce BW requirement of prefetching
Definition: RubyPrefetcher.hh:174
MessageBuffer.hh
RubyPrefetcher::observePfMiss
void observePfMiss(Addr address)
Definition: RubyPrefetcher.cc:210
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:292
Address.hh
RubyPrefetcher::numAllocatedStreams
Stats::Scalar numAllocatedStreams
Count of prefetch streams allocated.
Definition: RubyPrefetcher.hh:211
RubyPrefetcher::m_nonunit_filter
std::vector< Addr > m_nonunit_filter
a non-unit stride filter array: helps reduce BW requirement of prefetching
Definition: RubyPrefetcher.hh:192
RubyPrefetcher::regStats
void regStats()
Callback to set stat parameters.
Definition: RubyPrefetcher.cc:101
RubyPrefetcher::m_page_shift
const Addr m_page_shift
Definition: RubyPrefetcher.hh:206
RubyPrefetcher::m_array
std::vector< PrefetchEntry > m_array
an array of the active prefetch streams
Definition: RubyPrefetcher.hh:161
addr
ip6_addr_t addr
Definition: inet.hh:423
RubyPrefetcher::m_unit_filter_hit
uint32_t * m_unit_filter_hit
An array used to count the of times particular filter entries have been hit.
Definition: RubyPrefetcher.hh:179
PrefetchEntry::m_address
Addr m_address
The base address for the stream prefetch.
Definition: RubyPrefetcher.hh:73
ArmISA::stride
Bitfield< 21, 20 > stride
Definition: miscregs_types.hh:441
RubyPrefetcher::Params
RubyPrefetcherParams Params
Definition: RubyPrefetcher.hh:96
Cycles
Cycles is a wrapper class for representing cycle counts, i.e.
Definition: types.hh:83
RubyPrefetcher::m_negative_filter
std::vector< Addr > m_negative_filter
a negative unit stride filter array: helps reduce BW requirement of prefetching
Definition: RubyPrefetcher.hh:183
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:333
RubyPrefetcher::m_train_misses
uint32_t m_train_misses
number of misses I must see before allocating a stream
Definition: RubyPrefetcher.hh:164
RubyPrefetcher::m_unit_filter_index
uint32_t m_unit_filter_index
a round robin pointer into the unit filter group
Definition: RubyPrefetcher.hh:176
RubyPrefetcher::numMissedPrefetchedBlocks
Stats::Scalar numMissedPrefetchedBlocks
Count of misses incurred for blocks that were prefetched.
Definition: RubyPrefetcher.hh:221
RubyPrefetcher::numPrefetchRequested
Stats::Scalar numPrefetchRequested
Count of prefetch requests made.
Definition: RubyPrefetcher.hh:213
RubyPrefetcher::m_prefetch_cross_pages
bool m_prefetch_cross_pages
Used for allowing prefetches across pages.
Definition: RubyPrefetcher.hh:202
MipsISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:323
RubyPrefetcher::~RubyPrefetcher
~RubyPrefetcher()
Definition: RubyPrefetcher.cc:92
RubyPrefetcher::m_nonunit_index
uint32_t m_nonunit_index
a round robin pointer into the unit filter group
Definition: RubyPrefetcher.hh:199
RubyPrefetcher::clearNonunitEntry
void clearNonunitEntry(uint32_t index)
clear a non-unit stride prefetcher entry
Definition: RubyPrefetcher.cc:284
RubyPrefetcher::m_num_unit_filters
uint32_t m_num_unit_filters
number of stride filters
Definition: RubyPrefetcher.hh:168
RubyPrefetcher::numMissObserved
Stats::Scalar numMissObserved
Count of accesses to the prefetcher.
Definition: RubyPrefetcher.hh:209
RubySystem::getBlockSizeBits
static uint32_t getBlockSizeBits()
Definition: RubySystem.hh:63
RubyPrefetcher::m_negative_filter_hit
uint32_t * m_negative_filter_hit
An array used to count the of times particular filter entries have been hit.
Definition: RubyPrefetcher.hh:188
SimObject
Abstract superclass for simulation objects.
Definition: sim_object.hh:92

Generated on Wed Sep 30 2020 14:02:13 for gem5 by doxygen 1.8.17