cpu-o3: Make the smtCommitPolicy a Param.ScopedEnum
authorNikos Nikoleris <nikos.nikoleris@arm.com>
Thu, 3 Jan 2019 19:01:04 +0000 (19:01 +0000)
committerNikos Nikoleris <nikos.nikoleris@arm.com>
Thu, 17 Jan 2019 11:09:08 +0000 (11:09 +0000)
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 <nikos.nikoleris@arm.com>
Reviewed-by: Giacomo Travaglini <giacomo.travaglini@arm.com>
Reviewed-on: https://gem5-review.googlesource.com/c/15400
Reviewed-by: Jason Lowe-Power <jason@lowepower.com>
Maintainer: Jason Lowe-Power <jason@lowepower.com>

src/cpu/o3/O3CPU.py
src/cpu/o3/commit.hh
src/cpu/o3/commit_impl.hh

index e3704c0fab1be9604ccc59628bc2179fcca5f73f..32cc19010eebdf0b3a1929eb70cdf231388db73c 100644 (file)
@@ -54,6 +54,9 @@ class FetchPolicy(ScopedEnum):
 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 @@ class DerivO3CPU(BaseCPU):
     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),
index b74917da37bf5524734d90de7dc2ae23b8672f70..2d7a23e5d809b4dd494299cc7922f4495cb094d4 100644 (file)
@@ -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 @@ class DefaultCommit
         SquashAfterPending, //< Committing instructions before a squash.
     };
 
-    /** Commit policy for SMT mode. */
-    enum CommitPolicy {
-        Aggressive,
-        RoundRobin,
-        OldestReady
-    };
-
   private:
     /** Overall commit status. */
     CommitStatus _status;
index 40ce8480eabe8023cd17e05c87aae2bfe52daf61..879fad2922ab39dde30500cc9c851aaeab033330 100644 (file)
@@ -82,7 +82,8 @@ DefaultCommit<Impl>::processTrapEvent(ThreadID tid)
 
 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 @@ DefaultCommit<Impl>::DefaultCommit(O3CPU *_cpu, DerivO3CPUParams *params)
 
     _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 @@ DefaultCommit<Impl>::getCommittingThread()
     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: