From 833a60a7aaddcf0f5264c6894bdd882c6d96371b Mon Sep 17 00:00:00 2001 From: "Daniel R. Carvalho" Date: Mon, 12 Aug 2019 09:59:07 +0200 Subject: [PATCH] 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 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/37095 Tested-by: kokoro Reviewed-by: Jason Lowe-Power Maintainer: Jason Lowe-Power --- src/base/filters/base.hh | 4 +- src/base/sat_counter.test.cc | 48 +++++++++---------- src/cpu/pred/2bit_local.cc | 2 +- src/cpu/pred/2bit_local.hh | 2 +- src/cpu/pred/bi_mode.cc | 6 +-- src/cpu/pred/bi_mode.hh | 6 +-- src/cpu/pred/tournament.cc | 6 +-- src/cpu/pred/tournament.hh | 6 +-- src/mem/cache/prefetch/indirect_memory.hh | 2 +- .../cache/prefetch/irregular_stream_buffer.hh | 2 +- src/mem/cache/prefetch/signature_path.hh | 4 +- .../spatio_temporal_memory_streaming.hh | 2 +- src/mem/cache/prefetch/stride.cc | 2 +- src/mem/cache/prefetch/stride.hh | 6 +-- .../cache/replacement_policies/brrip_rp.hh | 2 +- 15 files changed, 50 insertions(+), 50 deletions(-) diff --git a/src/base/filters/base.hh b/src/base/filters/base.hh index 3f4fac9ba..583e03533 100644 --- a/src/base/filters/base.hh +++ b/src/base/filters/base.hh @@ -47,7 +47,7 @@ class Base : public SimObject const unsigned offsetBits; /** The filter itself. */ - std::vector filter; + std::vector 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(); diff --git a/src/base/sat_counter.test.cc b/src/base/sat_counter.test.cc index 4d400c0f7..19f792eaf 100644 --- a/src/base/sat_counter.test.cc +++ b/src/base/sat_counter.test.cc @@ -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 diff --git a/src/cpu/pred/2bit_local.cc b/src/cpu/pred/2bit_local.cc index 5e5e54fbc..2e3aef9b6 100644 --- a/src/cpu/pred/2bit_local.cc +++ b/src/cpu/pred/2bit_local.cc @@ -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)) { diff --git a/src/cpu/pred/2bit_local.hh b/src/cpu/pred/2bit_local.hh index 60808ca95..3dddd8ce1 100644 --- a/src/cpu/pred/2bit_local.hh +++ b/src/cpu/pred/2bit_local.hh @@ -116,7 +116,7 @@ class LocalBP : public BPredUnit const unsigned localPredictorSets; /** Array of counters that make up the local predictor. */ - std::vector localCtrs; + std::vector localCtrs; /** Mask to get index bits. */ const unsigned indexMask; diff --git a/src/cpu/pred/bi_mode.cc b/src/cpu/pred/bi_mode.cc index de22e3f8b..37ba84260 100644 --- a/src/cpu/pred/bi_mode.cc +++ b/src/cpu/pred/bi_mode.cc @@ -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"); diff --git a/src/cpu/pred/bi_mode.hh b/src/cpu/pred/bi_mode.hh index 69c698bb6..bf56d3875 100644 --- a/src/cpu/pred/bi_mode.hh +++ b/src/cpu/pred/bi_mode.hh @@ -97,11 +97,11 @@ class BiModeBP : public BPredUnit unsigned globalHistoryMask; // choice predictors - std::vector choiceCounters; + std::vector choiceCounters; // taken direction predictors - std::vector takenCounters; + std::vector takenCounters; // not-taken direction predictors - std::vector notTakenCounters; + std::vector notTakenCounters; unsigned choiceThreshold; unsigned takenThreshold; diff --git a/src/cpu/pred/tournament.cc b/src/cpu/pred/tournament.cc index b50b6c79e..5c50fddb2 100644 --- a/src/cpu/pred/tournament.cc +++ b/src/cpu/pred/tournament.cc @@ -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"); diff --git a/src/cpu/pred/tournament.hh b/src/cpu/pred/tournament.hh index c109358d4..9a1ce6c31 100644 --- a/src/cpu/pred/tournament.hh +++ b/src/cpu/pred/tournament.hh @@ -180,7 +180,7 @@ class TournamentBP : public BPredUnit unsigned localCtrBits; /** Local counters. */ - std::vector localCtrs; + std::vector localCtrs; /** Array of local history table entries. */ std::vector localHistoryTable; @@ -198,7 +198,7 @@ class TournamentBP : public BPredUnit unsigned globalCtrBits; /** Array of counters that make up the global predictor. */ - std::vector globalCtrs; + std::vector 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 choiceCtrs; + std::vector choiceCtrs; /** Thresholds for the counter value; above the threshold is taken, * equal to or below the threshold is not taken. diff --git a/src/mem/cache/prefetch/indirect_memory.hh b/src/mem/cache/prefetch/indirect_memory.hh index a41f56acb..2c8661db7 100644 --- a/src/mem/cache/prefetch/indirect_memory.hh +++ b/src/mem/cache/prefetch/indirect_memory.hh @@ -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 diff --git a/src/mem/cache/prefetch/irregular_stream_buffer.hh b/src/mem/cache/prefetch/irregular_stream_buffer.hh index ce040d1e5..2ef17e2a2 100644 --- a/src/mem/cache/prefetch/irregular_stream_buffer.hh +++ b/src/mem/cache/prefetch/irregular_stream_buffer.hh @@ -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) {} }; diff --git a/src/mem/cache/prefetch/signature_path.hh b/src/mem/cache/prefetch/signature_path.hh index 8d61a5c49..c6667e3ca 100644 --- a/src/mem/cache/prefetch/signature_path.hh +++ b/src/mem/cache/prefetch/signature_path.hh @@ -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 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) diff --git a/src/mem/cache/prefetch/spatio_temporal_memory_streaming.hh b/src/mem/cache/prefetch/spatio_temporal_memory_streaming.hh index 8e3b202f4..d63f2e296 100644 --- a/src/mem/cache/prefetch/spatio_temporal_memory_streaming.hh +++ b/src/mem/cache/prefetch/spatio_temporal_memory_streaming.hh @@ -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 */ diff --git a/src/mem/cache/prefetch/stride.cc b/src/mem/cache/prefetch/stride.cc index 11ecd16c4..18366f7bd 100644 --- a/src/mem/cache/prefetch/stride.cc +++ b/src/mem/cache/prefetch/stride.cc @@ -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(); diff --git a/src/mem/cache/prefetch/stride.hh b/src/mem/cache/prefetch/stride.hh index 982f33e5e..36fc1943d 100644 --- a/src/mem/cache/prefetch/stride.hh +++ b/src/mem/cache/prefetch/stride.hh @@ -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 PCTable; std::unordered_map pcTables; diff --git a/src/mem/cache/replacement_policies/brrip_rp.hh b/src/mem/cache/replacement_policies/brrip_rp.hh index a9ddfe45c..4ed8ca510 100644 --- a/src/mem/cache/replacement_policies/brrip_rp.hh +++ b/src/mem/cache/replacement_policies/brrip_rp.hh @@ -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; -- 2.30.2