Hello Giacomo Travaglini,

I'd like you to do a code review. Please visit

    https://gem5-review.googlesource.com/c/public/gem5/+/15400

to review the following change.


Change subject: cpu-o3: Make the smtCommitPolicy a Param.ScopedEnum
......................................................................

cpu-o3: Make the smtCommitPolicy a Param.ScopedEnum

The smtCommitPolicy is a parameter in the o3 cpu that can have 3
different values. Previously this setting was done through a string
and a parser function would turn it into a c++ enum value. This
changeset turns the string into a python Param.ScopedEnum.

Change-Id: I3625f2c08a1ae0c3b0dce7a641c6ae1ce3fd79a5
Signed-off-by: Nikos Nikoleris <[email protected]>
Reviewed-by: Giacomo Travaglini <[email protected]>
---
M src/cpu/o3/O3CPU.py
M src/cpu/o3/commit.hh
M src/cpu/o3/commit_impl.hh
3 files changed, 11 insertions(+), 34 deletions(-)



diff --git a/src/cpu/o3/O3CPU.py b/src/cpu/o3/O3CPU.py
index e3704c0..32cc190 100644
--- a/src/cpu/o3/O3CPU.py
+++ b/src/cpu/o3/O3CPU.py
@@ -54,6 +54,9 @@
 class SMTQueuePolicy(ScopedEnum):
     vals = [ 'Dynamic', 'Partitioned', 'Threshold' ]

+class CommitPolicy(ScopedEnum):
+    vals = [ 'Aggressive', 'RoundRobin', 'OldestReady' ]
+
 class DerivO3CPU(BaseCPU):
     type = 'DerivO3CPU'
     cxx_header = 'cpu/o3/deriv.hh'
@@ -163,7 +166,7 @@
     smtROBPolicy   = Param.SMTQueuePolicy('Partitioned',
                                           "SMT ROB Sharing Policy")
     smtROBThreshold = Param.Int(100, "SMT ROB Threshold Sharing Parameter")
-    smtCommitPolicy = Param.String('RoundRobin', "SMT Commit Policy")
+    smtCommitPolicy = Param.CommitPolicy('RoundRobin', "SMT Commit Policy")

     branchPred = Param.BranchPredictor(TournamentBP(numThreads =
                                                        Parent.numThreads),
diff --git a/src/cpu/o3/commit.hh b/src/cpu/o3/commit.hh
index b74917d..2d7a23e 100644
--- a/src/cpu/o3/commit.hh
+++ b/src/cpu/o3/commit.hh
@@ -50,6 +50,7 @@
 #include "cpu/exetrace.hh"
 #include "cpu/inst_seq.hh"
 #include "cpu/timebuf.hh"
+#include "enums/CommitPolicy.hh"
 #include "sim/probe/probe.hh"

 struct DerivO3CPUParams;
@@ -119,13 +120,6 @@
         SquashAfterPending, //< Committing instructions before a squash.
     };

-    /** Commit policy for SMT mode. */
-    enum CommitPolicy {
-        Aggressive,
-        RoundRobin,
-        OldestReady
-    };
-
   private:
     /** Overall commit status. */
     CommitStatus _status;
diff --git a/src/cpu/o3/commit_impl.hh b/src/cpu/o3/commit_impl.hh
index 40ce848..879fad2 100644
--- a/src/cpu/o3/commit_impl.hh
+++ b/src/cpu/o3/commit_impl.hh
@@ -82,7 +82,8 @@

 template <class Impl>
 DefaultCommit<Impl>::DefaultCommit(O3CPU *_cpu, DerivO3CPUParams *params)
-    : cpu(_cpu),
+    : commitPolicy(params->smtCommitPolicy),
+      cpu(_cpu),
       iewToCommitDelay(params->iewToCommitDelay),
       commitToIEWDelay(params->commitToIEWDelay),
       renameToROBDelay(params->renameToROBDelay),
@@ -103,33 +104,12 @@

     _status = Active;
     _nextStatus = Inactive;
-    std::string policy = params->smtCommitPolicy;

-    //Convert string to lowercase
-    std::transform(policy.begin(), policy.end(), policy.begin(),
-                   (int(*)(int)) tolower);
-
-    //Assign commit policy
-    if (policy == "aggressive"){
-        commitPolicy = Aggressive;
-
-        DPRINTF(Commit,"Commit Policy set to Aggressive.\n");
-    } else if (policy == "roundrobin"){
-        commitPolicy = RoundRobin;
-
+    if (commitPolicy == CommitPolicy::RoundRobin) {
         //Set-Up Priority List
         for (ThreadID tid = 0; tid < numThreads; tid++) {
             priority_list.push_back(tid);
         }
-
-        DPRINTF(Commit,"Commit Policy set to Round Robin.\n");
-    } else if (policy == "oldestready"){
-        commitPolicy = OldestReady;
-
-        DPRINTF(Commit,"Commit Policy set to Oldest Ready.");
-    } else {
-        panic("Invalid SMT commit policy. Options are: Aggressive, "
-               "RoundRobin, OldestReady");
     }

     for (ThreadID tid = 0; tid < Impl::MaxThreads; tid++) {
@@ -1431,16 +1411,16 @@
     if (numThreads > 1) {
         switch (commitPolicy) {

-          case Aggressive:
+          case CommitPolicy::Aggressive:
             //If Policy is Aggressive, commit will call
             //this function multiple times per
             //cycle
             return oldestReady();

-          case RoundRobin:
+          case CommitPolicy::RoundRobin:
             return roundRobin();

-          case OldestReady:
+          case CommitPolicy::OldestReady:
             return oldestReady();

           default:

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

Gerrit-Project: public/gem5
Gerrit-Branch: master
Gerrit-Change-Id: I3625f2c08a1ae0c3b0dce7a641c6ae1ce3fd79a5
Gerrit-Change-Number: 15400
Gerrit-PatchSet: 1
Gerrit-Owner: Nikos Nikoleris <[email protected]>
Gerrit-Reviewer: Giacomo Travaglini <[email protected]>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to