fs_bigLITTLE.py revision 11682
111569Sgabor.dozsa@arm.com# Copyright (c) 2016 ARM Limited 211569Sgabor.dozsa@arm.com# All rights reserved. 311569Sgabor.dozsa@arm.com# 411569Sgabor.dozsa@arm.com# The license below extends only to copyright in the software and shall 511569Sgabor.dozsa@arm.com# not be construed as granting a license to any other intellectual 611569Sgabor.dozsa@arm.com# property including but not limited to intellectual property relating 711569Sgabor.dozsa@arm.com# to a hardware implementation of the functionality of the software 811569Sgabor.dozsa@arm.com# licensed hereunder. You may use the software subject to the license 911569Sgabor.dozsa@arm.com# terms below provided that you ensure that this notice is replicated 1011569Sgabor.dozsa@arm.com# unmodified and in its entirety in all distributions of the software, 1111569Sgabor.dozsa@arm.com# modified or unmodified, in source code or in binary form. 1211569Sgabor.dozsa@arm.com# 1311569Sgabor.dozsa@arm.com# Redistribution and use in source and binary forms, with or without 1411569Sgabor.dozsa@arm.com# modification, are permitted provided that the following conditions are 1511569Sgabor.dozsa@arm.com# met: redistributions of source code must retain the above copyright 1611569Sgabor.dozsa@arm.com# notice, this list of conditions and the following disclaimer; 1711569Sgabor.dozsa@arm.com# redistributions in binary form must reproduce the above copyright 1811569Sgabor.dozsa@arm.com# notice, this list of conditions and the following disclaimer in the 1911569Sgabor.dozsa@arm.com# documentation and/or other materials provided with the distribution; 2011569Sgabor.dozsa@arm.com# neither the name of the copyright holders nor the names of its 2111569Sgabor.dozsa@arm.com# contributors may be used to endorse or promote products derived from 2211569Sgabor.dozsa@arm.com# this software without specific prior written permission. 2311569Sgabor.dozsa@arm.com# 2411569Sgabor.dozsa@arm.com# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 2511569Sgabor.dozsa@arm.com# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 2611569Sgabor.dozsa@arm.com# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 2711569Sgabor.dozsa@arm.com# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 2811569Sgabor.dozsa@arm.com# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 2911569Sgabor.dozsa@arm.com# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 3011569Sgabor.dozsa@arm.com# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 3111569Sgabor.dozsa@arm.com# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 3211569Sgabor.dozsa@arm.com# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 3311569Sgabor.dozsa@arm.com# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 3411569Sgabor.dozsa@arm.com# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 3511569Sgabor.dozsa@arm.com# 3611569Sgabor.dozsa@arm.com# Authors: Gabor Dozsa 3711569Sgabor.dozsa@arm.com# Andreas Sandberg 3811569Sgabor.dozsa@arm.com 3911569Sgabor.dozsa@arm.com# This is an example configuration script for full system simulation of 4011569Sgabor.dozsa@arm.com# a generic ARM bigLITTLE system. 4111569Sgabor.dozsa@arm.com 4211569Sgabor.dozsa@arm.com 4311569Sgabor.dozsa@arm.comimport argparse 4411569Sgabor.dozsa@arm.comimport os 4511569Sgabor.dozsa@arm.comimport sys 4611569Sgabor.dozsa@arm.comimport m5 4711569Sgabor.dozsa@arm.comfrom m5.objects import * 4811569Sgabor.dozsa@arm.com 4911682Sandreas.hansson@arm.comm5.util.addToPath("../../") 5011682Sandreas.hansson@arm.com 5111682Sandreas.hansson@arm.comfrom common import SysPaths 5211682Sandreas.hansson@arm.comfrom common import CpuConfig 5311569Sgabor.dozsa@arm.com 5411569Sgabor.dozsa@arm.comimport devices 5511569Sgabor.dozsa@arm.com 5611569Sgabor.dozsa@arm.com 5711569Sgabor.dozsa@arm.comdefault_dtb = 'armv8_gem5_v1_big_little_2_2.dtb' 5811569Sgabor.dozsa@arm.comdefault_kernel = 'vmlinux4.3.aarch64' 5911569Sgabor.dozsa@arm.comdefault_disk = 'aarch64-ubuntu-trusty-headless.img' 6011569Sgabor.dozsa@arm.comdefault_rcs = 'bootscript.rcS' 6111569Sgabor.dozsa@arm.com 6211569Sgabor.dozsa@arm.comdefault_mem_size= "2GB" 6311569Sgabor.dozsa@arm.com 6411630Sgabor.dozsa@arm.com 6511630Sgabor.dozsa@arm.comclass BigCluster(devices.CpuCluster): 6611630Sgabor.dozsa@arm.com def __init__(self, system, num_cpus, cpu_clock, 6711630Sgabor.dozsa@arm.com cpu_voltage="1.0V"): 6811630Sgabor.dozsa@arm.com cpu_config = [ CpuConfig.get("arm_detailed"), devices.L1I, devices.L1D, 6911630Sgabor.dozsa@arm.com devices.WalkCache, devices.L2 ] 7011630Sgabor.dozsa@arm.com super(BigCluster, self).__init__(system, num_cpus, cpu_clock, 7111630Sgabor.dozsa@arm.com cpu_voltage, *cpu_config) 7211630Sgabor.dozsa@arm.com 7311630Sgabor.dozsa@arm.comclass LittleCluster(devices.CpuCluster): 7411630Sgabor.dozsa@arm.com def __init__(self, system, num_cpus, cpu_clock, 7511630Sgabor.dozsa@arm.com cpu_voltage="1.0V"): 7611630Sgabor.dozsa@arm.com cpu_config = [ CpuConfig.get("minor"), devices.L1I, devices.L1D, 7711630Sgabor.dozsa@arm.com devices.WalkCache, devices.L2 ] 7811630Sgabor.dozsa@arm.com super(LittleCluster, self).__init__(system, num_cpus, cpu_clock, 7911630Sgabor.dozsa@arm.com cpu_voltage, *cpu_config) 8011630Sgabor.dozsa@arm.com 8111630Sgabor.dozsa@arm.com 8211630Sgabor.dozsa@arm.comdef createSystem(kernel, bootscript, disks=[]): 8311569Sgabor.dozsa@arm.com sys = devices.SimpleSystem(kernel=SysPaths.binary(kernel), 8411569Sgabor.dozsa@arm.com readfile=bootscript, 8511569Sgabor.dozsa@arm.com machine_type="DTOnly") 8611569Sgabor.dozsa@arm.com 8711569Sgabor.dozsa@arm.com mem_region = sys.realview._mem_regions[0] 8811569Sgabor.dozsa@arm.com sys.mem_ctrls = SimpleMemory( 8911569Sgabor.dozsa@arm.com range=AddrRange(start=mem_region[0], size=default_mem_size)) 9011569Sgabor.dozsa@arm.com sys.mem_ctrls.port = sys.membus.master 9111569Sgabor.dozsa@arm.com 9211569Sgabor.dozsa@arm.com sys.connect() 9311569Sgabor.dozsa@arm.com 9411569Sgabor.dozsa@arm.com # Attach disk images 9511569Sgabor.dozsa@arm.com if disks: 9611569Sgabor.dozsa@arm.com def cow_disk(image_file): 9711569Sgabor.dozsa@arm.com image = CowDiskImage() 9811569Sgabor.dozsa@arm.com image.child.image_file = SysPaths.disk(image_file) 9911569Sgabor.dozsa@arm.com return image 10011569Sgabor.dozsa@arm.com 10111569Sgabor.dozsa@arm.com sys.disk_images = [ cow_disk(f) for f in disks ] 10211569Sgabor.dozsa@arm.com sys.pci_vio_block = [ PciVirtIO(vio=VirtIOBlock(image=img)) 10311569Sgabor.dozsa@arm.com for img in sys.disk_images ] 10411569Sgabor.dozsa@arm.com for dev in sys.pci_vio_block: 10511569Sgabor.dozsa@arm.com sys.attach_pci(dev) 10611569Sgabor.dozsa@arm.com 10711569Sgabor.dozsa@arm.com sys.realview.setupBootLoader(sys.membus, sys, SysPaths.binary) 10811569Sgabor.dozsa@arm.com 10911569Sgabor.dozsa@arm.com return sys 11011569Sgabor.dozsa@arm.com 11111569Sgabor.dozsa@arm.com 11211569Sgabor.dozsa@arm.comdef main(): 11311569Sgabor.dozsa@arm.com parser = argparse.ArgumentParser( 11411569Sgabor.dozsa@arm.com description="Generic ARM big.LITTLE configuration") 11511569Sgabor.dozsa@arm.com 11611569Sgabor.dozsa@arm.com parser.add_argument("--restore-from", type=str, default=None, 11711569Sgabor.dozsa@arm.com help="Restore from checkpoint") 11811569Sgabor.dozsa@arm.com parser.add_argument("--dtb", type=str, default=default_dtb, 11911569Sgabor.dozsa@arm.com help="DTB file to load") 12011569Sgabor.dozsa@arm.com parser.add_argument("--kernel", type=str, default=default_kernel, 12111569Sgabor.dozsa@arm.com help="Linux kernel") 12211569Sgabor.dozsa@arm.com parser.add_argument("--disk", action="append", type=str, default=[], 12311569Sgabor.dozsa@arm.com help="Disks to instantiate") 12411569Sgabor.dozsa@arm.com parser.add_argument("--bootscript", type=str, default=default_rcs, 12511569Sgabor.dozsa@arm.com help="Linux bootscript") 12611569Sgabor.dozsa@arm.com parser.add_argument("--atomic", action="store_true", default=False, 12711569Sgabor.dozsa@arm.com help="Use atomic CPUs") 12811569Sgabor.dozsa@arm.com parser.add_argument("--kernel-init", type=str, default="/sbin/init", 12911569Sgabor.dozsa@arm.com help="Override init") 13011569Sgabor.dozsa@arm.com parser.add_argument("--big-cpus", type=int, default=1, 13111569Sgabor.dozsa@arm.com help="Number of big CPUs to instantiate") 13211569Sgabor.dozsa@arm.com parser.add_argument("--little-cpus", type=int, default=1, 13311569Sgabor.dozsa@arm.com help="Number of little CPUs to instantiate") 13411569Sgabor.dozsa@arm.com parser.add_argument("--caches", action="store_true", default=False, 13511569Sgabor.dozsa@arm.com help="Instantiate caches") 13611569Sgabor.dozsa@arm.com parser.add_argument("--last-cache-level", type=int, default=2, 13711569Sgabor.dozsa@arm.com help="Last level of caches (e.g. 3 for L3)") 13811569Sgabor.dozsa@arm.com parser.add_argument("--big-cpu-clock", type=str, default="2GHz", 13911569Sgabor.dozsa@arm.com help="Big CPU clock frequency") 14011569Sgabor.dozsa@arm.com parser.add_argument("--little-cpu-clock", type=str, default="1GHz", 14111569Sgabor.dozsa@arm.com help="Little CPU clock frequency") 14211569Sgabor.dozsa@arm.com 14311569Sgabor.dozsa@arm.com m5.ticks.fixGlobalFrequency() 14411569Sgabor.dozsa@arm.com 14511569Sgabor.dozsa@arm.com options = parser.parse_args() 14611569Sgabor.dozsa@arm.com 14711569Sgabor.dozsa@arm.com kernel_cmd = [ 14811569Sgabor.dozsa@arm.com "earlyprintk=pl011,0x1c090000", 14911569Sgabor.dozsa@arm.com "console=ttyAMA0", 15011569Sgabor.dozsa@arm.com "lpj=19988480", 15111569Sgabor.dozsa@arm.com "norandmaps", 15211569Sgabor.dozsa@arm.com "loglevel=8", 15311569Sgabor.dozsa@arm.com "mem=%s" % default_mem_size, 15411569Sgabor.dozsa@arm.com "root=/dev/vda1", 15511569Sgabor.dozsa@arm.com "rw", 15611569Sgabor.dozsa@arm.com "init=%s" % options.kernel_init, 15711569Sgabor.dozsa@arm.com "vmalloc=768MB", 15811569Sgabor.dozsa@arm.com ] 15911569Sgabor.dozsa@arm.com 16011569Sgabor.dozsa@arm.com root = Root(full_system=True) 16111569Sgabor.dozsa@arm.com 16211569Sgabor.dozsa@arm.com disks = default_disk if len(options.disk) == 0 else options.disk 16311630Sgabor.dozsa@arm.com system = createSystem(options.kernel, options.bootscript, disks=disks) 16411569Sgabor.dozsa@arm.com 16511569Sgabor.dozsa@arm.com root.system = system 16611569Sgabor.dozsa@arm.com system.boot_osflags = " ".join(kernel_cmd) 16711569Sgabor.dozsa@arm.com 16811630Sgabor.dozsa@arm.com AtomicCluster = devices.AtomicCluster 16911630Sgabor.dozsa@arm.com 17011630Sgabor.dozsa@arm.com if options.big_cpus + options.little_cpus == 0: 17111630Sgabor.dozsa@arm.com m5.util.panic("Empty CPU clusters") 17211630Sgabor.dozsa@arm.com 17311569Sgabor.dozsa@arm.com # big cluster 17411569Sgabor.dozsa@arm.com if options.big_cpus > 0: 17511630Sgabor.dozsa@arm.com if options.atomic: 17611630Sgabor.dozsa@arm.com system.bigCluster = AtomicCluster(system, options.big_cpus, 17711630Sgabor.dozsa@arm.com options.big_cpu_clock) 17811630Sgabor.dozsa@arm.com else: 17911630Sgabor.dozsa@arm.com system.bigCluster = BigCluster(system, options.big_cpus, 18011630Sgabor.dozsa@arm.com options.big_cpu_clock) 18111630Sgabor.dozsa@arm.com mem_mode = system.bigCluster.memoryMode() 18211630Sgabor.dozsa@arm.com # little cluster 18311630Sgabor.dozsa@arm.com if options.little_cpus > 0: 18411630Sgabor.dozsa@arm.com if options.atomic: 18511630Sgabor.dozsa@arm.com system.littleCluster = AtomicCluster(system, options.little_cpus, 18611630Sgabor.dozsa@arm.com options.little_cpu_clock) 18711569Sgabor.dozsa@arm.com 18811630Sgabor.dozsa@arm.com else: 18911630Sgabor.dozsa@arm.com system.littleCluster = LittleCluster(system, options.little_cpus, 19011630Sgabor.dozsa@arm.com options.little_cpu_clock) 19111630Sgabor.dozsa@arm.com mem_mode = system.littleCluster.memoryMode() 19211569Sgabor.dozsa@arm.com 19311630Sgabor.dozsa@arm.com if options.big_cpus > 0 and options.little_cpus > 0: 19411630Sgabor.dozsa@arm.com if system.bigCluster.memoryMode() != system.littleCluster.memoryMode(): 19511630Sgabor.dozsa@arm.com m5.util.panic("Memory mode missmatch among CPU clusters") 19611630Sgabor.dozsa@arm.com system.mem_mode = mem_mode 19711569Sgabor.dozsa@arm.com 19811630Sgabor.dozsa@arm.com # create caches 19911630Sgabor.dozsa@arm.com system.addCaches(options.caches, options.last_cache_level) 20011630Sgabor.dozsa@arm.com if not options.caches: 20111630Sgabor.dozsa@arm.com if options.big_cpus > 0 and system.bigCluster.requireCaches(): 20211630Sgabor.dozsa@arm.com m5.util.panic("Big CPU model requires caches") 20311630Sgabor.dozsa@arm.com if options.little_cpus > 0 and system.littleCluster.requireCaches(): 20411630Sgabor.dozsa@arm.com m5.util.panic("Little CPU model requires caches") 20511569Sgabor.dozsa@arm.com 20611569Sgabor.dozsa@arm.com # Linux device tree 20711569Sgabor.dozsa@arm.com system.dtb_filename = SysPaths.binary(options.dtb) 20811569Sgabor.dozsa@arm.com 20911569Sgabor.dozsa@arm.com # Get and load from the chkpt or simpoint checkpoint 21011569Sgabor.dozsa@arm.com if options.restore_from is not None: 21111569Sgabor.dozsa@arm.com m5.instantiate(options.restore_from) 21211569Sgabor.dozsa@arm.com else: 21311569Sgabor.dozsa@arm.com m5.instantiate() 21411569Sgabor.dozsa@arm.com 21511569Sgabor.dozsa@arm.com # start simulation (and drop checkpoints when requested) 21611569Sgabor.dozsa@arm.com while True: 21711569Sgabor.dozsa@arm.com event = m5.simulate() 21811569Sgabor.dozsa@arm.com exit_msg = event.getCause() 21911569Sgabor.dozsa@arm.com if exit_msg == "checkpoint": 22011569Sgabor.dozsa@arm.com print "Dropping checkpoint at tick %d" % m5.curTick() 22111569Sgabor.dozsa@arm.com cpt_dir = os.path.join(m5.options.outdir, "cpt.%d" % m5.curTick()) 22211569Sgabor.dozsa@arm.com m5.checkpoint(os.path.join(cpt_dir)) 22311569Sgabor.dozsa@arm.com print "Checkpoint done." 22411569Sgabor.dozsa@arm.com else: 22511569Sgabor.dozsa@arm.com print exit_msg, " @ ", m5.curTick() 22611569Sgabor.dozsa@arm.com break 22711569Sgabor.dozsa@arm.com 22811569Sgabor.dozsa@arm.com sys.exit(event.getCode()) 22911569Sgabor.dozsa@arm.com 23011569Sgabor.dozsa@arm.com 23111569Sgabor.dozsa@arm.comif __name__ == "__m5_main__": 23211569Sgabor.dozsa@arm.com main() 233