gem5 v24.0.0.0
|
Duel between two sampled options to determine which is the winner. More...
#include <dueling.hh>
Public Member Functions | |
DuelingMonitor (std::size_t constituency_size, std::size_t team_size=1, unsigned num_bits=10, double low_threshold=0.5, double high_threshold=0.5) | |
~DuelingMonitor ()=default | |
void | sample (const Dueler *dueler) |
If given dueler is a sampling entry, sample it and check if the winning team must be updated. | |
bool | isSample (const Dueler *dueler, bool &team) const |
Check if the given dueler is a sample for this instance. | |
bool | getWinner () const |
Get the team that is currently winning the duel. | |
void | initEntry (Dueler *dueler) |
Initialize a dueler entry, deciding wether it is a sample or not. | |
Static Public Attributes | |
static unsigned | numInstances = 0 |
Number of times this class has been instantiated. | |
Private Attributes | |
const int | NUM_DUELERS = 2 |
const uint64_t | id |
Unique identifier of this instance. | |
const std::size_t | constituencySize |
Given a table containing X entries, a constituency is a region of the table such that it contains X/constituencySize entries. | |
const std::size_t | teamSize |
Number of entries that belong to each team within a constituency. | |
const double | lowThreshold |
If the winning team was "True", and the counter is decreased further than this threshold, "False" will become the winning team. | |
const double | highThreshold |
If the winning team was "False", and the counter is increased further than this threshold, "True" will become the winning team. | |
SatCounter32 | selector |
Counter that determines which dueler is winning. | |
int | regionCounter |
Counts the number of entries have been initialized in the current constituency. | |
bool | winner |
The team that is currently winning. | |
Duel between two sampled options to determine which is the winner.
The duel happens when a sample is taken: the saturating counter is increased if the team is "True", or decreased if the team is "False". Whenever the counter passes the flipping threshold the winning team changes.
By default the threshold to change teams is the same on both ways, but this may introduce unwanted flickering, so the threshold can be split so that it takes longer to change the winning team again just after changing it.
Based on Set Dueling, proposed in "Adaptive Insertion Policies for High Performance Caching".
Definition at line 107 of file dueling.hh.
gem5::DuelingMonitor::DuelingMonitor | ( | std::size_t | constituency_size, |
std::size_t | team_size = 1, | ||
unsigned | num_bits = 10, | ||
double | low_threshold = 0.5, | ||
double | high_threshold = 0.5 ) |
Definition at line 63 of file dueling.cc.
References gem5::GenericSatCounter< T >::calcSaturation(), constituencySize, fatal_if, highThreshold, lowThreshold, NUM_DUELERS, numInstances, gem5::GenericSatCounter< T >::saturate(), selector, teamSize, and winner.
|
default |
bool gem5::DuelingMonitor::getWinner | ( | ) | const |
Get the team that is currently winning the duel.
Definition at line 118 of file dueling.cc.
References winner.
Referenced by gem5::replacement_policy::Dueling::getVictim().
void gem5::DuelingMonitor::initEntry | ( | Dueler * | dueler | ) |
Initialize a dueler entry, deciding wether it is a sample or not.
We opt for a complement approach, which dedicates the first entries of a constituency to a team, and the last entries to the other team.
dueler | The entry to be initialized. |
Definition at line 124 of file dueling.cc.
References constituencySize, regionCounter, gem5::Dueler::setSample(), and teamSize.
Referenced by gem5::replacement_policy::Dueling::instantiateEntry().
bool gem5::DuelingMonitor::isSample | ( | const Dueler * | dueler, |
bool & | team ) const |
Check if the given dueler is a sample for this instance.
If so, get its team.
dueler | The selected entry. |
team | Team to which this sampling entry belongs (only 2 possible). |
Definition at line 112 of file dueling.cc.
References gem5::Dueler::isSample().
Referenced by gem5::replacement_policy::Dueling::getVictim().
void gem5::DuelingMonitor::sample | ( | const Dueler * | dueler | ) |
If given dueler is a sampling entry, sample it and check if the winning team must be updated.
dueler | The selected entry. |
Definition at line 91 of file dueling.cc.
References gem5::GenericSatCounter< T >::calcSaturation(), highThreshold, gem5::Dueler::isSample(), lowThreshold, selector, and winner.
Referenced by gem5::replacement_policy::Dueling::reset(), and gem5::replacement_policy::Dueling::reset().
|
private |
Given a table containing X entries, a constituency is a region of the table such that it contains X/constituencySize entries.
Each constituency contains one sample of each dueler.
Definition at line 128 of file dueling.hh.
Referenced by DuelingMonitor(), and initEntry().
|
private |
If the winning team was "False", and the counter is increased further than this threshold, "True" will become the winning team.
Definition at line 143 of file dueling.hh.
Referenced by DuelingMonitor(), and sample().
|
private |
Unique identifier of this instance.
It is a one bit mask used to identify which Dueler refers to this duel. This is done so that an entry can be dueled by many different policies simultaneously, which may even be of different domains (e.g., an entry can duel for 2 replacement policies, and 2 compression methods at the same time).
Definition at line 121 of file dueling.hh.
|
private |
If the winning team was "True", and the counter is decreased further than this threshold, "False" will become the winning team.
Definition at line 137 of file dueling.hh.
Referenced by DuelingMonitor(), and sample().
|
private |
Definition at line 112 of file dueling.hh.
Referenced by DuelingMonitor().
|
static |
Number of times this class has been instantiated.
It is used to assign unique ids to each dueling monitor instance.
Definition at line 165 of file dueling.hh.
Referenced by DuelingMonitor().
|
private |
Counts the number of entries have been initialized in the current constituency.
Definition at line 155 of file dueling.hh.
Referenced by initEntry().
|
private |
Counter that determines which dueler is winning.
In the DIP paper they propose using a 10-11 bit saturating counter.
Definition at line 149 of file dueling.hh.
Referenced by DuelingMonitor(), and sample().
|
private |
Number of entries that belong to each team within a constituency.
Definition at line 131 of file dueling.hh.
Referenced by DuelingMonitor(), and initEntry().
|
private |
The team that is currently winning.
Definition at line 158 of file dueling.hh.
Referenced by DuelingMonitor(), getWinner(), and sample().