-
Notifications
You must be signed in to change notification settings - Fork 4
Simulation.py
File Path: configs/common/Simulation.py
Simulation is used to generate the appropriate cpu classes (not instances) and memory controller classes (not instances). It also deals with checkpoint. In se.py, it finally calls Simulation.run.
setCPUClass(options): This function create proper CPU Classes according to user provided options, such as --cpu-type="timing"
. The function returns a tuple of three elements (CPUClass, test_mem_mode, FutureClass). It consists of two cpu classes and the initial mode of operation. Restsoring from a checkpoint or fast forwarding through a benchmark can be done using one type of cpu, and then the actual simulation can be carried out using the other type. If it is a checkpoint, the simulation is first restored with one cpu (CPUClass, --restore-with-cpu) then continues with the other type (FutureClass, --cpu-type). If it is a fast forwarding (no restore required), FutureClass is indicated by --cpu-type and CPUClass is AtomicSimpleCPU
which is used to fast forwarding. Otherwise, CPUClass is set by --cpu-type and FutureClass is None.
getCPUClass(cpu_type): Returns the required cpu class (by CpuConfig with cpu_type) and the mode of operation.
setMemClass(options): Returns a memory controller class by MemConfig with mem_type in argument options.
run(options, root, testsys, cpu_class): This function first sets up checkpoint directory where to restore. There are three possible places to search. The first one is indicated by checkpoint-dir in script options. Then look for gem5's output directory and finally is the current directory. Note that fast forwarding and checkpoint can't be used at the same time (What if we want to restore from a checkpoint and then use fast forwarding to warm up cache?). It then checks for standard switch
(switch from timing to detailed CPU after warmup period of N). '--caches' must be specified when using standard switch. If checkpoint or fast forwarding is used, then the cpu_class is the future class and its current status is switched out. Each cpu has a switch_cpu and switch_cpu is properly set.
Running mode: Standard Switch (SS), Repeat Switch (RS), Checkpoint (CP), Fast Forwarding (FF). As the figure shown below, either SS or RS is chosen. Also only one of CP and FF is enabled.
Let us first figure out what kind of cpus is used for each stage. The argument testsys
passed to Simulation is already configured in se.py. It has a cpu list named cpu
. The argument cpu_class
passed to Simulation is the future cpu class for testsys. For example, if the system is fast forwarded, the testsys.cpu is used to run fast-forwarding, then cpus are switched to cpu_class (Future CPU Class). Simulation flow is shown below.