gem5  v20.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 class BaseIndexingPolicy;
65 struct StridePrefetcherParams;
66 
67 namespace Prefetcher {
68 
74 {
75  protected:
76  uint32_t extractSet(const Addr addr) const override;
77  Addr extractTag(const Addr addr) const override;
78 
79  public:
81  const StridePrefetcherHashedSetAssociativeParams *p)
82  : SetAssociative(p)
83  {
84  }
86 };
87 
88 class Stride : public Queued
89 {
90  protected:
93 
95  const double threshConf;
96 
97  const bool useRequestorId;
98 
99  const int degree;
100 
104  const struct PCTableInfo
105  {
106  const int assoc;
107  const int numEntries;
108 
111 
112  PCTableInfo(int assoc, int num_entries,
113  BaseIndexingPolicy* indexing_policy,
114  BaseReplacementPolicy* replacement_policy)
115  : assoc(assoc), numEntries(num_entries),
116  indexingPolicy(indexing_policy),
117  replacementPolicy(replacement_policy)
118  {
119  }
120  } pcTableInfo;
121 
123  struct StrideEntry : public TaggedEntry
124  {
125  StrideEntry(const SatCounter& init_confidence);
126 
127  void invalidate() override;
128 
130  int stride;
132  };
134  std::unordered_map<int, PCTable> pcTables;
135 
143  PCTable* findTable(int context);
144 
151  PCTable* allocateNewContext(int context);
152 
153  public:
154  Stride(const StridePrefetcherParams *p);
155 
156  void calculatePrefetch(const PrefetchInfo &pfi,
157  std::vector<AddrPriority> &addresses) override;
158 };
159 
160 } // namespace Prefetcher
161 
162 #endif // __MEM_CACHE_PREFETCH_STRIDE_HH__
Prefetcher::Stride
Definition: stride.hh:88
Prefetcher::Stride::useRequestorId
const bool useRequestorId
Definition: stride.hh:97
Prefetcher::Stride::PCTableInfo::replacementPolicy
BaseReplacementPolicy *const replacementPolicy
Definition: stride.hh:110
Prefetcher::Stride::StrideEntry::lastAddr
Addr lastAddr
Definition: stride.hh:129
TaggedEntry
Copyright (c) 2018 Metempsy Technology Consulting All rights reserved.
Definition: associative_set.hh:39
AssociativeSet
Associative container based on the previosuly defined Entry type Each element is indexed by a key of ...
Definition: associative_set.hh:117
Prefetcher::Stride::PCTableInfo::PCTableInfo
PCTableInfo(int assoc, int num_entries, BaseIndexingPolicy *indexing_policy, BaseReplacementPolicy *replacement_policy)
Definition: stride.hh:112
Prefetcher::Stride::allocateNewContext
PCTable * allocateNewContext(int context)
Create a PC table for the given context.
Definition: stride.cc:100
Prefetcher::Stride::PCTable
AssociativeSet< StrideEntry > PCTable
Definition: stride.hh:133
std::vector
STL vector class.
Definition: stl.hh:37
Prefetcher::Stride::pcTables
std::unordered_map< int, PCTable > pcTables
Definition: stride.hh:134
Prefetcher::StridePrefetcherHashedSetAssociative::StridePrefetcherHashedSetAssociative
StridePrefetcherHashedSetAssociative(const StridePrefetcherHashedSetAssociativeParams *p)
Definition: stride.hh:80
Prefetcher::Stride::threshConf
const double threshConf
Confidence threshold for prefetch generation.
Definition: stride.hh:95
Prefetcher::Stride::calculatePrefetch
void calculatePrefetch(const PrefetchInfo &pfi, std::vector< AddrPriority > &addresses) override
Definition: stride.cc:115
sat_counter.hh
set_associative.hh
queued.hh
Prefetcher::Stride::StrideEntry::stride
int stride
Definition: stride.hh:130
packet.hh
replaceable_entry.hh
Prefetcher::Stride::Stride
Stride(const StridePrefetcherParams *p)
Definition: stride.cc:76
Prefetcher::StridePrefetcherHashedSetAssociative::extractSet
uint32_t extractSet(const Addr addr) const override
Apply a hash function to calculate address set.
Definition: stride.cc:190
Prefetcher::Stride::StrideEntry::StrideEntry
StrideEntry(const SatCounter &init_confidence)
Definition: stride.cc:62
BaseReplacementPolicy
A common base class of cache replacement policy objects.
Definition: base.hh:46
SetAssociative
A set associative indexing policy.
Definition: set_associative.hh:79
Prefetcher
Copyright (c) 2018 Metempsy Technology Consulting All rights reserved.
Definition: base.hh:78
Prefetcher::StridePrefetcherHashedSetAssociative::~StridePrefetcherHashedSetAssociative
~StridePrefetcherHashedSetAssociative()=default
Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
Prefetcher::Stride::PCTableInfo
Information used to create a new PC table.
Definition: stride.hh:104
Prefetcher::Queued
Definition: queued.hh:54
Prefetcher::Stride::findTable
PCTable * findTable(int context)
Try to find a table of entries for the given context.
Definition: stride.cc:88
Prefetcher::Stride::initConfidence
const SatCounter initConfidence
Initial confidence counter value for the pc tables.
Definition: stride.hh:92
SatCounter
Implements an n bit saturating counter and provides methods to increment, decrement,...
Definition: sat_counter.hh:54
Prefetcher::StridePrefetcherHashedSetAssociative
Override the default set associative to apply a specific hash function when extracting a set.
Definition: stride.hh:73
Prefetcher::StridePrefetcherHashedSetAssociative::extractTag
Addr extractTag(const Addr addr) const override
Generate the tag from the given address.
Definition: stride.cc:198
types.hh
Prefetcher::Stride::PCTableInfo::assoc
const int assoc
Definition: stride.hh:106
Prefetcher::Stride::pcTableInfo
const struct Prefetcher::Stride::PCTableInfo pcTableInfo
addr
ip6_addr_t addr
Definition: inet.hh:423
Prefetcher::Base::PrefetchInfo
Class containing the information needed by the prefetch to train and generate new prefetch requests.
Definition: base.hh:90
BaseIndexingPolicy
A common base class for indexing table locations.
Definition: base.hh:63
Prefetcher::Stride::PCTableInfo::numEntries
const int numEntries
Definition: stride.hh:107
Prefetcher::Stride::StrideEntry::confidence
SatCounter confidence
Definition: stride.hh:131
associative_set.hh
Prefetcher::Stride::StrideEntry::invalidate
void invalidate() override
Invalidates the entry.
Definition: stride.cc:69
Prefetcher::Stride::StrideEntry
Tagged by hashed PCs.
Definition: stride.hh:123
MipsISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:323
Prefetcher::Stride::degree
const int degree
Definition: stride.hh:99
Prefetcher::Stride::PCTableInfo::indexingPolicy
BaseIndexingPolicy *const indexingPolicy
Definition: stride.hh:109

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