Modifying CPU Paramteres in Gem5 From Config

59 Views Asked by At

Many CPU parameters in the O3 CPU are initialised by reading out of a 'params' object passed to their the class of the different components (fetch, decode etc). For instance:

Fetch::Fetch(CPU *_cpu, const BaseO3CPUParams &params)
    : fetchPolicy(params.smtFetchPolicy),
      cpu(_cpu),
      branchPred(nullptr),
      decodeToFetchDelay(params.decodeToFetchDelay),
    ...
{

I want to add a new parameter that can be modified via the command line with the config script (in my case configs/example/se.py). I've implemented this by adding a new option in /configs/common/Options.py and the following code in se.py:

for cpu in system.cpu:
    cpu.my_new_param = args.my_new_param

I've then added the new parameter field to BaseCPU.py as: my_new_param = Param.String(...)

The problem is that I'm restoring from checkpoints into the atomic CPU, then switching to the O3 CPU where I want my new parameter to be used. It seems in this case, the CPUs in system.cpu (which is a list) is only ever the atomic CPU object.

How can I access the DerivO3CPU object from the se.py script then? What's the best way to set this parameter at the command line so I don't have to rebuild every time I want to change it?

Thanks.

0

There are 0 best solutions below