brrip_rp.hh (12626:e161d7725d4b) brrip_rp.hh (12684:44ebd2bc020f)
1/**
2 * Copyright (c) 2018 Inria
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;

--- 19 unchanged lines hidden (view full) ---

28 * Authors: Daniel Carvalho
29 */
30
31/**
32 * @file
33 * Declaration of a Re-Reference Interval Prediction replacement policy.
34 *
35 * Not-Recently Used (NRU) is an approximation of LRU that uses a single bit
1/**
2 * Copyright (c) 2018 Inria
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;

--- 19 unchanged lines hidden (view full) ---

28 * Authors: Daniel Carvalho
29 */
30
31/**
32 * @file
33 * Declaration of a Re-Reference Interval Prediction replacement policy.
34 *
35 * Not-Recently Used (NRU) is an approximation of LRU that uses a single bit
36 * to determine if a block is going to be re-referenced in the near or distant
36 * to determine if an entry is going to be re-referenced in the near or distant
37 * future.
38 *
39 * Re-Reference Interval Prediction (RRIP) is an extension of NRU that uses a
37 * future.
38 *
39 * Re-Reference Interval Prediction (RRIP) is an extension of NRU that uses a
40 * re-reference prediction value to determine if blocks are going to be re-
40 * re-reference prediction value to determine if entries are going to be re-
41 * used in the near future or not.
42 *
41 * used in the near future or not.
42 *
43 * The higher the value of the RRPV, the more distant the block is from
44 * its next access.
43 * The higher the value of the RRPV, the more distant the entry is from its
44 * next access.
45 *
46 * Bimodal Re-Reference Interval Prediction (BRRIP) is an extension of RRIP
45 *
46 * Bimodal Re-Reference Interval Prediction (BRRIP) is an extension of RRIP
47 * that has a probability of not inserting blocks as the LRU. This probability
47 * that has a probability of not inserting entries as the LRU. This probability
48 * is controlled by the bimodal throtle parameter (btp).
49 *
50 * From the original paper, this implementation of RRIP is also called
48 * is controlled by the bimodal throtle parameter (btp).
49 *
50 * From the original paper, this implementation of RRIP is also called
51 * Static RRIP (SRRIP), as it always inserts blocks with the same RRPV.
51 * Static RRIP (SRRIP), as it always inserts entries with the same RRPV.
52 */
53
54#ifndef __MEM_CACHE_REPLACEMENT_POLICIES_BRRIP_RP_HH__
55#define __MEM_CACHE_REPLACEMENT_POLICIES_BRRIP_RP_HH__
56
57#include "mem/cache/replacement_policies/base.hh"
58#include "params/BRRIPRP.hh"
59
60class BRRIPRP : public BaseReplacementPolicy
61{
62 protected:
52 */
53
54#ifndef __MEM_CACHE_REPLACEMENT_POLICIES_BRRIP_RP_HH__
55#define __MEM_CACHE_REPLACEMENT_POLICIES_BRRIP_RP_HH__
56
57#include "mem/cache/replacement_policies/base.hh"
58#include "params/BRRIPRP.hh"
59
60class BRRIPRP : public BaseReplacementPolicy
61{
62 protected:
63 /** BRRIP-specific implementation of replacement data. */
64 struct BRRIPReplData : ReplacementData
65 {
66 /**
67 * Re-Reference Interval Prediction Value.
68 * A value equal to max_RRPV + 1 indicates an invalid entry.
69 */
70 int rrpv;
71
72 /**
73 * Default constructor. Invalidate data.
74 */
75 BRRIPReplData(const int max_RRPV) : rrpv(max_RRPV + 1) {}
76 };
77
63 /**
78 /**
64 * Maximum Re-Reference Prediction Value possible. A block with this
79 * Maximum Re-Reference Prediction Value possible. An entry with this
65 * value as the rrpv has the longest possible re-reference interval,
66 * that is, it is likely not to be used in the near future, and is
67 * among the best eviction candidates.
68 * A maxRRPV of 1 implies in a NRU.
69 */
80 * value as the rrpv has the longest possible re-reference interval,
81 * that is, it is likely not to be used in the near future, and is
82 * among the best eviction candidates.
83 * A maxRRPV of 1 implies in a NRU.
84 */
70 const unsigned maxRRPV;
85 const int maxRRPV;
71
72 /**
86
87 /**
73 * The hit priority (HP) policy replaces blocks that do not receive cache
74 * hits over any cache block that receives a hit, while the frequency
75 * priority (FP) policy replaces infrequently re-referenced blocks.
88 * The hit priority (HP) policy replaces entries that do not receive cache
89 * hits over any cache entry that receives a hit, while the frequency
90 * priority (FP) policy replaces infrequently re-referenced entries.
76 */
77 const bool hitPriority;
78
79 /**
80 * Bimodal throtle parameter. Value in the range [0,100] used to decide
91 */
92 const bool hitPriority;
93
94 /**
95 * Bimodal throtle parameter. Value in the range [0,100] used to decide
81 * if a new block is inserted with long or distant re-reference.
96 * if a new entry is inserted with long or distant re-reference.
82 */
83 const unsigned btp;
84
85 public:
86 /** Convenience typedef. */
87 typedef BRRIPRPParams Params;
88
89 /**
90 * Construct and initiliaze this replacement policy.
91 */
92 BRRIPRP(const Params *p);
93
94 /**
95 * Destructor.
96 */
97 ~BRRIPRP() {}
98
99 /**
97 */
98 const unsigned btp;
99
100 public:
101 /** Convenience typedef. */
102 typedef BRRIPRPParams Params;
103
104 /**
105 * Construct and initiliaze this replacement policy.
106 */
107 BRRIPRP(const Params *p);
108
109 /**
110 * Destructor.
111 */
112 ~BRRIPRP() {}
113
114 /**
100 * Touch a block to update its replacement data.
115 * Invalidate replacement data to set it as the next probable victim.
116 * Set RRPV as the the most distant re-reference.
101 *
117 *
102 * @param blk Cache block to be touched.
118 * @param replacement_data Replacement data to be invalidated.
103 */
119 */
104 void touch(CacheBlk *blk) override;
120 void invalidate(const std::shared_ptr<ReplacementData>& replacement_data)
121 const override;
105
106 /**
122
123 /**
107 * Reset replacement data for a block. Used when a block is inserted.
108 * Sets the insertion tick, and update correspondent replacement data.
124 * Touch an entry to update its replacement data.
125 *
126 * @param replacement_data Replacement data to be touched.
127 */
128 void touch(const std::shared_ptr<ReplacementData>& replacement_data) const
129 override;
130
131 /**
132 * Reset replacement data. Used when an entry is inserted.
109 * Set RRPV according to the insertion policy used.
110 *
133 * Set RRPV according to the insertion policy used.
134 *
111 * @param blk Cache block to be reset.
135 * @param replacement_data Replacement data to be reset.
112 */
136 */
113 void reset(CacheBlk *blk) override;
137 void reset(const std::shared_ptr<ReplacementData>& replacement_data) const
138 override;
114
115 /**
116 * Find replacement victim using rrpv.
117 *
118 * @param cands Replacement candidates, selected by indexing policy.
139
140 /**
141 * Find replacement victim using rrpv.
142 *
143 * @param cands Replacement candidates, selected by indexing policy.
119 * @return Cache block to be replaced.
144 * @return Replacement entry to be replaced.
120 */
145 */
121 CacheBlk* getVictim(const ReplacementCandidates& candidates) override;
146 ReplaceableEntry* getVictim(const ReplacementCandidates& candidates) const
147 override;
148
149 /**
150 * Instantiate a replacement data entry.
151 *
152 * @return A shared pointer to the new replacement data.
153 */
154 std::shared_ptr<ReplacementData> instantiateEntry() override;
122};
123
124#endif // __MEM_CACHE_REPLACEMENT_POLICIES_BRRIP_RP_HH__
155};
156
157#endif // __MEM_CACHE_REPLACEMENT_POLICIES_BRRIP_RP_HH__