Difference between revisions of "Introduction"
m (→Getting a copy)
|Line 52:||Line 52:|
In your source tree, you'd then find a new '''build/
In your source tree, you'd then find a new '''build//''' directory with the requested '''m5.opt''' in it. For the rest of this chapter we'll assume this is the binary you're using.
(See the [[Compiling M5]] page for more details on building M5 binaries)
(See the [[Compiling M5]] page for more details on building M5 binaries)
Revision as of 01:55, 13 July 2011
What is gem5?
gem5 is a modular discrete event driven computer system simulator platform. That means that:
- gem5's components can be rearranged, parameterized, extended or replaced easily to suite your needs.
- It simulates the passing of time as a series of discrete events.
- It's intended use is to simulate one or more computer systems in various ways.
- It's more than just a simulator, it's a simulator platform that lets you use as many of its premade components as you want to build up your own simulation system.
gem5 is written primarily in C++ and python and most components are provided under a BSD style license. It can simulate a complete system with devices and an operating system in full system mode (FS mode), or user space only programs where system services are provided directly by the simulator in syscall emulation mode (SE mode). There are varying levels of support for executing Alpha, ARM, MIPS, Power, SPARC, and 64 bit x86 binaries on CPU models including two simple single CPI models, an out of order model, and an in order pipelined model. A memory system can be flexibly built out of caches and interconnects. Recently the Ruby simulator has been integrated with gem5 to provide even better, more flexible memory system modeling.
There are many components and features not mentioned here, but from just this partial list it should be obvious that M5 is a sophisticated and capable simulation platform. Even with all gem5 can do today, active development continues through the support of individuals and some companies, and new features are added and existing features improved on a regular basis.
Capabilities out of the box
gem5 is designed for use in computer architecture research, but if you're trying to research something new and novel it probably won't be able to evaluate your idea out of the box. If it could, that probably means someone has already evaluated a similar idea and published about it.
To get the most out of gem5, you'll most likely need to add new capabilities specific to your project's goals. Gem5's modular design should help you make modifications without having to understand every part of the simulator.
As you add the new features you need, please consider contributing your changes back to gem5. That way others can take advantage of your hard work, and gem5 can become an even better simulator.
Getting a copy
gem5's source code is managed using the mercurial revision control system. There are several repositories you may be interested in:
- m5 – The main repository where active development takes place.
- m5-stable – A repository which lags behind “m5” repository but has basically the same contents. It’s usually better to use “m5” instead of “m5-stable”
- encumbered – A repository for extensions to M5 that are under a different, more restrictive license. Currently this only includes support for SimpleScalar's EIO trace format.
- linux-patches – A repository for patches to the linux kernel that modify it so it can be simulated more efficiently. These patches are optional, but it's a good idea to use them if possible to cut down on simulation run time.
To check out a copy, first, make sure you have mercurial installed on your system and that you can run the hg command. Then use hg clone to create your own local copy using the URL http://repo.m5sim.org/XXX where XXX is replaced by the name of the repository your interested in. For example, to check out the main repository, you'd use the command:
hg clone http://repo.m5sim.org/gem5
You can find out more about mercurial and its commands using its built in help by running:
or by visiting any of the following websites:
- hginit provides a good introduction to the basic Mercurial concept
- Mercurial Guide also provides a good basic introduction
- HGBook is the definitive guide to Mercurial
Getting Additional Support Files
Need to talk about the system files and put links to grab them.
M5 uses the scons build system which is based on python. To build the simulator binary, run scons from the top of the source directory with a target of the form build/<config>/<binary> where <config> is replaced with one of the predefined set of build parameters and <binary> is replaced with one of the possible m5 binary names. The predefined set of parameters determine build wide configuration settings that affect the behavior, composition, and capabilities of the binary being built. These include whether the simulator will run in FS or SE mode, if Ruby support is included, which ISA will be supported, which CPU models to build, and what coherence protocol Ruby should use. Examples are ARM_FS, X86_SE, and ALPHA_SE_MOESI_CMP_token. All of the available options can be found in the build_opts directory, and it should be fairly easy to see what each is for. We'll talk about the build system in more detail later. Valid binary names are m5.debug, m5.opt, m5.fast, and m5.prof. These binaries all have different properties suggested by their extension. m5.debug has optimization turned off to make debugging easier in tools like gdb, m5.opt has optimizations turned on but debug output and asserts left in, m5.fast removes those debugging tools, and m5.prof is built to use with gprof. Normally you'll want to use m5.opt. To build the simulator in syscall emulation mode with Alpha support, optimizations turned on, and debugging left in, you would run:
In your source tree, you'd then find a new build/ALPHA_SE/ directory with the requested m5.opt in it. For the rest of this chapter we'll assume this is the binary you're using.
(See the Compiling M5 page for more details on building M5 binaries)
Now that you've built M5, it's time to try running it. An M5 command line is composed of four parts, the binary itself, options for M5, a configuration script to run, and then finally options for the configuration script. Several example configuration scripts are provided in the “configs/example” directory and are generally pretty powerful. You are encouraged to make your own scripts, but these are a good starting point. The example script we'll use in SE mode is called se.py and sets up a basic SE mode simulation for us. We'll tell it to run the hello world binary provided in the M5 source tree.
build/ALPHA_SE/m5.opt configs/example/se.py -c tests/test-progs/hello/bin/alpha/linux/hello
This builds up a simulated system, tells it to run the binary found at the location specified, and kicks off the simulation. As the binary runs, it's output is sent to the console by default and looks like this:
M5 Simulator System Copyright (c) 2001-2008 The Regents of The University of Michigan All Rights Reserved M5 compiled Feb 12 2011 20:43:55 M5 revision e00ef55a2c49 7933 default tip M5 started Feb 12 2011 20:45:47 M5 executing on fajita command line: build/ALPHA_SE/m5.opt configs/example/se.py -c tests/test-progs/hello/bin/alpha/linux/hello Global frequency set at 1000000000000 ticks per second 0: system.remote_gdb.listener: listening for remote gdb #0 on port 7000 **** REAL SIMULATION **** info: Entering event queue @ 0. Starting simulation... info: Increasing stack size by one page. Hello world! hack: be nice to actually delete the event here Exiting @ tick 3240000 because target called exit()
You can see a lot of output from the simulator itself, but the line “Hello world!” came from the simulated program. Output files generated from the simulation are put in the m5out directory, including statistics in stats.txt.
In this example we didn't provide any options to M5 itself. If we had, they would have gone on the command line between m5.opt and se.py. If you'd like to see what command line options are supported, you can pass the --help option to either M5 or the configuration script. Note that the two groups of options are different, so make sure you keep track of whether they go before or after the configuration script.
(See the Running M5 page for more details on running M5 simulations)
Asking for help
gem5 has two main mailing lists where you can ask for help or advice. m5-dev is for developers who are working on the main version of M5. This is the version that's distributed from the website and most likely what you'll base your own work off of. m5-users is a larger mailing list and is for people working on their own projects which are not, at least initially, going to be distributed as part of the official version of M5. Most of the time m5-users is the right mailing list to use. Most of the people on m5-dev are also on m5-users including all the main developers, and in addition many other members of the M5 community will see your post. That helps you because they might be able to answer your question, and it also helps them because they'll be able to see the answers people send you. To find more information about the mailing lists, to sign up, or to look through archived posts visit Mailing Lists.
Before reporting a problem on the mailing list, please read Reporting Problems
gem5 combines several different ISAs, system modes (SE or FS), CPU models and memory models which all need to work together. Every combination of these may not be fully tested or completely work. The Status Matrix describes the current status of these combinations. Please send an e-mail to the mailing list if a supported combination no longer works, or if you find that a combination works that we're unsure of.