30
Approximating the Worst- Approximating the Worst- Case Execution Time of Soft Case Execution Time of Soft Real-time Applications Real-time Applications Matteo Corti

Approximating the Worst-Case Execution Time of Soft Real-time Applications Matteo Corti

Embed Size (px)

Citation preview

Page 1: Approximating the Worst-Case Execution Time of Soft Real-time Applications Matteo Corti

Approximating the Worst-Case Approximating the Worst-Case Execution Time of Soft Real-time Execution Time of Soft Real-time

ApplicationsApplications

Matteo Corti

Page 2: Approximating the Worst-Case Execution Time of Soft Real-time Applications Matteo Corti

Matteo Corti, 2005-03-03 2

GoalGoal

WCET analysis:

• estimation of the longest possible running time

Soft real-time systems:

• allow some approximations

• large applications

Page 3: Approximating the Worst-Case Execution Time of Soft Real-time Applications Matteo Corti

Matteo Corti, 2005-03-03 3

ThesisThesis

• It is possible to perform the WCET estimation without relying on path enumeration:– bound the iterations of cyclic structures– find infeasible paths– analyze the call graph of object-oriented

languages– estimate the instruction duration on modern

architectures

Page 4: Approximating the Worst-Case Execution Time of Soft Real-time Applications Matteo Corti

Matteo Corti, 2005-03-03 4

ChallengesChallenges

Semantic:

• bounds on the iterations of cyclic control-flow structures

• infeasible paths

Hardware-level:

• instruction duration

• modern architectures (caches, pipelines, branch prediction)

Page 5: Approximating the Worst-Case Execution Time of Soft Real-time Applications Matteo Corti

Matteo Corti, 2005-03-03 5

OutlineOutline• Goal and thesis

• Semantic analysis

• Hardware-level analysis

• Environment

• Results

• Concluding remarks

Page 6: Approximating the Worst-Case Execution Time of Soft Real-time Applications Matteo Corti

Matteo Corti, 2005-03-03 6

Structure: Separated ApproachStructure: Separated Approach

semanticanalysis

HW-levelanalysis

binary

annotatedbinary

WCET

Page 7: Approximating the Worst-Case Execution Time of Soft Real-time Applications Matteo Corti

Matteo Corti, 2005-03-03 7

Semantic AnalysisSemantic AnalysisJava bytecode

Structural analysis

Partial abstract interpretation

Loop iteration bounds

Block iteration bounds

Call graph analysis

Annotated assembler

Page 8: Approximating the Worst-Case Execution Time of Soft Real-time Applications Matteo Corti

Matteo Corti, 2005-03-03 8

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 9: Approximating the Worst-Case Execution Time of Soft Real-time Applications Matteo Corti

Matteo Corti, 2005-03-03 9

Abstract InterpretationAbstract Interpretation

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

• 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..MAX_INT[ ]

Page 10: Approximating the Worst-Case Execution Time of Soft Real-time Applications Matteo Corti

Matteo Corti, 2005-03-03 10

Loop Iteration BoundsLoop Iteration Bounds

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

• Each loop is handled in isolation by analyzing the behavior of induction variables.– we consider integer local variables– we handle loops with several induction variables

and multiple exit points– computes the minimal and maximal number of

iterations for each loop header

Page 11: Approximating the Worst-Case Execution Time of Soft Real-time Applications Matteo Corti

Matteo Corti, 2005-03-03 11

Loop Header IterationsLoop Header Iterations

[101]

[101][101]

[101]

[50] [50]

[100]

• 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 12: Approximating the Worst-Case Execution Time of Soft Real-time Applications Matteo Corti

Matteo Corti, 2005-03-03 12

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.

P0

B

H

P1

Page 13: Approximating the Worst-Case Execution Time of Soft Real-time Applications Matteo Corti

Matteo Corti, 2005-03-03 13

ExampleExamplevoid foo() {

int i,j;

for(i=0; i<100; i++) {

if (i < 50) {

for(j=0; j<10; j++) ;

}

}

}

[1]

[101]

[550]

[100]

[50]

[500]

[1]

Page 14: Approximating the Worst-Case Execution Time of Soft Real-time Applications Matteo Corti

Matteo Corti, 2005-03-03 14

Contributions (Semantic Analysis)Contributions (Semantic Analysis)

• We compute bounds on the iterations of basic blocks in quadratic time:– Structural analysis: O(B2)– Loop bounds: O(B)– Block bounds: O(B)

• Related work– Automatically detected value-dependent

constraints [Healy, RTAS’99]:– Abstract interpretation based approaches

Page 15: Approximating the Worst-Case Execution Time of Soft Real-time Applications Matteo Corti

Matteo Corti, 2005-03-03 15

OutlineOutline• Goal and thesis

• Semantic analysis

• Hardware-level analysis

• Environment

• Results

• Concluding remarks

Page 16: Approximating the Worst-Case Execution Time of Soft Real-time Applications Matteo Corti

Matteo Corti, 2005-03-03 16

Instruction Duration EstimationInstruction Duration Estimation• Goal: compute the duration of the single

instructions• The maximum number of iteration for each

instruction is known• The duration depends on the context• Limited computational context:

We assume that the effects on the pipeline and caches of an instruction fade over time.

Page 17: Approximating the Worst-Case Execution Time of Soft Real-time Applications Matteo Corti

Matteo Corti, 2005-03-03 17

0

10

20

30

40

50

10 25 50 75 100 125 150 175 200

n

overestimation

Partial TracesPartial Traces

• the last n instructions before the instruction i on a given trace

• n is determined experimentally (50-100 instructions)

i

Page 18: Approximating the Worst-Case Execution Time of Soft Real-time Applications Matteo Corti

Matteo Corti, 2005-03-03 18

WCET EstimationWCET Estimation

• For every partial trace:

– CPU behavior simulation (cycle precise)

– duration according to the context

• We account for all the incoming partial traces (contexts) according to their iteration counts

• Block duration = ∑ instruction durations

• WCET = longest path

Page 19: Approximating the Worst-Case Execution Time of Soft Real-time Applications Matteo Corti

Matteo Corti, 2005-03-03 19

Data CachesData Caches• Partial traces are too short to gather enough

information on data caches

• Data caches are not simulated but estimated using run-time statistics

• The average frequency of data cache misses is measured with a set of test runs of the program

Page 20: Approximating the Worst-Case Execution Time of Soft Real-time Applications Matteo Corti

Matteo Corti, 2005-03-03 20

Structure: Separated ApproachStructure: Separated Approach

semanticanalysis

HW-levelanalysis

run-timemonitor

binary

annotatedbinary

WCETcache

behavior

Page 21: Approximating the Worst-Case Execution Time of Soft Real-time Applications Matteo Corti

Matteo Corti, 2005-03-03 21

ApproximationApproximation

• We approximate the duration of single instructions.

• We do not approximate the number of times an instruction is executed.

• Inaccuracies are only due to cache and pipeline effects.

• No severe WCET underestimations are possible.

Page 22: Approximating the Worst-Case Execution Time of Soft Real-time Applications Matteo Corti

Matteo Corti, 2005-03-03 22

Contributions (HW-level Analysis)Contributions (HW-level Analysis)

• Partial traces evaluation– O(B)– analyze the instructions in their context– approximates the effects of instructions

over time– includes run-time data for the analysis of

data caches

• Related work– abstract interpretation based– data flow analyses

Page 23: Approximating the Worst-Case Execution Time of Soft Real-time Applications Matteo Corti

Matteo Corti, 2005-03-03 23

OutlineOutline• Goal and thesis

• Semantic analysis

• Hardware-level analysis

• Environment

• Results

• Concluding remarks

Page 24: Approximating the Worst-Case Execution Time of Soft Real-time Applications Matteo Corti

Matteo Corti, 2005-03-03 24

EnvironmentEnvironment

• Java ahead-of-time bytecode to native compiler

• Linux

• Intel Pentium Pro family

• Semantic analysis: language independent

• Hardware-level analysis: architecture independent

Page 25: Approximating the Worst-Case Execution Time of Soft Real-time Applications Matteo Corti

Matteo Corti, 2005-03-03 25

OutlineOutline• Goal and thesis

• Semantic analysis

• Hardware-level analysis

• Environment

• Results

• Concluding remarks

Page 26: Approximating the Worst-Case Execution Time of Soft Real-time Applications Matteo Corti

Matteo Corti, 2005-03-03 26

EvaluationEvaluation

• It is not possible to test the whole input space to determine the WCET experimentally.

• small applications: known algorithm, the WCET can be forced at run time

• big applications: several runs with random input

Page 27: Approximating the Worst-Case Execution Time of Soft Real-time Applications Matteo Corti

Matteo Corti, 2005-03-03 27

Results – Small KernelsResults – Small Kernels

Benchmark LoopsMeasured Estimated

Overestimation[cycles] [cycles]

BubbleSort 4 9.16·109 1.53·1010 67%

Division 2 1.40·109 1.55·109 10%

ExpInt 3 1.28·108 2.38·108 86%

Jacobi 5 0.88·1010 1.08·1010 22%

JanneComplex 4 1.39·108 2.48·108 78%

MatMult 6 2.67·109 2.73·109 2%

MatrixInversion 11 1.42·109 1.55·109 10%

Sieve 4 1.29·1010 1.40·1010 9%

Page 28: Approximating the Worst-Case Execution Time of Soft Real-time Applications Matteo Corti

Matteo Corti, 2005-03-03 28

Results – Application BenchmarksResults – Application Benchmarks

Program

Classes

Methods

Loops

Observed EstimatedOver-

estimation [cycles] [cycles]

_201_compress 13 43 17 7.20·109 1.05·1010 46%

JavaLayer 63 202 117 6.09·109 1.18·1010 94%

Linpack 1 17 24 1.40·1010 2.72·1010 94%

SciMark 9 43 43 1.91·1010 1.22·1011 538%

Whetstone 1 7 14 1.86·109 2.11·109 13%

Page 29: Approximating the Worst-Case Execution Time of Soft Real-time Applications Matteo Corti

Matteo Corti, 2005-03-03 29

OutlineOutline• Goal and thesis

• Semantic analysis

• Hardware-level analysis

• Environment

• Results

• Concluding remarks

Page 30: Approximating the Worst-Case Execution Time of Soft Real-time Applications Matteo Corti

Matteo Corti, 2005-03-03 30

ConclusionsConclusions

• Semantic analysis– fast partial abstract interpretation pass– scalable block iterations bounding algorithm

taking into consideration different path frequencies inside loop bodies

– no restrictions on the analyzed code

• Hardware-level analysis– instruction duration analyzed in the execution

context– architecture independent