Prefetcher.hh (10466:73b7549d979e) | Prefetcher.hh (11025:4872dbdea907) |
---|---|
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; --- 12 unchanged lines hidden (view full) --- 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 | 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; --- 12 unchanged lines hidden (view full) --- 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 PREFETCHER_H 30#define PREFETCHER_H | 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" 37#include "mem/ruby/common/Address.hh" 38#include "mem/ruby/network/MessageBuffer.hh" --- 14 unchanged lines hidden (view full) --- 53 { 54 // default: 1 cache-line stride 55 m_stride = (1 << RubySystem::getBlockSizeBits()); 56 m_use_time = Cycles(0); 57 m_is_valid = false; 58 } 59 60 //! The base address for the stream prefetch | 31 32// Implements Power 4 like prefetching 33 34#include <bitset> 35 36#include "base/statistics.hh" 37#include "mem/ruby/common/Address.hh" 38#include "mem/ruby/network/MessageBuffer.hh" --- 14 unchanged lines hidden (view full) --- 53 { 54 // default: 1 cache-line stride 55 m_stride = (1 << RubySystem::getBlockSizeBits()); 56 m_use_time = Cycles(0); 57 m_is_valid = false; 58 } 59 60 //! The base address for the stream prefetch |
61 Address m_address; | 61 Addr m_address; |
62 63 //! stride distance to get next address from 64 int m_stride; 65 66 //! the last time that any prefetched request was used 67 Cycles m_use_time; 68 69 //! valid bit for each stream --- 10 unchanged lines hidden (view full) --- 80 81class Prefetcher : public SimObject 82{ 83 public: 84 typedef PrefetcherParams Params; 85 Prefetcher(const Params *p); 86 ~Prefetcher(); 87 | 62 63 //! stride distance to get next address from 64 int m_stride; 65 66 //! the last time that any prefetched request was used 67 Cycles m_use_time; 68 69 //! valid bit for each stream --- 10 unchanged lines hidden (view full) --- 80 81class Prefetcher : public SimObject 82{ 83 public: 84 typedef PrefetcherParams Params; 85 Prefetcher(const Params *p); 86 ~Prefetcher(); 87 |
88 void issueNextPrefetch(const Address &address, PrefetchEntry *stream); | 88 void issueNextPrefetch(Addr address, PrefetchEntry *stream); |
89 /** 90 * Implement the prefetch hit(miss) callback interface. 91 * These functions are called by the cache when it hits(misses) 92 * on a line with the line's prefetch bit set. If this address 93 * hits in m_array we will continue prefetching the stream. 94 */ | 89 /** 90 * Implement the prefetch hit(miss) callback interface. 91 * These functions are called by the cache when it hits(misses) 92 * on a line with the line's prefetch bit set. If this address 93 * hits in m_array we will continue prefetching the stream. 94 */ |
95 void observePfHit(const Address& address); 96 void observePfMiss(const Address& address); | 95 void observePfHit(Addr address); 96 void observePfMiss(Addr address); |
97 98 /** 99 * Observe a memory miss from the cache. 100 * 101 * @param address The physical address that missed out of the cache. 102 */ | 97 98 /** 99 * Observe a memory miss from the cache. 100 * 101 * @param address The physical address that missed out of the cache. 102 */ |
103 void observeMiss(const Address& address, const RubyRequestType& type); | 103 void observeMiss(Addr address, const RubyRequestType& type); |
104 105 /** 106 * Print out some statistics 107 */ 108 void print(std::ostream& out) const; 109 void setController(AbstractController *_ctrl) 110 { m_controller = _ctrl; } 111 --- 6 unchanged lines hidden (view full) --- 118 * @return The index of the least recently used stream buffer. 119 */ 120 uint32_t getLRUindex(void); 121 122 //! clear a non-unit stride prefetcher entry 123 void clearNonunitEntry(uint32_t index); 124 125 //! allocate a new stream buffer at a specific index | 104 105 /** 106 * Print out some statistics 107 */ 108 void print(std::ostream& out) const; 109 void setController(AbstractController *_ctrl) 110 { m_controller = _ctrl; } 111 --- 6 unchanged lines hidden (view full) --- 118 * @return The index of the least recently used stream buffer. 119 */ 120 uint32_t getLRUindex(void); 121 122 //! clear a non-unit stride prefetcher entry 123 void clearNonunitEntry(uint32_t index); 124 125 //! allocate a new stream buffer at a specific index |
126 void initializeStream(const Address& address, int stride, | 126 void initializeStream(Addr address, int stride, |
127 uint32_t index, const RubyRequestType& type); 128 129 //! get pointer to the matching stream entry, returns NULL if not found 130 //! index holds the multiple of the stride this address is. | 127 uint32_t index, const RubyRequestType& type); 128 129 //! get pointer to the matching stream entry, returns NULL if not found 130 //! index holds the multiple of the stride this address is. |
131 PrefetchEntry* getPrefetchEntry(const Address &address, | 131 PrefetchEntry* getPrefetchEntry(Addr address, |
132 uint32_t &index); 133 134 /// access a unit stride filter to determine if there is a hit | 132 uint32_t &index); 133 134 /// access a unit stride filter to determine if there is a hit |
135 bool accessUnitFilter(std::vector<Address>& filter_table, 136 uint32_t *hit_table, uint32_t &index, const Address &address, | 135 bool accessUnitFilter(std::vector 136 uint32_t *hit_table, uint32_t &index, Addr address, |
137 int stride, bool &alloc); 138 139 /// access a unit stride filter to determine if there is a hit | 137 int stride, bool &alloc); 138 139 /// access a unit stride filter to determine if there is a hit |
140 bool accessNonunitFilter(const Address& address, int *stride, | 140 bool accessNonunitFilter(Addr address, int *stride, |
141 bool &alloc); 142 143 /// determine the page aligned address | 141 bool &alloc); 142 143 /// determine the page aligned address |
144 Address pageAddress(const Address& addr) const; | 144 Addr pageAddress(Addr addr) const; |
145 146 //! number of prefetch streams available 147 uint32_t m_num_streams; 148 //! an array of the active prefetch streams 149 std::vector<PrefetchEntry> m_array; 150 151 //! number of misses I must see before allocating a stream 152 uint32_t m_train_misses; 153 //! number of initial prefetches to startup a stream 154 uint32_t m_num_startup_pfs; 155 //! number of stride filters 156 uint32_t m_num_unit_filters; 157 //! number of non-stride filters 158 uint32_t m_num_nonunit_filters; 159 160 /// a unit stride filter array: helps reduce BW requirement of 161 /// prefetching | 145 146 //! number of prefetch streams available 147 uint32_t m_num_streams; 148 //! an array of the active prefetch streams 149 std::vector<PrefetchEntry> m_array; 150 151 //! number of misses I must see before allocating a stream 152 uint32_t m_train_misses; 153 //! number of initial prefetches to startup a stream 154 uint32_t m_num_startup_pfs; 155 //! number of stride filters 156 uint32_t m_num_unit_filters; 157 //! number of non-stride filters 158 uint32_t m_num_nonunit_filters; 159 160 /// a unit stride filter array: helps reduce BW requirement of 161 /// prefetching |
162 std::vector<Address> m_unit_filter; | 162 std::vector |
163 /// a round robin pointer into the unit filter group 164 uint32_t m_unit_filter_index; 165 //! An array used to count the of times particular filter entries 166 //! have been hit 167 uint32_t *m_unit_filter_hit; 168 169 //! a negative nit stride filter array: helps reduce BW requirement 170 //! of prefetching | 163 /// a round robin pointer into the unit filter group 164 uint32_t m_unit_filter_index; 165 //! An array used to count the of times particular filter entries 166 //! have been hit 167 uint32_t *m_unit_filter_hit; 168 169 //! a negative nit stride filter array: helps reduce BW requirement 170 //! of prefetching |
171 std::vector<Address> m_negative_filter; | 171 std::vector |
172 /// a round robin pointer into the negative filter group 173 uint32_t m_negative_filter_index; 174 /// An array used to count the of times particular filter entries 175 /// have been hit 176 uint32_t *m_negative_filter_hit; 177 178 /// a non-unit stride filter array: helps reduce BW requirement of 179 /// prefetching | 172 /// a round robin pointer into the negative filter group 173 uint32_t m_negative_filter_index; 174 /// An array used to count the of times particular filter entries 175 /// have been hit 176 uint32_t *m_negative_filter_hit; 177 178 /// a non-unit stride filter array: helps reduce BW requirement of 179 /// prefetching |
180 std::vector<Address> m_nonunit_filter; | 180 std::vector |
181 /// An array of strides (in # of cache lines) for the filter entries 182 int *m_nonunit_stride; 183 /// An array used to count the of times particular filter entries 184 /// have been hit 185 uint32_t *m_nonunit_hit; 186 /// a round robin pointer into the unit filter group 187 uint32_t m_nonunit_index; 188 --- 19 unchanged lines hidden (view full) --- 208 //! Count of partial successful prefetches 209 Stats::Scalar numPartialHits; 210 //! Count of pages crossed 211 Stats::Scalar numPagesCrossed; 212 //! Count of misses incurred for blocks that were prefetched 213 Stats::Scalar numMissedPrefetchedBlocks; 214}; 215 | 181 /// An array of strides (in # of cache lines) for the filter entries 182 int *m_nonunit_stride; 183 /// An array used to count the of times particular filter entries 184 /// have been hit 185 uint32_t *m_nonunit_hit; 186 /// a round robin pointer into the unit filter group 187 uint32_t m_nonunit_index; 188 --- 19 unchanged lines hidden (view full) --- 208 //! Count of partial successful prefetches 209 Stats::Scalar numPartialHits; 210 //! Count of pages crossed 211 Stats::Scalar numPagesCrossed; 212 //! Count of misses incurred for blocks that were prefetched 213 Stats::Scalar numMissedPrefetchedBlocks; 214}; 215 |
216#endif // PREFETCHER_H | 216#endif // __MEM_RUBY_STRUCTURES_PREFETCHER_HH__ |