Due Sunday, February 3. 11:59PM Pacific Time
In this assignment you will learn how to use Simics. Simics is a hardware simulator. It is a software program simulates actions of a processor. Simics runs real software that you would run on a Solaris/SPARC or Linux/x86 system just like on real hardware (albeit more slowly).
Simics is a very useful tool for microarchitectural research. Since a processor is simulated in software, and most of the source code is available, you can virtually “look inside” the processor. You can implement your own cache architecture, add new performance counters to the processor, etc. Isn’t this awesome?!
Simics runs on many platforms: Linux/x86, Solaris/SPARC, Windows/x86, etc., and simulates many different processors. Niagara is one of them. The real machine on which the simics program runs is called a host machine. The machine that is simulated by simics is called a target machine. To find out anything there is to know about simics, visit simics.net.
To begin working with simics, one usually begins with a bare simics target – that is, a simulated machine with no software on it. Then, one needs to install an operating system on it (using a real OS CD). This is a very time consuming process, but fortunately, you do not have to do any of this. We have installed operating systems on simics for you and created simics configurations. A simics configuration is a saved state of a simulated target. After installing and booting the operating system on a simulated machine, we saved the machine state in a file, called a simics configuration. You can continue execution from this saved state simply by loading an existing configuration file.
Begin learning about simics by studying this
Begin using Simics
Your first task is to learn how to run Simics. You will accomplish this
using the steps below. Instructions on how to complete these
steps can be found on this
site. Note, if you want to run simics on quad, it must be
booted into Linux (it's a dual-boot machine). Type
-a to find out the current OS. If it is not running
Linux, contact Viren Kumar (email@example.com). You'll also contact
Viren for the account on quad/Linux.
Congratulations! Now you know how to use simics. Your next step is to run some real benchmarks on simics.
Initialize your simics workspace.
Run simics using an existing configuration, like this:
./simics –c /cs/systems/Simics/Configs/peanut-1p-config/\ root-shell-simicsFS.config
This should pop up a gray window – this is the shell window on the target (i.e., simulated) machine. The window where you typed the “simics” command is the host window.
At the simics prompt (in the host window) type “c”. This will let the simulation continue. You can now switch to the window of the target window and try typing familiar UNIX commands like “ls” or “ps”. It looks just like real system, right? Only a bit slower… Now try typing “date” in the simulated target window. Do you notice that the date is shown incorrectly? That’s a give-away that you are running on a simulated system.
If you want to get control back in the host shell, type Ctrl-C in the host shell window. To quit out of simics, type "q" at the host shell.
Run "Hello World" on Simics
Congratulations! Now you know how to run programs on simics. Your next step is to configure simics to simulate a cache.
Start simics as described in the previous step.
Mount the host file system - the directory root on the host machine by typing:
Command "con0.input" replaces the typing of commands by hand in the simulated machine's window. Now the root directory of the host file syste is accessible under
con0.input "mount /host \n"
/host on the target.
At the host prompt, type the following command:
This will execute a series of commands in Simics that will result in copying a hello_world program from the host machine to the target machine and running it on a target machine.
Read and analyze the script to understand how it works.
Cache Simulation on Simics
Start simics using the configuration described in the previous step, but pass an option
-stall to Simics. This option will enable simics perform a more detailed simulation of processor timing, which is relevant when you simulate a cache hierarchy.
At the host prompt, run the following script:
This adds a cache hierarchy to your simulated target. Study these scripts along with Simics manuals to understand what they do and how they work.
run-command-file /cs/systems/Simics/Scripts/\ Caches/D_16K-I_16K-L2_1MB-MEM_200c.simics
list-objects at the host prompt. Simics will list all its simulated objects along with their types. Notice these three objects:
These are the cache objects added by the script that you just ran. "dc" is a first-level data cache, "ic" is a first-level instruction cache, and "l2c" is a unified second-level cache.
- <g-cache> dc
- <g-cache< ic
- <g-cache< l2c
Now type this command:
This command will tell simics to make all instruction fetches
visible to the memory hierarcy. Without this command, your
i-cache will not see any instruction fetches.
help dc. Simics will show you all commands that you can run on the dc object. For example, typing
dc.statistics will show you statistics of the data cache. At this point all statistics are 0, because the target has not yet run anything with caches.
Now run the hello_world program again. Notice that it is running much slower now! Guess why? Because cache simulation requires the simulator to do more work!
Now display the cache statistics again. Notice that the numbers have changed. Now simics shows you the number of data references and misses.
Other Simics commands and Help
This link has many Simics reference guides. Of a particular interest are the user guide, the programming manual, the reference manual (which as all simics commands) and the target-specifific reference guide. For the simulated target you used in this assignment, use the sunfire target reference.
When running long simulations, it is particularly useful to let simics run for a certain number of simulated steps, i.e., 1 billion steps. To accomplish this, after you are ready to run your benchmark, type:
Upon executing 1 billion steps, the simulator will break.
To measure time in simics use command
print-time. It will display the elapsed time, simulation steps (same as instructions) and CPU cycles. By displaying time before and after your benchmark runs, you can measure the time it took to run. By dividing the total number of instructions by the number of cycles, you can compute the IPC.
To speed up your simulation, you may prepare the simulated machine for running the benchmarks before you load the caches. This will speed up the overall simulation time.
Simics has a useful command
apropos. It lets you
search the documentation while you are inside the simics
shell. For example, to find out anything related to module
"processor, you'd type
Notes on simulations
To run simics, it is better to use oak and quad - the other machines will be
very slow for Simics. Note, on quad there is no emacs installed
(yet). So to save your shell output (as requested by the
assignment) you will need to:
- Open xemacs on another machine, such as dogwood
- Open a shell inside xemacs
- From that shell ssh to quad
- Run simics on quad (ensure your display variable is set, so
that simics shell pops up on dogwood
What to submit
You will need to submit the results of experiments of running one SPEC CPU2000 benchmark on a simulated machine (peanut) with two different cache sizes. You will need to change cache configuration parameters for that. Do not run the entire benchmark, it will take a very long time. Execute a portion of the benchmark, say the first 1 billion steps after you start of the benchmark. You will turn in:
- A short description of your experiment: i.e., what benchmark and what cache configurations you used.
- Saved output of the host shell where you launched your simics experiments and any statistics that you print. To save the output of the shell, start your shell in emacs by typing "M-x shell", and then save that buffer in a file.
- Saved output of the shell on the target machine. To save the target's output, you "con0.capture" command.
- Any script files you write for this assignment.
- Charts showing cache miss rates and IPC of your SPEC benchmark with two different cache configurations.