stars and metropolis: static and dynamic rtos modeling felice balarin cadence berkeley labs

49
STARS and Metropolis: static and dynamic RTOS modeling Felice Balarin Cadence Berkeley Labs

Post on 19-Dec-2015

215 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: STARS and Metropolis: static and dynamic RTOS modeling Felice Balarin Cadence Berkeley Labs

STARS and Metropolis: static and dynamic RTOS modeling

Felice Balarin

Cadence Berkeley Labs

Page 2: STARS and Metropolis: static and dynamic RTOS modeling Felice Balarin Cadence Berkeley Labs

RTOS modeling

Any OS has two basic function:

• To create abstraction of computational tasks running concurrently while sharing HW resources like CPU

• To offer communication services between tasks and the rest of the world, and between tasks themselves

In addition, Real-time OS (RTOS) needs to ensure that computation and communication done by tasks occurs in a predictable time-frame

• dynamic or static performance analysis

• Metropolis and STARS

Page 3: STARS and Metropolis: static and dynamic RTOS modeling Felice Balarin Cadence Berkeley Labs

RTOS: a Metropolis architectural componentAn RTOS is modeled by

• what it can do

• how much it costs

: interfaces

: time, energy, resource utilization

medium RTOS implements RTOSservices …{

port MemService Mem; …

void compute(int time) {

[[

Sheduler.request(B(thisAction),thisProcess);

TimeMgr.request(E(thisAction),

TimeMgr.A(B(thisAction))+time);

Sheduler.request(E(thisAction), rtosProcess);

]]

;

}

interface RTOSservices extends Port {

void send(message m, mailbox b);

message receive(mailbox b);

void compute(int time);

}

Scheduler

RTOS

TimeMgr

Page 4: STARS and Metropolis: static and dynamic RTOS modeling Felice Balarin Cadence Berkeley Labs

Metropolis: architecture netlist

Bus

ArbiterBus

Mem

RTOS Sched

MyArchNetlist

Master

CPU + OS

Slave

Mem

Arbiter

Architecture netlist specifies configurations of architecture components.

Each constructor

- instantiates arch. components,

- connects them,

Page 5: STARS and Metropolis: static and dynamic RTOS modeling Felice Balarin Cadence Berkeley Labs

Meta-model: mapping netlist

Bus

ArbiterBus

Mem

RTOS OsSched

MyArchNetlist

mP1 mP2mP1 mP2

MyFncNetlist

MP1 P2

Env1 Env2

B(P1, M.write) <=> B(mP1, mP1.send); E(P1, M.write) <=> E(mP1, mP1.send);

B(P1, P1.f) <=> B(mP1, mP1.compute); E(P1, P1.f) <=> E(mP1, mP1.compute);

B(P2, M.read) <=> B(P2, mP2.receive); E(P2, M.read) <=> E(mP2, mP2.receive);

B(P2, P2.f) <=> B(mP2, mP2.compute); E(P2, P2.f) <=> E(mP2, mP2.compute);

MyMapNetlist

Page 6: STARS and Metropolis: static and dynamic RTOS modeling Felice Balarin Cadence Berkeley Labs

Outline

• Background

– VCC

– STARS

• VCC-STARS integration

– extend any VCC simulation model with abstractions required by STARS

• Automatic abstraction generation

– for a class of VCC models

Page 7: STARS and Metropolis: static and dynamic RTOS modeling Felice Balarin Cadence Berkeley Labs

VCC Behavior

• network of behavioral blocks

• many ways to specify a block (BlackBox C++, WhiteBox C, ...)

• simulation used to verify functionality

Page 8: STARS and Metropolis: static and dynamic RTOS modeling Felice Balarin Cadence Berkeley Labs

VCC Architecture

• network of architectural blocks

• needed to determine performance of behavioral blocks

Page 9: STARS and Metropolis: static and dynamic RTOS modeling Felice Balarin Cadence Berkeley Labs

VCC Mapping

• performance of each behavioral block is modeled

• simulation is used to verify performance

Page 10: STARS and Metropolis: static and dynamic RTOS modeling Felice Balarin Cadence Berkeley Labs

BlackBox C++ behavioral blocks

class fifo:

public FxCPPBlackBoxModel { InputPort<int> Request, Input; OutputPort<int> Output; ...};

void fifo::Run() { if(Request.Enabled()&& !empty) Output.Post(FIFOPop()); if (Input.Enabled()) FIFOPush(Input.Value()); ...}

Input Output

Request

fifo

•the only kind understood by VCC simulation core

Page 11: STARS and Metropolis: static and dynamic RTOS modeling Felice Balarin Cadence Berkeley Labs

WhiteBox C behavioral blocks

void point_entry_run() {

if(Request_Enabled()&& !empty) Output_Post(FIFOPop()); if (Input_Enabled()) FIFOPush(Input_Value()); ...}

void fifo::Run() { _delayCycles(60); if(Request.Enabled()&& !empty){ Output.Post(FIFOPop()); _delayCycles(80); } _delayCycles(75); if (Input.Enabled()) { _delayCycles(100); FIFOPush(Input.Value()); } ...}

Input Output

Request

fifo

estimation

CPU model

Page 12: STARS and Metropolis: static and dynamic RTOS modeling Felice Balarin Cadence Berkeley Labs

Outline

• Background

– VCC

– STARS

• VCC-STARS integration

– extend any VCC simulation model with abstractions required by STARS

• Automatic abstraction generation

– for a class of VCC models

Page 13: STARS and Metropolis: static and dynamic RTOS modeling Felice Balarin Cadence Berkeley Labs

STatic Analysis of Reactive Systems

For all inputs:

• Can I process all workload between two ticks?

• How much bus traffic will I generate?

• How much energy will I use?

play

messagecontrol buffernetwork

ticksample

request

frame

Page 14: STARS and Metropolis: static and dynamic RTOS modeling Felice Balarin Cadence Berkeley Labs

Outline

• STARS

– overview

– representing signals

– representing system components

– finding worst-case behaviors

– representing timing information

Page 15: STARS and Metropolis: static and dynamic RTOS modeling Felice Balarin Cadence Berkeley Labs

STARS overview

• STARS finds worst-case signature of any execution window of a given length

• STARS finds the worst-case CPU busy period

play

messagecontrol buffernetwork

ticksample

request

frame

pl

ms

tksm

rq

fr

SIGNATURE

Fcntr Fbfr

Fenv

SIGNATURE ABSTRACTION

tick

play

frame

pl = 1fr = 2tk = 3

Page 16: STARS and Metropolis: static and dynamic RTOS modeling Felice Balarin Cadence Berkeley Labs

Signatures

• in practice, counting “events”

– state transitions may be considered events

– combinations of events may have separate counters

– may need linear constraints over counters

• less events is “better than” () more events

Page 17: STARS and Metropolis: static and dynamic RTOS modeling Felice Balarin Cadence Berkeley Labs

t t+T

s,T

t t+Tq

Signature Abstractions

Estimate output signature based on input signature and length

• must be conservative

F( s, T)F

system

Page 18: STARS and Metropolis: static and dynamic RTOS modeling Felice Balarin Cadence Berkeley Labs

Signature Abstractions: Environment

• at least 625s between messages

– Fms (s, T) = T/625 + 1

• tick has 125s period

– Ftk (s, T) = T/125 + 1

• at most 1 play a second

– Fpl (s, T) = T/1,000,000 + 1

play

messagecontrol buffernetwork

ticksample

request

frame

Page 19: STARS and Metropolis: static and dynamic RTOS modeling Felice Balarin Cadence Berkeley Labs

Signature Abstraction: Buffer

BUFFER:if ( present ( frame ) {

samples = frame; last = 50; }

if ( present ( tick ) && last > 0) {emit sample ( samples[ last -- ] );if ( last == 20 ) emit request(); }

play

messagecontrol buffernetwork

ticksample

request

frame

Frq (s, T) = min( fr, tk/30)

Fsm (s, T) = min( tk, 50*fr )

Page 20: STARS and Metropolis: static and dynamic RTOS modeling Felice Balarin Cadence Berkeley Labs

s

t t+T

Fix-point Theorem

If:

• s = F(s, T),

• s is worse than signature of initial state,

then s is worse than signature of any execution segment of length T

Page 21: STARS and Metropolis: static and dynamic RTOS modeling Felice Balarin Cadence Berkeley Labs

Workload Function

Estimates required processor time from signatures

• must be conservative

s

Task 2Task 1

Idle

W(s)

Page 22: STARS and Metropolis: static and dynamic RTOS modeling Felice Balarin Cadence Berkeley Labs

Workload Function: VM pager

BUFFER:if ( present ( frame ) {

samples = frame; last = 50; }

if ( present ( tick ) && last > 0) {emit sample ( samples[ last -- ] );if ( last == 20 ) emit request(); }

play

messagecontrol buffernetwork

ticksample

request

frame

W (s) = 20*fr + 20*sm + ...

1 line = 10 time units

Page 23: STARS and Metropolis: static and dynamic RTOS modeling Felice Balarin Cadence Berkeley Labs

STARS

1Pick a signature

2Chose a signature abstraction F and workload function W and verify they and conservative

3Solve

s = F(s,T)

T = W(s)

4T is a bound on response time

the processor cannot be continuously busy for more than T time units

Page 24: STARS and Metropolis: static and dynamic RTOS modeling Felice Balarin Cadence Berkeley Labs

Outline

• Background

– VCC

– STARS

• VCC-STARS integration

– why, what and how

• Automatic abstraction generation

– for a class of VCC models

Page 25: STARS and Metropolis: static and dynamic RTOS modeling Felice Balarin Cadence Berkeley Labs

Why VCC-STARS?

• cannot relate components to their abstractions

play

messagecontrol buffernetwork

ticksample

request

frame

pl

ms

tksm

rq

frFcntr Fbfr

Fenv

VCC

STARS

??? ??? ???

Page 26: STARS and Metropolis: static and dynamic RTOS modeling Felice Balarin Cadence Berkeley Labs

VCC-STARS: What?

• abstract models used by STARS can be validated by VCC simulation

play

messagecontrol buffernetwork

ticksample

request

frame

pl

ms

tksm

rq

frFcntr Fbfr

Fenv

monitor

Page 27: STARS and Metropolis: static and dynamic RTOS modeling Felice Balarin Cadence Berkeley Labs

VCC-STARS: How?

BlackBox C++ extensions to represent signatures

• vectors of counter values

• each behavioral block has:

– one counter for each input port

– one counter for each output port

– a counter measuring CPU time usage

– optional user-defined counters

Page 28: STARS and Metropolis: static and dynamic RTOS modeling Felice Balarin Cadence Berkeley Labs

Signature: example

class fifo: public FxCPPBlackBoxModel { InputPort<int> Request, Input; OutputPort<int> Output; starsCounter numExecutions; ... };

counters:

•Output.count•Input.count•Request.count •numExecutions• the one pointed to by processorTimeCounter()

Page 29: STARS and Metropolis: static and dynamic RTOS modeling Felice Balarin Cadence Berkeley Labs

VCC-STARS: How?

BlackBox C++ extensions to represent signature abstractions

• each block has member function: void starsAbstraction()

• sets bounds of output-port, CPU-usage, and user-defined counters, based on input-port counters and length of time

• must be conservative:

t t+T

sign.

t t+Tsign.

est. sign.starsAbstraction()

Run()

Page 30: STARS and Metropolis: static and dynamic RTOS modeling Felice Balarin Cadence Berkeley Labs

Signature abstraction example

class fifo: public FxCPPBlackBoxModel { InputPort<int> Request, Input; OutputPort<int> Output; starsCounter numExecutions; ... };

void fifo::Run() { numExecutions++; if(Request.Enabled()&& !empty) Output.Post(FIFOPop()); if (Input.Enabled()) FIFOPush(Input.Value()); ... }

void fifo::starsAbstraction() { Output.count.setBound( min( Input.count, Request.count)); numExecutions.setBound( Input.count + Request.count); ... }

Page 31: STARS and Metropolis: static and dynamic RTOS modeling Felice Balarin Cadence Berkeley Labs

Signature abstraction example (cont’d)

delay_model(){input(Input);input(Request);run();delay('0.000001');output(Output);

}

void fifo::starsAbstraction() { Output.count.setBound(min(Input.count, Request.count)); numExecutions.setBound(Input.count

+ Request.count);

starsCounter * p = processorTimeCounter(); if(p) p->setBound(1000*numExecutions); }

Page 32: STARS and Metropolis: static and dynamic RTOS modeling Felice Balarin Cadence Berkeley Labs

Signature abstractions

• may depend on time:

void env::starsAbstraction() {

Burst.count.setBound(mgr()->timeWindow()/625000+1);

}

•mgr() is a manager containing STARS info

• timeWindow() depends on context

– in simulation, it’s the time since monitor creation

– in STARS, it can be a constant

– in STARS, it can be current estimate of the busy-period

Page 33: STARS and Metropolis: static and dynamic RTOS modeling Felice Balarin Cadence Berkeley Labs

starsAbstraction()

• is verified to be conservative by simulation monitors that perform the following check every time an output counter is changed

– evaluate starsAbstraction() using current values of input counters

– compare output counters with bounds computed by starsAbstraction()

– if bounds are violated, warn that starsAbstraction() is not conservative

• is used by STARS to compute to compute worst-case bounds of all the counters in the network

Page 34: STARS and Metropolis: static and dynamic RTOS modeling Felice Balarin Cadence Berkeley Labs

Voice Mail Pager

• 16 modules

• ~ 4000 lines of C++ code annotated with timing estimates

• build signature abstractions manually

– 150 lines of C code

Page 35: STARS and Metropolis: static and dynamic RTOS modeling Felice Balarin Cadence Berkeley Labs

VMP First experiment

• model environment so that a single message is received and then played

– same as VCC test-bench

• max busy period:

– VCC: 82 s (simulating 8s took ~ 30 s)

– STARS: 83 s (took 16 ms to compute)

Page 36: STARS and Metropolis: static and dynamic RTOS modeling Felice Balarin Cadence Berkeley Labs

VMP second experiment

• same as first except:

– don’t limit the environment to a single message

• max busy period:

– STARS 148 s (more than 125 s between two ticks)

– VCC: can find input that has 146 s

1 2 3 29 30 31 49 50

50x125

125

message, play

66s wide window in a 6250 s period

Page 37: STARS and Metropolis: static and dynamic RTOS modeling Felice Balarin Cadence Berkeley Labs

Outline

• Background

– VCC

– STARS

– other related work

• VCC-STARS

– BlackBox C++ extensions

• Automatic abstraction generation

– for WhiteBox C blocks

Page 38: STARS and Metropolis: static and dynamic RTOS modeling Felice Balarin Cadence Berkeley Labs

What?

• abstract models can be automatically generated for WhiteBox C blocks

play

messagecontrol buffernetwork

ticksample

request

frame

pl

ms

tksm

rq

fr

Fenv

Fcntr Fbfr

VC

C-S

TA

RS

VC

C-S

TA

RS

Page 39: STARS and Metropolis: static and dynamic RTOS modeling Felice Balarin Cadence Berkeley Labs

Automatic abstraction: How?

• WhiteBox C flow in VCC

WhiteBox C

estimation

CPU model

annotatedBlackBox C++

signatureabstraction

Hints

estimation

-STARS

Page 40: STARS and Metropolis: static and dynamic RTOS modeling Felice Balarin Cadence Berkeley Labs

Automatic abstraction algorithm

starting from:

– input counters

– user hints,

propagate bounds to

– statements

– output counters

for each output counter with a bound

set its bound to the minimum of all

if each basic block of code has a bound

use VCC delay estimates to bound CPU time

boundpropagation

codegeneration

Page 41: STARS and Metropolis: static and dynamic RTOS modeling Felice Balarin Cadence Berkeley Labs

Example

void point_entry_run() { starsIncrement(numExecutions); if (Request_Enabled() && !empty ) Output_Post(FIFOPop()); if (Input_Enabled()) FIFOPush(Input_Value());}

Request.count

void fifo::starsAbstraction() { Output.count.setBound( Request.count ); }

Page 42: STARS and Metropolis: static and dynamic RTOS modeling Felice Balarin Cadence Berkeley Labs

Hints

void point_entry_run() { starsIncrement(numExecutions); if (Request_Enabled() && !empty ) Output_Post(FIFOPop()); if (Input_Enabled()) FIFOPush(Input_Value());}

Request.count

void fifo::starsAbstraction() { numExecutions.setBound( 10 ); int b = min( numExecutions, Request.count); Output.count.setBound( b ); starsCounter * p = processorTimeCounter(); if(p) p->setBound(numExecutions*(D1+D3+D4) + b*D2);}

void starsSetBounds() { numExecutions_SetBound(10); }

numExecutionsD1

D2D3D4

Page 43: STARS and Metropolis: static and dynamic RTOS modeling Felice Balarin Cadence Berkeley Labs

RESULTS ON AUTOMATIC ABSTRACTION

IMMEDIATE

• generating signature abstractions automatically is undecidable for arbitrary code

DATE 2000

• if transition relation of a memory-less component is a Boolean function represented with a BDD then its ideal signature abstraction can be generated automatically

SASIMI 2001

• generating signature abstraction automatically is possible for finite-state machines

Page 44: STARS and Metropolis: static and dynamic RTOS modeling Felice Balarin Cadence Berkeley Labs

Related Work

• YAPI-STARS, presented at CODES 2000

– systems in YAPI are networks of concurrent processes, similar to Khan’s process networks

– YAPI-STARS is good for bounding communication requirements

– no performance analysis

• Program path analysis (Cinderella), Li and Malik 1999

– intended for timing analysis of embedded software

– useful for automatically generating abstractions used by STARS

Page 45: STARS and Metropolis: static and dynamic RTOS modeling Felice Balarin Cadence Berkeley Labs

Conclusions

• STARS adds worst-case analysis to simulation

– can prove that performance requirements are met

– helps find hard performance bugs

• requires additional designer effort to specify abstractions

– typically |STARS abstractions| < 10% * |simulation models|

– even smaller for estimated WhiteBox C

• abstractions can be verified by VCC simulations

• could be applied to any simulation environment where meaningful counters can be defined

Page 46: STARS and Metropolis: static and dynamic RTOS modeling Felice Balarin Cadence Berkeley Labs

Thank you

Page 47: STARS and Metropolis: static and dynamic RTOS modeling Felice Balarin Cadence Berkeley Labs

Outline

• Background

– VCC

– STARS

– other related work

• VCC-STARS intergration

– BlackBox C++ extensions

• Automatic abstraction generation

– for WhiteBox C blocks

Page 48: STARS and Metropolis: static and dynamic RTOS modeling Felice Balarin Cadence Berkeley Labs

t t+T

sign.

t t+Tsign.

Signature Abstractions

Estimate signature of output counters based on the signature of input counters

– must be conservative

boundstarsAbstraction()

Run()

Page 49: STARS and Metropolis: static and dynamic RTOS modeling Felice Balarin Cadence Berkeley Labs

Proposal

VCC + STARS = VCC-STARS

• Black Box C++ extensions:

– providing signatures of events on ports

– enabling the user to associate a signature abstraction for

each BlackBox C++ block