gem5  v21.1.0.2
Public Member Functions | Static Public Attributes | Private Attributes | List of all members
gem5::DuelingMonitor Class Reference

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. More...
 
bool isSample (const Dueler *dueler, bool &team) const
 Check if the given dueler is a sample for this instance. More...
 
bool getWinner () const
 Get the team that is currently winning the duel. More...
 
void initEntry (Dueler *dueler)
 Initialize a dueler entry, deciding wether it is a sample or not. More...
 

Static Public Attributes

static unsigned numInstances = 0
 Number of times this class has been instantiated. More...
 

Private Attributes

const int NUM_DUELERS = 2
 
const uint64_t id
 Unique identifier of this instance. More...
 
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. More...
 
const std::size_t teamSize
 Number of entries that belong to each team within a constituency. More...
 
const double lowThreshold
 If the winning team was "True", and the counter is decreased further than this threshold, "False" will become the winning team. More...
 
const double highThreshold
 If the winning team was "False", and the counter is increased further than this threshold, "True" will become the winning team. More...
 
SatCounter32 selector
 Counter that determines which dueler is winning. More...
 
int regionCounter
 Counts the number of entries have been initialized in the current constituency. More...
 
bool winner
 The team that is currently winning. More...
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ DuelingMonitor()

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 
)

◆ ~DuelingMonitor()

gem5::DuelingMonitor::~DuelingMonitor ( )
default

Member Function Documentation

◆ getWinner()

bool gem5::DuelingMonitor::getWinner ( ) const

Get the team that is currently winning the duel.

Returns
Winning team.

Definition at line 118 of file dueling.cc.

References winner.

Referenced by gem5::replacement_policy::Dueling::getVictim().

◆ initEntry()

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.

Parameters
duelerThe 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().

◆ isSample()

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.

Parameters
duelerThe selected entry.
teamTeam to which this sampling entry belongs (only 2 possible).
Returns
Whether this is a sampling entry.

Definition at line 112 of file dueling.cc.

References gem5::Dueler::isSample().

Referenced by gem5::replacement_policy::Dueling::getVictim().

◆ sample()

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.

Parameters
duelerThe 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().

Member Data Documentation

◆ constituencySize

const std::size_t gem5::DuelingMonitor::constituencySize
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().

◆ highThreshold

const double gem5::DuelingMonitor::highThreshold
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().

◆ id

const uint64_t gem5::DuelingMonitor::id
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.

◆ lowThreshold

const double gem5::DuelingMonitor::lowThreshold
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().

◆ NUM_DUELERS

const int gem5::DuelingMonitor::NUM_DUELERS = 2
private

Definition at line 112 of file dueling.hh.

Referenced by DuelingMonitor().

◆ numInstances

unsigned gem5::DuelingMonitor::numInstances = 0
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().

◆ regionCounter

int gem5::DuelingMonitor::regionCounter
private

Counts the number of entries have been initialized in the current constituency.

Definition at line 155 of file dueling.hh.

Referenced by initEntry().

◆ selector

SatCounter32 gem5::DuelingMonitor::selector
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().

◆ teamSize

const std::size_t gem5::DuelingMonitor::teamSize
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().

◆ winner

bool gem5::DuelingMonitor::winner
private

The team that is currently winning.

Definition at line 158 of file dueling.hh.

Referenced by DuelingMonitor(), getWinner(), and sample().


The documentation for this class was generated from the following files:

Generated on Tue Sep 21 2021 12:27:30 for gem5 by doxygen 1.8.17