Document 242681

Why Use Simulation?
Simics & dark2 Assignment 1
Understanding real systems
„ More inspectable
„ Less dangerous
„ Fault injection
„ Debugging
„ Prototype HW before expensive
implementations
„
Håkan Zeffer
Uppsala University, Sweden
zeffer@it.uu.se
DARK2
2004
2
Dept of Information Technology| www.it.uu.se
What is a Simulator?
Full-System Simulation
What to simulate? Instructions,
memory etc.
„ What happens when an operating
system boots, traps, disk accesses etc.
„ Simulation vs. Emulation
„
User program
Libraries
Database
IDE
ISA
DARK2
2004
3
© Håkan Zeffer | zeffer@it.uu.se
Real OS &
Software
Network
PCI
RAM
Dept of Information Technology| www.it.uu.se
Middleware
Operating system
CPU
DARK2
2004
© Håkan Zeffer | zeffer@it.uu.se
ROM
(Flash)
Disk
Simulated
hardware
LCD
Devices
Hardware
Dept of Information Technology| www.it.uu.se
4
© Håkan Zeffer | zeffer@it.uu.se
Advantages with Full
System Simulation
„
„
„
„
„
„
„
DARK2
2004
DARK2
2004
Dept of Information Technology| www.it.uu.se
5
© Håkan Zeffer | zeffer@it.uu.se
OS debugging (such as, single stepping
during boot, break on traps etc.).
Performance tuning of applications and
operating systems
Fault injection
Teaching and research
Checkpointing
Determinism
Non intrusive – inspect without effecting
state
Dept of Information Technology| www.it.uu.se
Possible Problems
6
© Håkan Zeffer | zeffer@it.uu.se
Wisconsin Experiments
Can I trust the results that my
simulator have produced?
„ How do I verify my results?
„ Wisconsin experiments
Cycles Per Trans. (millions)
„
4.0
max
avg
min
3.5
3.0
2.5
16
DARK2
2004
32
ROB Size
64
DARK2
2004
Dept of Information Technology| www.it.uu.se
7
© Håkan Zeffer | zeffer@it.uu.se
Dept of Information Technology| www.it.uu.se
8
© Håkan Zeffer | zeffer@it.uu.se
Speed vs. Accuracy
Virtutech AB - Simics
Spice, etc
Virtutech is a small Swedish company.
25-30 persons. Office in Stockholm,
Uppsala and U.S.
„ Simics is the only full system simulator
that supports multiple targets and is
capable of booting unmodified
operating systems.
„
gate/RTL model
(>1,000,000x)
accuracy
“cycle-accurate”
architecture simulator
(>10,000x)
emulator
(~5x)
Simics™
Virtual PC, VMWare,
Crusoe, etc.
1 KIPS
DARK2
2004
Dept of Information Technology| www.it.uu.se
100 MIPS
speed
9
DARK2
2004
© Håkan Zeffer | zeffer@it.uu.se
Dept of Information Technology| www.it.uu.se
Simics’s Three Modes
Fast mode: No cache simulation. Just
in time compilation (code name turbo).
„ Normal mode: Simple cache
simulation.
„ Out-of-order mode: MAI (Micro
Architecture Interface). Supports
speculative execution, such as, branch
and value prediction. Cache simulation
etc.
Dept of Information Technology| www.it.uu.se
11
© Håkan Zeffer | zeffer@it.uu.se
Supported architectures
„
DARK2
2004
10
© Håkan Zeffer | zeffer@it.uu.se
X86 (from 486 to Pentium4)
„ AMD-64 (Hammer/Opteron)
„ Itanium
„ SUN SunFire & Serengeti (USII & USIII)
„ PowerPC
„ Alpha
„ ARM, MIPS + lots of devices
„
DARK2
2004
Dept of Information Technology| www.it.uu.se
12
© Håkan Zeffer | zeffer@it.uu.se
Unmodified OSs
tested/supported
Windows (XP, NT, 98, 95 and more)
„ Solaris 9 (and more)
„ Linux
„ Tru64
„ VxWorks
„
DARK2
2004
Linux on
Itanium
Solaris on Sun
SunFire
Windows XP/64 on
AMD Hammer
Linux
on x86
DARK2
2004
13
Dept of Information Technology| www.it.uu.se
© Håkan Zeffer | zeffer@it.uu.se
CPU
CPU
CPU
$$$
$$$
$$$
$$$
SCSI
„
„
„
RAM
„
Arbitrary
configurations
Multiple processors
Multiple nodes
Multiple address
spaces
Arbitrary device
configurations
DARK2
2004
15
© Håkan Zeffer | zeffer@it.uu.se
© Håkan Zeffer | zeffer@it.uu.se
Applications
Operating
System
Firmware
Simics
configuration
event handling
memory
VHDL
simulator
memory bus
target machine
DARK2
2004
Dept of Information Technology| www.it.uu.se
14
Simics Architecture
Programming Interface (Simics API)
CPU
All running on a
Linux host
Dept of Information Technology| www.it.uu.se
Simulating Multiprocessors
„
Windows NT
on x86
VxWorks on
PowerPC
interpreter
Dept of Information Technology| www.it.uu.se
graphics
devices
Ethernet
SCSI
disks
MMU
other
Simics
process
CLI
Simics
Central
scripting
tracing
debugger
cache models
16
local
disk
real
network
© Håkan Zeffer | zeffer@it.uu.se
Simics Dir Structure
Target vs. Host
Most of the files in the user dir install dir are soft links:
LICENSE
Makefile.in
README
README.SOURCE
README.previous
README.proxy
README_1.8
Version
configure
doc
licenses
master-install
The target is the simulated system
„ The host is the computer that runs
Simics
„ The different prompts:
„
- the targets prompt: root on the
target system
“ host$ - the host prompt: user on the host
system (xterm etc.).
“ simics> - the Simics prompt
Real but for this course uninteresting files:
import
scripts
config
“ target#
DARK2
2004
Dept of Information Technology| www.it.uu.se
17
Interesting dirs:
home
- home for different configurations. We will use the
sarek configuration
src
- simics module source code
v9-sol8-64
- binaries and build place
DARK2
2004
© Håkan Zeffer | zeffer@it.uu.se
Dept of Information Technology| www.it.uu.se
simics> c
“
“
„
„
Causes Simics to run another 1000 machine
instructions and then stop.
„
Dept of Information Technology| www.it.uu.se
19
© Håkan Zeffer | zeffer@it.uu.se
Simics.
simics> load-module
“ Load
Gives help on selected topics. Try it out!
This help command will list all commands created
for this assignment.
simics> q
“ Quit
a module into Simics.
simics> list-modules
“ Prints
a list of available modules and their
current status, loaded or not.
simics> help dark2-cache
“
DARK2
2004
„
simics> help
“
„
Causes Simics to continue its simulation.
Pressing Ctrl-c when Simics is running causes it to
stop.
simics> c 1000
“
„
© Håkan Zeffer | zeffer@it.uu.se
Simics Commands (cont)
Simics Commands
„
18
DARK2
2004
Dept of Information Technology| www.it.uu.se
20
© Håkan Zeffer | zeffer@it.uu.se
hostfs
„
“
„
hostfs is a virtutech module that makes it
possible to mount the host’s file system in the
simulated target’s operating system.
A module can register multiple classes
„ A class can register multiple attributes
„ The configuration system uses classes
and attributes for:
„
target# mount /host
“
„
Simics API
hostfs – accessing host files
This will mount the host’s file system under /host
on the target. The hostfs module has to be
loaded (module-load hostfs).
“ Checkpointing
target# ls /host/it/kurs/dark2
“
“ Python
command wrapping
“ And more...
This will list the contents on the host machine’s
file system at /stud/it/dark2
DARK2
2004
DARK2
2004
21
Dept of Information Technology| www.it.uu.se
© Håkan Zeffer | zeffer@it.uu.se
Dept of Information Technology| www.it.uu.se
Register a class
22
Register an attribute
conf_class_t *
int
SIM_register_class(const char
*name,
class_data_t
SIM_register_attribute(conf_class_t
*class_data);
const char
get_attr_t
lang_void
Example:
static conf_class_t
static class_data_t
set_attr_t
*my_class;
lang_void
my_class_data;
my_class = SIM_register_class(”my-class-name”,
DARK2
2004
23
*class_struct,
*attr_name,
get_attr,
*get_attr_data,
set_attr,
*set_attr_data,
attr_attr_t
attr,
const char
*doc);
DARK2
2004
&my_class_data);
Dept of Information Technology| www.it.uu.se
© Håkan Zeffer | zeffer@it.uu.se
© Håkan Zeffer | zeffer@it.uu.se
Dept of Information Technology| www.it.uu.se
24
© Håkan Zeffer | zeffer@it.uu.se
Simics Command Files
Adding New Commands
The file dark2-cache.simics contains the following:
Edit the commands.py file in the dark2-cache dir
read-configuration /it/kurs/dark2/simics-checkpoints/booted-sarek-1p
def dc_resize_cmd(dc, size, block_size):
dc.size = size;
dc.block_size = block_size;
@SIM_new_object("dark2-cache", "dc0")
@conf.dc0.size = 512
@conf.dc0.block_size = 64
@conf.phys_mem0.timing_model = conf.dc0
new_command("resize", dc_resize_cmd,
[arg(integer_t, "size"), arg(integer_t, ”block-size")],
namespace = "dark2-cache",
type ="dark2-cache commands",
short="resize the cache",
doc = """
Resize the cache. The long version
""");
Command files can contain any Simics commands
Lines that starts with @ are interpreted by the Simics Python
virtual machine.
DARK2
2004
”@conf.dc0.size = 512” calles the set-attribute function
Dept of Information Technology| www.it.uu.se
25
DARK2
2004
© Håkan Zeffer | zeffer@it.uu.se
Dept of Information Technology| www.it.uu.se
STC
Simics uses a fast address cache called
ISTC and DSTC for instructions resp.
data accesses.
„ Direct mapped SW cache containing
”safe” address translations
„
„
“ No
traps are possible, that is, TLB and
cache hit is guaranteed.
DARK2
2004
This caching have to be disabled when
cache simulations are performed.
Dept of Information Technology| www.it.uu.se
© Håkan Zeffer | zeffer@it.uu.se
HAP (happening)
„
„
26
27
© Håkan Zeffer | zeffer@it.uu.se
„
DARK2
2004
There are multiple haps that a user can
register callbacks for.
Initial-configuration – makes it possible to
get a callback when the configuration phase
is over.
Magic-instruction – makes it possible to get a
callback when such an instruction is
executed. This is for example done in the
magic-break-enable and magic-breakdisable commands.
Dept of Information Technology| www.it.uu.se
28
© Håkan Zeffer | zeffer@it.uu.se
The Step- and Time-Queue
Simics uses two queues that events can
be posted on.
„ The STEP QUEUE: incremented on
instruction completions and interrupt
events
„ The TIME QUEUE: incremented each
cycle
„ The time queue is used when the outof-order mode are used.
The Assignment
„
DARK2
2004
Dept of Information Technology| www.it.uu.se
29
© Håkan Zeffer | zeffer@it.uu.se
„
Questions?
DARK2
2004
Dept of Information Technology| www.it.uu.se
30
© Håkan Zeffer | zeffer@it.uu.se