gem5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Prefetcher.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 1999-2012 Mark D. Hill and David A. Wood
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are
7  * met: redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer;
9  * redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution;
12  * neither the name of the copyright holders nor the names of its
13  * contributors may be used to endorse or promote products derived from
14  * this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  */
28 
29 #ifndef __MEM_RUBY_STRUCTURES_PREFETCHER_HH__
30 #define __MEM_RUBY_STRUCTURES_PREFETCHER_HH__
31 
32 // Implements Power 4 like prefetching
33 
34 #include <bitset>
35 
36 #include "base/statistics.hh"
42 #include "params/Prefetcher.hh"
43 #include "sim/sim_object.hh"
44 #include "sim/system.hh"
45 
46 #define MAX_PF_INFLIGHT 8
47 
49 {
50  public:
53  {
54  // default: 1 cache-line stride
56  m_use_time = Cycles(0);
57  m_is_valid = false;
58  }
59 
62 
64  int m_stride;
65 
68 
70  bool m_is_valid;
71 
73  RubyRequestType m_type;
74 
77  std::bitset<MAX_PF_INFLIGHT> requestIssued;
78  std::bitset<MAX_PF_INFLIGHT> requestCompleted;
79 };
80 
81 class Prefetcher : public SimObject
82 {
83  public:
84  typedef PrefetcherParams Params;
85  Prefetcher(const Params *p);
86  ~Prefetcher();
87 
88  void issueNextPrefetch(Addr address, PrefetchEntry *stream);
95  void observePfHit(Addr address);
96  void observePfMiss(Addr address);
97 
103  void observeMiss(Addr address, const RubyRequestType& type);
104 
108  void print(std::ostream& out) const;
110  { m_controller = _ctrl; }
111 
112  void regStats();
113 
114  private:
120  uint32_t getLRUindex(void);
121 
123  void clearNonunitEntry(uint32_t index);
124 
126  void initializeStream(Addr address, int stride,
127  uint32_t index, const RubyRequestType& type);
128 
132  uint32_t &index);
133 
135  bool accessUnitFilter(std::vector<Addr>& filter_table,
136  uint32_t *hit_table, uint32_t &index, Addr address,
137  int stride, bool &alloc);
138 
140  bool accessNonunitFilter(Addr address, int *stride,
141  bool &alloc);
142 
144  Addr pageAddress(Addr addr) const;
145 
147  uint32_t m_num_streams;
150 
152  uint32_t m_train_misses;
159 
167  uint32_t *m_unit_filter_hit;
168 
177 
185  uint32_t *m_nonunit_hit;
187  uint32_t m_nonunit_index;
188 
191 
193 
195 
214 };
215 
216 #endif // __MEM_RUBY_STRUCTURES_PREFETCHER_HH__
uint32_t m_negative_filter_index
a round robin pointer into the negative filter group
Definition: Prefetcher.hh:173
Stats::Scalar numPartialHits
Count of partial successful prefetches.
Definition: Prefetcher.hh:209
void setController(AbstractController *_ctrl)
Definition: Prefetcher.hh:109
int * m_nonunit_stride
An array of strides (in # of cache lines) for the filter entries.
Definition: Prefetcher.hh:182
Bitfield< 30, 0 > index
Cycles is a wrapper class for representing cycle counts, i.e.
Definition: types.hh:83
uint32_t getLRUindex(void)
Returns an unused stream buffer (or if all are used, returns the least recently used (accessed) strea...
Definition: Prefetcher.cc:261
std::bitset< MAX_PF_INFLIGHT > requestIssued
Bitset for tracking prefetches for which addresses have been issued, which ones have completed...
Definition: Prefetcher.hh:77
Stats::Scalar numMissedPrefetchedBlocks
Count of misses incurred for blocks that were prefetched.
Definition: Prefetcher.hh:213
Stats::Scalar numMissObserved
Count of accesses to the prefetcher.
Definition: Prefetcher.hh:197
Bitfield< 21, 20 > stride
Definition: miscregs.hh:1627
const Addr m_page_shift
Definition: Prefetcher.hh:194
void observePfHit(Addr address)
Implement the prefetch hit(miss) callback interface.
Definition: Prefetcher.cc:215
ip6_addr_t addr
Definition: inet.hh:335
RubyRequestType m_type
L1D prefetches loads and stores.
Definition: Prefetcher.hh:73
Stats::Scalar numHits
Count of successful prefetches.
Definition: Prefetcher.hh:207
void clearNonunitEntry(uint32_t index)
clear a non-unit stride prefetcher entry
Definition: Prefetcher.cc:280
Prefetcher(const Params *p)
Definition: Prefetcher.cc:41
int m_stride
stride distance to get next address from
Definition: Prefetcher.hh:64
std::vector< Addr > m_negative_filter
a negative nit stride filter array: helps reduce BW requirement of prefetching
Definition: Prefetcher.hh:171
Declaration of Statistics objects.
This is a simple scalar statistic, like a counter.
Definition: statistics.hh:2475
uint32_t m_train_misses
number of misses I must see before allocating a stream
Definition: Prefetcher.hh:152
Stats::Scalar numPrefetchAccepted
Count of prefetch requests accepted.
Definition: Prefetcher.hh:203
uint32_t m_unit_filter_index
a round robin pointer into the unit filter group
Definition: Prefetcher.hh:164
std::vector< Addr > m_nonunit_filter
a non-unit stride filter array: helps reduce BW requirement of prefetching
Definition: Prefetcher.hh:180
bool m_is_valid
valid bit for each stream
Definition: Prefetcher.hh:70
uint32_t m_num_nonunit_filters
number of non-stride filters
Definition: Prefetcher.hh:158
bool accessNonunitFilter(Addr address, int *stride, bool &alloc)
access a unit stride filter to determine if there is a hit
Definition: Prefetcher.cc:380
Stats::Scalar numPagesCrossed
Count of pages crossed.
Definition: Prefetcher.hh:211
uint32_t * m_nonunit_hit
An array used to count the of times particular filter entries have been hit.
Definition: Prefetcher.hh:185
void initializeStream(Addr address, int stride, uint32_t index, const RubyRequestType &type)
allocate a new stream buffer at a specific index
Definition: Prefetcher.cc:288
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
bool m_prefetch_cross_pages
Used for allowing prefetches across pages.
Definition: Prefetcher.hh:190
void regStats()
Register statistics for this object.
Definition: Prefetcher.cc:88
std::vector< PrefetchEntry > m_array
an array of the active prefetch streams
Definition: Prefetcher.hh:149
Addr m_address
The base address for the stream prefetch.
Definition: Prefetcher.hh:61
void issueNextPrefetch(Addr address, PrefetchEntry *stream)
Definition: Prefetcher.cc:223
type
Definition: misc.hh:728
uint32_t m_nonunit_index
a round robin pointer into the unit filter group
Definition: Prefetcher.hh:187
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: Prefetcher.cc:347
uint32_t m_num_unit_filters
number of stride filters
Definition: Prefetcher.hh:156
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: Prefetcher.cc:329
Addr pageAddress(Addr addr) const
determine the page aligned address
Definition: Prefetcher.cc:476
void observeMiss(Addr address, const RubyRequestType &type)
Observe a memory miss from the cache.
Definition: Prefetcher.cc:139
PrefetchEntry()
constructor
Definition: Prefetcher.hh:52
Stats::Scalar numPrefetchRequested
Count of prefetch requests made.
Definition: Prefetcher.hh:201
std::bitset< MAX_PF_INFLIGHT > requestCompleted
Definition: Prefetcher.hh:78
uint32_t * m_unit_filter_hit
An array used to count the of times particular filter entries have been hit.
Definition: Prefetcher.hh:167
void print(std::ostream &out) const
Print out some statistics.
Definition: Prefetcher.cc:443
Stats::Scalar numAllocatedStreams
Count of prefetch streams allocated.
Definition: Prefetcher.hh:199
PrefetcherParams Params
Definition: Prefetcher.hh:84
uint32_t m_num_streams
number of prefetch streams available
Definition: Prefetcher.hh:147
uint32_t * m_negative_filter_hit
An array used to count the of times particular filter entries have been hit.
Definition: Prefetcher.hh:176
uint32_t m_num_startup_pfs
number of initial prefetches to startup a stream
Definition: Prefetcher.hh:154
Bitfield< 0 > p
static uint32_t getBlockSizeBits()
Definition: RubySystem.hh:75
AbstractController * m_controller
Definition: Prefetcher.hh:192
Abstract superclass for simulation objects.
Definition: sim_object.hh:94
void observePfMiss(Addr address)
Definition: Prefetcher.cc:207
Stats::Scalar numDroppedPrefetches
Count of prefetches dropped.
Definition: Prefetcher.hh:205
std::vector< Addr > m_unit_filter
a unit stride filter array: helps reduce BW requirement of prefetching
Definition: Prefetcher.hh:162
Cycles m_use_time
the last time that any prefetched request was used
Definition: Prefetcher.hh:67

Generated on Fri Jun 9 2017 13:03:50 for gem5 by doxygen 1.8.6