cpu-o3: Make the smtIQPolicy a Param.ScopedEnum
authorNikos Nikoleris <nikos.nikoleris@arm.com>
Thu, 3 Jan 2019 17:54:09 +0000 (17:54 +0000)
committerNikos Nikoleris <nikos.nikoleris@arm.com>
Thu, 17 Jan 2019 11:09:08 +0000 (11:09 +0000)
The smtIQPolicy 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: Ieecf0a19427dd250b0d5ae3d531ab46a37326ae5
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/15398
Reviewed-by: Jason Lowe-Power <jason@lowepower.com>
Maintainer: Jason Lowe-Power <jason@lowepower.com>

src/cpu/o3/O3CPU.py
src/cpu/o3/inst_queue.hh
src/cpu/o3/inst_queue_impl.hh

index 02d56de9231b5cb415023fb1f101c9acc084c30f..5908260f53b075b957d71eb822c6304f090bec48 100644 (file)
@@ -157,7 +157,8 @@ class DerivO3CPU(BaseCPU):
     smtLSQPolicy    = Param.SMTQueuePolicy('Partitioned',
                                            "SMT LSQ Sharing Policy")
     smtLSQThreshold = Param.Int(100, "SMT LSQ Threshold Sharing Parameter")
-    smtIQPolicy    = Param.String('Partitioned', "SMT IQ Sharing Policy")
+    smtIQPolicy    = Param.SMTQueuePolicy('Partitioned',
+                                          "SMT IQ Sharing Policy")
     smtIQThreshold = Param.Int(100, "SMT IQ Threshold Sharing Parameter")
     smtROBPolicy   = Param.String('Partitioned', "SMT ROB Sharing Policy")
     smtROBThreshold = Param.Int(100, "SMT ROB Threshold Sharing Parameter")
index 37cc3a2bb740956a8b8ba73c60b459c60f926a10..d6bc654df95dffe38c9fa3d15b02d524e37b44a1 100644 (file)
@@ -55,6 +55,7 @@
 #include "cpu/inst_seq.hh"
 #include "cpu/op_class.hh"
 #include "cpu/timebuf.hh"
+#include "enums/SMTQueuePolicy.hh"
 #include "sim/eventq.hh"
 
 struct DerivO3CPUParams;
@@ -403,15 +404,8 @@ class InstructionQueue
     // Various parameters
     //////////////////////////////////////
 
-    /** IQ Resource Sharing Policy */
-    enum IQPolicy {
-        Dynamic,
-        Partitioned,
-        Threshold
-    };
-
     /** IQ sharing policy for SMT. */
-    IQPolicy iqPolicy;
+    SMTQueuePolicy iqPolicy;
 
     /** Number of Total Threads*/
     ThreadID numThreads;
index b34e6d98085a2df257784cacecd2a84908c4fe1a..a8895f8ffe84b84b9fab228ee57f00bd2e613589 100644 (file)
@@ -90,6 +90,7 @@ InstructionQueue<Impl>::InstructionQueue(O3CPU *cpu_ptr, IEW *iew_ptr,
     : cpu(cpu_ptr),
       iewStage(iew_ptr),
       fuPool(params->fuPool),
+      iqPolicy(params->smtIQPolicy),
       numEntries(params->numIQEntries),
       totalWidth(params->issueWidth),
       commitToIEWDelay(params->commitToIEWDelay)
@@ -120,24 +121,14 @@ InstructionQueue<Impl>::InstructionQueue(O3CPU *cpu_ptr, IEW *iew_ptr,
 
     resetState();
 
-    std::string policy = params->smtIQPolicy;
-
-    //Convert string to lowercase
-    std::transform(policy.begin(), policy.end(), policy.begin(),
-                   (int(*)(int)) tolower);
-
     //Figure out resource sharing policy
-    if (policy == "dynamic") {
-        iqPolicy = Dynamic;
-
+    if (iqPolicy == SMTQueuePolicy::Dynamic) {
         //Set Max Entries to Total ROB Capacity
         for (ThreadID tid = 0; tid < numThreads; tid++) {
             maxEntries[tid] = numEntries;
         }
 
-    } else if (policy == "partitioned") {
-        iqPolicy = Partitioned;
-
+    } else if (iqPolicy == SMTQueuePolicy::Partitioned) {
         //@todo:make work if part_amt doesnt divide evenly.
         int part_amt = numEntries / numThreads;
 
@@ -148,9 +139,7 @@ InstructionQueue<Impl>::InstructionQueue(O3CPU *cpu_ptr, IEW *iew_ptr,
 
         DPRINTF(IQ, "IQ sharing policy set to Partitioned:"
                 "%i entries per thread.\n",part_amt);
-    } else if (policy == "threshold") {
-        iqPolicy = Threshold;
-
+    } else if (iqPolicy == SMTQueuePolicy::Threshold) {
         double threshold =  (double)params->smtIQThreshold / 100;
 
         int thresholdIQ = (int)((double)threshold * numEntries);
@@ -162,9 +151,6 @@ InstructionQueue<Impl>::InstructionQueue(O3CPU *cpu_ptr, IEW *iew_ptr,
 
         DPRINTF(IQ, "IQ sharing policy set to Threshold:"
                 "%i entries per thread.\n",thresholdIQ);
-   } else {
-       panic("Invalid IQ sharing policy. Options are: Dynamic, "
-              "Partitioned, Threshold");
    }
     for (ThreadID tid = numThreads; tid < Impl::MaxThreads; tid++) {
         maxEntries[tid] = 0;
@@ -502,7 +488,7 @@ template <class Impl>
 int
 InstructionQueue<Impl>::entryAmount(ThreadID num_threads)
 {
-    if (iqPolicy == Partitioned) {
+    if (iqPolicy == SMTQueuePolicy::Partitioned) {
         return numEntries / num_threads;
     } else {
         return 0;
@@ -514,7 +500,7 @@ template <class Impl>
 void
 InstructionQueue<Impl>::resetEntries()
 {
-    if (iqPolicy != Dynamic || numThreads > 1) {
+    if (iqPolicy != SMTQueuePolicy::Dynamic || numThreads > 1) {
         int active_threads = activeThreads->size();
 
         list<ThreadID>::iterator threads = activeThreads->begin();
@@ -523,9 +509,10 @@ InstructionQueue<Impl>::resetEntries()
         while (threads != end) {
             ThreadID tid = *threads++;
 
-            if (iqPolicy == Partitioned) {
+            if (iqPolicy == SMTQueuePolicy::Partitioned) {
                 maxEntries[tid] = numEntries / active_threads;
-            } else if (iqPolicy == Threshold && active_threads == 1) {
+            } else if (iqPolicy == SMTQueuePolicy::Threshold &&
+                       active_threads == 1) {
                 maxEntries[tid] = numEntries;
             }
         }