Skip to main content

Processors in the Standard Library

The processor abstraction is contained in the $GEM_PATH/src/python/gem5/components/processors/ directory. We'll take a look at the SimpleProcessor class, which we can use as a starting point if we were to create our own processors.

Fundamentally, you will see that our SimpleProcessor class is a wrapper around creating a collection of SimpleCores. This makes it easier to develop homogenous systems (where every core is the same), but we can extend this functionality to contain heterogeneous cores as well. If we dive deeper into the SimpleCore code, we can see a little bit more of the magic:

if cpu_type == CPUTypes.KVM:
# For some reason, the KVM CPU is under "m5.objects" not the
# "m5.objects.{ISA}CPU".
module_str = f"m5.objects"
else:
module_str = f"m5.objects.{_isa_string_map[isa]}CPU"

Surprise! This whole factory is just a wrapper around loading the same CPU that you loaded manually in the basic examples! If you wanted a RISCV, out of order core, then this function would just load the m5.objects.RiscvO3CPU class instead of you doing it manually. Subsequently, the Processor class will instantiate as many of these 'cores' as you want and any operation we perform on the Processor will be done on all of the cores as if they were the all the same.