sw model in bip - artist-embedded.org · system model in bip distributed bip code generator c++...

41

Upload: others

Post on 27-May-2020

10 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: SW model in BIP - artist-embedded.org · System model in BIP Distributed BIP Code Generator C++ Code Deployed SW . O V E R V I E W 4 ... Safe and efficient execution from partial
Page 2: SW model in BIP - artist-embedded.org · System model in BIP Distributed BIP Code Generator C++ Code Deployed SW . O V E R V I E W 4 ... Safe and efficient execution from partial

Programming Model Application SW

SW model in BIP

Source2Source Compiler

Multicore Platform

BIP Engine/Linux

Productivity

Functional Correctness

Performance

Correctness Simulation/ Model Checking

Efficiency/ Correctness

Translator

D-Finder DOL System model in BIP

Distributed BIP

Code Generator

C++ Code

Deployed SW

Page 3: SW model in BIP - artist-embedded.org · System model in BIP Distributed BIP Code Generator C++ Code Deployed SW . O V E R V I E W 4 ... Safe and efficient execution from partial
Page 4: SW model in BIP - artist-embedded.org · System model in BIP Distributed BIP Code Generator C++ Code Deployed SW . O V E R V I E W 4 ... Safe and efficient execution from partial

O V E R V I E W

4

  BIP – Global state model

  Distributed centralized implementation

  Decentralized implementations

  Architecture transformations

 Discussion

Page 5: SW model in BIP - artist-embedded.org · System model in BIP Distributed BIP Code Generator C++ Code Deployed SW . O V E R V I E W 4 ... Safe and efficient execution from partial

BIP – Basic Concepts

B E H A V I O R

Interactions(collaboration)Priorities(conflictresolution)

Layered component model

Composition operation parameterized by glue IN12, PR12

IN12PR12

PR1IN1

PR2IN2 IN1⊗IN2⊗IN12

PR1⊕PR2⊕PR12

Page 6: SW model in BIP - artist-embedded.org · System model in BIP Distributed BIP Code Generator C++ Code Deployed SW . O V E R V I E W 4 ... Safe and efficient execution from partial

BIP – Basic Concepts

s

Sender

r1

Receiver1

Interactions:sr1r2r3Priorities:∅

Rendezvous

s r1

r2

Receiver2

r2

r3

Receiver3

r3

Page 7: SW model in BIP - artist-embedded.org · System model in BIP Distributed BIP Code Generator C++ Code Deployed SW . O V E R V I E W 4 ... Safe and efficient execution from partial

BIP – Basic Concepts

Interactions: s + sr1 + sr2 + sr3 + sr1r2 + sr2r3 + sr1r3 + sr1r2r3

Priorities:xπxy for x,xy∈Interactions

Broadcast

s

Sender

r1

Receiver1

s r1

r2

Receiver2

r2

r3

Receiver3

r3

Page 8: SW model in BIP - artist-embedded.org · System model in BIP Distributed BIP Code Generator C++ Code Deployed SW . O V E R V I E W 4 ... Safe and efficient execution from partial

BIP – Basic Concepts

Interactions:s+sr1r2r3Priorities:xπxy for x,xy∈Interactions

Atomic Broadcast

s

Sender

r1

Receiver1

s r1

r2

Receiver2

r2

r3

Receiver3

r3

Page 9: SW model in BIP - artist-embedded.org · System model in BIP Distributed BIP Code Generator C++ Code Deployed SW . O V E R V I E W 4 ... Safe and efficient execution from partial

BIP – Basic Concepts

Interactions:s+sr1+sr1r2+sr1r2r3Priorities:xπxy for x,xy∈Interactions

Causal Chain

s

Sender

r1

Receiver1

s r1

r2

Receiver2

r2

r3

Receiver3

r3

Page 10: SW model in BIP - artist-embedded.org · System model in BIP Distributed BIP Code Generator C++ Code Deployed SW . O V E R V I E W 4 ... Safe and efficient execution from partial

BIP – Basic Concepts: Semantics

Interactions a∈γ ∀i∈[1,n] qi - a∩Pi→i q’i (q1 ,., qn) - a →γ (q’1 ,., q’n) where q’I =qI if a∩Pi=∅

  a set of atomic components {Bi }i=1..n where Bi =(Qi, 2Pi, →i)

  a set of interactions γ

  priorities π⊆ γ ×(⊗ Qi )×γ

π γ (B1,., Bn)

Priorities q- a →γ q’ ¬ (∃ q- b→γ ∧ a πq b ) q- a →π q’

Page 11: SW model in BIP - artist-embedded.org · System model in BIP Distributed BIP Code Generator C++ Code Deployed SW . O V E R V I E W 4 ... Safe and efficient execution from partial

BIP – The execution Engine

busy

filter

stable

ready

execute

choose

init

Page 12: SW model in BIP - artist-embedded.org · System model in BIP Distributed BIP Code Generator C++ Code Deployed SW . O V E R V I E W 4 ... Safe and efficient execution from partial

O V E R V I E W

12

  BIP – Global state model

  Distributed centralized implementation

  Decentralized implementations

  Architecture transformations

 Discussion

Page 13: SW model in BIP - artist-embedded.org · System model in BIP Distributed BIP Code Generator C++ Code Deployed SW . O V E R V I E W 4 ... Safe and efficient execution from partial

Distributed Implementation

BIP is based on:  Global state semantics, defined by operational semantics rules,

implemented by the Engine  Atomic multiparty interactions, e.g. by rendezvous or broadcast

Translate BIP models into distributed models  Collection of independent components intrinsically concurrent - No

global state   Separate interaction from internal computation of components  Point to point communication by asynchronous message passing   Correctness by construction that is, the initial BIP model is

observationally equivalent to the implementation

Approach: BIP ⇒ Partial state BIP ⇒ Distributed BIP

Page 14: SW model in BIP - artist-embedded.org · System model in BIP Distributed BIP Code Generator C++ Code Deployed SW . O V E R V I E W 4 ... Safe and efficient execution from partial

Centralized Distributed Implementation – The Principle

Interactions:γPriorities:π

B1 B2

Bn

Interactions:γ ⊥ Priorities:π ⊥

B1⊥ B2

⊥ Bn⊥

B1⊥ B2

⊥ Bn⊥

Engine Oracle

Page 15: SW model in BIP - artist-embedded.org · System model in BIP Distributed BIP Code Generator C++ Code Deployed SW . O V E R V I E W 4 ... Safe and efficient execution from partial

Distributed Implementation – Global vs. Partial State Models

Interactions:γPriorities:π

a,fa

a

b,fb

b

c,fc

c

d,fd

d

(a) Global State Model

Broadcast γ = a+ab+ac+ad+abc+abd+acd+abcd, with maximal progress.

(a): only abcd is possible.

Rendezvous γ = ab+bc+cd and priority abπbc, cdπbc . (a): only bc is possible

Broadcast γ = a+ab+ac+ad+abc+abd+acd+abcd, with maximal progress.

(a): only abcd is possible. (b): arbitrary desynchronization may occur.

Rendezvous γ = ab+bc+cd and priority abπbc, cdπbc . (a): only (bc)ω is possible (b): it is possible to reach a state from which bc never occurs e.g. ab(fa cd fb fd ab fc)ω.

Interactions:γ ⊥ Priorities:π ⊥

a b c d

a

β

b fb c fc d fd

(b) Partial State Model

fa

β β β

Page 16: SW model in BIP - artist-embedded.org · System model in BIP Distributed BIP Code Generator C++ Code Deployed SW . O V E R V I E W 4 ... Safe and efficient execution from partial

Distributed Implementation – Partial state semantics

q1   States are global or partial   β-transitions interleave   From any state q a unique global state is reached by application of β-transitions

q2

p, f

q1

p

q2

β,f

Objective: Safe and efficient execution from partial states

a∈γ ∀i∈[1,n] qi - a∩Pi→i q’i O(q1 ,., qn ;a) (q1 ,., qn) - a →γ (q’1 ,., q’n) where q’I =qI if a∩Pi=∅

qA qB qC qD ⊥ ⊥ ⊥ ⊥ qA ⊥ ⊥ ⊥ qA qB ⊥ ⊥ qA qB ⊥ qD abcd β β β

β

a? ab? abd?

Page 17: SW model in BIP - artist-embedded.org · System model in BIP Distributed BIP Code Generator C++ Code Deployed SW . O V E R V I E W 4 ... Safe and efficient execution from partial

Distributed Implementation – Oracles

a

O(⊥ y1;a)

x2y1

b ¬ (a π b)

x2y1 x1y1

b ¬ (a π b)

more precise global state Dynamic Oracle

Ideal Oracle

Par

alle

lism

Overhead

Static Oracle x2y1 x1y1

b ¬ (a π b)

x2y2 x1y2

Lazy Oracle O(⊥ y1;a) = false

Knowledge-based Oracle

Page 18: SW model in BIP - artist-embedded.org · System model in BIP Distributed BIP Code Generator C++ Code Deployed SW . O V E R V I E W 4 ... Safe and efficient execution from partial

Distributed Implementation – Asynchronous MP Model

 Before reaching a ready state, the set of the enabled ports is sent to the Engine  From a ready state, await notification from the Engine indicating the selected port

a

a b

Partial State Model

β, fa

b

β, fb

?a

?a

?b

!{a,b} !{a,b}

?b !{a,b}

Message Passing Model

β, fa β, fb

Page 19: SW model in BIP - artist-embedded.org · System model in BIP Distributed BIP Code Generator C++ Code Deployed SW . O V E R V I E W 4 ... Safe and efficient execution from partial

Distributed Implementation – Example (Forte 08)

Page 20: SW model in BIP - artist-embedded.org · System model in BIP Distributed BIP Code Generator C++ Code Deployed SW . O V E R V I E W 4 ... Safe and efficient execution from partial

O V E R V I E W

20

  BIP – Global state model

  Distributed centralized implementation

  Decentralized implementations

  Architecture transformations

 Discussion

Page 21: SW model in BIP - artist-embedded.org · System model in BIP Distributed BIP Code Generator C++ Code Deployed SW . O V E R V I E W 4 ... Safe and efficient execution from partial

Decentralized Distributed Implementation – The principle

a c

b

A

B

C

!a

Engine ?a

!b ?b

!c

?c A⊥

B⊥

C⊥

Page 22: SW model in BIP - artist-embedded.org · System model in BIP Distributed BIP Code Generator C++ Code Deployed SW . O V E R V I E W 4 ... Safe and efficient execution from partial

Distributed Implementation – Implementing Connectors

!a

Engine ?a

!b ?b

!c

?c

!a

?a

!b ?b

!c

?c

!a

?a

!b ?b

!c

?c

Page 23: SW model in BIP - artist-embedded.org · System model in BIP Distributed BIP Code Generator C++ Code Deployed SW . O V E R V I E W 4 ... Safe and efficient execution from partial

Centralized solution – Conflict Resolution

I4 I5 I6

I1 I2 I3

A⊥ B⊥ C⊥ D⊥

I1 I2 I3

I4 I6 I5 A B C D

Page 24: SW model in BIP - artist-embedded.org · System model in BIP Distributed BIP Code Generator C++ Code Deployed SW . O V E R V I E W 4 ... Safe and efficient execution from partial

Centralized solution – Conflict Resolution

I1 I2 I3

I4 I6 I5 A B C D

I2 I6

A⊥ B⊥ C⊥ D⊥

Page 25: SW model in BIP - artist-embedded.org · System model in BIP Distributed BIP Code Generator C++ Code Deployed SW . O V E R V I E W 4 ... Safe and efficient execution from partial

Centralized solution – Conflict Resolution

I1 I2 I3

I4 I6 I5 A B C D

I1 alpha core I2 alpha

core I3

I4 I5 I6

alpha core

alpha core

alpha core

alpha core

A⊥ B⊥ C⊥ D⊥ alpha core

alpha core

alpha core

alpha core

Page 26: SW model in BIP - artist-embedded.org · System model in BIP Distributed BIP Code Generator C++ Code Deployed SW . O V E R V I E W 4 ... Safe and efficient execution from partial

Centralized solution – Conflict Resolution

I1 I2 I3

I4 I6 I5 A B C D

I1 I2 I3

I4 I5 I6

A⊥ B⊥ C⊥ D⊥

Distributed Independent Set of Conflicting Interactions

Distributed Independent Set of Conflicting Interactions

Page 27: SW model in BIP - artist-embedded.org · System model in BIP Distributed BIP Code Generator C++ Code Deployed SW . O V E R V I E W 4 ... Safe and efficient execution from partial

Distributed Clique of non Conflicting Interactions

Distributed Clique of non Conflicting Interactions

Centralized solution – Conflict Resolution

I1 I2 I3

I4 I6 I5 A B C D

I1 I2 I3

I4 I5 I6

A⊥ B⊥ C⊥ D⊥

Page 28: SW model in BIP - artist-embedded.org · System model in BIP Distributed BIP Code Generator C++ Code Deployed SW . O V E R V I E W 4 ... Safe and efficient execution from partial

Distributed Graph Matching (edges not sharing a common vertex)

Decentralized Solution

I1 I2 I3

I4 I6 I5 A B C D

A⊥ B⊥ C⊥ D⊥

Pro

toco

l

Pro

toco

l

Pro

toco

l

Pro

toco

l

Page 29: SW model in BIP - artist-embedded.org · System model in BIP Distributed BIP Code Generator C++ Code Deployed SW . O V E R V I E W 4 ... Safe and efficient execution from partial

O V E R V I E W

29

  BIP – Global state model

  Distributed centralized implementation

  Decentralized implementations

  Architecture transformations

 Discussion

Page 30: SW model in BIP - artist-embedded.org · System model in BIP Distributed BIP Code Generator C++ Code Deployed SW . O V E R V I E W 4 ... Safe and efficient execution from partial

Architecture Transformations

Partitioning

Monolithic Code Generation

Page 31: SW model in BIP - artist-embedded.org · System model in BIP Distributed BIP Code Generator C++ Code Deployed SW . O V E R V I E W 4 ... Safe and efficient execution from partial

Architecture Transformations – Composite to Monolithic

Connector Flattening

Component Flattening

Page 32: SW model in BIP - artist-embedded.org · System model in BIP Distributed BIP Code Generator C++ Code Deployed SW . O V E R V I E W 4 ... Safe and efficient execution from partial

Architecture Transformations – Composite to Monolithic

g1f1p1 g2

f2p2

p1 p2

G,F

g1f1p1 g2

f2p2

p1 p2 p1p2

p1p2gf

g=g1∧g2∧Gf=F;(f1||f2)

Page 33: SW model in BIP - artist-embedded.org · System model in BIP Distributed BIP Code Generator C++ Code Deployed SW . O V E R V I E W 4 ... Safe and efficient execution from partial

Transform the monolithic sequential program (12000 lines of C code) into a componentized one:

++ reusability, schedulability analysis, reconfigurability – – overhead in memory and execution time

f_in f_out

grabFrame()

f_in f_out

outputFrame()

GrabFrame OutputFrame

f_out f_out f_outf_in f_inf_in

Encode

Decomposition:   GrabFrame: gets a frame and produces macroblocks   OutputFrame: produces an encoded frame   Encode: encodes macroblocks

Example – MPEG4 Video Encoder

Page 34: SW model in BIP - artist-embedded.org · System model in BIP Distributed BIP Code Generator C++ Code Deployed SW . O V E R V I E W 4 ... Safe and efficient execution from partial

Reconstruction

Intraprediction

IQuant

IDCT

MotionEstimation

DCT

Quant

Coding

GrabMacroBlock

outin

outin

outin

outin

outin

out

f_in

outin

outin

in1 in2

f_in

f_out

f_out

:bufferedconnections

GrabMacroBlock:splitsaframein(W*H)/256macroblocks,outputsoneatatime

Reconstruction:regeneratestheencodedframefromtheencodedmacroblocks.

Example – MPEG4 Video Encoder

Page 35: SW model in BIP - artist-embedded.org · System model in BIP Distributed BIP Code Generator C++ Code Deployed SW . O V E R V I E W 4 ... Safe and efficient execution from partial

in out

fn()

inc<MAXc:=c+1

f_outc=MAXc:=0

Reconstruction

GenericFunctionalcomponent

f_in

out

GrabMacroBlock

c<MAXgrabMacroBlock(),c:=c+1

in f_outout

out

f_in

in

reconstruction()

exitc=MAXc:=0

MAX=(W*H)/256 W=width of frame H=height of frame

Example – MPEG4 Video Encoder

Page 36: SW model in BIP - artist-embedded.org · System model in BIP Distributed BIP Code Generator C++ Code Deployed SW . O V E R V I E W 4 ... Safe and efficient execution from partial

  ~ 500 lines of BIP code   Consists of 20 atomic components and 34 connectors   Components call routines from the encoder library

  The generated C++ code from BIP is ~ 2,000 lines   BIP binary is 288 KB compared to 172 KB of monolithic binary

100% overhead in execution time wrt monolithic code   ~66% due to computation of interactions (can be reduced by

composing components)   ~34% due to evaluation of priorities (can be reduced by applying

priorities to atomic components)

Axample – MPEG4 Video Encoder: Results

Page 37: SW model in BIP - artist-embedded.org · System model in BIP Distributed BIP Code Generator C++ Code Deployed SW . O V E R V I E W 4 ... Safe and efficient execution from partial

Source-to-Source – MPEG4 Video Encoder: Results

Page 38: SW model in BIP - artist-embedded.org · System model in BIP Distributed BIP Code Generator C++ Code Deployed SW . O V E R V I E W 4 ... Safe and efficient execution from partial

O V E R V I E W

38

  BIP – Global state model

  Distributed centralized implementation

  Decentralized implementations

  Architecture transformations

 Discussion

Page 39: SW model in BIP - artist-embedded.org · System model in BIP Distributed BIP Code Generator C++ Code Deployed SW . O V E R V I E W 4 ... Safe and efficient execution from partial

Results

Papers   A. Basu, Ph. Bidinger, M. Bozga and J. Sifakis. Distributed Semantics and

Implementation for Systems with Interaction and Priority FORTE, 2008, pp. 116-133.   Marius Bozga, Mohamad Jaber, Joseph Sifakis: Source-to-source architecture

transformation for performance optimization in BIP. IEEE Fourth International Symposium on Industrial Embedded Systems 2009, pp 152-160

  Ananda Basu, Saddek Bensalem, Doron Peled, Joseph Sifakis: Priority Scheduling of Distributed Systems Based on Model Checking. CAV 2009: 79-93

  Borzoo Bonakdarpour, Marius Bozga, Mohamad Jaber, Joseph Sifakis. Incremental Component-based Modeling, Verification, and Performnce Evaluation of Distributed Reset, DISC 09.

Distributed Implementations

  Centralized BIP Engine (FORTE08)

  Weakly decentralized (one Engine per set of conflicting interactions ) over Linux using TCP sockets

  Weakly decentralized (one Engine per interaction + Conflict resolution with alpha-core) over Linux using TCP sockets

Page 40: SW model in BIP - artist-embedded.org · System model in BIP Distributed BIP Code Generator C++ Code Deployed SW . O V E R V I E W 4 ... Safe and efficient execution from partial

Discussion

  Study different distributed implementations from fully decentralized to fully centralized ones

  Use existing distributed algorithms for multiparty interaction and conflict resolution e.g. maximal matching algorithm

  Prove correctness by using composability techniques - non interference of features of the composed algorithms

  Performance evaluation – tradeoffs wrt two criteria:   degree of parallelism   overhead for coordination

  Implementation tools and case studies.

Page 41: SW model in BIP - artist-embedded.org · System model in BIP Distributed BIP Code Generator C++ Code Deployed SW . O V E R V I E W 4 ... Safe and efficient execution from partial