Daniel Carvalho has submitted this change. ( https://gem5-review.googlesource.com/c/public/gem5/+/37095 )

Change subject: base,cpu,mem: Use templatized SatCounter
......................................................................

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 <[email protected]>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/37095
Tested-by: kokoro <[email protected]>
Reviewed-by: Jason Lowe-Power <[email protected]>
Maintainer: Jason Lowe-Power <[email protected]>
---
M src/base/filters/base.hh
M src/base/sat_counter.test.cc
M src/cpu/pred/2bit_local.cc
M src/cpu/pred/2bit_local.hh
M src/cpu/pred/bi_mode.cc
M src/cpu/pred/bi_mode.hh
M src/cpu/pred/tournament.cc
M src/cpu/pred/tournament.hh
M src/mem/cache/prefetch/indirect_memory.hh
M src/mem/cache/prefetch/irregular_stream_buffer.hh
M src/mem/cache/prefetch/signature_path.hh
M src/mem/cache/prefetch/spatio_temporal_memory_streaming.hh
M src/mem/cache/prefetch/stride.cc
M src/mem/cache/prefetch/stride.hh
M src/mem/cache/replacement_policies/brrip_rp.hh
15 files changed, 50 insertions(+), 50 deletions(-)

Approvals:
  Jason Lowe-Power: Looks good to me, approved; Looks good to me, approved
  kokoro: Regressions pass



diff --git a/src/base/filters/base.hh b/src/base/filters/base.hh
index 3f4fac9..583e035 100644
--- a/src/base/filters/base.hh
+++ b/src/base/filters/base.hh
@@ -47,7 +47,7 @@
     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 @@
      */
     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 4d400c0..19f792e 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 @@
 {
     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, MinimumValue)
 {
     const unsigned bits = 3;
-    SatCounter counter(bits);
+    SatCounter8 counter(bits);

     for (int i = 0; i < 2; i++) {
         counter--;
@@ -71,7 +71,7 @@
 {
     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 @@
 {
     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 @@
 {
     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, IntComparison)
 {
     const unsigned bits = 3;
-    SatCounter counter(bits);
+    SatCounter8 counter(bits);
     int value = 0;

     ASSERT_EQ(counter++, value++);
@@ -144,11 +144,11 @@
     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 @@
 {
     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 @@

     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 @@
     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 @@
     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 @@
 {
     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 @@
 {
     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 5e5e54f..2e3aef9 100644
--- a/src/cpu/pred/2bit_local.cc
+++ b/src/cpu/pred/2bit_local.cc
@@ -38,7 +38,7 @@
       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 60808ca..3dddd8c 100644
--- a/src/cpu/pred/2bit_local.hh
+++ b/src/cpu/pred/2bit_local.hh
@@ -116,7 +116,7 @@
     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;
diff --git a/src/cpu/pred/bi_mode.cc b/src/cpu/pred/bi_mode.cc
index de22e3f..37ba842 100644
--- a/src/cpu/pred/bi_mode.cc
+++ b/src/cpu/pred/bi_mode.cc
@@ -43,9 +43,9 @@
       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 69c698b..bf56d38 100644
--- a/src/cpu/pred/bi_mode.hh
+++ b/src/cpu/pred/bi_mode.hh
@@ -97,11 +97,11 @@
     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;
diff --git a/src/cpu/pred/tournament.cc b/src/cpu/pred/tournament.cc
index b50b6c7..5c50fdd 100644
--- a/src/cpu/pred/tournament.cc
+++ b/src/cpu/pred/tournament.cc
@@ -47,12 +47,12 @@
     : 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 @@
           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 c109358..9a1ce6c 100644
--- a/src/cpu/pred/tournament.hh
+++ b/src/cpu/pred/tournament.hh
@@ -180,7 +180,7 @@
     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 @@
     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 @@
     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.
diff --git a/src/mem/cache/prefetch/indirect_memory.hh b/src/mem/cache/prefetch/indirect_memory.hh
index a41f56a..2c8661d 100644
--- a/src/mem/cache/prefetch/indirect_memory.hh
+++ b/src/mem/cache/prefetch/indirect_memory.hh
@@ -85,7 +85,7 @@
         /** 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 ce040d1..2ef17e2 100644
--- a/src/mem/cache/prefetch/irregular_stream_buffer.hh
+++ b/src/mem/cache/prefetch/irregular_stream_buffer.hh
@@ -70,7 +70,7 @@
     /** 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 8d61a5c..c6667e3 100644
--- a/src/mem/cache/prefetch/signature_path.hh
+++ b/src/mem/cache/prefetch/signature_path.hh
@@ -87,7 +87,7 @@
         /** 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 @@
         /** 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)
diff --git a/src/mem/cache/prefetch/spatio_temporal_memory_streaming.hh b/src/mem/cache/prefetch/spatio_temporal_memory_streaming.hh
index 8e3b202..d63f2e2 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 @@
         /** 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 11ecd16..18366f7 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 982f33e..36fc194 100644
--- a/src/mem/cache/prefetch/stride.hh
+++ b/src/mem/cache/prefetch/stride.hh
@@ -91,7 +91,7 @@
 {
   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 @@
     /** 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;
diff --git a/src/mem/cache/replacement_policies/brrip_rp.hh b/src/mem/cache/replacement_policies/brrip_rp.hh
index a9ddfe4..4ed8ca5 100644
--- a/src/mem/cache/replacement_policies/brrip_rp.hh
+++ b/src/mem/cache/replacement_policies/brrip_rp.hh
@@ -72,7 +72,7 @@
          * max_RRPV-1 -> long re-rereference interval
          * max_RRPV -> distant re-rereference interval
          */
-        SatCounter rrpv;
+        SatCounter8 rrpv;

         /** Whether the entry is valid. */
         bool valid;

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/37095
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: Ie943c553dd8a8c24c80e737783708b033ce001da
Gerrit-Change-Number: 37095
Gerrit-PatchSet: 6
Gerrit-Owner: Daniel Carvalho <[email protected]>
Gerrit-Reviewer: Andreas Sandberg <[email protected]>
Gerrit-Reviewer: Bobby R. Bruce <[email protected]>
Gerrit-Reviewer: Ciro Santilli <[email protected]>
Gerrit-Reviewer: Daniel Carvalho <[email protected]>
Gerrit-Reviewer: Gabe Black <[email protected]>
Gerrit-Reviewer: Gabe Black <[email protected]>
Gerrit-Reviewer: Giacomo Travaglini <[email protected]>
Gerrit-Reviewer: Hoa Nguyen <[email protected]>
Gerrit-Reviewer: Jason Lowe-Power <[email protected]>
Gerrit-Reviewer: Jason Lowe-Power <[email protected]>
Gerrit-Reviewer: Matthew Poremba <[email protected]>
Gerrit-Reviewer: Nikos Nikoleris <[email protected]>
Gerrit-Reviewer: kokoro <[email protected]>
Gerrit-MessageType: merged
_______________________________________________
gem5-dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

Reply via email to