qemu qemu and systemcand systemc

41
QEMU and SystemC QEMU and SystemC Màrius Montón Màrius Montón March 2011 QUF'11 Grenoble March 2011 QUF'11 Grenoble

Upload: others

Post on 12-Sep-2021

74 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: QEMU QEMU and SystemCand SystemC

QEMU and SystemCQEMU and SystemC

Màrius MontónMàrius MontónMarch 2011

QUF'11Grenoble

March 2011

QUF'11Grenoble

Page 2: QEMU QEMU and SystemCand SystemC

2

Outline

➢ Introduction➢ Objectives➢ Virtual Platforms and SystemC➢ Checkpointing for SystemC➢ Conclusions

Page 3: QEMU QEMU and SystemCand SystemC

3

Introduction – Virtual Platforms

➢ Functional models of physical platforms➢ Target SW unable to distinguish virtual

platform from real HW➢ Run SW or OS on Virtual HW➢ Develop SW for non-existing HW➢ Simulate complex system interconnectivity

Page 4: QEMU QEMU and SystemCand SystemC

4

Introduction – Virtual Platforms

Page 5: QEMU QEMU and SystemCand SystemC

5

Introduction – Virtual Platforms

Page 6: QEMU QEMU and SystemCand SystemC

6

Virtual Platform Design

Hardware

SoftwareIntegration

& Test

time

Eng

inee

ring

Res

ourc

es

© WindRiver (Virtutech)

Page 7: QEMU QEMU and SystemCand SystemC

7

Virtual Platform Design

Hardware

SoftwareIntegration

& Test

time

Eng

inee

ring

Res

ourc

es

time

Engi

neer

ing

Res

ourc

es Resources

Time to Market

Hardware

SoftwareIntegration

& Test© WindRiver

(Virtutech)

Page 8: QEMU QEMU and SystemCand SystemC

8

Virtual Platform

Generic Virtual Platform Diagram

ISSISS

VP Back-end functions

DevicesDevicesMemories

Target Drivers Boot code

Target Operating System

User UserUser

Page 9: QEMU QEMU and SystemCand SystemC

9

Introduction – SystemC & TLM-2

➢ SystemC language for systems description (HW mainly)

➢ OSCI simulator➢ TLM-2 standarizes communication model

● Sockets to emulate any memory-mapped bus➢ De facto standard for system modeling

Page 10: QEMU QEMU and SystemCand SystemC

10

Introduction – VP Languages

➢ Different Virtual Platforms uses different languages (C, C++, DLM, ...) and APIs

➢ HW engineers know (or should) SystemC, not other languages

➢ Different VP Rewrite own models →

➢ No interoperability

Page 11: QEMU QEMU and SystemCand SystemC

11

Objectives

➢ Add SystemC-TLM to any Virtual Platform● Different strategies to add two simulators● Add SystemC-TLM support to an open-sourced VP

➢ Add checkpointing support to SystemC● C++ not checkpointable● Overcome limitations

Page 12: QEMU QEMU and SystemCand SystemC

12

Generic Virtual Platform Diagram

Virtual Platform

ISSISS

VP Back-end functions

DevicesDevicesMemories

Target Drivers Boot code

Target Operating System

User UserUser

SystemC

SystemCDevices

Sync

Page 13: QEMU QEMU and SystemCand SystemC

13

Virtual Platforms and SystemC

➢ Link together two simulators➢ Synchronization strategy➢ Generic bridge➢ Support for generic TLM-2 devices

● LT, AT, DMI...

Page 14: QEMU QEMU and SystemCand SystemC

14

➢ Link together two simulators

Virtual Platforms and SystemC

Synch

VP

SystemC

Virtual time

Page 15: QEMU QEMU and SystemCand SystemC

15

Virtual Platforms and SystemC

Execution time

Synch

VP

SystemC

Virtual execution

Page 16: QEMU QEMU and SystemCand SystemC

16

QEMU-SC

➢ Transition from RTL to TLM➢ Generic fabric bus (TLM) → any architecture➢ QEMU master and SystemC slave (simulation)

● QEMU manages simulation➢ Focus on few SystemC devices

LinuxDriver

Application

VP SystemCmoduleSC

_Brid

ge

SC_L

ink TLM Socket

Page 17: QEMU QEMU and SystemCand SystemC

17

QEMU-SC

LinuxDriver

Application

VP SystemCmodule

SC_B

ridge

SC_L

ink TLM Socket

Page 18: QEMU QEMU and SystemCand SystemC

18

Synchronization

➢ Only synchronize when needed (sc_start())● When SystemC devices are accessed● When pending event in current simulation time

– SystemC events list● When I/O to/from SystemC device

– Capture or notify all I/O in SystemC device● QuantumKeeper asks to

– To adhere to standard

Page 19: QEMU QEMU and SystemCand SystemC

19

Communication

➢ QEMU works with zero-delay communication● CPU accesses one device and the device responds

immediately➢ Fit to LT devices➢ Need to manage AT devices

● Special synchronization● Finish all protocol phases before return to VP

Page 20: QEMU QEMU and SystemCand SystemC

20

Communication - LT

SC Bridge LT DeviceVP

operation()

b_transport()

operation()

Page 21: QEMU QEMU and SystemCand SystemC

21

Communication - AT

SC Bridge AT DeviceVP

operation()

nb_transport_fw()

nb_transport_bw()

nb_transport_fw()

nb_transport_bw()

operation()

BEGIN_REQ

END_REQ

BEGIN_RESP

END_RESP

Page 22: QEMU QEMU and SystemCand SystemC

22

Synchronization

➢ Manage external I/O from/to SC device● Devices use QEMU callbacks for I/O● Bridge knows when a I/O is performed

– Synchronize simulators➢ Continue SystemC simulation when

● VP time arrives to first SC event● Every quantum time (TLM-2)

➢ Advance SystemC time until transaction ends

Page 23: QEMU QEMU and SystemCand SystemC

23

QBox

➢ Change simulation manager● QEMU becomes simulator slave

➢ SystemC manages simulation➢ QEMU is a TLM-2 Initiator module➢ Easy integration➢ Focus on many SystemC

models Targetmodule

TLM SocketWrapper

SystemC simulation

QEMU

Page 24: QEMU QEMU and SystemCand SystemC

24

QBox

Targetmodule

TLM SocketWrapper

SystemC simulation

QEMU

Page 25: QEMU QEMU and SystemCand SystemC

25

QBox internal architecture

SC_Link

QEMU

GhostPCI dev 1

GhostPCI dev 2

QEMU Wrapper

sc_write()

sc_read()

sc_dmi_write()

sc_dmi_read()

DMI Pointer

TLM 2 Socket

PCI Bus

manage_int()SignalSocket

Stop

Start

Page 26: QEMU QEMU and SystemCand SystemC

26

QBox complex example

QEMU Wrapper

QEMUNIC

NoC

TILE TILE

TILE

Page 27: QEMU QEMU and SystemCand SystemC

27

Test & results

➢ Different tests and examples● Validate implementation● Extract performance metrics

➢ Results for performance● relatives to same system in native language

– C in QEMU & Qbox

Page 28: QEMU QEMU and SystemCand SystemC

28

QEMU-SC Test System

TLM Socket

MPEG accelerator

QEMU

SystemCiDCT acc.

SC_B

ridge

SC_L

ink DMI Pointer

Reg.

File

IRQIRQ

irq_event

LinuxDriver

MPEG-2 decoder

Page 29: QEMU QEMU and SystemCand SystemC

29

QEMU-SC Results

➢ No acc.➢ No acc. w/ drivers➢ QEMU style 1 acc.➢ SystemC 1 acc.➢ QEMU style 2 acc.➢ SystemC 2 acc.➢ SystemC skel. (1 acc.)➢ SystemC skel. (2 acc.)

A B C D E F G H0

5

10

15

20

25

30

35

1,10

22,1023,26

25,25

28,13

32,17

26,60 27,29

Configurations

Tim

e in

sec

onds

Page 30: QEMU QEMU and SystemCand SystemC

30

QEMU-SC Results

➢ No acc.➢ No acc. w/ drivers➢ QEMU style 1 acc.➢ SystemC 1 acc.➢ QEMU style 2 acc.➢ SystemC 2 acc.➢ SystemC skel. (1 acc.)➢ SystemC skel. (2 acc.)

A B C D E F G H0

5

10

15

20

25

30

35

1,10

22,1023,26

25,25

28,13

32,17

26,60 27,29

Configurations

Tim

e in

sec

onds

Penalty 8% ~ 14%

Page 31: QEMU QEMU and SystemCand SystemC

31

QBox Test System

TLM Socket

SystemCiDCT acc.

Reg.

File

IRQ

irq_event

SignalSocket (IRQ)QEMU Wrapper

QEMU GreenRouter

Linux Driver

MPEG-2 decoder

Page 32: QEMU QEMU and SystemCand SystemC

32

QBox Results

➢ No acc.➢ No acc. w/ drivers➢ QEMU style 1 acc.➢ SystemC 1 acc.➢ QEMU style 2 acc.➢ SystemC 2 acc.➢ SystemC skel. (1 acc.)➢ SystemC skel. (2 acc.)

A B C D E F G H0

10

20

30

40

50

60

70

80

Configurations

Tim

e in

sec

onds

Page 33: QEMU QEMU and SystemCand SystemC

33

QBox Results

➢ No acc.➢ No acc. w/ drivers➢ QEMU style 1 acc.➢ SystemC 1 acc.➢ QEMU style 2 acc.➢ SystemC 2 acc.➢ SystemC skel. (1 acc.)➢ SystemC skel. (2 acc.)

Penalty ~ 100%!!!

A B C D E F G H0

10

20

30

40

50

60

70

80

Configurations

Tim

e in

sec

onds

Page 34: QEMU QEMU and SystemCand SystemC

34

QBox Test System

TLM Socket

SystemCiDCT acc.

Reg.

File

IRQ

irq_event

SignalSocket (IRQ)QEMU Wrapper

QEMU GreenRouter

Linux Driver

MPEG-2 decoder

Penalty ~ 100%!!!

Page 35: QEMU QEMU and SystemCand SystemC

35

Complex QBox system

DMI Pointer

TLM 2 Socket

SignalSocket (IRQ)QEMU Wrapper

QEMUGreenRouter

NE2000

NE2000

TLM 2 Socket(Ethernet)Linux

Testbench

Page 36: QEMU QEMU and SystemCand SystemC

36

➢ Joined SystemC to two Virtual Platforms➢ Tested two different strategies for joining two

simulators● QEMU-SC● QBox

➢ Minor performance impact SystemC bridge➢ Published as open-sourced projects

www.greensocs.com

Conclusions – SystemC

Page 37: QEMU QEMU and SystemCand SystemC

37

Conclusions – SystemC

Simulation Manager Penalty System for

QEMU-SC Yes 10% SW

QBox No 25~30% HW

Page 38: QEMU QEMU and SystemCand SystemC

38

Future Work

➢ Automagic configuration of QBox systems● Manage map-address in QEMU, Router, BIOS, etc.

➢ Enhance QEMU time management● Hard to measure virtual time in QEMU

➢ Add multiple instances from QEMU● Current QBox library allows one

➢ Explore QEMU user mode● Simplified version, only ISS, run applications

Page 39: QEMU QEMU and SystemCand SystemC

39

Future Work

➢ Merge SystemC methods into QEMU kernel● Remove OSCI simulator and write an API

SystemC <-> QEMU➢ Merge QEMU functionality into OSCI kernel

● Make QEMU a truly SystemC ISS➢ Both merges increase simulation speed due to

removed synchronization

Page 40: QEMU QEMU and SystemCand SystemC

40

Proposal

➢ Join efforts and teams to develop ● just one QEMU & SystemC virtual platform

Page 41: QEMU QEMU and SystemCand SystemC

Thank you!Thank you!

Questions?Questions?