59
“Software” Esterel Execution (work in progress) Dumitru POTOP-BUTUCARU Ecole des Mines de Paris [email protected]

“Software” Esterel Execution (work in progress) Dumitru POTOP-BUTUCARU Ecole des Mines de Paris [email protected]

Embed Size (px)

Citation preview

Page 1: “Software” Esterel Execution (work in progress) Dumitru POTOP-BUTUCARU Ecole des Mines de Paris tyshbe@math.tau.ac.il

“Software” Esterel Execution(work in progress)

Dumitru POTOP-BUTUCARU

Ecole des Mines de Paris

[email protected]

Page 2: “Software” Esterel Execution (work in progress) Dumitru POTOP-BUTUCARU Ecole des Mines de Paris tyshbe@math.tau.ac.il

loop emit S ; pause end

Page 3: “Software” Esterel Execution (work in progress) Dumitru POTOP-BUTUCARU Ecole des Mines de Paris tyshbe@math.tau.ac.il

»loop emit S ; pause end

Start

Page 4: “Software” Esterel Execution (work in progress) Dumitru POTOP-BUTUCARU Ecole des Mines de Paris tyshbe@math.tau.ac.il

loop »emit S ; pause end

Start

Page 5: “Software” Esterel Execution (work in progress) Dumitru POTOP-BUTUCARU Ecole des Mines de Paris tyshbe@math.tau.ac.il

loop emit S ; »pause end

Start

Page 6: “Software” Esterel Execution (work in progress) Dumitru POTOP-BUTUCARU Ecole des Mines de Paris tyshbe@math.tau.ac.il

loop emit S ; pause end

Start

Page 7: “Software” Esterel Execution (work in progress) Dumitru POTOP-BUTUCARU Ecole des Mines de Paris tyshbe@math.tau.ac.il

»loop emit S ; pause end

Resume

Page 8: “Software” Esterel Execution (work in progress) Dumitru POTOP-BUTUCARU Ecole des Mines de Paris tyshbe@math.tau.ac.il

loop emit S ; »pause end

Resume

Page 9: “Software” Esterel Execution (work in progress) Dumitru POTOP-BUTUCARU Ecole des Mines de Paris tyshbe@math.tau.ac.il

loop »emit S ; pause end

Resume

Page 10: “Software” Esterel Execution (work in progress) Dumitru POTOP-BUTUCARU Ecole des Mines de Paris tyshbe@math.tau.ac.il

loop emit S ; »pause end

Resume

Page 11: “Software” Esterel Execution (work in progress) Dumitru POTOP-BUTUCARU Ecole des Mines de Paris tyshbe@math.tau.ac.il

loop emit S ; pause end

Resume

Page 12: “Software” Esterel Execution (work in progress) Dumitru POTOP-BUTUCARU Ecole des Mines de Paris tyshbe@math.tau.ac.il

Overview

• Building an Intermediate Representation

• Giving it a (proper) meaning, based on existing semantics

• Some interesting classes of programs

• Simulation and tentative optimization

Page 13: “Software” Esterel Execution (work in progress) Dumitru POTOP-BUTUCARU Ecole des Mines de Paris tyshbe@math.tau.ac.il

What Esterel

• Esterel v5 (with data)

• In this paper, examples without data

Page 14: “Software” Esterel Execution (work in progress) Dumitru POTOP-BUTUCARU Ecole des Mines de Paris tyshbe@math.tau.ac.il

signal S in emit S ; pause || present S then pause end end

Page 15: “Software” Esterel Execution (work in progress) Dumitru POTOP-BUTUCARU Ecole des Mines de Paris tyshbe@math.tau.ac.il

signal S in emit S ; pause1

||3

present S then pause2

end end

Page 16: “Software” Esterel Execution (work in progress) Dumitru POTOP-BUTUCARU Ecole des Mines de Paris tyshbe@math.tau.ac.il

Organizing Actions in a Graph

»signal S in emit S ; pause1

||3

present S then pause2

end end

·start

Page 17: “Software” Esterel Execution (work in progress) Dumitru POTOP-BUTUCARU Ecole des Mines de Paris tyshbe@math.tau.ac.il

Organizing Actions in a Graph

signal S in »emit S ; pause1

||3

»present S then pause2

end end

fork start enter

3

·

·

Page 18: “Software” Esterel Execution (work in progress) Dumitru POTOP-BUTUCARU Ecole des Mines de Paris tyshbe@math.tau.ac.il

Organizing Actions in a Graph

signal S+ in emit S ; »pause1

||3

»present S then pause2

end end

fork

Sstart enter

3

·

·

Page 19: “Software” Esterel Execution (work in progress) Dumitru POTOP-BUTUCARU Ecole des Mines de Paris tyshbe@math.tau.ac.il

Organizing Actions in a Graph

signal S+ in emit S ; »pause1

||3

present S then »pause2

end end

fork

S

S

startF

T

enter3

·

·

Page 20: “Software” Esterel Execution (work in progress) Dumitru POTOP-BUTUCARU Ecole des Mines de Paris tyshbe@math.tau.ac.il

Organizing Actions in a Graph

signal S+ in emit S ; pause1

||3

present S then »pause2

end end

p

fork

S

S

enter1start

F

T

enter3

·

·

Page 21: “Software” Esterel Execution (work in progress) Dumitru POTOP-BUTUCARU Ecole des Mines de Paris tyshbe@math.tau.ac.il

Organizing Actions in a Graph

signal S+ in emit S ; pause1

||3

present S then pause2

end end

p

p

fork

S

S

enter1

enter2

startF

T

enter3

·

·

Page 22: “Software” Esterel Execution (work in progress) Dumitru POTOP-BUTUCARU Ecole des Mines de Paris tyshbe@math.tau.ac.il

Organizing Actions in a Graph

signal S in emit S ; pause1

||3

present S then pause2

end end

fork

S

S

enter1

enter2

pause(1)

term(2)

pause(2)

pause

startF

T

enter3

pause ·

join

Page 23: “Software” Esterel Execution (work in progress) Dumitru POTOP-BUTUCARU Ecole des Mines de Paris tyshbe@math.tau.ac.il

Organizing Actions in a Graph

»signal S in emit S ; pause1

||3

present S then pause2

end end

term

fork

active2

exit1

exit2

term(1)

inactive(2)

term(2)

resume

active1

inactive(1)

T

T

F

F

exit3term

·

fork

S

S

enter1

enter2

pause(1)

term(2)

pause(2)

pause

startF

T

enter3

pause

join

join

Page 24: “Software” Esterel Execution (work in progress) Dumitru POTOP-BUTUCARU Ecole des Mines de Paris tyshbe@math.tau.ac.il

Organizing Actions in a Graph

signal S- in emit S ; »pause1

||3

present S then »pause2

end end

term

fork

active2

exit1

exit2

term(1)

inactive(2)

term(2)

resume

active1

inactive(1)

T

T

F

F

exit3term

·

·

F

fork

S

S

enter1

enter2

pause(1)

term(2)

pause(2)

pause

startF

T

enter3

pause

join

join

Page 25: “Software” Esterel Execution (work in progress) Dumitru POTOP-BUTUCARU Ecole des Mines de Paris tyshbe@math.tau.ac.il

Organizing Actions in a Graph

signal S- in emit S ; pause1

||3

present S then »pause2

end end

t

term

fork

active2

exit1

exit2

term(1)

inactive(2)

term(2)

resume

active1

inactive(1)

T

T

F

F

exit3term

·

·

F

fork

S

S

enter1

enter2

pause(1)

term(2)

pause(2)

pause

startF

T

enter3

pause

join

join

Page 26: “Software” Esterel Execution (work in progress) Dumitru POTOP-BUTUCARU Ecole des Mines de Paris tyshbe@math.tau.ac.il

Organizing Actions in a Graph

signal S- in emit S ; pause1

||3

present S then pause2

end end

t

t

term

fork

active2

exit1

exit2

term(1)

inactive(2)

term(2)

resume

active1

inactive(1)

T

T

F

F

exit3term

·

·

F

fork

S

S

enter1

enter2

pause(1)

term(2)

pause(2)

pause

startF

T

enter3

pause

join

join

Page 27: “Software” Esterel Execution (work in progress) Dumitru POTOP-BUTUCARU Ecole des Mines de Paris tyshbe@math.tau.ac.il

Organizing Actions in a Graph

signal S in emit S ; pause1

||3

present S then pause2

end end

term

fork

active2

exit1

exit2

term(1)

inactive(2)

term(2)

resume

active1

inactive(1)

T

T

F

F

exit3term ·

fork

S

S

enter1

enter2

pause(1)

term(2)

pause(2)

pause

startF

T

enter3

pause

join

join

Page 28: “Software” Esterel Execution (work in progress) Dumitru POTOP-BUTUCARU Ecole des Mines de Paris tyshbe@math.tau.ac.il

Intermediate format

• Vertices – represent computation– test – fork – join (parallel branch termination synchronizing)– emit– state/memory update action

• Edges – control flow and signal dependencies

S

S

Page 29: “Software” Esterel Execution (work in progress) Dumitru POTOP-BUTUCARU Ecole des Mines de Paris tyshbe@math.tau.ac.il

State representation issues

• no state encoding decision yet

• intuitive semantics: – one boolean variable per pause and

composed statement– all false, in the beginning– enter sets it to 1, exit sets it to 0

• several possible encoding techniques

• optimization issues

Page 30: “Software” Esterel Execution (work in progress) Dumitru POTOP-BUTUCARU Ecole des Mines de Paris tyshbe@math.tau.ac.il

Semantics

1. SOS rules (using Cannot auxiliary functions) - dynamic

2. CCFG-like semantics on the intermediate graph

3. Translation to Constructive Circuits – fine grained, static

Page 31: “Software” Esterel Execution (work in progress) Dumitru POTOP-BUTUCARU Ecole des Mines de Paris tyshbe@math.tau.ac.il

SOS rules

p’ p’’k , E’E

p’ p0 , E’E

p’;q p;·q , E’E

k {} – completion code

E:S v{0,1,} – input event

E’ – emitted signal or

p’, p’’ are terms over statement p

Page 32: “Software” Esterel Execution (work in progress) Dumitru POTOP-BUTUCARU Ecole des Mines de Paris tyshbe@math.tau.ac.il

SOS rules

signal S in p’ end signal S- in p’ end,E

SCannot(p’)

signal S in p’ end signal S+ in p’’ end,E

p’ p’’E(S,),S

CONSTRUCTIVE

Page 33: “Software” Esterel Execution (work in progress) Dumitru POTOP-BUTUCARU Ecole des Mines de Paris tyshbe@math.tau.ac.il

CCFG-based semantics

• goal is sequential code generation

• graph interpreted as a classical flowchart

• limited class of programs

• related to intermediate representation of Stephen Edwards and of the CNET group

• graph acyclicity required

• lesser grain

• static

Page 34: “Software” Esterel Execution (work in progress) Dumitru POTOP-BUTUCARU Ecole des Mines de Paris tyshbe@math.tau.ac.il

CCFG-based semantics

signal S, in p’ end signal S- in p’ end,E

signal S, in p’ end signal S ,+ in p’’ end,E

p’ p’’E(S,),S

SCannot’(p’)

signal S, + in p’ end signal S+ in p’ end,E

SCannot’(p’)

Page 35: “Software” Esterel Execution (work in progress) Dumitru POTOP-BUTUCARU Ecole des Mines de Paris tyshbe@math.tau.ac.il

S Cannot(p’)

• CCFG view– all the signal emission statements have been

ruled out by executed tests

• Constructive view– all the signal emission statements have been

ruled out by either:• executed tests• not yet executed tests for which the test condition

is already computed so that we can prune one of the test branches.

Page 36: “Software” Esterel Execution (work in progress) Dumitru POTOP-BUTUCARU Ecole des Mines de Paris tyshbe@math.tau.ac.il

Acyclicity

• Can be defined on both intermediate graph and associated circuit

• Simple (cheap) correctness criteria for big programs

• Basis of static scheduling

• Problem: graph acyclicity is not the same as circuit acyclicity– what is a compilable program

Page 37: “Software” Esterel Execution (work in progress) Dumitru POTOP-BUTUCARU Ecole des Mines de Paris tyshbe@math.tau.ac.il

Acyclicity discrepancysignal S in [ nothing || present I then nothing else present S then pause else pause end end present ]; emit Send signal fork

S

S

I

F

TF

T

term(1)

term(2)

pause(2)

term

pause

start

Page 38: “Software” Esterel Execution (work in progress) Dumitru POTOP-BUTUCARU Ecole des Mines de Paris tyshbe@math.tau.ac.il

Acyclicity discrepancysignal S in [ nothing || present I then nothing else present S then pause else pause end end present ]; emit Send signal fork

S

S

I

F

TF

T

term(1)

term(2)

pause(2)

term

pause

start

Page 39: “Software” Esterel Execution (work in progress) Dumitru POTOP-BUTUCARU Ecole des Mines de Paris tyshbe@math.tau.ac.il

Acyclicity discrepancysignal S in [ nothing || present I then nothing else present S then pause else pause end end present ]; emit Send signal

S

F

TF

T

term

pause

start

Page 40: “Software” Esterel Execution (work in progress) Dumitru POTOP-BUTUCARU Ecole des Mines de Paris tyshbe@math.tau.ac.il

Acyclicity discrepancy

• Possible solutions:– splitting the synchronizers with problems, and

so borrow some expressive power from circuit semantics

– duplicate cycle code based on the trigger or the problem test (improve the CCFG model)

Page 41: “Software” Esterel Execution (work in progress) Dumitru POTOP-BUTUCARU Ecole des Mines de Paris tyshbe@math.tau.ac.il

acyclic circuit

Compilable Program Classes

acyclic CCFG

Page 42: “Software” Esterel Execution (work in progress) Dumitru POTOP-BUTUCARU Ecole des Mines de Paris tyshbe@math.tau.ac.il

acyclic circuit

Compilable Program Classes

acyclic CCFG

Page 43: “Software” Esterel Execution (work in progress) Dumitru POTOP-BUTUCARU Ecole des Mines de Paris tyshbe@math.tau.ac.il

Static analysis

• Graph arc removal in the circuit

• Results hold in CCFG, if the result is acyclic

• Problem: causality

• Some particular simplifications proved, like erasing dependencies based on state incompatibility

Page 44: “Software” Esterel Execution (work in progress) Dumitru POTOP-BUTUCARU Ecole des Mines de Paris tyshbe@math.tau.ac.il

Static analysis

• What I would like to do

fork S

S

I

F

TF

T

term(1)

term(2)

pause(2)

term

pause

start

·

Page 45: “Software” Esterel Execution (work in progress) Dumitru POTOP-BUTUCARU Ecole des Mines de Paris tyshbe@math.tau.ac.il

Static analysis

• What I would like to do

fork S

S

I

F

TF

T

term(1)

term(2)

pause(2)

term

pause

start

·

Page 46: “Software” Esterel Execution (work in progress) Dumitru POTOP-BUTUCARU Ecole des Mines de Paris tyshbe@math.tau.ac.il

Static analysis

• What I would like to do

fork S

S

I

F

TF

T

term(1)

term(2)

pause(2)

term

pause

start

·

Page 47: “Software” Esterel Execution (work in progress) Dumitru POTOP-BUTUCARU Ecole des Mines de Paris tyshbe@math.tau.ac.il

acyclic after simplif.

acyclic circuit

Compilable Program Classes

acyclic CCFG

Page 48: “Software” Esterel Execution (work in progress) Dumitru POTOP-BUTUCARU Ecole des Mines de Paris tyshbe@math.tau.ac.il

correct programs

acyclic after simplif.

Compilable Program Classes

acyclic circuit

acyclic CCFG

Page 49: “Software” Esterel Execution (work in progress) Dumitru POTOP-BUTUCARU Ecole des Mines de Paris tyshbe@math.tau.ac.il

Cyclic specifications

• Proving correctness – not my goal

• Execution (Simulation)

Page 50: “Software” Esterel Execution (work in progress) Dumitru POTOP-BUTUCARU Ecole des Mines de Paris tyshbe@math.tau.ac.il

Cyclic specifications

• 3-valued simulation

• Resynthesis of cyclic parts

Page 51: “Software” Esterel Execution (work in progress) Dumitru POTOP-BUTUCARU Ecole des Mines de Paris tyshbe@math.tau.ac.il

3-valued simulation

• expensive, if applied to the entire circuit (Esterel simulation compiler)

• can be restricted to the nodes/arcs in SCCs, and maybe more

• doesn’t need expensive analysis at compile time

• doesn’t prove correctness

• knowledge about correctness can improve simulation (loop unrolling, no error handling code)

Page 52: “Software” Esterel Execution (work in progress) Dumitru POTOP-BUTUCARU Ecole des Mines de Paris tyshbe@math.tau.ac.il

Implementation in progress…

Page 53: “Software” Esterel Execution (work in progress) Dumitru POTOP-BUTUCARU Ecole des Mines de Paris tyshbe@math.tau.ac.il
Page 54: “Software” Esterel Execution (work in progress) Dumitru POTOP-BUTUCARU Ecole des Mines de Paris tyshbe@math.tau.ac.il

The Esterel Langu• p || q• p ; q• pause• loop p end• signal S in p end• emit S• present S then p else q end• suspend p when S• exit T• trap T in p end

Page 55: “Software” Esterel Execution (work in progress) Dumitru POTOP-BUTUCARU Ecole des Mines de Paris tyshbe@math.tau.ac.il

term

Execution

signal S in emit S ; pause || present S then pause end end

join

fork

S

S

updatestate

updatestate

pause(1)

term(2)

pause(2)

pause

start

join

fork

active1

updatestate

updatestate

term(1)

inactive(2)

term(2)

resume

active2

inactive(1)

T

F

T

T

F

F

updatestate

updatestateterm

pause

Page 56: “Software” Esterel Execution (work in progress) Dumitru POTOP-BUTUCARU Ecole des Mines de Paris tyshbe@math.tau.ac.il

Giving it a (proper) meaning

• Dynamic SOS rules (Gerard Berry, Can/Must predicates)

• Direct Concurrent Control-Flow Graph Execution?• Translation to Constructive Circuits

– nodes are increasing constructive functions and they can be evaluated several times, in order to obtain partial results (finer grain).

– A signal is present once it has been emitted (weak synchronization, possible cycles)

– Berry’s circuit translation (with non-essential changes)

Page 57: “Software” Esterel Execution (work in progress) Dumitru POTOP-BUTUCARU Ecole des Mines de Paris tyshbe@math.tau.ac.il

Direct Concurrent Control-Flow Graph Execution

– nodes are atomic operations that map Boolean inputs into Boolean outputs exactly once in an instant

– all signal emission statements are either executed or tested out before signal tests (strong synchronization, acyclicity required)

– related to Stephen Edwards’ and CNET’s compilers (?)

Page 58: “Software” Esterel Execution (work in progress) Dumitru POTOP-BUTUCARU Ecole des Mines de Paris tyshbe@math.tau.ac.il

[email protected]

• Concurrent Control-Flow Graph– good for sequential execution – restricts the class of accepted programs

• Constructive Circuit– good for circuit generation– implements the exact semantics of Esterel

(proof in work)

Page 59: “Software” Esterel Execution (work in progress) Dumitru POTOP-BUTUCARU Ecole des Mines de Paris tyshbe@math.tau.ac.il

Static analysis

• Graph arc removal in the circuit• Results hold in CCFG, if the result is

acyclic• Basic idea: precompute Cannot

– for signal arcs coming to a test: may be refined to use some form of synchronization

– for control arcs

• Generalizes existing techniques, like graph coloring