base,cpu,mem: Use templatized SatCounter
Change the deprecated SatCounter instances to the new type-size- aware SatCounters. Jira: https://gem5.atlassian.net/browse/GEM5-813 Change-Id: Ie943c553dd8a8c24c80e737783708b033ce001da Signed-off-by: Daniel R. Carvalho <odanrc@yahoo.com.br> Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/37095 Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Jason Lowe-Power <power.jg@gmail.com> Maintainer: Jason Lowe-Power <power.jg@gmail.com>
This commit is contained in:
committed by
Daniel Carvalho
parent
37add2103c
commit
833a60a7aa
@@ -47,7 +47,7 @@ class Base : public SimObject
|
||||
const unsigned offsetBits;
|
||||
|
||||
/** The filter itself. */
|
||||
std::vector<SatCounter> filter;
|
||||
std::vector<SatCounter8> filter;
|
||||
|
||||
/** Number of bits needed to represent the size of the filter. */
|
||||
const int sizeBits;
|
||||
@@ -61,7 +61,7 @@ class Base : public SimObject
|
||||
*/
|
||||
Base(const BloomFilterBaseParams &p)
|
||||
: SimObject(p), offsetBits(p.offset_bits),
|
||||
filter(p.size, SatCounter(p.num_bits)),
|
||||
filter(p.size, SatCounter8(p.num_bits)),
|
||||
sizeBits(floorLog2(p.size)), setThreshold(p.threshold)
|
||||
{
|
||||
clear();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2019 Inria
|
||||
* Copyright (c) 2019, 2020 Inria
|
||||
* All rights reserved
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -40,7 +40,7 @@ TEST(SatCounterTest, MaximumValue)
|
||||
{
|
||||
const unsigned bits = 3;
|
||||
const unsigned max_value = (1 << bits) - 1;
|
||||
SatCounter counter(bits);
|
||||
SatCounter8 counter(bits);
|
||||
|
||||
for (int i = 0; i < 2*max_value; i++) {
|
||||
counter++;
|
||||
@@ -55,7 +55,7 @@ TEST(SatCounterTest, MaximumValue)
|
||||
TEST(SatCounterTest, MinimumValue)
|
||||
{
|
||||
const unsigned bits = 3;
|
||||
SatCounter counter(bits);
|
||||
SatCounter8 counter(bits);
|
||||
|
||||
for (int i = 0; i < 2; i++) {
|
||||
counter--;
|
||||
@@ -71,7 +71,7 @@ TEST(SatCounterTest, InitialValue)
|
||||
{
|
||||
const unsigned bits = 3;
|
||||
const unsigned initial_value = 4;
|
||||
SatCounter counter(bits, initial_value);
|
||||
SatCounter8 counter(bits, initial_value);
|
||||
ASSERT_EQ(counter, initial_value);
|
||||
counter++;
|
||||
counter.reset();
|
||||
@@ -85,7 +85,7 @@ TEST(SatCounterTest, SaturationPercentile)
|
||||
{
|
||||
const unsigned bits = 3;
|
||||
const unsigned max_value = (1 << bits) - 1;
|
||||
SatCounter counter(bits);
|
||||
SatCounter8 counter(bits);
|
||||
|
||||
ASSERT_FALSE(counter.isSaturated());
|
||||
for (double value = 0.0; value <= max_value; value++, counter++) {
|
||||
@@ -102,7 +102,7 @@ TEST(SatCounterTest, Saturate)
|
||||
{
|
||||
const unsigned bits = 3;
|
||||
const unsigned max_value = (1 << bits) - 1;
|
||||
SatCounter counter(bits);
|
||||
SatCounter8 counter(bits);
|
||||
counter++;
|
||||
ASSERT_FALSE(counter.isSaturated());
|
||||
|
||||
@@ -118,7 +118,7 @@ TEST(SatCounterTest, Saturate)
|
||||
TEST(SatCounterTest, IntComparison)
|
||||
{
|
||||
const unsigned bits = 3;
|
||||
SatCounter counter(bits);
|
||||
SatCounter8 counter(bits);
|
||||
int value = 0;
|
||||
|
||||
ASSERT_EQ(counter++, value++);
|
||||
@@ -144,11 +144,11 @@ TEST(SatCounterTest, Shift)
|
||||
const unsigned bits = 3;
|
||||
const unsigned max_value = (1 << bits) - 1;
|
||||
const unsigned initial_value = 1;
|
||||
SatCounter counter(bits, initial_value);
|
||||
SatCounter other(bits, initial_value);
|
||||
SatCounter8 counter(bits, initial_value);
|
||||
SatCounter8 other(bits, initial_value);
|
||||
// The saturated shift value is just enough to saturate, since greater
|
||||
// values could generate undefined behavior
|
||||
SatCounter saturated_counter(bits, bits);
|
||||
SatCounter8 saturated_counter(bits, bits);
|
||||
int value = initial_value;
|
||||
|
||||
// Test random shifts
|
||||
@@ -201,12 +201,12 @@ TEST(SatCounterTest, PrePostOperators)
|
||||
{
|
||||
const unsigned bits = 3;
|
||||
const unsigned max_value = (1 << bits) - 1;
|
||||
SatCounter counter_pre(bits);
|
||||
SatCounter counter_post(bits);
|
||||
SatCounter8 counter_pre(bits);
|
||||
SatCounter8 counter_post(bits);
|
||||
|
||||
for (int i = 0; i < 2*max_value; i++) {
|
||||
counter_post++;
|
||||
SatCounter value_pre = ++counter_pre;
|
||||
SatCounter8 value_pre = ++counter_pre;
|
||||
ASSERT_EQ(counter_post, value_pre);
|
||||
}
|
||||
|
||||
@@ -215,7 +215,7 @@ TEST(SatCounterTest, PrePostOperators)
|
||||
|
||||
for (int i = 0; i < 2*max_value; i++) {
|
||||
counter_post--;
|
||||
SatCounter value_pre = --counter_pre;
|
||||
SatCounter8 value_pre = --counter_pre;
|
||||
ASSERT_EQ(counter_post, value_pre);
|
||||
}
|
||||
|
||||
@@ -231,16 +231,16 @@ TEST(SatCounterTest, CopyMove)
|
||||
const unsigned bits = 3;
|
||||
const unsigned max_value = (1 << bits) - 1;
|
||||
const unsigned initial_value = 1;
|
||||
SatCounter counter(bits, initial_value);
|
||||
SatCounter deep_copy(1);
|
||||
SatCounter counter_copy(2);
|
||||
SatCounter8 counter(bits, initial_value);
|
||||
SatCounter8 deep_copy(1);
|
||||
SatCounter8 counter_copy(2);
|
||||
|
||||
// Increase counter value so that we can check if the inner counter is
|
||||
// being copied
|
||||
counter++;
|
||||
|
||||
// Copy counter using both the copy constructor and the copy assignment
|
||||
SatCounter counter_copy_constructor(counter);
|
||||
SatCounter8 counter_copy_constructor(counter);
|
||||
deep_copy = counter_copy = counter;
|
||||
ASSERT_EQ(counter_copy_constructor, initial_value + 1);
|
||||
ASSERT_EQ(counter_copy, initial_value + 1);
|
||||
@@ -267,11 +267,11 @@ TEST(SatCounterTest, CopyMove)
|
||||
ASSERT_EQ(deep_copy, initial_value);
|
||||
|
||||
// Now check move
|
||||
SatCounter counter_move_constructor(std::move(counter));
|
||||
SatCounter8 counter_move_constructor(std::move(counter));
|
||||
ASSERT_EQ(counter, 0);
|
||||
ASSERT_EQ(counter_move_constructor, initial_value + 1);
|
||||
|
||||
SatCounter counter_move(bits);
|
||||
SatCounter8 counter_move(bits);
|
||||
counter_move = std::move(counter_move_constructor);
|
||||
ASSERT_EQ(counter_move_constructor, 0);
|
||||
ASSERT_EQ(counter_move, initial_value + 1);
|
||||
@@ -284,9 +284,9 @@ TEST(SatCounterTest, AddSubAssignment)
|
||||
{
|
||||
const unsigned bits = 3;
|
||||
const unsigned max_value = (1 << bits) - 1;
|
||||
SatCounter counter(bits);
|
||||
SatCounter other(bits, 2);
|
||||
SatCounter saturated_counter(bits, max_value);
|
||||
SatCounter8 counter(bits);
|
||||
SatCounter8 other(bits, 2);
|
||||
SatCounter8 saturated_counter(bits, max_value);
|
||||
int value = 0;
|
||||
|
||||
// Test add-assignment for a few random values and then saturate
|
||||
@@ -334,7 +334,7 @@ TEST(SatCounterTest, NegativeAddSubAssignment)
|
||||
{
|
||||
const unsigned bits = 3;
|
||||
const unsigned max_value = (1 << bits) - 1;
|
||||
SatCounter counter(bits, max_value);
|
||||
SatCounter8 counter(bits, max_value);
|
||||
int value = max_value;
|
||||
|
||||
// Test add-assignment for a few negative values until zero is reached
|
||||
|
||||
@@ -38,7 +38,7 @@ LocalBP::LocalBP(const LocalBPParams ¶ms)
|
||||
localPredictorSize(params.localPredictorSize),
|
||||
localCtrBits(params.localCtrBits),
|
||||
localPredictorSets(localPredictorSize / localCtrBits),
|
||||
localCtrs(localPredictorSets, SatCounter(localCtrBits)),
|
||||
localCtrs(localPredictorSets, SatCounter8(localCtrBits)),
|
||||
indexMask(localPredictorSets - 1)
|
||||
{
|
||||
if (!isPowerOf2(localPredictorSize)) {
|
||||
|
||||
@@ -116,7 +116,7 @@ class LocalBP : public BPredUnit
|
||||
const unsigned localPredictorSets;
|
||||
|
||||
/** Array of counters that make up the local predictor. */
|
||||
std::vector<SatCounter> localCtrs;
|
||||
std::vector<SatCounter8> localCtrs;
|
||||
|
||||
/** Mask to get index bits. */
|
||||
const unsigned indexMask;
|
||||
|
||||
@@ -43,9 +43,9 @@ BiModeBP::BiModeBP(const BiModeBPParams ¶ms)
|
||||
choiceCtrBits(params.choiceCtrBits),
|
||||
globalPredictorSize(params.globalPredictorSize),
|
||||
globalCtrBits(params.globalCtrBits),
|
||||
choiceCounters(choicePredictorSize, SatCounter(choiceCtrBits)),
|
||||
takenCounters(globalPredictorSize, SatCounter(globalCtrBits)),
|
||||
notTakenCounters(globalPredictorSize, SatCounter(globalCtrBits))
|
||||
choiceCounters(choicePredictorSize, SatCounter8(choiceCtrBits)),
|
||||
takenCounters(globalPredictorSize, SatCounter8(globalCtrBits)),
|
||||
notTakenCounters(globalPredictorSize, SatCounter8(globalCtrBits))
|
||||
{
|
||||
if (!isPowerOf2(choicePredictorSize))
|
||||
fatal("Invalid choice predictor size.\n");
|
||||
|
||||
@@ -97,11 +97,11 @@ class BiModeBP : public BPredUnit
|
||||
unsigned globalHistoryMask;
|
||||
|
||||
// choice predictors
|
||||
std::vector<SatCounter> choiceCounters;
|
||||
std::vector<SatCounter8> choiceCounters;
|
||||
// taken direction predictors
|
||||
std::vector<SatCounter> takenCounters;
|
||||
std::vector<SatCounter8> takenCounters;
|
||||
// not-taken direction predictors
|
||||
std::vector<SatCounter> notTakenCounters;
|
||||
std::vector<SatCounter8> notTakenCounters;
|
||||
|
||||
unsigned choiceThreshold;
|
||||
unsigned takenThreshold;
|
||||
|
||||
@@ -47,12 +47,12 @@ TournamentBP::TournamentBP(const TournamentBPParams ¶ms)
|
||||
: BPredUnit(params),
|
||||
localPredictorSize(params.localPredictorSize),
|
||||
localCtrBits(params.localCtrBits),
|
||||
localCtrs(localPredictorSize, SatCounter(localCtrBits)),
|
||||
localCtrs(localPredictorSize, SatCounter8(localCtrBits)),
|
||||
localHistoryTableSize(params.localHistoryTableSize),
|
||||
localHistoryBits(ceilLog2(params.localPredictorSize)),
|
||||
globalPredictorSize(params.globalPredictorSize),
|
||||
globalCtrBits(params.globalCtrBits),
|
||||
globalCtrs(globalPredictorSize, SatCounter(globalCtrBits)),
|
||||
globalCtrs(globalPredictorSize, SatCounter8(globalCtrBits)),
|
||||
globalHistory(params.numThreads, 0),
|
||||
globalHistoryBits(
|
||||
ceilLog2(params.globalPredictorSize) >
|
||||
@@ -61,7 +61,7 @@ TournamentBP::TournamentBP(const TournamentBPParams ¶ms)
|
||||
ceilLog2(params.choicePredictorSize)),
|
||||
choicePredictorSize(params.choicePredictorSize),
|
||||
choiceCtrBits(params.choiceCtrBits),
|
||||
choiceCtrs(choicePredictorSize, SatCounter(choiceCtrBits))
|
||||
choiceCtrs(choicePredictorSize, SatCounter8(choiceCtrBits))
|
||||
{
|
||||
if (!isPowerOf2(localPredictorSize)) {
|
||||
fatal("Invalid local predictor size!\n");
|
||||
|
||||
@@ -180,7 +180,7 @@ class TournamentBP : public BPredUnit
|
||||
unsigned localCtrBits;
|
||||
|
||||
/** Local counters. */
|
||||
std::vector<SatCounter> localCtrs;
|
||||
std::vector<SatCounter8> localCtrs;
|
||||
|
||||
/** Array of local history table entries. */
|
||||
std::vector<unsigned> localHistoryTable;
|
||||
@@ -198,7 +198,7 @@ class TournamentBP : public BPredUnit
|
||||
unsigned globalCtrBits;
|
||||
|
||||
/** Array of counters that make up the global predictor. */
|
||||
std::vector<SatCounter> globalCtrs;
|
||||
std::vector<SatCounter8> globalCtrs;
|
||||
|
||||
/** Global history register. Contains as much history as specified by
|
||||
* globalHistoryBits. Actual number of bits used is determined by
|
||||
@@ -228,7 +228,7 @@ class TournamentBP : public BPredUnit
|
||||
unsigned choiceCtrBits;
|
||||
|
||||
/** Array of counters that make up the choice predictor. */
|
||||
std::vector<SatCounter> choiceCtrs;
|
||||
std::vector<SatCounter8> choiceCtrs;
|
||||
|
||||
/** Thresholds for the counter value; above the threshold is taken,
|
||||
* equal to or below the threshold is not taken.
|
||||
|
||||
2
src/mem/cache/prefetch/indirect_memory.hh
vendored
2
src/mem/cache/prefetch/indirect_memory.hh
vendored
@@ -85,7 +85,7 @@ class IndirectMemory : public Queued
|
||||
/** Shift detected */
|
||||
int shift;
|
||||
/** Confidence counter of the indirect fields */
|
||||
SatCounter indirectCounter;
|
||||
SatCounter8 indirectCounter;
|
||||
/**
|
||||
* This variable is set to indicate that there has been at least one
|
||||
* match with the current index value. This information is later used
|
||||
|
||||
@@ -70,7 +70,7 @@ class IrregularStreamBuffer : public Queued
|
||||
/** Address Mapping entry, holds an address and a confidence counter */
|
||||
struct AddressMapping {
|
||||
Addr address;
|
||||
SatCounter counter;
|
||||
SatCounter8 counter;
|
||||
AddressMapping(unsigned bits) : address(0), counter(bits)
|
||||
{}
|
||||
};
|
||||
|
||||
4
src/mem/cache/prefetch/signature_path.hh
vendored
4
src/mem/cache/prefetch/signature_path.hh
vendored
@@ -87,7 +87,7 @@ class SignaturePath : public Queued
|
||||
/** stride in a page in blkSize increments */
|
||||
stride_t stride;
|
||||
/** Saturating counter */
|
||||
SatCounter counter;
|
||||
SatCounter8 counter;
|
||||
PatternStrideEntry(unsigned bits) : stride(0), counter(bits)
|
||||
{}
|
||||
};
|
||||
@@ -97,7 +97,7 @@ class SignaturePath : public Queued
|
||||
/** group of stides */
|
||||
std::vector<PatternStrideEntry> strideEntries;
|
||||
/** use counter, used by SPPv2 */
|
||||
SatCounter counter;
|
||||
SatCounter8 counter;
|
||||
PatternEntry(size_t num_strides, unsigned counter_bits)
|
||||
: TaggedEntry(), strideEntries(num_strides, counter_bits),
|
||||
counter(counter_bits)
|
||||
|
||||
@@ -76,7 +76,7 @@ class STeMS : public Queued
|
||||
/** Sequence entry data type */
|
||||
struct SequenceEntry {
|
||||
/** 2-bit confidence counter */
|
||||
SatCounter counter;
|
||||
SatCounter8 counter;
|
||||
/** Offset, in cache lines, within the spatial region */
|
||||
unsigned int offset;
|
||||
/** Intearleaving position on the global access sequence */
|
||||
|
||||
2
src/mem/cache/prefetch/stride.cc
vendored
2
src/mem/cache/prefetch/stride.cc
vendored
@@ -59,7 +59,7 @@
|
||||
|
||||
namespace Prefetcher {
|
||||
|
||||
Stride::StrideEntry::StrideEntry(const SatCounter& init_confidence)
|
||||
Stride::StrideEntry::StrideEntry(const SatCounter8& init_confidence)
|
||||
: TaggedEntry(), confidence(init_confidence)
|
||||
{
|
||||
invalidate();
|
||||
|
||||
6
src/mem/cache/prefetch/stride.hh
vendored
6
src/mem/cache/prefetch/stride.hh
vendored
@@ -91,7 +91,7 @@ class Stride : public Queued
|
||||
{
|
||||
protected:
|
||||
/** Initial confidence counter value for the pc tables. */
|
||||
const SatCounter initConfidence;
|
||||
const SatCounter8 initConfidence;
|
||||
|
||||
/** Confidence threshold for prefetch generation. */
|
||||
const double threshConf;
|
||||
@@ -124,13 +124,13 @@ class Stride : public Queued
|
||||
/** Tagged by hashed PCs. */
|
||||
struct StrideEntry : public TaggedEntry
|
||||
{
|
||||
StrideEntry(const SatCounter& init_confidence);
|
||||
StrideEntry(const SatCounter8& init_confidence);
|
||||
|
||||
void invalidate() override;
|
||||
|
||||
Addr lastAddr;
|
||||
int stride;
|
||||
SatCounter confidence;
|
||||
SatCounter8 confidence;
|
||||
};
|
||||
typedef AssociativeSet<StrideEntry> PCTable;
|
||||
std::unordered_map<int, PCTable> pcTables;
|
||||
|
||||
@@ -72,7 +72,7 @@ class BRRIP : public Base
|
||||
* max_RRPV-1 -> long re-rereference interval
|
||||
* max_RRPV -> distant re-rereference interval
|
||||
*/
|
||||
SatCounter rrpv;
|
||||
SatCounter8 rrpv;
|
||||
|
||||
/** Whether the entry is valid. */
|
||||
bool valid;
|
||||
|
||||
Reference in New Issue
Block a user