gem5  v22.1.0.0
stride.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018 Inria
3  * Copyright (c) 2012-2013, 2015 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) 2005 The Regents of The University of Michigan
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 
47 #ifndef __MEM_CACHE_PREFETCH_STRIDE_HH__
48 #define __MEM_CACHE_PREFETCH_STRIDE_HH__
49 
50 #include <string>
51 #include <unordered_map>
52 #include <vector>
53 
54 #include "base/sat_counter.hh"
55 #include "base/types.hh"
60 #include "mem/packet.hh"
61 #include "params/StridePrefetcherHashedSetAssociative.hh"
62 
63 namespace gem5
64 {
65 
66 class BaseIndexingPolicy;
67 GEM5_DEPRECATED_NAMESPACE(ReplacementPolicy, replacement_policy);
68 namespace replacement_policy
69 {
70  class Base;
71 }
72 struct StridePrefetcherParams;
73 
75 namespace prefetch
76 {
77 
83 {
84  protected:
85  uint32_t extractSet(const Addr addr) const override;
86  Addr extractTag(const Addr addr) const override;
87 
88  public:
90  const StridePrefetcherHashedSetAssociativeParams &p)
91  : SetAssociative(p)
92  {
93  }
95 };
96 
97 class Stride : public Queued
98 {
99  protected:
102 
104  const double threshConf;
105 
106  const bool useRequestorId;
107 
108  const int degree;
109 
113  const struct PCTableInfo
114  {
115  const int assoc;
116  const int numEntries;
117 
120 
121  PCTableInfo(int assoc, int num_entries,
122  BaseIndexingPolicy* indexing_policy,
123  replacement_policy::Base* repl_policy)
124  : assoc(assoc), numEntries(num_entries),
125  indexingPolicy(indexing_policy), replacementPolicy(repl_policy)
126  {
127  }
129 
131  struct StrideEntry : public TaggedEntry
132  {
133  StrideEntry(const SatCounter8& init_confidence);
134 
135  void invalidate() override;
136 
138  int stride;
140  };
142  std::unordered_map<int, PCTable> pcTables;
143 
151  PCTable* findTable(int context);
152 
159  PCTable* allocateNewContext(int context);
160 
161  public:
162  Stride(const StridePrefetcherParams &p);
163 
164  void calculatePrefetch(const PrefetchInfo &pfi,
165  std::vector<AddrPriority> &addresses) override;
166 };
167 
168 } // namespace prefetch
169 } // namespace gem5
170 
171 #endif // __MEM_CACHE_PREFETCH_STRIDE_HH__
Defines global host-dependent types: Counter, Tick, and (indirectly) {int,uint}{8,...
Associative container based on the previosuly defined Entry type Each element is indexed by a key of ...
A common base class for indexing table locations.
Definition: base.hh:67
A set associative indexing policy.
A tagged entry is an entry containing a tag.
Definition: tagged_entry.hh:47
Class containing the information needed by the prefetch to train and generate new prefetch requests.
Definition: base.hh:98
Override the default set associative to apply a specific hash function when extracting a set.
Definition: stride.hh:83
Addr extractTag(const Addr addr) const override
Generate the tag from the given address.
Definition: stride.cc:204
StridePrefetcherHashedSetAssociative(const StridePrefetcherHashedSetAssociativeParams &p)
Definition: stride.hh:89
uint32_t extractSet(const Addr addr) const override
Apply a hash function to calculate address set.
Definition: stride.cc:196
AssociativeSet< StrideEntry > PCTable
Definition: stride.hh:141
const SatCounter8 initConfidence
Initial confidence counter value for the pc tables.
Definition: stride.hh:101
const double threshConf
Confidence threshold for prefetch generation.
Definition: stride.hh:104
PCTable * allocateNewContext(int context)
Create a PC table for the given context.
Definition: stride.cc:106
void calculatePrefetch(const PrefetchInfo &pfi, std::vector< AddrPriority > &addresses) override
Definition: stride.cc:121
Stride(const StridePrefetcherParams &p)
Definition: stride.cc:82
std::unordered_map< int, PCTable > pcTables
Definition: stride.hh:142
const bool useRequestorId
Definition: stride.hh:106
const struct gem5::prefetch::Stride::PCTableInfo pcTableInfo
PCTable * findTable(int context)
Try to find a table of entries for the given context.
Definition: stride.cc:94
A common base class of cache replacement policy objects.
Definition: base.hh:56
STL vector class.
Definition: stl.hh:37
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
GEM5_DEPRECATED_NAMESPACE(GuestABI, guest_abi)
Declaration of the Packet class.
Declaration of a set associative indexing policy.
Information used to create a new PC table.
Definition: stride.hh:114
replacement_policy::Base *const replacementPolicy
Definition: stride.hh:119
BaseIndexingPolicy *const indexingPolicy
Definition: stride.hh:118
PCTableInfo(int assoc, int num_entries, BaseIndexingPolicy *indexing_policy, replacement_policy::Base *repl_policy)
Definition: stride.hh:121
Tagged by hashed PCs.
Definition: stride.hh:132
StrideEntry(const SatCounter8 &init_confidence)
Definition: stride.cc:67
void invalidate() override
Invalidate the block.
Definition: stride.cc:74

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