config, arm: Add multi-core KVM support to bL config
Add support for KVM in the big.LITTLE(tm) example configuration. This replaces the --atomic option with a --cpu-type option that can be used to switch between atomic, kvm, and timing simulation. When running in KVM mode, the simulation script automatically assigns separate event queues (threads) to each of the simulated CPUs. All simulated devices, including CPU child devices (e.g., interrupt controllers and caches), are assigned to event queue 0. Change-Id: Ic9a3f564db91f5a3d3cb754c5a02fdd5c17d5fdf Signed-off-by: Andreas Sandberg <andreas.sandberg@arm.com> Reviewed-by: Curtis Dunham <curtis.dunham@arm.com> Reviewed-by: Sascha Bischoff <sascha.bischoff@arm.com> Reviewed-by: Gabor Dozsa <gabor.dozsa@arm.com> Reviewed-on: https://gem5-review.googlesource.com/2561 Reviewed-by: Jason Lowe-Power <jason@lowepower.com> Reviewed-by: Weiping Liao <weipingliao@google.com>
This commit is contained in:
parent
3547af6e44
commit
9a13acaa36
|
@ -1,4 +1,4 @@
|
||||||
# Copyright (c) 2016 ARM Limited
|
# Copyright (c) 2016-2017 ARM Limited
|
||||||
# All rights reserved.
|
# All rights reserved.
|
||||||
#
|
#
|
||||||
# The license below extends only to copyright in the software and shall
|
# The license below extends only to copyright in the software and shall
|
||||||
|
@ -44,6 +44,8 @@ m5.util.addToPath('../../')
|
||||||
from common.Caches import *
|
from common.Caches import *
|
||||||
from common import CpuConfig
|
from common import CpuConfig
|
||||||
|
|
||||||
|
have_kvm = "kvm" in CpuConfig.cpu_names()
|
||||||
|
|
||||||
class L1I(L1_ICache):
|
class L1I(L1_ICache):
|
||||||
tag_latency = 1
|
tag_latency = 1
|
||||||
data_latency = 1
|
data_latency = 1
|
||||||
|
@ -170,6 +172,14 @@ class AtomicCluster(CpuCluster):
|
||||||
def addL1(self):
|
def addL1(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
class KvmCluster(CpuCluster):
|
||||||
|
def __init__(self, system, num_cpus, cpu_clock, cpu_voltage="1.0V"):
|
||||||
|
cpu_config = [ CpuConfig.get("kvm"), None, None, None, None ]
|
||||||
|
super(KvmCluster, self).__init__(system, num_cpus, cpu_clock,
|
||||||
|
cpu_voltage, *cpu_config)
|
||||||
|
def addL1(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
class SimpleSystem(LinuxArmSystem):
|
class SimpleSystem(LinuxArmSystem):
|
||||||
cache_line_size = 64
|
cache_line_size = 64
|
||||||
|
|
|
@ -44,6 +44,7 @@ import argparse
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import m5
|
import m5
|
||||||
|
import m5.util
|
||||||
from m5.objects import *
|
from m5.objects import *
|
||||||
|
|
||||||
m5.util.addToPath("../../")
|
m5.util.addToPath("../../")
|
||||||
|
@ -52,6 +53,7 @@ from common import SysPaths
|
||||||
from common import CpuConfig
|
from common import CpuConfig
|
||||||
|
|
||||||
import devices
|
import devices
|
||||||
|
from devices import AtomicCluster, KvmCluster
|
||||||
|
|
||||||
|
|
||||||
default_dtb = 'armv8_gem5_v1_big_little_2_2.dtb'
|
default_dtb = 'armv8_gem5_v1_big_little_2_2.dtb'
|
||||||
|
@ -61,6 +63,21 @@ default_rcs = 'bootscript.rcS'
|
||||||
|
|
||||||
default_mem_size= "2GB"
|
default_mem_size= "2GB"
|
||||||
|
|
||||||
|
def _to_ticks(value):
|
||||||
|
"""Helper function to convert a latency from string format to Ticks"""
|
||||||
|
|
||||||
|
return m5.ticks.fromSeconds(m5.util.convert.anyToLatency(value))
|
||||||
|
|
||||||
|
def _using_pdes(root):
|
||||||
|
"""Determine if the simulator is using multiple parallel event queues"""
|
||||||
|
|
||||||
|
for obj in root.descendants():
|
||||||
|
if not m5.proxy.isproxy(obj.eventq_index) and \
|
||||||
|
obj.eventq_index != root.eventq_index:
|
||||||
|
return True
|
||||||
|
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
class BigCluster(devices.CpuCluster):
|
class BigCluster(devices.CpuCluster):
|
||||||
def __init__(self, system, num_cpus, cpu_clock,
|
def __init__(self, system, num_cpus, cpu_clock,
|
||||||
|
@ -107,6 +124,15 @@ def createSystem(caches, kernel, bootscript, disks=[]):
|
||||||
|
|
||||||
return sys
|
return sys
|
||||||
|
|
||||||
|
cpu_types = {
|
||||||
|
"atomic" : (AtomicCluster, AtomicCluster),
|
||||||
|
"timing" : (BigCluster, LittleCluster),
|
||||||
|
}
|
||||||
|
|
||||||
|
# Only add the KVM CPU if it has been compiled into gem5
|
||||||
|
if devices.have_kvm:
|
||||||
|
cpu_types["kvm"] = (KvmCluster, KvmCluster)
|
||||||
|
|
||||||
|
|
||||||
def addOptions(parser):
|
def addOptions(parser):
|
||||||
parser.add_argument("--restore-from", type=str, default=None,
|
parser.add_argument("--restore-from", type=str, default=None,
|
||||||
|
@ -119,8 +145,9 @@ def addOptions(parser):
|
||||||
help="Disks to instantiate")
|
help="Disks to instantiate")
|
||||||
parser.add_argument("--bootscript", type=str, default=default_rcs,
|
parser.add_argument("--bootscript", type=str, default=default_rcs,
|
||||||
help="Linux bootscript")
|
help="Linux bootscript")
|
||||||
parser.add_argument("--atomic", action="store_true", default=False,
|
parser.add_argument("--cpu-type", type=str, choices=cpu_types.keys(),
|
||||||
help="Use atomic CPUs")
|
default="timing",
|
||||||
|
help="CPU simulation mode. Default: %(default)s")
|
||||||
parser.add_argument("--kernel-init", type=str, default="/sbin/init",
|
parser.add_argument("--kernel-init", type=str, default="/sbin/init",
|
||||||
help="Override init")
|
help="Override init")
|
||||||
parser.add_argument("--big-cpus", type=int, default=1,
|
parser.add_argument("--big-cpus", type=int, default=1,
|
||||||
|
@ -135,9 +162,11 @@ def addOptions(parser):
|
||||||
help="Big CPU clock frequency")
|
help="Big CPU clock frequency")
|
||||||
parser.add_argument("--little-cpu-clock", type=str, default="1GHz",
|
parser.add_argument("--little-cpu-clock", type=str, default="1GHz",
|
||||||
help="Little CPU clock frequency")
|
help="Little CPU clock frequency")
|
||||||
|
parser.add_argument("--sim-quantum", type=str, default="1ms",
|
||||||
|
help="Simulation quantum for parallel simulation. " \
|
||||||
|
"Default: %(default)s")
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
|
|
||||||
def build(options):
|
def build(options):
|
||||||
m5.ticks.fixGlobalFrequency()
|
m5.ticks.fixGlobalFrequency()
|
||||||
|
|
||||||
|
@ -165,35 +194,31 @@ def build(options):
|
||||||
root.system = system
|
root.system = system
|
||||||
system.boot_osflags = " ".join(kernel_cmd)
|
system.boot_osflags = " ".join(kernel_cmd)
|
||||||
|
|
||||||
AtomicCluster = devices.AtomicCluster
|
|
||||||
|
|
||||||
if options.big_cpus + options.little_cpus == 0:
|
if options.big_cpus + options.little_cpus == 0:
|
||||||
m5.util.panic("Empty CPU clusters")
|
m5.util.panic("Empty CPU clusters")
|
||||||
|
|
||||||
|
big_model, little_model = cpu_types[options.cpu_type]
|
||||||
|
|
||||||
|
all_cpus = []
|
||||||
# big cluster
|
# big cluster
|
||||||
if options.big_cpus > 0:
|
if options.big_cpus > 0:
|
||||||
if options.atomic:
|
system.bigCluster = big_model(system, options.big_cpus,
|
||||||
system.bigCluster = AtomicCluster(system, options.big_cpus,
|
options.big_cpu_clock)
|
||||||
options.big_cpu_clock)
|
system.mem_mode = system.bigCluster.memoryMode()
|
||||||
else:
|
all_cpus += system.bigCluster.cpus
|
||||||
system.bigCluster = BigCluster(system, options.big_cpus,
|
|
||||||
options.big_cpu_clock)
|
|
||||||
mem_mode = system.bigCluster.memoryMode()
|
|
||||||
# little cluster
|
# little cluster
|
||||||
if options.little_cpus > 0:
|
if options.little_cpus > 0:
|
||||||
if options.atomic:
|
system.littleCluster = little_model(system, options.little_cpus,
|
||||||
system.littleCluster = AtomicCluster(system, options.little_cpus,
|
options.little_cpu_clock)
|
||||||
options.little_cpu_clock)
|
system.mem_mode = system.littleCluster.memoryMode()
|
||||||
|
all_cpus += system.littleCluster.cpus
|
||||||
|
|
||||||
else:
|
# Figure out the memory mode
|
||||||
system.littleCluster = LittleCluster(system, options.little_cpus,
|
if options.big_cpus > 0 and options.little_cpus > 0 and \
|
||||||
options.little_cpu_clock)
|
system.littleCluster.memoryMode() != system.littleCluster.memoryMode():
|
||||||
mem_mode = system.littleCluster.memoryMode()
|
m5.util.panic("Memory mode missmatch among CPU clusters")
|
||||||
|
|
||||||
if options.big_cpus > 0 and options.little_cpus > 0:
|
|
||||||
if system.bigCluster.memoryMode() != system.littleCluster.memoryMode():
|
|
||||||
m5.util.panic("Memory mode missmatch among CPU clusters")
|
|
||||||
system.mem_mode = mem_mode
|
|
||||||
|
|
||||||
# create caches
|
# create caches
|
||||||
system.addCaches(options.caches, options.last_cache_level)
|
system.addCaches(options.caches, options.last_cache_level)
|
||||||
|
@ -203,13 +228,43 @@ def build(options):
|
||||||
if options.little_cpus > 0 and system.littleCluster.requireCaches():
|
if options.little_cpus > 0 and system.littleCluster.requireCaches():
|
||||||
m5.util.panic("Little CPU model requires caches")
|
m5.util.panic("Little CPU model requires caches")
|
||||||
|
|
||||||
|
# Create a KVM VM and do KVM-specific configuration
|
||||||
|
if issubclass(big_model, KvmCluster):
|
||||||
|
_build_kvm(system, all_cpus)
|
||||||
|
|
||||||
# Linux device tree
|
# Linux device tree
|
||||||
system.dtb_filename = SysPaths.binary(options.dtb)
|
system.dtb_filename = SysPaths.binary(options.dtb)
|
||||||
|
|
||||||
return root
|
return root
|
||||||
|
|
||||||
|
def _build_kvm(system, cpus):
|
||||||
|
system.kvm_vm = KvmVM()
|
||||||
|
|
||||||
|
# Assign KVM CPUs to their own event queues / threads. This
|
||||||
|
# has to be done after creating caches and other child objects
|
||||||
|
# since these mustn't inherit the CPU event queue.
|
||||||
|
if len(cpus) > 1:
|
||||||
|
device_eq = 0
|
||||||
|
first_cpu_eq = 1
|
||||||
|
for idx, cpu in enumerate(cpus):
|
||||||
|
# Child objects usually inherit the parent's event
|
||||||
|
# queue. Override that and use the same event queue for
|
||||||
|
# all devices.
|
||||||
|
for obj in cpu.descendants():
|
||||||
|
obj.eventq_index = device_eq
|
||||||
|
cpu.eventq_index = first_cpu_eq + idx
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def instantiate(options, checkpoint_dir=None):
|
def instantiate(options, checkpoint_dir=None):
|
||||||
|
# Setup the simulation quantum if we are running in PDES-mode
|
||||||
|
# (e.g., when using KVM)
|
||||||
|
root = Root.getInstance()
|
||||||
|
if root and _using_pdes(root):
|
||||||
|
m5.util.inform("Running in PDES mode with a %s simulation quantum.",
|
||||||
|
options.sim_quantum)
|
||||||
|
root.sim_quantum = _to_ticks(options.sim_quantum)
|
||||||
|
|
||||||
# Get and load from the chkpt or simpoint checkpoint
|
# Get and load from the chkpt or simpoint checkpoint
|
||||||
if options.restore_from:
|
if options.restore_from:
|
||||||
if checkpoint_dir and not os.path.isabs(options.restore_from):
|
if checkpoint_dir and not os.path.isabs(options.restore_from):
|
||||||
|
|
Loading…
Reference in a new issue