Top Banner
Approximation of the Worst- Approximation of the Worst- Case Execution Time Using Case Execution Time Using Structural Analysis Structural Analysis Matteo Corti and Thomas Gross Zürich
32

Approximation of the Worst-Case Execution Time Using Structural Analysis Matteo Corti and Thomas Gross Zürich.

Mar 29, 2015

Download

Documents

Edward Solomon
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Approximation of the Worst-Case Execution Time Using Structural Analysis Matteo Corti and Thomas Gross Zürich.

Approximation of the Worst-Case Approximation of the Worst-Case Execution Time Using Structural Execution Time Using Structural

AnalysisAnalysis

Matteo Corti and Thomas Gross

Zürich

Page 2: Approximation of the Worst-Case Execution Time Using Structural Analysis Matteo Corti and Thomas Gross Zürich.

EMSOFT 2004, © Matteo Corti 2

GoalGoal

• Worst-case execution time estimation of soft-real time Java applications.

• We focus on semantic analysis:– compute a tight bound on the max and min

number of iterations for every block– consider different path frequencies inside loops– avoid path enumeration

Page 3: Approximation of the Worst-Case Execution Time Using Structural Analysis Matteo Corti and Thomas Gross Zürich.

EMSOFT 2004, © Matteo Corti 3

OutlineOutline• Goal

• Loop bounds

• Block bounds

• Complexity and related work

• Testing environment

• Results

• Concluding remarks

Page 4: Approximation of the Worst-Case Execution Time Using Structural Analysis Matteo Corti and Thomas Gross Zürich.

EMSOFT 2004, © Matteo Corti 4

Semantic analysis

System’s overviewSystem’s overview

bytecode

annotatedasm

partialabstract

interpretation

loopheaderbounds

blockbounds

instructiondurationanalysis

WCET

Page 5: Approximation of the Worst-Case Execution Time Using Structural Analysis Matteo Corti and Thomas Gross Zürich.

EMSOFT 2004, © Matteo Corti 5

JavaJava

• Whole program analysis.

• Variable type based analysis to resolve polymorphism.

• We consider only local integer variables for the loop analysis.

• Our block iterations bounding technique is language independent.

Page 6: Approximation of the Worst-Case Execution Time Using Structural Analysis Matteo Corti and Thomas Gross Zürich.

EMSOFT 2004, © Matteo Corti 6

Semantic analysis

System’s overviewSystem’s overview

bytecode

annotatedasm

partialabstract

interpretation

loopheaderbounds

blockbounds

instructiondurationanalysis

WCET

Page 7: Approximation of the Worst-Case Execution Time Using Structural Analysis Matteo Corti and Thomas Gross Zürich.

EMSOFT 2004, © Matteo Corti 7

Partial abstract interpretationPartial abstract interpretation

• We perform a limited abstract interpretation pass over linear code.

• We discover some false paths (not containing cycles).

• We gather information on possible variables’ values. void foo(int i) {

if (i > 0) {

for(;i<10;i++) { bar(); } }}

i∈ 1..∞[ [

Page 8: Approximation of the Worst-Case Execution Time Using Structural Analysis Matteo Corti and Thomas Gross Zürich.

EMSOFT 2004, © Matteo Corti 8

Partial abstract interpretationPartial abstract interpretation

Benchmark Infeasible paths

_201_compress 2

_202_jess 3

_205_raytrace 7

_209_db 2

_213_javac 240

_222_mpegaudio 19

_228_jack 22

Page 9: Approximation of the Worst-Case Execution Time Using Structural Analysis Matteo Corti and Thomas Gross Zürich.

EMSOFT 2004, © Matteo Corti 9

Partial abstract interpretationPartial abstract interpretation

Benchmark Infeasible longest path

JavaLayer 2

linpack 2

whetstone 1

Page 10: Approximation of the Worst-Case Execution Time Using Structural Analysis Matteo Corti and Thomas Gross Zürich.

EMSOFT 2004, © Matteo Corti 10

Semantic analysis

System’s overviewSystem’s overview

bytecode

annotatedasm

partialabstract

interpretation

loopheaderbounds

blockbounds

instructiondurationanalysis

WCET

Page 11: Approximation of the Worst-Case Execution Time Using Structural Analysis Matteo Corti and Thomas Gross Zürich.

EMSOFT 2004, © Matteo Corti 11

Loop boundsLoop bounds

• Bounds on the loop header computed similarly to C. Healy [RTAS’98].

• We introduce noncontiguous sets of integers to easily handle equality operators.

• Iteration branch: a block where the conditional jump could be responsible for a loop exit.

• For each edge e and iteration branch ib we compute the possible number of iterations.

Page 12: Approximation of the Worst-Case Execution Time Using Structural Analysis Matteo Corti and Thomas Gross Zürich.

EMSOFT 2004, © Matteo Corti 12

[101]

[101][101]

[101]

[50] [50]

[100]

Loop boundsLoop bounds

• The bounds on the iterations of the header are safe for the whole loop.

• But: some parts of the loop could be executed less frequently:

for(int i=0; i<100; i++) { if (i < 50) { A; } else { B; }}

A B

[101]

[1]

[100]

Page 13: Approximation of the Worst-Case Execution Time Using Structural Analysis Matteo Corti and Thomas Gross Zürich.

EMSOFT 2004, © Matteo Corti 13

Semantic analysis

System’s overviewSystem’s overview

bytecode

annotatedasm

partialabstract

interpretation

loopheaderbounds

blockbounds

instructiondurationanalysis

WCET

Page 14: Approximation of the Worst-Case Execution Time Using Structural Analysis Matteo Corti and Thomas Gross Zürich.

EMSOFT 2004, © Matteo Corti 14

Basic block iterationsBasic block iterations

• The number of iterations of a block is not a local property (based on immediate predecessors).

P0 P1

B

[10]

[10]

[0..10][0..10]

void foo(boolean b) { for(int i=0; i<10; i++) { if (b) { P0; } else { P1; } B; }}

Page 15: Approximation of the Worst-Case Execution Time Using Structural Analysis Matteo Corti and Thomas Gross Zürich.

EMSOFT 2004, © Matteo Corti 15

Basic block iterationsBasic block iterations

• The number of iterations of a block is not a local property (based on immediate predecessors).

void foo(boolean b) { for(int i=0; i<20; i++) { if (i<10) { P0; } else { P1; } B; }}

P0 P1

B

[20]

[20]

[10][10]

Page 16: Approximation of the Worst-Case Execution Time Using Structural Analysis Matteo Corti and Thomas Gross Zürich.

EMSOFT 2004, © Matteo Corti 16

Basic block iterationsBasic block iterations

• The number of iterations of a block is not a local property (based on immediate predecessors). void foo(boolean b) {

int i = 0; if (b) { do { i++; P0; } while (i<10); } else { do { i++; P1; } while (i<10); } B;}

B

P1

[1]

[1]

[0][10]

[0][10]P0

[0][10]

[0][10]

Page 17: Approximation of the Worst-Case Execution Time Using Structural Analysis Matteo Corti and Thomas Gross Zürich.

EMSOFT 2004, © Matteo Corti 17

Basic block iterationsBasic block iterations

• The number of iterations of a block is not a local property (based on immediate predecessors).

[1]

[1]

[0][10]

[0][10]

[20]

[20]

[10][10]

[10]

[10]

[0..10][0..10]

[0][10]

[0][10]

Page 18: Approximation of the Worst-Case Execution Time Using Structural Analysis Matteo Corti and Thomas Gross Zürich.

EMSOFT 2004, © Matteo Corti 18

Structural analysisStructural analysis

• Powerful interval analysis.

• Recognizes semantic constructs.

• Useful when the source code is not available.

• Iteratively matches the blocks with predefined patterns.

Page 19: Approximation of the Worst-Case Execution Time Using Structural Analysis Matteo Corti and Thomas Gross Zürich.

EMSOFT 2004, © Matteo Corti 19

Structural analysisStructural analysis

• Powerful interval analysis.

• Recognizes semantic constructs.

• Useful when the source code is not available.

• Iteratively matches the blocks with predefined patterns.

Page 20: Approximation of the Worst-Case Execution Time Using Structural Analysis Matteo Corti and Thomas Gross Zürich.

EMSOFT 2004, © Matteo Corti 20

Structural analysisStructural analysis

if (A || (B && C)) { D;} else { E;}F;

A

D

B

E

C

F

Static patterns:

Dynamic patterns:

Page 21: Approximation of the Worst-Case Execution Time Using Structural Analysis Matteo Corti and Thomas Gross Zürich.

EMSOFT 2004, © Matteo Corti 21

Block iterationsBlock iterations

• Block iterations are computed using the CFG root and the iteration branches.

• The header and the type of the biggest semantic region that includes all the predecessors of a node determine its number of iterations.

• Complete algorithm in the paper.

P0

B

H

P1

Page 22: Approximation of the Worst-Case Execution Time Using Structural Analysis Matteo Corti and Thomas Gross Zürich.

EMSOFT 2004, © Matteo Corti 22

ExampleExample

P0 P1

B

H [20]

[20]

[10][10]

void foo(boolean b) { for(int i=0; i<20; i++) { if (i<10) { P0; } else { P1; } B; }}

Page 23: Approximation of the Worst-Case Execution Time Using Structural Analysis Matteo Corti and Thomas Gross Zürich.

EMSOFT 2004, © Matteo Corti 23

ExampleExample

B

H

P1

[1]

[1]

[0..10]

[0..10]P0

[0..10]

[0..10]

void foo(boolean b) { int i = 0; if (b) { do { i++; P0; } while (i<10); } else { do { i++; P1; } while (i<10); } B;}

Page 24: Approximation of the Worst-Case Execution Time Using Structural Analysis Matteo Corti and Thomas Gross Zürich.

EMSOFT 2004, © Matteo Corti 24

ExampleExample

B

PH

L

H

[1]

[1]

[11]

[10]

void foo(boolean b) { PH; for(int i=0; i<10; i++) { L; } B;}

Page 25: Approximation of the Worst-Case Execution Time Using Structural Analysis Matteo Corti and Thomas Gross Zürich.

EMSOFT 2004, © Matteo Corti 25

Related workRelated work

• Automatically detected value-dependent constraints [Healy, RTAS’99]:– per block bounds– requires path enumeration (in the loop body)

• We propagate the header bounds to the blocks in quadratic time:– Structural analysis: O(B2)– Loop bounds: O(B)– Block bounds: O(B)

Page 26: Approximation of the Worst-Case Execution Time Using Structural Analysis Matteo Corti and Thomas Gross Zürich.

EMSOFT 2004, © Matteo Corti 26

Evaluation: hardware-level analysisEvaluation: hardware-level analysis

• The semantic analysis is platform independent.• Evaluation: Pentium III on Linux.• We approximate the effects of caches and

pipelines:– we assume that the effects of an instruction fade over

time.– caches and pipelines are analyzed locally.

• Possible sources of inaccuracies:– cache misses and pipeline stalls– but not the number of iterations of an instruction

(conservative)

Page 27: Approximation of the Worst-Case Execution Time Using Structural Analysis Matteo Corti and Thomas Gross Zürich.

EMSOFT 2004, © Matteo Corti 27

EvaluationEvaluation

• Base: the bounds on the iterations of the loop header are used for the whole loop.

• Enhanced: structural analysis is used to consider different path frequencies in loop bodies.

Page 28: Approximation of the Worst-Case Execution Time Using Structural Analysis Matteo Corti and Thomas Gross Zürich.

EMSOFT 2004, © Matteo Corti 28

Results: synthetic benchmarksResults: synthetic benchmarks

for (i=0; i<10000; i++) { if (i<5000) { array[i] = -array[i]; } if (array[i] > max) { max = array[i]; }}

for(i=0; i<10; i++) { for (j=0; j<10; j++) { if(j<9) { m[i][j] *= m[i][j]; } else { for(k=0; k<9; k++) { m[i][j]+=m[i][k]; } } } }

B1 B2 B3 B4

Base 10’000 10’000 100 100

Enhanced 5’000 10’000 90 10

B1

B2

B3

B4

Example 1 Example 2

Page 29: Approximation of the Worst-Case Execution Time Using Structural Analysis Matteo Corti and Thomas Gross Zürich.

EMSOFT 2004, © Matteo Corti 29

ResultsResults

Benchmark Max observed

[cycles]

Enhanced

[cycles]

Base

[cycles]

MatMult 2.68·109 2.73·109 2% 2.73·109 2%

Jacobi 0.88·1010 1.08·1010 22% 1.08·1010 22%

JavaLayer 2.67·109 1.30·1010 487% 1.49·109 558%

SciMark 2.47·1010 1.42·1011 579% 2.12·1011 858%

_201_compress 9.45·109 1.11·1010 117% 4.76·1012 50’370%

Page 30: Approximation of the Worst-Case Execution Time Using Structural Analysis Matteo Corti and Thomas Gross Zürich.

EMSOFT 2004, © Matteo Corti 30

_201_compress_201_compress

for (data = 0; data < N; data++) {

// compress data

if (data == 10’000) {

// update structures

}

}

Page 31: Approximation of the Worst-Case Execution Time Using Structural Analysis Matteo Corti and Thomas Gross Zürich.

EMSOFT 2004, © Matteo Corti 31

Concluding remarksConcluding remarks

• We tighten the bounds of basic blocks iteration considering different paths inside loop bodies.

• We do not perform path enumeration

• Tests with real applications validate the semantic analysis.

Page 32: Approximation of the Worst-Case Execution Time Using Structural Analysis Matteo Corti and Thomas Gross Zürich.

Questions?Questions?