optimizations for faster execution of esterel programs

39
Optimizations for Faster Execution of Esterel Programs Dumitru Potop Robert de Simone IRISA Rennes INRIA Sophia Antipolis

Upload: braith

Post on 02-Feb-2016

39 views

Category:

Documents


2 download

DESCRIPTION

Optimizations for Faster Execution of Esterel Programs. Dumitru Potop Robert de Simone IRISA Rennes INRIA Sophia Antipolis. Outline. The Esterel language The problem of efficient code generation The GRC intermediate representation Intuitive description - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Optimizations for Faster Execution of Esterel Programs

Optimizations for Faster Execution of Esterel Programs

Dumitru Potop Robert de Simone IRISA Rennes INRIA Sophia Antipolis

Page 2: Optimizations for Faster Execution of Esterel Programs

Outline

1. The Esterel language

• The problem of efficient code generation

2. The GRC intermediate representation

• Intuitive description

• Software code generation

• Code analysis and optimizations

3. Practical results. Conclusion. Future work

Page 3: Optimizations for Faster Execution of Esterel Programs

The Esterel language

Esterelspecification

SWtranslation

HW (RTL)generation

• Formal semantics (FSMs, circuits)

• Formal verification

• Simulation• SW implementation

• HW prototype (FPGA)• Synthesis input

Page 4: Optimizations for Faster Execution of Esterel Programs

The Esterel language

• Reactive, clock-driven execution

module ABRO:input A,B,R;output O; » loop [ await A || await B ]; emit O; halt every R end module

Page 5: Optimizations for Faster Execution of Esterel Programs

The Esterel language

• Reactive, clock-driven execution

module ABRO:input A,B,R;output O;

loop [ await A || await B ]; emit O; halt every R end module

execution instant inputs outputs

0 any -

Page 6: Optimizations for Faster Execution of Esterel Programs

The Esterel language

• Reactive, clock-driven execution

module ABRO:input A,B,R;output O;

loop [ await A || await B ]; emit O; halt every R end module

execution instant inputs outputs

0 any -

1 AB O

Page 7: Optimizations for Faster Execution of Esterel Programs

The Esterel language

• Reactive, clock-driven execution

module ABRO:input A,B,R;output O;

loop [ await A || await B ]; emit O; halt every R end module

execution instant inputs outputs

0 any -

1 AB O

2 R -

Page 8: Optimizations for Faster Execution of Esterel Programs

The Esterel language

• Synchrony– Causality cycles present S else emit S end– Constructive semantics (SOS rules)

·signal S,T in emit S; present T then present S else emit T end else emit O end; end

Page 9: Optimizations for Faster Execution of Esterel Programs

The Esterel language

signal S,T in ·emit S; present T then present S else emit T end else emit O end; end

• Synchrony– Causality cycles present S else emit S end– Constructive semantics (SOS rules)

Page 10: Optimizations for Faster Execution of Esterel Programs

The Esterel language

signal S,T in emit S; ·present T then present S else emit T end else emit O end; end

• Synchrony– Causality cycles present S else emit S end– Constructive semantics (SOS rules)

Page 11: Optimizations for Faster Execution of Esterel Programs

The Esterel language

signal S,T in emit S; ·present T then present S else emit T end else emit O end; end

causality cycle

• Synchrony– Causality cycles present S else emit S end– Constructive semantics (SOS rules)

Page 12: Optimizations for Faster Execution of Esterel Programs

The Esterel language

signal S,T in emit S; ·present T then present S else emit T end else emit O end; end

causality cycle

break the cycle

• Synchrony– Causality cycles present S else emit S end– Constructive semantics (SOS rules)

Page 13: Optimizations for Faster Execution of Esterel Programs

First compilation scheme (1980’s)

• FSM-based translation – Exhaustive semantic expansion– Explosion in size, expensive analysis– Fast code (execute only active code)

loop [ await A || await B ]; emit O; halt every R

1

2 3

4

0

A/ B/

AB/O

A/OB/O

R/ R/

R/

Page 14: Optimizations for Faster Execution of Esterel Programs

• Circuit-based translation – Encode primitives into gates– Small circuit size (quasi-linear)– Slow software code (acyclic circuit evaluation)

loop [ await A || await B ]; emit O; halt every R start

R

A

B

O

Second compilation scheme (1990’s)

Page 15: Optimizations for Faster Execution of Esterel Programs

• “Simulation” code – Follows the naïve semantics (control-flow) – Accept less programs (acyclic circuits)– Code: small and very fast (statically scheduled)– Edwards, Closse/Weil

loop [ await A || await B ]; emit O; halt every R

if(START){A_active=1;B_active=1;START=0}else { if(R){A_active=1;B_active=1;} else if(A_active|B_active) { if(A_active) if(A) A_active=0; if(B_active) if(B) B_active=0; if(!(A_active|B_active)) O=1; } }

Third compilation scheme (2000’s)

Page 16: Optimizations for Faster Execution of Esterel Programs

• My goal: Formal intermediate model– Preserve high-level information from Esterel

(Static analysis, optimization techniques)– Relation with constructive semantics

(soundness of analysis and optimization)– Relation with the circuit translation

(soundness of execution, unique notion of acyclicity)

Third compilation scheme (2000’s)

Page 17: Optimizations for Faster Execution of Esterel Programs

#

||

01

2

boot:

await A

await B

haltsequenceloop-every

#

34

5

6

loop [ await A;emit B || await B ]; emit O; halt every R

[2]

[3]

0[1]

enter 5

enter 4enter 3enter 2exit 1

2

enter 6exit 3term

Inactive[4]R

exit 2

4A

exit 4 term[4]

pause[4]Inactive[5]

5B

exit 5 term[5]

pause[5]

[6]

emit Oemit B

3

3

3

pause

The GRC intermediate formatHierarchical state

(structure)

Control/Dataflow graph(behaviour)

activation new state

Page 18: Optimizations for Faster Execution of Esterel Programs

#

||

0

1

2

boot:

await A

await B

haltsequenceloop-every

#

34

5

6

loop [ await A;emit B || await B ]; emit O; halt every R

The hierarchical state structure

• parallel/exclusive abstraction of the syntax tree• nodes represent the activity condition of various

subprogram fragments

Page 19: Optimizations for Faster Execution of Esterel Programs

#

||

0

1

2

boot:

await A

await B

halt

#

34

5

6

loop [ await A;emit B || await B ]; emit O; halt every R

Flowgraph execution

[2]

[3]

0[1]

enter 5

enter 4enter 3enter 2exit 1

2

enter 6exit 3term

Inactive[4]

R

exit 2

4A

exit 4 term[4]

pause[4]Inactive[5]

5B

exit 5 term[5]

pause[5]

[6]

emit Oemit B

3

3

3

pause

Activated from the

hierarchical state

sequenceloop-every

Page 20: Optimizations for Faster Execution of Esterel Programs

#

||

0

1

2

boot:

await A

await B

halt

#

34

5

6

• loop [ await A;emit B || await B ]; emit O; halt every R

R absent,A present

Flowgraph execution

[2]

[3]

0[1]

enter 5

enter 4enter 3enter 2exit 1

2

enter 6exit 3term

Inactive[4]

R

exit 2

4A

exit 4 term[4]

pause[4]Inactive[5]

5B

exit 5 term[5]

pause[5]

[6]

emit Oemit B

3

3

3

pause

Activated from the

hierarchical state

sequenceloop-every

Page 21: Optimizations for Faster Execution of Esterel Programs

#

||

0

1

2

boot:

await A

await B

halt

#

34

5

6

•loop [ await A;emit B || await B ]; emit O; halt every R

R absent,A present

Flowgraph execution

•[2]

[3]

0[1]

enter 5

enter 4enter 3enter 2exit 1

2

enter 6exit 3term

Inactive[4]

R

exit 2

4A

exit 4 term[4]

pause[4]Inactive[5]

5B

exit 5 term[5]

pause[5]

[6]

emit Oemit B

3

3

3

pause

Activated from the

hierarchical state

sequenceloop-every

Page 22: Optimizations for Faster Execution of Esterel Programs

#

||

0

1

2

boot:

await A

await B

halt

#

34

5

6

loop [ await A;emit B •|| await B ]; emit O; halt every R

R absent,A present

Flowgraph execution

[2]

[3]

0[1]

enter 5

enter 4enter 3enter 2exit 1

2

enter 6exit 3term

Inactive[4]

R

exit 2

4A

exit 4 term[4]

pause[4]Inactive[5]

5B

exit 5 term[5]

pause[5]

[6]

emit Oemit B

3

3

3

pause

Activated from the

hierarchical state

sequenceloop-every

Page 23: Optimizations for Faster Execution of Esterel Programs

#

||

0

1

2

boot:

await A

await B

halt

#

34

5

6

loop [ •await A;emit B || await B ]; emit O; halt every R

R absent,A present

Flowgraph execution

[2]

[3]

0[1]

enter 5

enter 4enter 3enter 2exit 1

2

enter 6exit 3term

Inactive[4]

R

exit 2

4A

exit 4 term[4]

pause[4]Inactive[5]

5B

exit 5 term[5]

pause[5]

[6]

emit Oemit B

3

3

3

pause

Activated from the

hierarchical state

sequenceloop-every

Page 24: Optimizations for Faster Execution of Esterel Programs

#

||

0

1

2

boot:

await A

await B

halt

#

34

5

6

loop [ await A;•emit B || await B ]; emit O; halt every R

R absent,A present

•[2]

[3]

0[1]

enter 5

enter 4enter 3enter 2exit 1

2

enter 6exit 3term

Inactive[4]

R

exit 2

4A

exit 4 term[4]

pause[4]Inactive[5]

5B

exit 5 term[5]

pause[5]

[6]

emit Oemit B

3

3

3

pause

Flowgraph executionActivated from the

hierarchical state

sequenceloop-every

Page 25: Optimizations for Faster Execution of Esterel Programs

#

||

0

1

2

boot:

await A

await B

halt

#

34

5

6

loop [ await A;emit B• || await B ]; emit O; halt every R

R absent,A present

Flowgraph execution

[2]

[3]

0[1]

enter 5

enter 4enter 3enter 2exit 1

2

enter 6exit 3term

Inactive[4]

R

exit 2

4A

exit 4 term[4]

pause[4]Inactive[5]

5B

exit 5 term[5]

pause[5]

[6]

emit Oemit B

3

3

3

pause

Activated from the

hierarchical state

sequenceloop-every

Page 26: Optimizations for Faster Execution of Esterel Programs

#

||

0

1

2

boot:

await A

await B

halt

#

34

5

6

loop [ await A;emit B || await B ]; •emit O; halt every R

R absent,A present

Flowgraph execution

•[2]

[3]

0[1]

enter 5

enter 4enter 3enter 2exit 1

2

enter 6exit 3term

Inactive[4]

R

exit 2

4A

exit 4 term[4]

pause[4]Inactive[5]

5B

exit 5 term[5]

pause[5]

[6]

emit Oemit B

3

3

3

pause

Activated from the

hierarchical state

sequenceloop-every

Page 27: Optimizations for Faster Execution of Esterel Programs

#

||

0

1

2

boot:

await A

await B

halt

#

34

5

6

loop [ await A;emit B || await B ]; emit O; •halt every R

R absent,A present

Flowgraph execution

•[2]

[3]

0[1]

enter 5

enter 4enter 3enter 2exit 1

2

enter 6exit 3term

Inactive[4]

R

exit 2

4A

exit 4 term[4]

pause[4]Inactive[5]

5B

exit 5 term[5]

pause[5]

[6]

emit Oemit B

3

3

3

pause

Activated from the

hierarchical state

sequenceloop-every

Page 28: Optimizations for Faster Execution of Esterel Programs

#

||

0

1

2

boot:

await A

await B

halt

#

34

5

6

loop [ await A;emit B || await B ]; emit O; halt every R

R absent,A present

Flowgraph execution

[2]

[3]

0[1]

enter 5

enter 4enter 3enter 2exit 1

2

enter 6exit 3term

Inactive[4]

R

exit 2

4A

exit 4 term[4]

pause[4]Inactive[5]

5B

exit 5 term[5]

pause[5]

[6]

emit Oemit B

3

3

3

pause

Activated from the

hierarchical state

sequenceloop-every

Page 29: Optimizations for Faster Execution of Esterel Programs

Simulation code generation

• State encoding

• Static scheduling– Sequential code– Respects the causality (signal emission

statements before tests statements)

Page 30: Optimizations for Faster Execution of Esterel Programs

Inactive[5]

Simulation code generation#

||

boot:

#

await A

await B

loop-every

0 1 2 3 4

0

1

0

1

halt

0

2

34

5

6

term

Inactive[4]

R

A

term[4]

pause[4]

B

term[5]

pause[5]

emit Oemit B

3

3

pause

S[1]

S[2]

S[3]

S[4]

S[4]=1

S[3]=1S[2]=0S[1]=1 3

S[2]=1 S[3]=0

S[4]=0

• State encoding

Page 31: Optimizations for Faster Execution of Esterel Programs

Inactive[5]

Simulation code generation

term

Inactive[4]

R

A

term[4]

pause[4]

B

term[5]

pause[5]

emit Oemit B

3

3

pause

S[1]

S[2]

S[3]

S[4]

S[1..4]=1011

S[2]=1S[3]=0

S[4]=0

• Static schedulingbool aux=0;if(S[1]){ if(R){aux=1;} else { if(!S[2]){ if(S[3])if(A){S[3]=0;B=1;} if(S[4])if(B)S[4]=0; if(S[3]=0&S[4]=0){ O=1;S[2]=1; } }}} else {aux=1;}if(aux){S[1..4]=1011;}

Page 32: Optimizations for Faster Execution of Esterel Programs

• Based on static analysis (semantic-preserving, fast, efficient)– Redundant state bit elimination– False signal/data dependency elimination– Node grouping– Dead code removal

Optimizations

Page 33: Optimizations for Faster Execution of Esterel Programs

• Utility– Simplify the state access/update protocol– Simplify the state encoding

• Static analysis, example

trap T in sustain A|| await B;await C;exit Tend

||

sustain A

await B

#

await C

#

boot:

nt:

nt:Same status at all instants

Optimizations

Page 34: Optimizations for Faster Execution of Esterel Programs

• Dependency removal

[2]

0[1]

enter 3enter 2exit 1

exit 3 S

exit 4

enter 4

exit 2 exit 0

[4]

2[3]

pause; present S then emit T end;pause;emit S;

#

#

0

1

2

3

4

boot:

emit S

emit T

GRC code optimizations

Page 35: Optimizations for Faster Execution of Esterel Programs

[2]

0[1]

enter 3enter 2exit 1

exit 3 S

exit 4

enter 4

exit 2 exit 0

[4]

2[3]

pause; present S then emit T end;pause;emit S;

#

#

0

1

2

3

4

boot:

emit S

emit T

GRC code optimizations

• Dependency removal

Page 36: Optimizations for Faster Execution of Esterel Programs

pause; present S then emit T end;pause;emit S;

GRC code optimizations

[2]

0[1]

enter 3enter 2exit 1

exit 3 S

exit 4

enter 4

exit 2 exit 0

[4]

2[3]

#

#

0

1

2

3

4

boot:

emit S

emit T

• Dependency removal

Page 37: Optimizations for Faster Execution of Esterel Programs

Results Size (kbytes)

0

50

100

150

200

250

300

350

1 2 3 4 5 6 7 8

GRC2C

FTR&D

Synopsys

Test configuration: PIII/1GHz/128M/Linuxgcc-2.96 –O, 1Mcycle random or given

Relative execution

time(%grc2c)

0

50

100

150

200

250

300

350

400

450

500

1 2 3 4 5 6 7 8

GRC2C

FTR&D

Synopsys

• Optimizing compiler

• Examples:– Turbo channel bus– Berry’s wristwatch– Video generator– Shock absorber– Operating system model– Avionics fuel controller– Avionics cockpit– Man-machine interface

Page 38: Optimizations for Faster Execution of Esterel Programs

• Intermediate model for Esterel programs

• Static analysis, optimizations at GRC level

• GRC-acyclic = circuit-acyclic

• Code generation scheme

• Good practical results

Conclusion

Page 39: Optimizations for Faster Execution of Esterel Programs

Future work

• Digital circuit synthesis– State encoding + translation into gates– Good partial results

• Distributed implementation– Connection between Esterel and Signal at

source or GRC/HCDG level

Control registers Control clock hierarchy