cpus: fix cpu progress event
authorKorey Sewell <ksewell@umich.edu>
Tue, 5 May 2009 06:51:31 +0000 (02:51 -0400)
committerKorey Sewell <ksewell@umich.edu>
Tue, 5 May 2009 06:51:31 +0000 (02:51 -0400)
this was double scheduling itself (once in constructor and once in cpu code). also add support for stopping / starting
progress events through repeatEvent flag and also changing the interval of the progress event as well

configs/common/Options.py
configs/common/Simulation.py
src/cpu/base.cc
src/cpu/base.hh
src/cpu/inorder/cpu.hh

index e5d867cfa99b0073ee5d9f6d6d19a53185709392..0ddd2f06dd2bb4b2e8dc75134e0dc67a0c754260 100644 (file)
@@ -38,6 +38,8 @@ parser.add_option("--fastmem", action="store_true")
 # Run duration options
 parser.add_option("-m", "--maxtick", type="int")
 parser.add_option("--maxtime", type="float")
+parser.add_option("--prog_intvl", type="int")
+
 
 # Checkpointing options
 ###Note that performing checkpointing via python script files will override
index 0004e4fe632418ce8a65431dbf5bc415b554b856..d7dde241ccf8ab7796136a56d24a47161048ca5e 100644 (file)
@@ -91,6 +91,10 @@ def run(options, root, testsys, cpu_class):
     max_checkpoints = options.max_checkpoints
     switch_cpus = None
 
+    if options.prog_intvl:
+        for i in xrange(np):
+            testsys.cpu[i].progress_interval = options.prog_intvl
+
     if cpu_class:
         switch_cpus = [cpu_class(defer_registration=True, cpu_id=(np+i))
                        for i in xrange(np)]
index 0ef206d901a8766b85a14d030c2433976c6c2994..78ff4f998538650c723d004920f7167af70e66b3 100644 (file)
@@ -61,11 +61,11 @@ vector<BaseCPU *> BaseCPU::cpuList;
 int maxThreadsPerCPU = 1;
 
 CPUProgressEvent::CPUProgressEvent(BaseCPU *_cpu, Tick ival)
-    : Event(Event::Progress_Event_Pri), interval(ival), lastNumInst(0),
-      cpu(_cpu)
+    : Event(Event::Progress_Event_Pri), _interval(ival), lastNumInst(0),
+      cpu(_cpu), _repeatEvent(true)
 {
-    if (interval)
-        cpu->schedule(this, curTick + interval);
+    if (_interval)
+        cpu->schedule(this, curTick + _interval);
 }
 
 void
@@ -73,17 +73,21 @@ CPUProgressEvent::process()
 {
     Counter temp = cpu->totalInstructions();
 #ifndef NDEBUG
-    double ipc = double(temp - lastNumInst) / (interval / cpu->ticks(1));
+    double ipc = double(temp - lastNumInst) / (_interval / cpu->ticks(1));
 
-    DPRINTFN("%s progress event, instructions committed: %lli, IPC: %0.8d\n",
-             cpu->name(), temp - lastNumInst, ipc);
+    DPRINTFN("%s progress event, total committed:%i, progress insts committed: "
+             "%lli, IPC: %0.8d\n", cpu->name(), temp, temp - lastNumInst,
+             ipc);
     ipc = 0.0;
 #else
-    cprintf("%lli: %s progress event, instructions committed: %lli\n",
-            curTick, cpu->name(), temp - lastNumInst);
+    cprintf("%lli: %s progress event, total committed:%i, progress insts "
+            "committed: %lli\n", curTick, cpu->name(), temp,
+            temp - lastNumInst);
 #endif
     lastNumInst = temp;
-    cpu->schedule(this, curTick + interval);
+
+    if (_repeatEvent)
+        cpu->schedule(this, curTick + _interval);
 }
 
 const char *
@@ -230,8 +234,9 @@ BaseCPU::startup()
 
     if (params()->progress_interval) {
         Tick num_ticks = ticks(params()->progress_interval);
-        Event *event = new CPUProgressEvent(this, num_ticks);
-        schedule(event, curTick + num_ticks);
+
+        Event *event;
+        event = new CPUProgressEvent(this, num_ticks);
     }
 }
 
index 8af3295eb945848814a58aab2bcbf9d97078d47a..e63960cc1392597f7ad075618b4dc26b1e5b1e7b 100644 (file)
@@ -61,15 +61,21 @@ namespace TheISA
 class CPUProgressEvent : public Event
 {
   protected:
-    Tick interval;
+    Tick _interval;
     Counter lastNumInst;
     BaseCPU *cpu;
+    bool _repeatEvent;
 
   public:
-    CPUProgressEvent(BaseCPU *_cpu, Tick ival);
+    CPUProgressEvent(BaseCPU *_cpu, Tick ival = 0);
 
     void process();
 
+    void interval(Tick ival) { _interval = ival; }
+    Tick interval() { return _interval; }
+
+    void repeatEvent(bool repeat) { _repeatEvent = repeat; }
+
     virtual const char *description() const;
 };
 
index 0545f4bf8dbdaf411422b132d9aab38200907de8..744dd5cf900de08de4f249fb601cae149cc4876a 100644 (file)
@@ -589,6 +589,17 @@ class InOrderCPU : public BaseCPU
         return thread[tid]->getTC();
     }
 
+    /** Count the Total Instructions Committed in the CPU. */
+    virtual Counter totalInstructions() const
+    {
+        Counter total(0);
+
+        for (int i=0; i < thread.size(); i++)
+            total += thread[i]->numInst;
+
+        return total;
+    }
+
     /** The global sequence number counter. */
     InstSeqNum globalSeqNum[ThePipeline::MaxThreads];