0% found this document useful (0 votes)
112 views52 pages

01 Marss PTLSim QEMU

The document describes datacenter simulation methodologies MARSSx86 and DRAMSim2. It provides an overview of the simulators and their components, including how MARSSx86 uses QEMU for emulation and PTLsim for detailed processor simulation, while DRAMSim2 simulates the memory system. It also outlines the steps to set up the simulators, including creating a disk image, configuring the simulators, compiling them, and running a simulation.

Uploaded by

BINOD KUMAR
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
112 views52 pages

01 Marss PTLSim QEMU

The document describes datacenter simulation methodologies MARSSx86 and DRAMSim2. It provides an overview of the simulators and their components, including how MARSSx86 uses QEMU for emulation and PTLsim for detailed processor simulation, while DRAMSim2 simulates the memory system. It also outlines the steps to set up the simulators, including creating a disk image, configuring the simulators, compiling them, and running a simulation.

Uploaded by

BINOD KUMAR
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 52

Datacenter Simulation Methodologies:

MARSSx86 and DRAMSim2

Tamara Silbergleit Lehman, Qiuyun Wang, Seyed Majid Zahedi


and Benjamin C. Lee
Tutorial Schedule

Time Topic
9:00 - 10:00 Setting up MARSSx86 and DRAMSim2
10:00 - 10:30 Web search simulation
10:30 - 11:00 GraphLab simulation
11:00 - 11:30 Spark simulation
11:30 - 12:30 Questions and hands on session

2 / 53
Agenda

• Objectives
• Understand simulator components
• Be able to perform full system simulation
• Be able to control simulation environment

• Outline
• Create a disk image, qcow2 format
• Configure and compile DRAMSim2, MARSSx86
• Simulate programs
• Create checkpoints
• Simulate from checkpoints
• Parse results

3 / 53
Simulator Requirements

• Software
• Full system simulation: evaluate software stack behavior
• Fast and easy to use: simulate long running applications
• Multithread, multiprogram: support complex workloads
• Architecture
• x86 support: most servers use x86 architecture
• Multicore support: servers have many cores
• Future
• Heterogeneous simulation (e.g., processors, memories)

4 / 53
Full System Simulation Overview

• Simulate complete software


stack – applications, libraries,
operating system.

• Use emulation engine to


manage virtual environment

“MARSS: Micro Architectural System Simulator”, ISCA Tutorial 2012 by Ghose et al.
5 / 53
MARSSx86 Overview

• PTLsim, QEMU
Collaboration
• QEMU is emulator engine
• PTLsim is processor simulator
• Detailed pipeline, cache
simulation
• Simple memory
controller interface

“MARSS: Micro Architectural System Simulator”, ISCA Tutorial 2012 by Ghose et al.
6 / 53
QEMU Overview

• Fast, easy to use emulator


• Uses dynamic binary
translation
• Translate instructions to
C code
• Compile C code for host
• QEMU emulates devices for
functionality only. No
performance estimates.

“MARSS: Micro Architectural System Simulator”, ISCA Tutorial 2012 by Ghose et al.
7 / 53
PTLsim Overview

• Cycle-accurate core, cache simulator


• Event-based simulation
• Specify microarchitecture in configuration files

“MARSS: Micro Architectural System Simulator”, ISCA Tutorial 2012 by Ghose et al.
8 / 53
MARSSx86 Execution Flow

• In simulation mode, PTLsim


checks for interrupts,
exceptions

• PTLsim saves its state,


transfers control to QEMU

• In emulation mode, QEMU


handles interrupt, returns
control to PTLsim

• PTLsim restores state,


continues execution

9 / 53
DRAMSim2 Overview

• Simulates memory system in detail

• Simulates diverse memory technologies

• Specifies device details in configuration files


• Scheduling policies
• Addressing modes
• Row buffer management policies

10 / 53
DRAMSim2 Overview

P. Rosenfeld et al. ”DRAMSim2: A Cycle Accurate Memory System Simulator” CAL 2010
11 / 53
Putting All Together

• QEMU handles interrupt, exceptions, complex opcodes

• PTLsim simulates datapath, caches

• PTLsim sends memory requests to DRAMSim2

12 / 53
MARSSx86 and DRAMSim2 Introduction

Questions?

13 / 53
Datacenter Simulation Methodologies
Getting Started with MARSSx86, DRAMSim2

Tamara Silbergleit Lehman, Qiuyun Wang, Seyed Majid Zahedi


and Benjamin C. Lee
Agenda

• Objectives
• Understand simulator components
• Be able to perform full system simulation
• Be able to control simulation environment

• Outline
• Create a disk image, qcow2 format
• Configure and compile DRAMSim2, MARSSx86
• Simulate programs
• Create checkpoints
• Simulate from checkpoints
• Parse results

15 / 53
Getting Started With MARSSx86

• Libraries needed:
git g ++ scons zlib1g - dev libsdl1 .2 - dev
libsdl1 .2 debian qemu

• Get MARSSx86 source code:


$ git clone https :// github . com / dramninjasUMD /
marss . dramsim . git

• Get DRAMSim2 source code:


$ git clone git :// github . com / dramninjasUMD /
DRAMSim2 . git

16 / 53
Creating a Disk Image

• The following instructions are just for illustration purposes.


For today’s tutorial we will use an already prepared image.

• Create a 10 GB qcow2 image:


$ qemu - img create -f qcow2 demo . qcow2 10 G

• Install the operating system on the image:


$ qemu - system - x86_64 -m 4 G - drive file = demo .
qcow2 , cache = unsafe - cdrom mini . iso - boot d
-k en - us

• On the installation menu choose the command-line install


Note: This will take approximately 25 minutes.

17 / 53
Creating a Disk Image

• Once the operating system is installed re-run QEMU to


prepare the virtual machine to run with PTLsim.
$ qemu - system - x86_64 -m 4 G - drive file = demo .
qcow2 , cache = unsafe -k en - us - nographic

• Change the root password and login as root.


# sudo passwd root
# su

18 / 53
Creating a Disk Image

• Create file /etc/init/ttyS0.conf to be able to run simulations


with a script:

• Open the tty port


# start ttyS0

19 / 53
Creating a Disk Image

• Open /etc/default/grub and modify it to look as below:

• After closing the file update grub and power down the virtual
machine:
# update - grub
# poweroff

20 / 53
DRAMSim2 Configuration

• Change into the DRAMSim2 directory

• DRAMSim2 uses system.ini to specify the system


configuration parameters

• Open system.ini.example and save it as system.ini

21 / 53
DRAMSim2 Configuration

• The simulated device can be configured with an ini file.

• There are many ini files to choose from provided by the


DRAMSim2 team in the ini directory.

• We will use ini/DDR3 micron 8M 8B x16 sg15.ini

• Build the shared library to be used by MARSSx86:


$ make libdramsim . so
side note: for debugging add DEBUG=1 to the command.
22 / 53
MARSSx86 Configuration

• Change into marss.dramsim directory and open the machine


configuration file: config/default.conf

• In this file we can import configuration files

• We can specify many machine configurations

• To select which one to simulate, use the machine option in


the simulation configuration file.

23 / 53
MARSSx86 Custom Configuration

• Below is the single core configuration example.

• We will create a new configuration file to add


microarchitectural details about the core and caches.

• We have provided an example configuration file. Open


˜/custom.conf

24 / 53
MARSSx86 Custom Configuration

• Details about configuration file


• Core section

• Cache section

• Memory section

25 / 53
MARSSx86 Custom Configuration

• More details about the configuration file


• Machine section specifies number threads per core, which
core, cache and memory controller to use

• Within the machine section we can also specify the


connections between all the components

• More information available on the MARSSx86 web site:


http://marss86.org/~marss86/index.php/Machine_Configuration

26 / 53
Simulation Configuration

• Simulation configuration parameters are specified through a


file (demo.simcfg).
- logfile demo . log
# - run
- machine custom
- corefreq 4 G
- stats demo . yml
# - kill - after - run - quiet
- dramsim - device - ini - file ini /
D D R 3 _ m i c r o n _ 8 M _ 8 B _ x 1 6 _ s g 1 5 . ini
- dramsim - system - ini - file system . ini
- dramsim - results - dir - name demo_dramsim

27 / 53
Compiling MARSSx86

• Build MARSSx86 with the custom configuration file and 4


cores:
$ scons -Q c =4 config =/ hometemp / userXX / custom
. conf dramsim =/ hometemp / userXX / DRAMSim2
Note: for debugging add debug=2

• Previous command produces a new QEMU binary that


integrates PTLsim into it.

• Run MARSSx86 with the simulation configuration file:


$ ./ qemu / qemu - system - x86_64 -m 4 G - drive file
= demo . qcow2 , cache = unsafe - nographic -
simconfig demo . simcfg

28 / 53
Running MARSSx86

• Run MARSSx86 with the simulation configuration file:


$ ./ qemu / qemu - system - x86_64 -m 4 G - drive file
=/ hometemp / userXX / demo . qcow2 , cache = unsafe
- nographic - simconfig / hometemp / userXX /
demo . simcfg

29 / 53
PtlCalls

• PtlCalls is the interface between PTLsim and QEMU.

• Many different functions:


• ptlcall switch to sim(): Goes into simulation mode.
• ptlcall checkpoint and shutdown(chkpt name): Takes a
snapshot of the vm and shuts down.
• ptlcall switch to native(): Goes into emulation mode.
• ptlcall kill(): Terminate the simulation.

• Copy the file ptlcalls.h from the ptlsim/tools directory


# scp userna me@ho stname :// hometemp / userXX /
marss . dramsim / ptlsim / tools / ptlcalls . h .

• Create 3 binaries for start sim, stop sim and kill sim

30 / 53
start sim.c

//start sim.c
# include < stdlib .h >
# include < stdio .h >
# include " ptlcalls . h "

int main ( int argc , char ** argv ) {


printf ( " Starting simulation \ n " ) ;
ptl c a l l _ s w i t c h _ t o _ s i m () ;
return EXIT_SUCCESS ;
}

31 / 53
stop sim.c

//stop sim.c
# include < stdlib .h >
# include < stdio .h >
# include < ptlcalls .h >

int main ( int argc , char ** argv ) {


printf ( " Stopping simulation \ n " ) ;
p t lc a l l _ s w i t c h _ t o _ n a t i v e () ;
return EXIT_SUCCESS ;
}

32 / 53
kill sim.c

//kill sim.c
# include < stdlib .h >
# include < stdio .h >
# include < ptlcalls .h >

int main ( int argc , char ** argv ) {


printf ( " Shutting down simulation and vm \ n " ) ;
ptlcall_kill () ;
return EXIT_SUCCESS ;
}

33 / 53
Makefile

#Makefile
all : start_sim stop_sim kill_sim helloWorld
start_sim : start_sim . c ptlcalls . h
gcc - std = gnu99 - D_GNU_SOURCE - O3 -o $@ start_sim
.c
stop_sim : stop_sim . c ptlcalls . h
gcc - std = gnu99 - D_GNU_SOURCE - O3 -o $@ stop_sim .
c
kill_sim : kill_sim . c ptlcalls . h
gcc - std = gnu99 - D_GNU_SOURCE - O3 -o $@ kill_sim .
c
helloWorld : helloWorld
gcc - std = gnu99 - D_GNU_SOURCE - O3 -o $@
helloWorld . c
clean :
- rm -f start_sim stop_sim kill_sim helloWorld *~

34 / 53
Running MARSSx86

• Create a simple program (helloWorld.c)


//helloWorld.c
# include < stdlib .h >
# include < stdio .h >

int main ( int argc , char ** argv ) {


printf ( " Hello World \ n " ) ;
return EXIT_SUCCESS ;
}

• Compile and run the program with start sim, stop sim and
kill sim.
# ./ start_sim ; ./ helloWorld ; ./ stop_sim
#
# ./ start_sim ; ./ helloWorld ; ./ kill_sim

35 / 53
About Checkpoints

• Checkpoints are snapshots of the qcow2 image.

• Saves the state of your machine at a particular point in time.

• To load a virtual machine from a checkpoint add ”-loadvm


checkpoint name” to the MARSSx86 command

• Checkpoints are hardware configuration dependent (number


cores, cache sizes, etc)

36 / 53
How to Checkpoint

• There are 3 ways of creating checkpoints:


• Create checkpoint from the command line within QEMU
(we will see this during the WebSearch presentation)

• Embed ptlcall function calls within the source code

• Use a script that uses either the first or second method


to create multiple checkpoints (batch mode)

• There are 2 ways of running from checkpoints:


• Add -loadvm checkpointname option to the QEMU
command

• Use a script to run multiple simulations (batch mode)

37 / 53
Creating Checkpoints: PtlCall Function Call

• Add a PtlCall to create a checkpoint inside the source code:


// helloWorld . c
# include < stdlib .h >
# include < stdio .h >
# include " ptlcalls . h "

int main ( int argc , char ** argv ) {


char * chk_name = getenv ( " CHECKPOINT_NAME " ) ;
if ( chk_name != NULL ) {
printf ( " Creating checkpoint with name % s \
n " , chk_name ) ;
p t l c a l l _ c h e c k p o i n t _ a n d _ s h u t d o w n ( chk_name )
;
}
printf ( " Hello World \ n " ) ;
ptlcall_kill () ;
return EXIT_SUCCESS ;
}
38 / 53
Creating Checkpoints: PtlCall Function Call

• Run the program again after setting the environment variable


# export CHECKPOINT_NAME = helloWorld
# ./ helloWorld

• Now the checkpoint was created within the source code.

39 / 53
Checkpoint Management

• Check the checkpoint was created:


$ qemu - img info / hometemp / userXX / demo . qcow2

• Delete checkpoint:
$ qemu - img snapshot -d helloWorld / hometemp /
userXX / demo . qcow2

40 / 53
Creating Checkpoints: Batch

• A Python script to create checkpoints is provided with the


MARSSx86 distribution code
• We provided a simplified one: /checkpoint script.py
• Modify the user variable to match your username
• We added the commands needed for helloWorld checkpoint as
shown below.
# HelloWorld
bench = ’ helloWorld ’
pre_command = " make clean ; make ; export
CHECKPOINT_NAME =\"% s \"\ n " % ( bench )
cmd = " ./ helloWorld "
bench_dict = { ’ name ’ : bench , ’ command ’ : ’% s
\ n % s \ n ’ % ( pre_command , cmd ) }
check_list . append ( bench_dict )

41 / 53
Creating Checkpoints: Batch

• Copy the provided ˜/checkpoint script.py into the


marss.dramsim/util/ directory
$ cp ../ checkp oint_ script . py util /.

• Run script:
$ ./ util / checkp oint_ script . py

42 / 53
Simulating from Checkpoints: Direct

• Make sure the simulation configuration file has the run and
kill commands: /hometemp/userXX/demo.simcfg
- logfile demo . log
-run
...
-kill-after-run -quiet
...

• Launch the simulation from the checkpoint


$ ./ qemu / qemu - system - x86_64 -m 4 G - drive file
=/ hometemp / userXX / demo . qcow2 , cache = unsafe
- nographic - simconfig / hometemp / userXX /
demo . simcfg - loadvm helloWorld - snapshot

43 / 53
Simulating from Checkpoints: Batch

• The Python script to run from checkpoints needs a cfg file to


specify the simulation parameters

• Open ˜/util.cfg

• Update the user name


[ DEFAULT ]
user = ’ userXX ’
marss_dir = / hometemp /%( user ) / marss . dramsim

• Copy ˜/util.cfg file into the util/ directory inside the


marss.dramsim directory
$ cp ../ util . cfg util /.
$ emacs - nw util / util . cfg

44 / 53
Simulating from Checkpoints: Batch

• util/run bench.py has been provided with the MARSSx86


distribution

• Command to run the script:


$ ./ util / run_bench . py demo -d demo_stats -c
util / util . cfg -- chk - name = helloWorld

45 / 53
MARSSx86 Results

• Open demo stats/test.yml

• Script to parse yml files:


$ ./ util / mstats . py -y -- flatten -n
base_machine :: ooo_custom_0_0 .*:: cycles -t
total demo_stats / helloWorld . yml

46 / 53
DRAMSim2 Results

• Open
../DRAMSim2/results/dramsim helloWorld/DDR3 micron 8M 8B
x16 sg15/4GB.1Ch.8R.scheme2.open page.32TQ.32CQ.RtB.pRank.vis

47 / 53
Agenda

• Objectives
• Understand simulator components
• Be able to perform full system simulation
• Be able to control simulation environment

• Outline
• Create a disk image, qcow2 format
• Configure and compile DRAMSim2, MARSSx86
• Simulate programs
• Create checkpoints
• Simulate from checkpoints
• Parse results

48 / 53
MARSSx86

For more information on MARSSx86 visit


http://marss86.org/~marss86/index.php/Home

For more information on DRAMSim2 visit


http://www.eng.umd.edu/~blj/dramsim/

49 / 53
Tutorial Schedule

Time Topic
9:00 - 10:00 Setting up MARSSx86 and DRAMSim2
10:00 - 10:30 Web search simulation
10:30 - 11:00 GraphLab simulation
11:00 - 11:30 Spark simulation
11:30 - 12:30 Questions and hands on session

50 / 53
Backup Slides

• The following command requires display redirection (ssh -X


option)
• If using Ubuntu do not need anything additional

• If using MacOS need to install xQuartz

• Run MARSSx86 with the following command (with graphics,


display redirection required):
$ ./ qemu / qemu - system - x86_64 -m 4 G - drive file
=/ hometemp / userXX / demo . qcow2 , cache = unsafe
- simconfig / hometemp / userXX / demo . simcfg

51 / 53
Running MARSSx86

• QEMU has a control console that you can switch to with:


Ctrl+Alt+2 (only with graphics mode)

• In the control console you can modify the simulation


environment.
• For example you can switch the machine being simulated:

• Press ctrl+alt+1 to go back to the virtual machine console.

52 / 53

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy