changeset 7e5c7412ac89 in /z/repo/m5
details: http://repo.m5sim.org/m5?cmd=changeset;node=7e5c7412ac89
description:
        cpus: fix cpu progress event
        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

diffstat:

5 files changed, 42 insertions(+), 14 deletions(-)
configs/common/Options.py    |    2 ++
configs/common/Simulation.py |    4 ++++
src/cpu/base.cc              |   29 +++++++++++++++++------------
src/cpu/base.hh              |   10 ++++++++--
src/cpu/inorder/cpu.hh       |   11 +++++++++++

diffs (133 lines):

diff -r 2bfd792b1cc0 -r 7e5c7412ac89 configs/common/Options.py
--- a/configs/common/Options.py Sun Apr 26 02:09:54 2009 -0700
+++ b/configs/common/Options.py Tue May 05 02:39:05 2009 -0400
@@ -38,6 +38,8 @@
 # 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
diff -r 2bfd792b1cc0 -r 7e5c7412ac89 configs/common/Simulation.py
--- a/configs/common/Simulation.py      Sun Apr 26 02:09:54 2009 -0700
+++ b/configs/common/Simulation.py      Tue May 05 02:39:05 2009 -0400
@@ -91,6 +91,10 @@
     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)]
diff -r 2bfd792b1cc0 -r 7e5c7412ac89 src/cpu/base.cc
--- a/src/cpu/base.cc   Sun Apr 26 02:09:54 2009 -0700
+++ b/src/cpu/base.cc   Tue May 05 02:39:05 2009 -0400
@@ -61,11 +61,11 @@
 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 @@
 {
     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 @@
 
     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);
     }
 }
 
diff -r 2bfd792b1cc0 -r 7e5c7412ac89 src/cpu/base.hh
--- a/src/cpu/base.hh   Sun Apr 26 02:09:54 2009 -0700
+++ b/src/cpu/base.hh   Tue May 05 02:39:05 2009 -0400
@@ -61,15 +61,21 @@
 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;
 };
 
diff -r 2bfd792b1cc0 -r 7e5c7412ac89 src/cpu/inorder/cpu.hh
--- a/src/cpu/inorder/cpu.hh    Sun Apr 26 02:09:54 2009 -0700
+++ b/src/cpu/inorder/cpu.hh    Tue May 05 02:39:05 2009 -0400
@@ -589,6 +589,17 @@
         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];
 
_______________________________________________
m5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/m5-dev

Reply via email to