fs_bigLITTLE.py (11935:28290ed77b03) fs_bigLITTLE.py (11936:8ab45fd19f40)
1# Copyright (c) 2016-2017 ARM Limited
2# All rights reserved.
3#
4# The license below extends only to copyright in the software and shall
5# not be construed as granting a license to any other intellectual
6# property including but not limited to intellectual property relating
7# to a hardware implementation of the functionality of the software
8# licensed hereunder. You may use the software subject to the license

--- 30 unchanged lines hidden (view full) ---

39# This is an example configuration script for full system simulation of
40# a generic ARM bigLITTLE system.
41
42
43import argparse
44import os
45import sys
46import m5
1# Copyright (c) 2016-2017 ARM Limited
2# All rights reserved.
3#
4# The license below extends only to copyright in the software and shall
5# not be construed as granting a license to any other intellectual
6# property including but not limited to intellectual property relating
7# to a hardware implementation of the functionality of the software
8# licensed hereunder. You may use the software subject to the license

--- 30 unchanged lines hidden (view full) ---

39# This is an example configuration script for full system simulation of
40# a generic ARM bigLITTLE system.
41
42
43import argparse
44import os
45import sys
46import m5
47import m5.util
47from m5.objects import *
48
49m5.util.addToPath("../../")
50
51from common import SysPaths
52from common import CpuConfig
53
54import devices
48from m5.objects import *
49
50m5.util.addToPath("../../")
51
52from common import SysPaths
53from common import CpuConfig
54
55import devices
56from devices import AtomicCluster, KvmCluster
55
56
57default_dtb = 'armv8_gem5_v1_big_little_2_2.dtb'
58default_kernel = 'vmlinux4.3.aarch64'
59default_disk = 'aarch64-ubuntu-trusty-headless.img'
60default_rcs = 'bootscript.rcS'
61
62default_mem_size= "2GB"
63
57
58
59default_dtb = 'armv8_gem5_v1_big_little_2_2.dtb'
60default_kernel = 'vmlinux4.3.aarch64'
61default_disk = 'aarch64-ubuntu-trusty-headless.img'
62default_rcs = 'bootscript.rcS'
63
64default_mem_size= "2GB"
65
66def _to_ticks(value):
67 """Helper function to convert a latency from string format to Ticks"""
64
68
69 return m5.ticks.fromSeconds(m5.util.convert.anyToLatency(value))
70
71def _using_pdes(root):
72 """Determine if the simulator is using multiple parallel event queues"""
73
74 for obj in root.descendants():
75 if not m5.proxy.isproxy(obj.eventq_index) and \
76 obj.eventq_index != root.eventq_index:
77 return True
78
79 return False
80
81
65class BigCluster(devices.CpuCluster):
66 def __init__(self, system, num_cpus, cpu_clock,
67 cpu_voltage="1.0V"):
68 cpu_config = [ CpuConfig.get("arm_detailed"), devices.L1I, devices.L1D,
69 devices.WalkCache, devices.L2 ]
70 super(BigCluster, self).__init__(system, num_cpus, cpu_clock,
71 cpu_voltage, *cpu_config)
72

--- 29 unchanged lines hidden (view full) ---

102 for img in sys.disk_images ]
103 for dev in sys.pci_vio_block:
104 sys.attach_pci(dev)
105
106 sys.realview.setupBootLoader(sys.membus, sys, SysPaths.binary)
107
108 return sys
109
82class BigCluster(devices.CpuCluster):
83 def __init__(self, system, num_cpus, cpu_clock,
84 cpu_voltage="1.0V"):
85 cpu_config = [ CpuConfig.get("arm_detailed"), devices.L1I, devices.L1D,
86 devices.WalkCache, devices.L2 ]
87 super(BigCluster, self).__init__(system, num_cpus, cpu_clock,
88 cpu_voltage, *cpu_config)
89

--- 29 unchanged lines hidden (view full) ---

119 for img in sys.disk_images ]
120 for dev in sys.pci_vio_block:
121 sys.attach_pci(dev)
122
123 sys.realview.setupBootLoader(sys.membus, sys, SysPaths.binary)
124
125 return sys
126
127cpu_types = {
128 "atomic" : (AtomicCluster, AtomicCluster),
129 "timing" : (BigCluster, LittleCluster),
130}
110
131
132# Only add the KVM CPU if it has been compiled into gem5
133if devices.have_kvm:
134 cpu_types["kvm"] = (KvmCluster, KvmCluster)
135
136
111def addOptions(parser):
112 parser.add_argument("--restore-from", type=str, default=None,
113 help="Restore from checkpoint")
114 parser.add_argument("--dtb", type=str, default=default_dtb,
115 help="DTB file to load")
116 parser.add_argument("--kernel", type=str, default=default_kernel,
117 help="Linux kernel")
118 parser.add_argument("--disk", action="append", type=str, default=[],
119 help="Disks to instantiate")
120 parser.add_argument("--bootscript", type=str, default=default_rcs,
121 help="Linux bootscript")
137def addOptions(parser):
138 parser.add_argument("--restore-from", type=str, default=None,
139 help="Restore from checkpoint")
140 parser.add_argument("--dtb", type=str, default=default_dtb,
141 help="DTB file to load")
142 parser.add_argument("--kernel", type=str, default=default_kernel,
143 help="Linux kernel")
144 parser.add_argument("--disk", action="append", type=str, default=[],
145 help="Disks to instantiate")
146 parser.add_argument("--bootscript", type=str, default=default_rcs,
147 help="Linux bootscript")
122 parser.add_argument("--atomic", action="store_true", default=False,
123 help="Use atomic CPUs")
148 parser.add_argument("--cpu-type", type=str, choices=cpu_types.keys(),
149 default="timing",
150 help="CPU simulation mode. Default: %(default)s")
124 parser.add_argument("--kernel-init", type=str, default="/sbin/init",
125 help="Override init")
126 parser.add_argument("--big-cpus", type=int, default=1,
127 help="Number of big CPUs to instantiate")
128 parser.add_argument("--little-cpus", type=int, default=1,
129 help="Number of little CPUs to instantiate")
130 parser.add_argument("--caches", action="store_true", default=False,
131 help="Instantiate caches")
132 parser.add_argument("--last-cache-level", type=int, default=2,
133 help="Last level of caches (e.g. 3 for L3)")
134 parser.add_argument("--big-cpu-clock", type=str, default="2GHz",
135 help="Big CPU clock frequency")
136 parser.add_argument("--little-cpu-clock", type=str, default="1GHz",
137 help="Little CPU clock frequency")
151 parser.add_argument("--kernel-init", type=str, default="/sbin/init",
152 help="Override init")
153 parser.add_argument("--big-cpus", type=int, default=1,
154 help="Number of big CPUs to instantiate")
155 parser.add_argument("--little-cpus", type=int, default=1,
156 help="Number of little CPUs to instantiate")
157 parser.add_argument("--caches", action="store_true", default=False,
158 help="Instantiate caches")
159 parser.add_argument("--last-cache-level", type=int, default=2,
160 help="Last level of caches (e.g. 3 for L3)")
161 parser.add_argument("--big-cpu-clock", type=str, default="2GHz",
162 help="Big CPU clock frequency")
163 parser.add_argument("--little-cpu-clock", type=str, default="1GHz",
164 help="Little CPU clock frequency")
165 parser.add_argument("--sim-quantum", type=str, default="1ms",
166 help="Simulation quantum for parallel simulation. " \
167 "Default: %(default)s")
138 return parser
139
168 return parser
169
140
141def build(options):
142 m5.ticks.fixGlobalFrequency()
143
144 kernel_cmd = [
145 "earlyprintk=pl011,0x1c090000",
146 "console=ttyAMA0",
147 "lpj=19988480",
148 "norandmaps",

--- 11 unchanged lines hidden (view full) ---

160 system = createSystem(options.caches,
161 options.kernel,
162 options.bootscript,
163 disks=disks)
164
165 root.system = system
166 system.boot_osflags = " ".join(kernel_cmd)
167
170def build(options):
171 m5.ticks.fixGlobalFrequency()
172
173 kernel_cmd = [
174 "earlyprintk=pl011,0x1c090000",
175 "console=ttyAMA0",
176 "lpj=19988480",
177 "norandmaps",

--- 11 unchanged lines hidden (view full) ---

189 system = createSystem(options.caches,
190 options.kernel,
191 options.bootscript,
192 disks=disks)
193
194 root.system = system
195 system.boot_osflags = " ".join(kernel_cmd)
196
168 AtomicCluster = devices.AtomicCluster
169
170 if options.big_cpus + options.little_cpus == 0:
171 m5.util.panic("Empty CPU clusters")
172
197 if options.big_cpus + options.little_cpus == 0:
198 m5.util.panic("Empty CPU clusters")
199
200 big_model, little_model = cpu_types[options.cpu_type]
201
202 all_cpus = []
173 # big cluster
174 if options.big_cpus > 0:
203 # big cluster
204 if options.big_cpus > 0:
175 if options.atomic:
176 system.bigCluster = AtomicCluster(system, options.big_cpus,
177 options.big_cpu_clock)
178 else:
179 system.bigCluster = BigCluster(system, options.big_cpus,
180 options.big_cpu_clock)
181 mem_mode = system.bigCluster.memoryMode()
205 system.bigCluster = big_model(system, options.big_cpus,
206 options.big_cpu_clock)
207 system.mem_mode = system.bigCluster.memoryMode()
208 all_cpus += system.bigCluster.cpus
209
182 # little cluster
183 if options.little_cpus > 0:
210 # little cluster
211 if options.little_cpus > 0:
184 if options.atomic:
185 system.littleCluster = AtomicCluster(system, options.little_cpus,
186 options.little_cpu_clock)
212 system.littleCluster = little_model(system, options.little_cpus,
213 options.little_cpu_clock)
214 system.mem_mode = system.littleCluster.memoryMode()
215 all_cpus += system.littleCluster.cpus
187
216
188 else:
189 system.littleCluster = LittleCluster(system, options.little_cpus,
190 options.little_cpu_clock)
191 mem_mode = system.littleCluster.memoryMode()
217 # Figure out the memory mode
218 if options.big_cpus > 0 and options.little_cpus > 0 and \
219 system.littleCluster.memoryMode() != system.littleCluster.memoryMode():
220 m5.util.panic("Memory mode missmatch among CPU clusters")
192
221
193 if options.big_cpus > 0 and options.little_cpus > 0:
194 if system.bigCluster.memoryMode() != system.littleCluster.memoryMode():
195 m5.util.panic("Memory mode missmatch among CPU clusters")
196 system.mem_mode = mem_mode
197
198 # create caches
199 system.addCaches(options.caches, options.last_cache_level)
200 if not options.caches:
201 if options.big_cpus > 0 and system.bigCluster.requireCaches():
202 m5.util.panic("Big CPU model requires caches")
203 if options.little_cpus > 0 and system.littleCluster.requireCaches():
204 m5.util.panic("Little CPU model requires caches")
205
222
223 # create caches
224 system.addCaches(options.caches, options.last_cache_level)
225 if not options.caches:
226 if options.big_cpus > 0 and system.bigCluster.requireCaches():
227 m5.util.panic("Big CPU model requires caches")
228 if options.little_cpus > 0 and system.littleCluster.requireCaches():
229 m5.util.panic("Little CPU model requires caches")
230
231 # Create a KVM VM and do KVM-specific configuration
232 if issubclass(big_model, KvmCluster):
233 _build_kvm(system, all_cpus)
234
206 # Linux device tree
207 system.dtb_filename = SysPaths.binary(options.dtb)
208
209 return root
210
235 # Linux device tree
236 system.dtb_filename = SysPaths.binary(options.dtb)
237
238 return root
239
240def _build_kvm(system, cpus):
241 system.kvm_vm = KvmVM()
211
242
243 # Assign KVM CPUs to their own event queues / threads. This
244 # has to be done after creating caches and other child objects
245 # since these mustn't inherit the CPU event queue.
246 if len(cpus) > 1:
247 device_eq = 0
248 first_cpu_eq = 1
249 for idx, cpu in enumerate(cpus):
250 # Child objects usually inherit the parent's event
251 # queue. Override that and use the same event queue for
252 # all devices.
253 for obj in cpu.descendants():
254 obj.eventq_index = device_eq
255 cpu.eventq_index = first_cpu_eq + idx
256
257
258
212def instantiate(options, checkpoint_dir=None):
259def instantiate(options, checkpoint_dir=None):
260 # Setup the simulation quantum if we are running in PDES-mode
261 # (e.g., when using KVM)
262 root = Root.getInstance()
263 if root and _using_pdes(root):
264 m5.util.inform("Running in PDES mode with a %s simulation quantum.",
265 options.sim_quantum)
266 root.sim_quantum = _to_ticks(options.sim_quantum)
267
213 # Get and load from the chkpt or simpoint checkpoint
214 if options.restore_from:
215 if checkpoint_dir and not os.path.isabs(options.restore_from):
216 cpt = os.path.join(checkpoint_dir, options.restore_from)
217 else:
218 cpt = options.restore_from
219
220 m5.util.inform("Restoring from checkpoint %s", cpt)

--- 34 unchanged lines hidden ---
268 # Get and load from the chkpt or simpoint checkpoint
269 if options.restore_from:
270 if checkpoint_dir and not os.path.isabs(options.restore_from):
271 cpt = os.path.join(checkpoint_dir, options.restore_from)
272 else:
273 cpt = options.restore_from
274
275 m5.util.inform("Restoring from checkpoint %s", cpt)

--- 34 unchanged lines hidden ---