gem5  v22.1.0.0
dueling.hh
Go to the documentation of this file.
1 
29 #ifndef __BASE_DUELING_HH__
30 #define __BASE_DUELING_HH__
31 
32 #include <cstddef>
33 #include <cstdint>
34 
35 #include "base/sat_counter.hh"
36 
37 namespace gem5
38 {
39 
52 class Dueler
53 {
54  private:
61  uint64_t _isSample;
62 
67  uint64_t _team;
68 
69  public:
71  Dueler();
72  virtual ~Dueler() = default;
73 
80  void setSample(uint64_t id, bool team);
81 
90  bool isSample(uint64_t id, bool& team) const;
91 };
92 
108 {
109  private:
110  // There are always exactly two duelers. If this is changed the logic
111  // must be revisited
112  const int NUM_DUELERS = 2;
113 
121  const uint64_t id;
122 
128  const std::size_t constituencySize;
129 
131  const std::size_t teamSize;
132 
137  const double lowThreshold;
138 
143  const double highThreshold;
144 
150 
156 
158  bool winner;
159 
160  public:
165  static unsigned numInstances;
166 
167  DuelingMonitor(std::size_t constituency_size, std::size_t team_size = 1,
168  unsigned num_bits = 10, double low_threshold = 0.5,
169  double high_threshold = 0.5);
170  ~DuelingMonitor() = default;
171 
178  void sample(const Dueler* dueler);
179 
188  bool isSample(const Dueler* dueler, bool& team) const;
189 
195  bool getWinner() const;
196 
204  void initEntry(Dueler* dueler);
205 };
206 
207 } // namespace gem5
208 
209 #endif // __BASE_DUELING_HH__
A dueler is an entry that may or may not be accounted for sampling.
Definition: dueling.hh:53
virtual ~Dueler()=default
uint64_t _team
If entry is a sample, it belongs to one of two possible teams.
Definition: dueling.hh:67
void setSample(uint64_t id, bool team)
Make this entry a sampling entry for a specific Dueling instance.
Definition: dueling.cc:45
bool isSample(uint64_t id, bool &team) const
Check if entry is a sample for the given instance.
Definition: dueling.cc:57
uint64_t _isSample
Whether this entry is a sample or a follower.
Definition: dueling.hh:61
Dueler()
By default initializes entries as followers.
Definition: dueling.cc:39
Duel between two sampled options to determine which is the winner.
Definition: dueling.hh:108
const int NUM_DUELERS
Definition: dueling.hh:112
~DuelingMonitor()=default
const std::size_t constituencySize
Given a table containing X entries, a constituency is a region of the table such that it contains X/c...
Definition: dueling.hh:128
const uint64_t id
Unique identifier of this instance.
Definition: dueling.hh:121
int regionCounter
Counts the number of entries have been initialized in the current constituency.
Definition: dueling.hh:155
SatCounter32 selector
Counter that determines which dueler is winning.
Definition: dueling.hh:149
const std::size_t teamSize
Number of entries that belong to each team within a constituency.
Definition: dueling.hh:131
bool winner
The team that is currently winning.
Definition: dueling.hh:158
bool getWinner() const
Get the team that is currently winning the duel.
Definition: dueling.cc:118
bool isSample(const Dueler *dueler, bool &team) const
Check if the given dueler is a sample for this instance.
Definition: dueling.cc:112
void sample(const Dueler *dueler)
If given dueler is a sampling entry, sample it and check if the winning team must be updated.
Definition: dueling.cc:91
const double lowThreshold
If the winning team was "True", and the counter is decreased further than this threshold,...
Definition: dueling.hh:137
static unsigned numInstances
Number of times this class has been instantiated.
Definition: dueling.hh:165
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: dueling.cc:63
const double highThreshold
If the winning team was "False", and the counter is increased further than this threshold,...
Definition: dueling.hh:143
void initEntry(Dueler *dueler)
Initialize a dueler entry, deciding wether it is a sample or not.
Definition: dueling.cc:124
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....

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