arch-arm: Add arm demo board (#1478)

This demo board is a preset arm board, that can be used to run example
gem5 simulations. This board doesnt simulate any known hardware.

The board will be used to run benchmarks such as gapbs and npb to
collect stats. The plan is to show these stats on the gem5 resources
website to provide more details about the resources.
This commit is contained in:
Harshil Patel
2024-10-18 05:36:31 -07:00
committed by GitHub
parent cb5d14f753
commit 946bf83b75
3 changed files with 205 additions and 0 deletions

View File

@@ -0,0 +1,92 @@
# Copyright (c) 2024 The Regents of the University of California
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met: redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer;
# redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution;
# neither the name of the copyright holders nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# 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.
"""
This script further shows an example of booting an ARM based full system Ubuntu
disk image. This simulation boots the disk image using the ArmDemoBoard.
Usage
-----
```bash
scons build/ARM/gem5.opt -j $(nproc)
./build/ARM/gem5.opt configs/example/gem5_library/arm-demo-ubuntu-run.py
```
"""
import argparse
from gem5.isas import ISA
from gem5.prebuilt.demo.arm_demo_board import ArmDemoBoard
from gem5.resources.resource import obtain_resource
from gem5.simulate.exit_event import ExitEvent
from gem5.simulate.simulator import Simulator
from gem5.utils.requires import requires
# This runs a check to ensure the gem5 binary interpreting this file is compiled to include the ARM ISA.
requires(isa_required=ISA.ARM)
parser = argparse.ArgumentParser(
description="An example configuration script to run the ArmDemoBoard."
)
parser.add_argument(
"--use-kvm",
action="store_true",
help="Use KVM cores instead of Timing.",
)
args = parser.parse_args()
board = ArmDemoBoard(use_kvm=args.use_kvm)
board.set_workload(
obtain_resource(
"arm-ubuntu-24.04-boot-with-systemd", resource_version="2.0.0"
)
)
def exit_event_handler():
print("First exit: kernel booted")
yield False # gem5 is now executing systemd startup
print("Second exit: Started `after_boot.sh` script")
# The after_boot.sh script is executed after the kernel and systemd have
# booted.
yield False # gem5 is now executing the `after_boot.sh` script
print("Third exit: Finished `after_boot.sh` script")
# The after_boot.sh script will run a script if it is passed via
# m5 readfile. This is the last exit event before the simulation exits.
yield True
# We define the system with the aforementioned system defined.
simulator = Simulator(
board=board,
on_exit_event={
ExitEvent.EXIT: exit_event_handler(),
},
)
simulator.run()

View File

@@ -280,6 +280,7 @@ PySource('gem5.components.processors',
PySource('gem5.prebuilt', 'gem5/prebuilt/__init__.py')
PySource('gem5.prebuilt.demo', 'gem5/prebuilt/demo/__init__.py')
PySource('gem5.prebuilt.demo', 'gem5/prebuilt/demo/x86_demo_board.py')
PySource('gem5.prebuilt.demo', 'gem5/prebuilt/demo/arm_demo_board.py')
PySource('gem5.prebuilt.riscvmatched',
'gem5/prebuilt/riscvmatched/__init__.py')
PySource('gem5.prebuilt.riscvmatched',

View File

@@ -0,0 +1,112 @@
# Copyright (c) 2024 The Regents of the University of California
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met: redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer;
# redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution;
# neither the name of the copyright holders nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# 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.
from m5.objects import (
ArmDefaultRelease,
VExpress_GEM5_Foundation,
VExpress_GEM5_V1,
)
from m5.util import warn
from ...components.boards.arm_board import ArmBoard
from ...components.cachehierarchies.classic.private_l1_shared_l2_cache_hierarchy import (
PrivateL1SharedL2CacheHierarchy,
)
from ...components.memory import DualChannelDDR4_2400
from ...components.processors.cpu_types import CPUTypes
from ...components.processors.simple_processor import SimpleProcessor
from ...isas import ISA
from ...utils.requires import requires
class ArmDemoBoard(ArmBoard):
"""
This prebuilt ARM board is used for demonstration purposes. It simulates an
ARM 3GHz dual-core system with a 4GiB DDR4_2400 memory system. It uses
a PrivateL1SharedL2CacheHierarchy with l1d and l1i caches set to 64KiB and
l2 shared cache set to 8MiB
**DISCLAIMER**: This board is solely for demonstration purposes. This board
is not known to be representative of any real-world system or produce
reliable statistical results.
"""
def __init__(self, use_kvm: bool = False) -> None:
"""
:param use_kvm: If True, the board will use a SimpleProcessor
with cpu type of CPUTypes.KVM. If False, the board will use a SimpleProcessor with
a cpu type of CPUTypes.TIMING.
"""
requires(
isa_required=ISA.ARM,
)
warn(
"The ARMDemoBoard is solely for demonstration purposes. "
"This board is not known to be be representative of any "
"real-world system. Use with caution."
)
cache_hierarchy = PrivateL1SharedL2CacheHierarchy(
l1d_size="64KiB", l1i_size="64KiB", l2_size="8MiB"
)
# Note: Normally a system with these specification would have 1
# GiB for memory but because some benchmarks would not run with
# 1 GiB of memory so we have set it to 4 GiB.
memory = DualChannelDDR4_2400(size="4GiB")
if use_kvm:
processor = SimpleProcessor(
cpu_type=CPUTypes.KVM, num_cores=2, isa=ISA.ARM
)
# The ArmBoard requires a `release` to be specified. This adds all the
# extensions or features to the system. We are setting this to for_kvm()
# to enable KVM simulation.
release = ArmDefaultRelease.for_kvm()
# The platform sets up the memory ranges of all the on-chip and off-chip
# devices present on the ARM system. ARM KVM only works with VExpress_GEM5_V1
# on the ArmBoard at the moment.
platform = VExpress_GEM5_V1()
else:
processor = SimpleProcessor(
cpu_type=CPUTypes.TIMING, num_cores=2, isa=ISA.ARM
)
release = ArmDefaultRelease()
# The platform sets up the memory ranges of all the on-chip and off-chip
# devices present on the ARM system.
platform = VExpress_GEM5_Foundation()
super().__init__(
clk_freq="3GHz",
processor=processor,
memory=memory,
cache_hierarchy=cache_hierarchy,
release=release,
platform=platform,
)