A full-system simulation running gem5 is missing files.

huangapple go评论93阅读模式
英文:

A full-system simulation running gem5 is missing files

问题

我正在尝试运行gem5的完整系统模拟,但我发现官方网站上的X86完整系统文件无法下载了,有人可以帮忙吗?谢谢。

我需要一个压缩包含x86完整系统文件的文件“x86-system.tar.bz2”和“config-x86.tar.bz2”。

英文:

I am trying to run a full system simulation of gem5, but I found that the full system file of X86 on the official website can no longer be downloaded, can someone help me?
thanks

I need a compressed package of x86 full system files“x86-system.tar.bz2”“config-x86.tar.bz2”

答案1

得分: 0

这是有关如何在gem5中运行FS的完整教程。首先下载您的操作系统映像:

https://www.gem5.org/documentation/gem5art/main/disks

从gem5.utils.requires导入需要的内容
从gem5.components.boards.x86_board导入X86Board
从gem5.components.memory.single_channel导入SingleChannelDDR3_1600
从gem5.components.cachehierarchies.ruby.mesi_two_level_cache_hierarchy导入MESITwoLevelCacheHierarchy
从gem5.components.processors.simple_switchable_processor导入SimpleSwitchableProcessor
从gem5.coherence_protocol导入CoherenceProtocol
从gem5.isas导入ISA
从gem5.components.processors.cpu_types导入CPUTypes
从gem5.resources.resource导入Resource
从gem5.simulate.simulator导入Simulator
从gem5.simulate.exit_event导入ExitEvent

这运行了一个检查,以确保gem5二进制文件已编译为X86并支持

requires(
isa_required=ISA.X86, coherence_protocol_required=CoherenceProtocol.MESI_TWO_LEVEL
)

在这里,我们设置了MESI Two Level Cache Hierarchy。

cache_hierarchy = MESITwoLevelCacheHierarchy(
l1d_size="32KiB",
l1d_assoc=8,
l1i_size="32KiB",
l1i_assoc=8,
l2_size="256KiB",
l2_assoc=16,
num_l2_banks=1,
)

设置系统内存。
请注意,默认情况下DDR3_1600默认大小为8GiB。但是,X86板的当前限制是只能接受最多3GiB的内存系统。因此,我们必须调整大小。

memory = SingleChannelDDR3_1600("2GiB")

在这里,我们设置处理器。这是一个特殊的可切换处理器,需要指定起始核心类型和切换核心类型。一旦配置实例化,用户可以调用processor.switch()来从起始核心类型切换到切换核心类型。在这个模拟中,我们从TIMING核心开始模拟操作系统引导,然后切换到O3核心以运行引导后的命令。

processor = SimpleSwitchableProcessor(
starting_core_type=CPUTypes.TIMING, switch_core_type=CPUTypes.O3, num_cores=2
)

在这里,我们设置了板。X86Board允许进行全系统X86模拟。

board = X86Board(
clk_freq="3GHz", processor=processor, memory=memory, cache_hierarchy=cache_hierarchy
)

这是在系统引导后运行的命令。第一个m5 exit将停止模拟,以便我们可以将CPU核心从TIMING切换到O3d,然后继续模拟以运行echo命令,休眠一秒,然后再次调用m5 exit来终止模拟。模拟结束后,您可以检查m5out/system.pc.com_1.device以查看echo输出。

command = (
"m5 exit;" + "echo 'This is running on O3 CPU cores.';" + "sleep 1;" + "m5 exit;"
)

在这里,我们设置了完整系统的工作负载。X86Board的set_workload函数接受一个内核、一个磁盘映像,以及可选的readfile内容。在“x86-ubuntu-18.04-img”案例中,这是在引导系统后要执行的脚本文件。

board.set_kernel_disk_workload(
kernel=Resource("x86-linux-kernel-5.4.49"),
disk_image=Resource("x86-ubuntu-18.04-img"),
readfile_contents=command,
)

在这里,我们要覆盖第一个m5 exit退出事件的默认行为。而不是退出模拟器,我们只想切换处理器。第二个'm5 exit'后将恢复使用默认行为,模拟器运行将退出。

simulator = Simulator(
board=board,
on_exit_event={

    ExitEvent.EXIT: (func() for func in [processor.switch])
},

)
simulator.run()

英文:

Here is a complete tutorial on how to run FS in gem5. Start by downloading your OS image:
https://www.gem5.org/documentation/gem5art/main/disks

from gem5.utils.requires import requires
from gem5.components.boards.x86_board import X86Board
from gem5.components.memory.single_channel import SingleChannelDDR3_1600
from gem5.components.cachehierarchies.ruby.mesi_two_level_cache_hierarchy import (
    MESITwoLevelCacheHierarchy,
)
from gem5.components.processors.simple_switchable_processor import (
    SimpleSwitchableProcessor,
)
from gem5.coherence_protocol import CoherenceProtocol
from gem5.isas import ISA
from gem5.components.processors.cpu_types import CPUTypes
from gem5.resources.resource import Resource
from gem5.simulate.simulator import Simulator
from gem5.simulate.exit_event import ExitEvent

> This runs a check to ensure the gem5 binary is compiled to X86 and supports

requires(
    isa_required=ISA.X86, coherence_protocol_required=CoherenceProtocol.MESI_TWO_LEVEL
)

> Here we setup a MESI Two Level Cache Hierarchy.

cache_hierarchy = MESITwoLevelCacheHierarchy(
    l1d_size="32KiB",
    l1d_assoc=8,
    l1i_size="32KiB",
    l1i_assoc=8,
    l2_size="256KiB",
    l2_assoc=16,
    num_l2_banks=1,
)

>Setup the system memory.
Note, by default DDR3_1600 defaults to a size of 8GiB. However, a current
limitation with the X86 board is it can only accept memory systems up to 3GiB.
As such, we must fix the size.

memory = SingleChannelDDR3_1600("2GiB")

> Here we setup the processor. This is a special switchable processor in which a starting core type and a switch core type must be specified. Once a configuration is instantiated a user may call processor.switch() to switch from the starting core types to the switch core types. In this simulation we start with TIMING cores to simulate the OS boot, then switch to the O3 cores for the command we wish to run after boot.

processor = SimpleSwitchableProcessor(
    starting_core_type=CPUTypes.TIMING, switch_core_type=CPUTypes.O3, num_cores=2
)

>Here we setup the board. The X86Board allows for Full-System X86 simulations.

board = X86Board(
    clk_freq="3GHz", processor=processor, memory=memory, cache_hierarchy=cache_hierarchy
)

>This is the command to run after the system has booted. The first m5 exit will stop the simulation so we can switch the CPU cores from TIMING to O3d and continue the simulation to run the echo command, sleep for a second, then, again, call m5 exit to terminate the simulation. After simulation has ended you may inspect m5out/system.pc.com_1.device to see the echo output.

command = (
    "m5 exit;" + "echo 'This is running on O3 CPU cores.';" + "sleep 1;" + "m5 exit;"
)

>Here we set the Full System workload. The set_workload function for the X86Board takes a kernel, a disk image, and, optionally, a the contents of the "readfile". In the case of the "x86-ubuntu-18.04-img", a file to be executed as a script after booting the system.

board.set_kernel_disk_workload(
    kernel=Resource("x86-linux-kernel-5.4.49"),
    disk_image=Resource("x86-ubuntu-18.04-img"),
    readfile_contents=command,
)

>Here we want override the default behavior for the first m5 exit exit event. Instead of exiting the simulator, we just want to switch the processor. The 2nd 'm5 exit' after will revert to using default behavior where the simulator run will exit.

simulator = Simulator(
    board=board,
    on_exit_event={
        
        ExitEvent.EXIT: (func() for func in [processor.switch])
    },
)
simulator.run()

huangapple
  • 本文由 发表于 2023年2月16日 14:05:30
  • 转载请务必保留本文链接:https://go.coder-hub.com/75468416.html
  • gem5
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定