コード例 #1
0
ファイル: arm_generic.py プロジェクト: een5afr-public/gem5
    def create_system(self):
        sc = SysConfig(None, self.mem_size, None)
        system = FSConfig.makeArmSystem(self.mem_mode,
                                        self.machine_type, self.num_cpus,
                                        sc, False, ruby=self.use_ruby)

        # We typically want the simulator to panic if the kernel
        # panics or oopses. This prevents the simulator from running
        # an obviously failed test case until the end of time.
        system.panic_on_panic = True
        system.panic_on_oops = True

        default_kernels = {
            "RealViewPBX": "vmlinux.arm.smp.fb.2.6.38.8",
            "VExpress_EMM": "vmlinux.aarch32.ll_20131205.0-gem5",
            "VExpress_EMM64": "vmlinux.aarch64.20140821",
        }
        system.kernel = SysPaths.binary(default_kernels[self.machine_type])
        default_dtbs = {
           "RealViewPBX": None,
           "VExpress_EMM": "vexpress.aarch32.ll_20131205.0-gem5.{}cpu.dtb" \
             .format(self.num_cpus),
           "VExpress_EMM64": "vexpress.aarch64.20140821.dtb",
        }
        system.dtb_filename = SysPaths.binary(default_dtbs[self.machine_type])

        self.init_system(system)
        return system
コード例 #2
0
def createSystem(caches, kernel, bootscript, disks=[]):
    sys = devices.SimpleSystem(caches, default_mem_size,
                               kernel=SysPaths.binary(kernel),
                               readfile=bootscript,
                               machine_type="DTOnly")

    sys.mem_ctrls = SimpleMemory(range=sys._mem_range)
    sys.mem_ctrls.port = sys.membus.master

    sys.connect()

    # Attach disk images
    if disks:
        def cow_disk(image_file):
            image = CowDiskImage()
            image.child.image_file = SysPaths.disk(image_file)
            return image

        sys.disk_images = [ cow_disk(f) for f in disks ]
        sys.pci_vio_block = [ PciVirtIO(vio=VirtIOBlock(image=img))
                              for img in sys.disk_images ]
        for dev in sys.pci_vio_block:
            sys.attach_pci(dev)

    sys.realview.setupBootLoader(sys.membus, sys, SysPaths.binary)

    return sys
コード例 #3
0
def main():
    parser = argparse.ArgumentParser(
        description="Generic ARM big.LITTLE configuration")

    parser.add_argument("--restore-from", type=str, default=None,
                        help="Restore from checkpoint")
    parser.add_argument("--dtb", type=str, default=default_dtb,
                        help="DTB file to load")
    parser.add_argument("--kernel", type=str, default=default_kernel,
                        help="Linux kernel")
    parser.add_argument("--disk", action="append", type=str, default=[],
                        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("--kernel-init", type=str, default="/sbin/init",
                        help="Override init")
    parser.add_argument("--big-cpus", type=int, default=1,
                        help="Number of big CPUs to instantiate")
    parser.add_argument("--little-cpus", type=int, default=1,
                        help="Number of little CPUs to instantiate")
    parser.add_argument("--caches", action="store_true", default=False,
                        help="Instantiate caches")
    parser.add_argument("--last-cache-level", type=int, default=2,
                        help="Last level of caches (e.g. 3 for L3)")
    parser.add_argument("--big-cpu-clock", type=str, default="2GHz",
                        help="Big CPU clock frequency")
    parser.add_argument("--little-cpu-clock", type=str, default="1GHz",
                        help="Little CPU clock frequency")

    m5.ticks.fixGlobalFrequency()

    options = parser.parse_args()

    kernel_cmd = [
        "earlyprintk=pl011,0x1c090000",
        "console=ttyAMA0",
        "lpj=19988480",
        "norandmaps",
        "loglevel=8",
        "mem=%s" % default_mem_size,
        "root=/dev/vda1",
        "rw",
        "init=%s" % options.kernel_init,
        "vmalloc=768MB",
    ]

    root = Root(full_system=True)

    disks = [default_disk] if len(options.disk) == 0 else options.disk
    system = createSystem(options.caches,
                          options.kernel,
                          options.bootscript,
                          disks=disks)

    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 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()
    # little cluster
    if options.little_cpus > 0:
        if options.atomic:
            system.littleCluster = AtomicCluster(system, options.little_cpus,
                                                 options.little_cpu_clock)

        else:
            system.littleCluster = LittleCluster(system, options.little_cpus,
                                                 options.little_cpu_clock)
        mem_mode = system.littleCluster.memoryMode()

    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)
    if not options.caches:
        if options.big_cpus > 0 and system.bigCluster.requireCaches():
            m5.util.panic("Big CPU model requires caches")
        if options.little_cpus > 0 and system.littleCluster.requireCaches():
            m5.util.panic("Little CPU model requires caches")

    # Linux device tree
    system.dtb_filename = SysPaths.binary(options.dtb)

    # Get and load from the chkpt or simpoint checkpoint
    if options.restore_from is not None:
        m5.instantiate(options.restore_from)
    else:
        m5.instantiate()

    # start simulation (and drop checkpoints when requested)
    while True:
        event = m5.simulate()
        exit_msg = event.getCause()
        if exit_msg == "checkpoint":
            print "Dropping checkpoint at tick %d" % m5.curTick()
            cpt_dir = os.path.join(m5.options.outdir, "cpt.%d" % m5.curTick())
            m5.checkpoint(os.path.join(cpt_dir))
            print "Checkpoint done."
        else:
            print exit_msg, " @ ", m5.curTick()
            break

    sys.exit(event.getCode())
コード例 #4
0
def build(options):
    m5.ticks.fixGlobalFrequency()

    kernel_cmd = [
        "earlyprintk=pl011,0x1c090000",
        "console=ttyAMA0",
        "lpj=19988480",
        "norandmaps",
        "loglevel=8",
        "mem=%s" % default_mem_size,
        "root=/dev/vda1",
        "rw",
        "init=%s" % options.kernel_init,
        "vmalloc=768MB",
    ]

    root = Root(full_system=True)

    disks = [default_disk] if len(options.disk) == 0 else options.disk
    system = createSystem(options.caches,
                          options.kernel,
                          options.bootscript,
                          disks=disks)

    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 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()
    # little cluster
    if options.little_cpus > 0:
        if options.atomic:
            system.littleCluster = AtomicCluster(system, options.little_cpus,
                                                 options.little_cpu_clock)

        else:
            system.littleCluster = LittleCluster(system, options.little_cpus,
                                                 options.little_cpu_clock)
        mem_mode = system.littleCluster.memoryMode()

    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)
    if not options.caches:
        if options.big_cpus > 0 and system.bigCluster.requireCaches():
            m5.util.panic("Big CPU model requires caches")
        if options.little_cpus > 0 and system.littleCluster.requireCaches():
            m5.util.panic("Little CPU model requires caches")

    # Linux device tree
    system.dtb_filename = SysPaths.binary(options.dtb)

    return root
コード例 #5
0
def create(args):
    ''' Create and configure the system object. '''

    if args.script and not os.path.isfile(args.script):
        print("Error: Bootscript %s does not exist" % args.script)
        sys.exit(1)

    cpu_class = cpu_types[args.cpu][0]
    mem_mode = cpu_class.memory_mode()
    # Only simulate caches when using a timing CPU (e.g., the HPI model)
    want_caches = True if mem_mode == "timing" else False

    system = devices.simpleSystem(
        ArmSystem,
        want_caches,
        args.mem_size,
        mem_mode=mem_mode,
        workload=ArmFsLinux(object_file=SysPaths.binary(args.kernel)),
        readfile=args.script)

    MemConfig.config_mem(args, system)

    # Add the PCI devices we need for this system. The base system
    # doesn't have any PCI devices by default since they are assumed
    # to be added by the configurastion scripts needin them.
    system.pci_devices = [
        # Create a VirtIO block device for the system's boot
        # disk. Attach the disk image using gem5's Copy-on-Write
        # functionality to avoid writing changes to the stored copy of
        # the disk image.
        PciVirtIO(vio=VirtIOBlock(image=create_cow_image(args.disk_image))),
    ]

    # Attach the PCI devices to the system. The helper method in the
    # system assigns a unique PCI bus ID to each of the devices and
    # connects them to the IO bus.
    for dev in system.pci_devices:
        system.attach_pci(dev)

    # Wire up the system's memory system
    system.connect()

    # Add CPU clusters to the system
    system.cpu_cluster = [
        devices.CpuCluster(system, args.num_cores, args.cpu_freq, "1.0V",
                           *cpu_types[args.cpu]),
    ]

    # Create a cache hierarchy for the cluster. We are assuming that
    # clusters have core-private L1 caches and an L2 that's shared
    # within the cluster.
    for cluster in system.cpu_cluster:
        system.addCaches(want_caches, last_cache_level=2)

    # Setup gem5's minimal Linux boot loader.
    system.realview.setupBootLoader(system, SysPaths.binary)

    if args.dtb:
        system.workload.dtb_filename = args.dtb
    else:
        # No DTB specified: autogenerate DTB
        system.workload.dtb_filename = \
            os.path.join(m5.options.outdir, 'system.dtb')
        system.generateDtb(system.workload.dtb_filename)

    # Linux boot command flags
    kernel_cmd = [
        # Tell Linux to use the simulated serial port as a console
        "console=ttyAMA0",
        # Hard-code timi
        "lpj=19988480",
        # Disable address space randomisation to get a consistent
        # memory layout.
        "norandmaps",
        # Tell Linux where to find the root disk image.
        "root=/dev/vda",
        # Mount the root disk read-write by default.
        "rw",
        # Tell Linux about the amount of physical memory present.
        "mem=%s" % args.mem_size,
    ]
    system.workload.command_line = " ".join(kernel_cmd)

    return system
コード例 #6
0
def create_cow_image(name):
    """Helper function to create a Copy-on-Write disk image"""
    image = CowDiskImage()
    image.child.image_file = SysPaths.disk(name)

    return image
コード例 #7
0
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# Authors: Lisa Hsu

import m5
from m5.objects import *
m5.util.addToPath('../configs/')
from common import Benchmarks, FSConfig, SysPaths

test_sys = FSConfig.makeLinuxAlphaSystem('atomic',
    Benchmarks.SysConfig('netperf-stream-client.rcS'))
test_sys.kernel = SysPaths.binary('vmlinux')

# Dummy voltage domain for all test_sys clock domains
test_sys.voltage_domain = VoltageDomain()

# Create the system clock domain
test_sys.clk_domain = SrcClockDomain(clock = '1GHz',
                                     voltage_domain = test_sys.voltage_domain)

test_sys.cpu = AtomicSimpleCPU(cpu_id=0)
# create the interrupt controller
test_sys.cpu.createInterruptController()
test_sys.cpu.connectAllPorts(test_sys.membus)

# Create a seperate clock domain for components that should run at
# CPUs frequency
コード例 #8
0
# Set the default cache size and associativity to be very small to encourage
# races between requests and writebacks.
options.l1d_size="32kB"
options.l1i_size="32kB"
options.l2_size="4MB"
options.l1d_assoc=2
options.l1i_assoc=2
options.l2_assoc=2
options.num_cpus = 2

#the system
mdesc = SysConfig(disk = 'linux-x86.img')
system = FSConfig.makeLinuxX86System('timing', options.num_cpus,
                                     mdesc=mdesc, Ruby=True)
system.kernel = SysPaths.binary('x86_64-vmlinux-2.6.22.9')
# Dummy voltage domain for all our clock domains
system.voltage_domain = VoltageDomain(voltage = options.sys_voltage)

system.kernel = FSConfig.binary('x86_64-vmlinux-2.6.22.9.smp')
system.clk_domain = SrcClockDomain(clock = '1GHz',
                                   voltage_domain = system.voltage_domain)
system.cpu_clk_domain = SrcClockDomain(clock = '2GHz',
                                       voltage_domain = system.voltage_domain)
system.cpu = [TimingSimpleCPU(cpu_id=i, clk_domain = system.cpu_clk_domain)
              for i in range(options.num_cpus)]

Ruby.create_system(options, True, system, system.iobus, system._dma_ports)

# Create a seperate clock domain for Ruby
system.ruby.clk_domain = SrcClockDomain(clock = options.ruby_clock,
コード例 #9
0
ファイル: starter_fs.py プロジェクト: lvzhengxu1987/gem5
def create_cow_image(name):
    """Helper function to create a Copy-on-Write disk image"""
    image = CowDiskImage()
    image.child.image_file = SysPaths.disk(name)

    return image;
コード例 #10
0
ファイル: fs_bigLITTLE.py プロジェクト: YanMeng991/test
def main():
    parser = argparse.ArgumentParser(
        description="Generic ARM big.LITTLE configuration")

    parser.add_argument("--restore-from",
                        type=str,
                        default=None,
                        help="Restore from checkpoint")
    parser.add_argument("--dtb",
                        type=str,
                        default=default_dtb,
                        help="DTB file to load")
    parser.add_argument("--kernel",
                        type=str,
                        default=default_kernel,
                        help="Linux kernel")
    parser.add_argument("--disk",
                        action="append",
                        type=str,
                        default=[],
                        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("--kernel-init",
                        type=str,
                        default="/sbin/init",
                        help="Override init")
    parser.add_argument("--big-cpus",
                        type=int,
                        default=1,
                        help="Number of big CPUs to instantiate")
    parser.add_argument("--little-cpus",
                        type=int,
                        default=1,
                        help="Number of little CPUs to instantiate")
    parser.add_argument("--caches",
                        action="store_true",
                        default=False,
                        help="Instantiate caches")
    parser.add_argument("--last-cache-level",
                        type=int,
                        default=2,
                        help="Last level of caches (e.g. 3 for L3)")
    parser.add_argument("--big-cpu-clock",
                        type=str,
                        default="2GHz",
                        help="Big CPU clock frequency")
    parser.add_argument("--little-cpu-clock",
                        type=str,
                        default="1GHz",
                        help="Little CPU clock frequency")

    m5.ticks.fixGlobalFrequency()

    options = parser.parse_args()

    kernel_cmd = [
        "earlyprintk=pl011,0x1c090000",
        "console=ttyAMA0",
        "lpj=19988480",
        "norandmaps",
        "loglevel=8",
        "mem=%s" % default_mem_size,
        "root=/dev/vda1",
        "rw",
        "init=%s" % options.kernel_init,
        "vmalloc=768MB",
    ]

    root = Root(full_system=True)

    disks = default_disk if len(options.disk) == 0 else options.disk
    system = createSystem(options.kernel, options.bootscript, disks=disks)

    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 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()
    # little cluster
    if options.little_cpus > 0:
        if options.atomic:
            system.littleCluster = AtomicCluster(system, options.little_cpus,
                                                 options.little_cpu_clock)

        else:
            system.littleCluster = LittleCluster(system, options.little_cpus,
                                                 options.little_cpu_clock)
        mem_mode = system.littleCluster.memoryMode()

    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)
    if not options.caches:
        if options.big_cpus > 0 and system.bigCluster.requireCaches():
            m5.util.panic("Big CPU model requires caches")
        if options.little_cpus > 0 and system.littleCluster.requireCaches():
            m5.util.panic("Little CPU model requires caches")

    # Linux device tree
    system.dtb_filename = SysPaths.binary(options.dtb)

    # Get and load from the chkpt or simpoint checkpoint
    if options.restore_from is not None:
        m5.instantiate(options.restore_from)
    else:
        m5.instantiate()

    # start simulation (and drop checkpoints when requested)
    while True:
        event = m5.simulate()
        exit_msg = event.getCause()
        if exit_msg == "checkpoint":
            print "Dropping checkpoint at tick %d" % m5.curTick()
            cpt_dir = os.path.join(m5.options.outdir, "cpt.%d" % m5.curTick())
            m5.checkpoint(os.path.join(cpt_dir))
            print "Checkpoint done."
        else:
            print exit_msg, " @ ", m5.curTick()
            break

    sys.exit(event.getCode())
コード例 #11
0
# races between requests and writebacks.
options.l1d_size = "32kB"
options.l1i_size = "32kB"
options.l2_size = "4MB"
options.l1d_assoc = 2
options.l1i_assoc = 2
options.l2_assoc = 2
options.num_cpus = 2

#the system
mdesc = SysConfig(disks=['linux-x86.img'])
system = FSConfig.makeLinuxX86System('timing',
                                     options.num_cpus,
                                     mdesc=mdesc,
                                     Ruby=True)
system.kernel = SysPaths.binary('x86_64-vmlinux-2.6.22.9')
# Dummy voltage domain for all our clock domains
system.voltage_domain = VoltageDomain(voltage=options.sys_voltage)

system.kernel = FSConfig.binary('x86_64-vmlinux-2.6.22.9.smp')
system.clk_domain = SrcClockDomain(clock='1GHz',
                                   voltage_domain=system.voltage_domain)
system.cpu_clk_domain = SrcClockDomain(clock='2GHz',
                                       voltage_domain=system.voltage_domain)
system.cpu = [
    TimingSimpleCPU(cpu_id=i, clk_domain=system.cpu_clk_domain)
    for i in range(options.num_cpus)
]

Ruby.create_system(options, True, system, system.iobus, system._dma_ports)
コード例 #12
0
ファイル: fs_bigLITTLE.py プロジェクト: ozturkosu/gem5-1
def build(options):
    m5.ticks.fixGlobalFrequency()

    kernel_cmd = [
        "earlyprintk=pl011,0x1c090000",
        "console=ttyAMA0",
        "lpj=19988480",
        "norandmaps",
        "loglevel=8",
        "mem=%s" % default_mem_size,
        "root=/dev/vda1",
        "rw",
        "init=%s" % options.kernel_init,
        "vmalloc=768MB",
    ]

    root = Root(full_system=True)

    disks = [default_disk] if len(options.disk) == 0 else options.disk
    system = createSystem(options.caches,
                          options.kernel,
                          options.bootscript,
                          disks=disks)

    root.system = system
    system.boot_osflags = " ".join(kernel_cmd)

    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:
        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:
        system.littleCluster = little_model(system, options.little_cpus,
                                            options.little_cpu_clock)
        system.mem_mode = system.littleCluster.memoryMode()
        all_cpus += system.littleCluster.cpus

    # 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")

    # create caches
    system.addCaches(options.caches, options.last_cache_level)
    if not options.caches:
        if options.big_cpus > 0 and system.bigCluster.requireCaches():
            m5.util.panic("Big CPU model requires caches")
        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
コード例 #13
0
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# Authors: Lisa Hsu

import m5
from m5.objects import *
m5.util.addToPath('../configs/')
from common import Benchmarks, FSConfig, SysPaths

test_sys = makeLinuxAlphaSystem('atomic',
                                SysConfig('netperf-stream-client.rcS'))
test_sys.kernel = SysPaths.binary('vmlinux')

# Dummy voltage domain for all test_sys clock domains
test_sys.voltage_domain = VoltageDomain()

# Create the system clock domain
test_sys.clk_domain = SrcClockDomain(clock='1GHz',
                                     voltage_domain=test_sys.voltage_domain)

test_sys.cpu = AtomicSimpleCPU(cpu_id=0)
# create the interrupt controller
test_sys.cpu.createInterruptController()
test_sys.cpu.connectAllPorts(test_sys.membus)

# Create a seperate clock domain for components that should run at
# CPUs frequency
コード例 #14
0
def build(options):
    m5.ticks.fixGlobalFrequency()

    kernel_cmd = [
        "earlyprintk",
        "earlycon=pl011,0x1c090000",
        "console=ttyAMA0",
        "lpj=19988480",
        "norandmaps",
        "loglevel=8",
        "mem=%s" % options.mem_size,
        "root=%s" % options.root,
        "rw",
        "init=%s" % options.kernel_init,
        "vmalloc=768MB",
    ]

    root = Root(full_system=True)

    disks = [default_disk] if len(options.disk) == 0 else options.disk
    system = createSystem(options.caches,
                          options.kernel,
                          options.bootscript,
                          options.machine_type,
                          disks=disks,
                          mem_size=options.mem_size,
                          bootloader=options.bootloader)

    root.system = system
    if options.kernel_cmd:
        system.workload.command_line = options.kernel_cmd
    else:
        system.workload.command_line = " ".join(kernel_cmd)

    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:
        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:
        system.littleCluster = little_model(system, options.little_cpus,
                                            options.little_cpu_clock)
        system.mem_mode = system.littleCluster.memoryMode()
        all_cpus += system.littleCluster.cpus

    # Figure out the memory mode
    if options.big_cpus > 0 and options.little_cpus > 0 and \
       system.bigCluster.memoryMode() != system.littleCluster.memoryMode():
        m5.util.panic("Memory mode missmatch among CPU clusters")

    # create caches
    system.addCaches(options.caches, options.last_cache_level)
    if not options.caches:
        if options.big_cpus > 0 and system.bigCluster.requireCaches():
            m5.util.panic("Big CPU model requires caches")
        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(options, system, all_cpus)

    # Linux device tree
    if options.dtb is not None:
        system.workload.dtb_filename = SysPaths.binary(options.dtb)
    else:
        system.workload.dtb_filename = \
            os.path.join(m5.options.outdir, 'system.dtb')
        system.generateDtb(system.workload.dtb_filename)

    if devices.have_fastmodel and issubclass(big_model, FastmodelCluster):
        from m5 import arm_fast_model as fm, systemc as sc
        # setup FastModels for simulation
        fm.setup_simulation("cortexa76")
        # setup SystemC
        root.systemc_kernel = m5.objects.SystemC_Kernel()
        m5.tlm.tlm_global_quantum_instance().set(
            sc.sc_time(10000.0 / 100000000.0, sc.sc_time.SC_SEC))

    if options.vio_9p:
        FSConfig.attach_9p(system.realview, system.iobus)

    return root
コード例 #15
0
ファイル: fs_bigLITTLE.py プロジェクト: een5afr-public/gem5
def build(options):
    m5.ticks.fixGlobalFrequency()

    kernel_cmd = [
        "earlyprintk=pl011,0x1c090000",
        "console=ttyAMA0",
        "lpj=19988480",
        "norandmaps",
        "loglevel=8",
        "mem=%s" % default_mem_size,
        "root=/dev/vda1",
        "rw",
        "init=%s" % options.kernel_init,
        "vmalloc=768MB",
    ]

    root = Root(full_system=True)

    disks = [default_disk] if len(options.disk) == 0 else options.disk
    system = createSystem(options.caches,
                          options.kernel,
                          options.bootscript,
                          disks=disks)

    root.system = system
    system.boot_osflags = " ".join(kernel_cmd)

    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:
        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:
        system.littleCluster = little_model(system, options.little_cpus,
                                            options.little_cpu_clock)
        system.mem_mode = system.littleCluster.memoryMode()
        all_cpus += system.littleCluster.cpus

    # 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")


    # create caches
    system.addCaches(options.caches, options.last_cache_level)
    if not options.caches:
        if options.big_cpus > 0 and system.bigCluster.requireCaches():
            m5.util.panic("Big CPU model requires caches")
        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
    if options.dtb is not None:
        system.dtb_filename = SysPaths.binary(options.dtb)
    else:
        system.generateDtb(m5.options.outdir, 'system.dtb')

    return root
コード例 #16
0
ファイル: arm_fs.py プロジェクト: ChenBoya-prj/gem5_cfg
def build(options):
    m5.ticks.fixGlobalFrequency()

    kernel_cmd = [
        "earlyprintk=pl011,0x1c090000",
        "console=ttyAMA0",
        "lpj=19988480",
        "norandmaps",
        "loglevel=8",
        "mem=%s" % options.mem_size,
        "root=%s" % options.root,
        "rw",
        "init=%s" % options.kernel_init,
        "vmalloc=768MB",
    ]

    root = Root(full_system=True)

    disks = [default_disk] if len(options.disk) == 0 else options.disk
    system = createSystem(options.caches,
                          options.kernel,
                          options.bootscript,
                          options.machine_type,
                          disks=disks,
                          mem_size=options.mem_size,
                          bootloader=options.bootloader)

    root.system = system
    if options.kernel_cmd:
        system.boot_osflags = options.kernel_cmd
    else:
        system.boot_osflags = " ".join(kernel_cmd)

    if options.big_cpus + options.little_cpus + options.mid_cpus == 0:
        m5.util.panic("Empty CPU clusters")

    big_model, mid_model, little_model = cpu_types[options.cpu_type]
    sw_big_cpu, sw_mid_cpu, sw_little_cpu = sw_cpu_types[options.sw_cpu_type]
    all_cpus = []
    sw_all_cpus = []

    if options.big_cpus > 0:
        system.bigCluster = big_model(system, options.big_cpus,
                                      options.big_cpu_clock)
        system.mem_mode = system.bigCluster.memoryMode()
        all_cpus += system.bigCluster.cpus

        cpu_class_tmp = ObjectList.cpu_list.get(sw_big_cpu)
        big_sw_cpus = [
            cpu_class_tmp(switched_out=True, cpu_id=(i))
            for i in range(options.big_cpus)
        ]
        for i in range(options.big_cpus):
            if options.fast_forward:
                system.bigCluster.cpus[i].max_insts_any_thread = int(
                    options.fast_forward)
            big_sw_cpus[i].system = system
            big_sw_cpus[i].workload = system.bigCluster.cpus[i].workload
            big_sw_cpus[i].clk_domain = system.bigCluster.cpus[i].clk_domain
            big_sw_cpus[i].progress_interval = system.bigCluster.cpus[
                i].progress_interval
            big_sw_cpus[i].isa = system.bigCluster.cpus[i].isa
        system.bigCluster.switch_cpus = big_sw_cpus

    if options.mid_cpus > 0:
        system.midCluster = mid_model(system, options.mid_cpus,
                                      options.mid_cpu_clock)
        system.mem_mode = system.midCluster.memoryMode()
        all_cpus += system.midCluster.cpus

        cpu_class_tmp = ObjectList.cpu_list.get(sw_mid_cpu)
        mid_sw_cpus = [
            cpu_class_tmp(switched_out=True, cpu_id=(i + options.big_cpus))
            for i in range(options.mid_cpus)
        ]
        for i in range(options.mid_cpus):
            if options.fast_forward:
                system.midCluster.cpus[i].max_insts_any_thread = int(
                    options.fast_forward)
            mid_sw_cpus[i].system = system
            mid_sw_cpus[i].workload = system.midCluster.cpus[i].workload
            mid_sw_cpus[i].clk_domain = system.midCluster.cpus[i].clk_domain
            mid_sw_cpus[i].progress_interval = system.midCluster.cpus[
                i].progress_interval
            mid_sw_cpus[i].isa = system.midCluster.cpus[i].isa
        system.midCluster.switch_cpus = mid_sw_cpus

    if options.little_cpus > 0:
        system.littleCluster = little_model(system, options.little_cpus,
                                            options.little_cpu_clock)
        system.mem_mode = system.littleCluster.memoryMode()
        all_cpus += system.littleCluster.cpus

        cpu_class_tmp = ObjectList.cpu_list.get(sw_little_cpu)
        little_sw_cpus = [
            cpu_class_tmp(switched_out=True,
                          cpu_id=(i + options.big_cpus + options.mid_cpus))
            for i in range(options.little_cpus)
        ]
        for i in range(options.little_cpus):
            if options.fast_forward:
                system.littleCluster.cpus[i].max_insts_any_thread = int(
                    options.fast_forward)
            little_sw_cpus[i].system = system
            little_sw_cpus[i].workload = system.littleCluster.cpus[i].workload
            little_sw_cpus[i].clk_domain = system.littleCluster.cpus[
                i].clk_domain
            little_sw_cpus[i].progress_interval = system.littleCluster.cpus[
                i].progress_interval
            little_sw_cpus[i].isa = system.littleCluster.cpus[i].isa
        system.littleCluster.switch_cpus = little_sw_cpus

    system.addCaches(options.caches)
    if not options.caches:
        if options.big_cpus > 0 and system.bigCluster.requireCaches():
            m5.util.panic("Big CPU model requires caches")
        if options.mid_cpus > 0 and system.bigCluster.requireCaches():
            m5.util.panic("Mid CPU model requires caches")
        if options.little_cpus > 0 and system.littleCluster.requireCaches():
            m5.util.panic("Little CPU model requires caches")

    if issubclass(big_model, KvmCluster):
        _build_kvm(system, all_cpus)

    # Linux device tree
    if options.dtb is not None:
        system.dtb_filename = SysPaths.binary(options.dtb)
    else:
        system.generateDtb(m5.options.outdir, 'system.dtb')

    if options.vio_9p:
        FSConfig.attach_9p(system.realview, system.iobus)

    return root
コード例 #17
0
 def cow_disk(image_file):
     image = CowDiskImage()
     image.child.image_file = SysPaths.disk(image_file)
     return image
コード例 #18
0
ファイル: fs_bigLITTLE.py プロジェクト: YanMeng991/test
 def cow_disk(image_file):
     image = CowDiskImage()
     image.child.image_file = SysPaths.disk(image_file)
     return image
コード例 #19
0
ファイル: starter_fs.py プロジェクト: lvzhengxu1987/gem5
def create(args):
    ''' Create and configure the system object. '''

    if not args.dtb:
        dtb_file = SysPaths.binary("armv8_gem5_v1_%icpu.%s.dtb" %
                                   (args.num_cores, default_dist_version))
    else:
        dtb_file = args.dtb

    if args.script and not os.path.isfile(args.script):
        print "Error: Bootscript %s does not exist" % args.script
        sys.exit(1)

    cpu_class = cpu_types[args.cpu][0]
    mem_mode = cpu_class.memory_mode()
    # Only simulate caches when using a timing CPU (e.g., the HPI model)
    want_caches = True if mem_mode == "timing" else False

    system = devices.SimpleSystem(want_caches,
                                  args.mem_size,
                                  mem_mode=mem_mode,
                                  dtb_filename=dtb_file,
                                  kernel=SysPaths.binary(args.kernel),
                                  readfile=args.script,
                                  machine_type="DTOnly")

    MemConfig.config_mem(args, system)

    # Add the PCI devices we need for this system. The base system
    # doesn't have any PCI devices by default since they are assumed
    # to be added by the configurastion scripts needin them.
    system.pci_devices = [
        # Create a VirtIO block device for the system's boot
        # disk. Attach the disk image using gem5's Copy-on-Write
        # functionality to avoid writing changes to the stored copy of
        # the disk image.
        PciVirtIO(vio=VirtIOBlock(image=create_cow_image(args.disk_image))),
    ]

    # Attach the PCI devices to the system. The helper method in the
    # system assigns a unique PCI bus ID to each of the devices and
    # connects them to the IO bus.
    for dev in system.pci_devices:
        system.attach_pci(dev)

    # Wire up the system's memory system
    system.connect()

    # Add CPU clusters to the system
    system.cpu_cluster = [
        devices.CpuCluster(system,
                           args.num_cores,
                           args.cpu_freq, "1.0V",
                           *cpu_types[args.cpu]),
    ]

    # Create a cache hierarchy for the cluster. We are assuming that
    # clusters have core-private L1 caches and an L2 that's shared
    # within the cluster.
    for cluster in system.cpu_cluster:
        system.addCaches(want_caches, last_cache_level=2)

    # Setup gem5's minimal Linux boot loader.
    system.realview.setupBootLoader(system.membus, system, SysPaths.binary)

    # Linux boot command flags
    kernel_cmd = [
        # Tell Linux to use the simulated serial port as a console
        "console=ttyAMA0",
        # Hard-code timi
        "lpj=19988480",
        # Disable address space randomisation to get a consistent
        # memory layout.
        "norandmaps",
        # Tell Linux where to find the root disk image.
        "root=/dev/vda1",
        # Mount the root disk read-write by default.
        "rw",
        # Tell Linux about the amount of physical memory present.
        "mem=%s" % args.mem_size,
    ]
    system.boot_osflags = " ".join(kernel_cmd)

    return system
コード例 #20
0
ファイル: alpha_generic.py プロジェクト: mrunalkp/cs251
 def create_system(self):
     system = FSConfig.makeLinuxAlphaSystem(self.mem_mode)
     system.kernel = SysPaths.binary('vmlinux')
     self.init_system(system)
     return system