cpu: Accurately count idle cycles for simple cpu
Added a couple missing updates to the notIdleFraction stat. Without these, it sometimes gives a (not) idle fraction that is greater than 1 or less than 0.
This commit is contained in:
parent
c26911013c
commit
646c4a23ca
3 changed files with 10 additions and 6 deletions
|
@ -282,7 +282,7 @@ OzoneCPU<Impl>::activateContext(int thread_num, int delay)
|
||||||
assert(thread_num == 0);
|
assert(thread_num == 0);
|
||||||
|
|
||||||
assert(_status == Idle);
|
assert(_status == Idle);
|
||||||
notIdleFraction++;
|
notIdleFraction = 1;
|
||||||
scheduleTickEvent(delay);
|
scheduleTickEvent(delay);
|
||||||
_status = Running;
|
_status = Running;
|
||||||
if (thread.quiesceEvent && thread.quiesceEvent->scheduled())
|
if (thread.quiesceEvent && thread.quiesceEvent->scheduled())
|
||||||
|
@ -300,7 +300,7 @@ OzoneCPU<Impl>::suspendContext(int thread_num)
|
||||||
// @todo: Figure out how to initially set the status properly so
|
// @todo: Figure out how to initially set the status properly so
|
||||||
// this is running.
|
// this is running.
|
||||||
// assert(_status == Running);
|
// assert(_status == Running);
|
||||||
notIdleFraction--;
|
notIdleFraction = 0;
|
||||||
unscheduleTickEvent();
|
unscheduleTickEvent();
|
||||||
_status = Idle;
|
_status = Idle;
|
||||||
}
|
}
|
||||||
|
|
|
@ -175,8 +175,10 @@ AtomicSimpleCPU::drainResume()
|
||||||
if (thread->status() == ThreadContext::Active) {
|
if (thread->status() == ThreadContext::Active) {
|
||||||
schedule(tickEvent, nextCycle());
|
schedule(tickEvent, nextCycle());
|
||||||
_status = BaseSimpleCPU::Running;
|
_status = BaseSimpleCPU::Running;
|
||||||
|
notIdleFraction = 1;
|
||||||
} else {
|
} else {
|
||||||
_status = BaseSimpleCPU::Idle;
|
_status = BaseSimpleCPU::Idle;
|
||||||
|
notIdleFraction = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
system->totalNumInsts = 0;
|
system->totalNumInsts = 0;
|
||||||
|
@ -244,7 +246,7 @@ AtomicSimpleCPU::activateContext(ThreadID thread_num, Cycles delay)
|
||||||
assert(_status == Idle);
|
assert(_status == Idle);
|
||||||
assert(!tickEvent.scheduled());
|
assert(!tickEvent.scheduled());
|
||||||
|
|
||||||
notIdleFraction++;
|
notIdleFraction = 1;
|
||||||
numCycles += ticksToCycles(thread->lastActivate - thread->lastSuspend);
|
numCycles += ticksToCycles(thread->lastActivate - thread->lastSuspend);
|
||||||
|
|
||||||
//Make sure ticks are still on multiples of cycles
|
//Make sure ticks are still on multiples of cycles
|
||||||
|
@ -271,7 +273,7 @@ AtomicSimpleCPU::suspendContext(ThreadID thread_num)
|
||||||
if (tickEvent.scheduled())
|
if (tickEvent.scheduled())
|
||||||
deschedule(tickEvent);
|
deschedule(tickEvent);
|
||||||
|
|
||||||
notIdleFraction--;
|
notIdleFraction = 0;
|
||||||
_status = Idle;
|
_status = Idle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -143,8 +143,10 @@ TimingSimpleCPU::drainResume()
|
||||||
if (thread->status() == ThreadContext::Active) {
|
if (thread->status() == ThreadContext::Active) {
|
||||||
schedule(fetchEvent, nextCycle());
|
schedule(fetchEvent, nextCycle());
|
||||||
_status = BaseSimpleCPU::Running;
|
_status = BaseSimpleCPU::Running;
|
||||||
|
notIdleFraction = 1;
|
||||||
} else {
|
} else {
|
||||||
_status = BaseSimpleCPU::Idle;
|
_status = BaseSimpleCPU::Idle;
|
||||||
|
notIdleFraction = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -206,7 +208,7 @@ TimingSimpleCPU::activateContext(ThreadID thread_num, Cycles delay)
|
||||||
|
|
||||||
assert(_status == Idle);
|
assert(_status == Idle);
|
||||||
|
|
||||||
notIdleFraction++;
|
notIdleFraction = 1;
|
||||||
_status = BaseSimpleCPU::Running;
|
_status = BaseSimpleCPU::Running;
|
||||||
|
|
||||||
// kick things off by initiating the fetch of the next instruction
|
// kick things off by initiating the fetch of the next instruction
|
||||||
|
@ -230,7 +232,7 @@ TimingSimpleCPU::suspendContext(ThreadID thread_num)
|
||||||
// just change status to Idle... if status != Running,
|
// just change status to Idle... if status != Running,
|
||||||
// completeInst() will not initiate fetch of next instruction.
|
// completeInst() will not initiate fetch of next instruction.
|
||||||
|
|
||||||
notIdleFraction--;
|
notIdleFraction = 0;
|
||||||
_status = Idle;
|
_status = Idle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue