The CPU Progress Interval was not working because it would schedule an
event at construction time, then try to reschedule itself right after
that in the BaseCPU startup() function.

Thus, doing this causes an error from the double scheduling:
event = new CPUProgressEvent(this, numTicks)
schedule(event, curtTick + numTicks)

So I fixed that issue here and also added the ability for this event
to be managed at run-time (i.e. I want to trigger this event not
always at the very start of simulation).

Lastly, I added an command line option for this in se.py since this is
typically something you want to use to help debug or ensure forward
progress of your simulation but the granularity is a bit trial/error.

Before I would commit, I would take out the debug line: "
cprintf("Setting num_ticks to %i.\n", num_ticks);" but that's the only
thing I see that needs a slight tweak.

If you have any comments on this, let me know.

On Wed, Apr 29, 2009 at 2:38 PM, Korey Sewell <ksew...@eecs.umich.edu> wrote:
> # HG changeset patch
> # User Korey Sewell <ksew...@umich.edu>
> # Date 1241030260 14400
> # Node ID 1e06d3c4aa338ee6c97b1ffc9626ca32991b98fe
> # Parent  2bfd792b1cc059cc58531c43c9ecf0bbcbad9f12
> [mq]: fix_cpu_progr_intvl
>
> diff --git a/configs/common/Options.py b/configs/common/Options.py
> --- a/configs/common/Options.py
> +++ b/configs/common/Options.py
> @@ -38,6 +38,8 @@ parser.add_option("--fastmem", action="s
>  # 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 --git a/configs/example/se.py b/configs/example/se.py
> --- a/configs/example/se.py
> +++ b/configs/example/se.py
> @@ -125,6 +125,9 @@ if options.detailed:
>
>  CPUClass.clock = '2GHz'
>
> +if options.prog_intvl:
> +    CPUClass.progress_interval = options.prog_intvl
> +
>  np = options.num_cpus
>
>  system = System(cpu = [CPUClass(cpu_id=i) for i in xrange(np)],
> diff --git a/src/cpu/base.cc b/src/cpu/base.cc
> --- a/src/cpu/base.cc
> +++ b/src/cpu/base.cc
> @@ -61,11 +61,11 @@ int maxThreadsPerCPU = 1;
>  int maxThreadsPerCPU = 1;
>
>  CPUProgressEvent::CPUProgressEvent(BaseCPU *_cpu, Tick ival)
> -    : Event(Event::Progress_Event_Pri), interval(ival), lastNumInst(0),
> -      cpu(_cpu)
> -{
> -    if (interval)
> -        cpu->schedule(this, curTick + interval);
> +    : Event(Event::Progress_Event_Pri), _interval(ival), lastNumInst(0),
> +      cpu(_cpu), _repeatEvent(true)
> +{
> +    if (_interval)
> +        cpu->schedule(this, curTick + _interval);
>  }
>
>  void
> @@ -73,17 +73,19 @@ CPUProgressEvent::process()
>  {
>     Counter temp = cpu->totalInstructions();
>  #ifndef NDEBUG
> -    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);
> +    double ipc = double(temp - lastNumInst) / (_interval / cpu->ticks(1));
> +
> +    DPRINTFN("%s progress event, total committed:%i, instructions 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);
>  #endif
>     lastNumInst = temp;
> -    cpu->schedule(this, curTick + interval);
> +
> +    if (_repeatEvent)
> +        cpu->schedule(this, curTick + _interval);
>  }
>
>  const char *
> @@ -230,8 +232,10 @@ 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);
> +        cprintf("Setting num_ticks to %i.\n", num_ticks);
> +
> +        Event *event;
> +        event = new CPUProgressEvent(this, num_ticks);
>     }
>  }
>
> diff --git a/src/cpu/base.hh b/src/cpu/base.hh
> --- a/src/cpu/base.hh
> +++ b/src/cpu/base.hh
> @@ -61,15 +61,21 @@ class CPUProgressEvent : public Event
>  class CPUProgressEvent : public Event
>  {
>   protected:
> -    Tick interval;
> +    Tick _interval;
>     Counter lastNumInst;
>     BaseCPU *cpu;
> -
> -  public:
> -    CPUProgressEvent(BaseCPU *_cpu, Tick ival);
> +    bool _repeatEvent;
> +
> +  public:
> +    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;
>  };
>
> _______________________________________________
> m5-dev mailing list
> m5-dev@m5sim.org
> http://m5sim.org/mailman/listinfo/m5-dev
>



-- 
===========
Korey L Sewell
PhD Candidate
Computer Science & Engineering
University of Michigan
_______________________________________________
m5-dev mailing list
m5-dev@m5sim.org
http://m5sim.org/mailman/listinfo/m5-dev

Reply via email to