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
This commit is contained in:
Korey Sewell 2009-05-05 02:51:31 -04:00
parent dc35d2f125
commit c70241810d
5 changed files with 42 additions and 14 deletions

View file

@ -38,6 +38,8 @@ parser.add_option("--fastmem", action="store_true")
# Run duration options # Run duration options
parser.add_option("-m", "--maxtick", type="int") parser.add_option("-m", "--maxtick", type="int")
parser.add_option("--maxtime", type="float") parser.add_option("--maxtime", type="float")
parser.add_option("--prog_intvl", type="int")
# Checkpointing options # Checkpointing options
###Note that performing checkpointing via python script files will override ###Note that performing checkpointing via python script files will override

View file

@ -91,6 +91,10 @@ def run(options, root, testsys, cpu_class):
max_checkpoints = options.max_checkpoints max_checkpoints = options.max_checkpoints
switch_cpus = None switch_cpus = None
if options.prog_intvl:
for i in xrange(np):
testsys.cpu[i].progress_interval = options.prog_intvl
if cpu_class: if cpu_class:
switch_cpus = [cpu_class(defer_registration=True, cpu_id=(np+i)) switch_cpus = [cpu_class(defer_registration=True, cpu_id=(np+i))
for i in xrange(np)] for i in xrange(np)]

View file

@ -61,11 +61,11 @@ vector<BaseCPU *> BaseCPU::cpuList;
int maxThreadsPerCPU = 1; int maxThreadsPerCPU = 1;
CPUProgressEvent::CPUProgressEvent(BaseCPU *_cpu, Tick ival) CPUProgressEvent::CPUProgressEvent(BaseCPU *_cpu, Tick ival)
: Event(Event::Progress_Event_Pri), interval(ival), lastNumInst(0), : Event(Event::Progress_Event_Pri), _interval(ival), lastNumInst(0),
cpu(_cpu) cpu(_cpu), _repeatEvent(true)
{ {
if (interval) if (_interval)
cpu->schedule(this, curTick + interval); cpu->schedule(this, curTick + _interval);
} }
void void
@ -73,17 +73,21 @@ CPUProgressEvent::process()
{ {
Counter temp = cpu->totalInstructions(); Counter temp = cpu->totalInstructions();
#ifndef NDEBUG #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", DPRINTFN("%s progress event, total committed:%i, progress insts committed: "
cpu->name(), temp - lastNumInst, ipc); "%lli, IPC: %0.8d\n", cpu->name(), temp, temp - lastNumInst,
ipc);
ipc = 0.0; ipc = 0.0;
#else #else
cprintf("%lli: %s progress event, instructions committed: %lli\n", cprintf("%lli: %s progress event, total committed:%i, progress insts "
curTick, cpu->name(), temp - lastNumInst); "committed: %lli\n", curTick, cpu->name(), temp,
temp - lastNumInst);
#endif #endif
lastNumInst = temp; lastNumInst = temp;
cpu->schedule(this, curTick + interval);
if (_repeatEvent)
cpu->schedule(this, curTick + _interval);
} }
const char * const char *
@ -230,8 +234,9 @@ BaseCPU::startup()
if (params()->progress_interval) { if (params()->progress_interval) {
Tick num_ticks = ticks(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);
} }
} }

View file

@ -61,15 +61,21 @@ namespace TheISA
class CPUProgressEvent : public Event class CPUProgressEvent : public Event
{ {
protected: protected:
Tick interval; Tick _interval;
Counter lastNumInst; Counter lastNumInst;
BaseCPU *cpu; BaseCPU *cpu;
bool _repeatEvent;
public: public:
CPUProgressEvent(BaseCPU *_cpu, Tick ival); CPUProgressEvent(BaseCPU *_cpu, Tick ival = 0);
void process(); void process();
void interval(Tick ival) { _interval = ival; }
Tick interval() { return _interval; }
void repeatEvent(bool repeat) { _repeatEvent = repeat; }
virtual const char *description() const; virtual const char *description() const;
}; };

View file

@ -589,6 +589,17 @@ class InOrderCPU : public BaseCPU
return thread[tid]->getTC(); 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. */ /** The global sequence number counter. */
InstSeqNum globalSeqNum[ThePipeline::MaxThreads]; InstSeqNum globalSeqNum[ThePipeline::MaxThreads];