This is what I did and made it work. Of course, I did this after I trace where 
they increment the cycles and made the changes make sense to me. I am using 
v22, so I would image it works for you. But, as Eliot pointed out, there are 
more places you need to check. I would suggest you starting with adding debug 
print on where the cycles incremented, and see if the changes do anything.

I can comment a bit more on the ticks and cycles. As Eliot said, ticks are in 
pico seconds, this number increment by fixed rate, representing the “time”, 
then depends on your simulated cpu frequency, the cycles will be different. 
cpu_cluster.clk_domain.clock will be the used to check how many picoseconds in 
one cycle, 250 means 4GHZ.

And, yes, if your cpu idles a lot, this can happens. For me, I can have a 4 
cpus simulation, but only a single thread program running. Then, I have 1 core 
with high numInsts, 3 cores with very low number.

Best,
Heng

On Apr 13, 2023, at 07:52, Eliot Moss <m...@cs.umass.edu> wrote:

On 4/13/2023 6:24 AM, Farbin Fayza via gem5-users wrote:
Hi Heng,
Thanks for your reply. Do you mean something like this? I changed atomic.cc 
like this:
void AtomicSimpleCPU::drainResume()
{
    assert(!tickEvent.scheduled());
    if (switchedOut())
        return;
    DPRINTF(SimpleCPU, "Resume\n");
    verifyMemoryMode();
    assert(!threadContexts.empty());
    _status = BaseSimpleCPU::Idle;
*threadInfo[0]->thread->lastSuspend = curTick();*
    for (ThreadID tid = 0; tid < numThreads; tid++) {
        if (threadInfo[tid]->thread->status() == ThreadContext::Active) {
            threadInfo[tid]->execContextStats.notIdleFraction = 1;
            activeThreads.push_back(tid);
            _status = BaseSimpleCPU::Running;
            // Tick if any threads active
            if (!tickEvent.scheduled()) {
                schedule(tickEvent, nextCycle());
            }
        } else {
            threadInfo[tid]->execContextStats.notIdleFraction = 0;
        }
    }
    // Reschedule any power gating event (if any)
    schedulePowerGatingEvent();
}
After this change, I rebuilt gem5 and ran a simulation on simple.py. But still, 
the number of cycles is very higher than the number of instructions.

Some things I can imagine happening ...

- Maybe numCycles is actually number of ticks?  A tick is the smallest unit of 
time in the system, usually picoseconds - though that would seem to imply a 
really high execution rate of nearly 10
insts per nanoseond

- Maybe the cpu is idle a lot

It should not be too hard to find where those statistics are defined, output, 
and manipulated
in the source code, by using grep.

HTH - Eliot Moss

_______________________________________________
gem5-users mailing list -- gem5-users@gem5.org
To unsubscribe send an email to gem5-users-le...@gem5.org

Reply via email to