Andreas Sandberg has submitted this change and it was merged. (
https://gem5-review.googlesource.com/2561 )
Change subject: config, arm: Add multi-core KVM support to bL config
......................................................................
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 <[email protected]>
Reviewed-by: Curtis Dunham <[email protected]>
Reviewed-by: Sascha Bischoff <[email protected]>
Reviewed-by: Gabor Dozsa <[email protected]>
Reviewed-on: https://gem5-review.googlesource.com/2561
Reviewed-by: Jason Lowe-Power <[email protected]>
Reviewed-by: Weiping Liao <[email protected]>
---
M configs/example/arm/devices.py
M configs/example/arm/fs_bigLITTLE.py
2 files changed, 89 insertions(+), 24 deletions(-)
Approvals:
Jason Lowe-Power: Looks good to me, but someone else must approve
Andreas Sandberg: Looks good to me, approved; Looks good to me, approved
Weiping Liao: Looks good to me, but someone else must approve
diff --git a/configs/example/arm/devices.py b/configs/example/arm/devices.py
index 7d3f383..f7375cd 100644
--- a/configs/example/arm/devices.py
+++ b/configs/example/arm/devices.py
@@ -1,4 +1,4 @@
-# Copyright (c) 2016 ARM Limited
+# Copyright (c) 2016-2017 ARM Limited
# All rights reserved.
#
# The license below extends only to copyright in the software and shall
@@ -43,6 +43,8 @@
m5.util.addToPath('../../')
from common.Caches import *
from common import CpuConfig
+
+have_kvm = "kvm" in CpuConfig.cpu_names()
class L1I(L1_ICache):
tag_latency = 1
@@ -170,6 +172,14 @@
def addL1(self):
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):
cache_line_size = 64
diff --git a/configs/example/arm/fs_bigLITTLE.py
b/configs/example/arm/fs_bigLITTLE.py
index c2ecf88..d6825df 100644
--- a/configs/example/arm/fs_bigLITTLE.py
+++ b/configs/example/arm/fs_bigLITTLE.py
@@ -44,6 +44,7 @@
import os
import sys
import m5
+import m5.util
from m5.objects import *
m5.util.addToPath("../../")
@@ -52,6 +53,7 @@
from common import CpuConfig
import devices
+from devices import AtomicCluster, KvmCluster
default_dtb = 'armv8_gem5_v1_big_little_2_2.dtb'
@@ -60,6 +62,21 @@
default_rcs = 'bootscript.rcS'
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):
@@ -107,6 +124,15 @@
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):
parser.add_argument("--restore-from", type=str, default=None,
@@ -119,8 +145,9 @@
help="Disks to instantiate")
parser.add_argument("--bootscript", type=str, default=default_rcs,
help="Linux bootscript")
- parser.add_argument("--atomic", action="store_true", default=False,
- help="Use atomic CPUs")
+ parser.add_argument("--cpu-type", type=str, choices=cpu_types.keys(),
+ default="timing",
+ help="CPU simulation mode. Default: %(default)s")
parser.add_argument("--kernel-init", type=str, default="/sbin/init",
help="Override init")
parser.add_argument("--big-cpus", type=int, default=1,
@@ -135,8 +162,10 @@
help="Big CPU clock frequency")
parser.add_argument("--little-cpu-clock", type=str, default="1GHz",
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
-
def build(options):
m5.ticks.fixGlobalFrequency()
@@ -165,35 +194,31 @@
root.system = system
system.boot_osflags = " ".join(kernel_cmd)
- AtomicCluster = devices.AtomicCluster
-
if options.big_cpus + options.little_cpus == 0:
m5.util.panic("Empty CPU clusters")
+ big_model, little_model = cpu_types[options.cpu_type]
+
+ all_cpus = []
# big cluster
if options.big_cpus > 0:
- if options.atomic:
- system.bigCluster = AtomicCluster(system, options.big_cpus,
- options.big_cpu_clock)
- else:
- system.bigCluster = BigCluster(system, options.big_cpus,
- options.big_cpu_clock)
- mem_mode = system.bigCluster.memoryMode()
+ system.bigCluster = big_model(system, options.big_cpus,
+ options.big_cpu_clock)
+ system.mem_mode = system.bigCluster.memoryMode()
+ all_cpus += system.bigCluster.cpus
+
# little cluster
if options.little_cpus > 0:
- if options.atomic:
- system.littleCluster = AtomicCluster(system,
options.little_cpus,
- options.little_cpu_clock)
+ system.littleCluster = little_model(system, options.little_cpus,
+ options.little_cpu_clock)
+ system.mem_mode = system.littleCluster.memoryMode()
+ all_cpus += system.littleCluster.cpus
- else:
- system.littleCluster = LittleCluster(system,
options.little_cpus,
- options.little_cpu_clock)
- mem_mode = system.littleCluster.memoryMode()
+ # Figure out the memory mode
+ if options.big_cpus > 0 and options.little_cpus > 0 and \
+ system.littleCluster.memoryMode() !=
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
system.addCaches(options.caches, options.last_cache_level)
@@ -203,13 +228,43 @@
if options.little_cpus > 0 and
system.littleCluster.requireCaches():
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
system.dtb_filename = SysPaths.binary(options.dtb)
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):
+ # 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
if options.restore_from:
if checkpoint_dir and not os.path.isabs(options.restore_from):
--
To view, visit https://gem5-review.googlesource.com/2561
To unsubscribe, visit https://gem5-review.googlesource.com/settings
Gerrit-Project: public/gem5
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Ic9a3f564db91f5a3d3cb754c5a02fdd5c17d5fdf
Gerrit-Change-Number: 2561
Gerrit-PatchSet: 2
Gerrit-Owner: Andreas Sandberg <[email protected]>
Gerrit-Reviewer: Andreas Sandberg <[email protected]>
Gerrit-Reviewer: Jason Lowe-Power <[email protected]>
Gerrit-Reviewer: Weiping Liao <[email protected]>
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev