WCET 2008, Prague, slide 1 of 15 Tid rum WCET'2008 Computing Time as a Program Variable: Niklas Holsti Tidorum Ltd a way around.

Slides:



Advertisements
Similar presentations
Approximating the Worst-Case Execution Time of Soft Real-time Applications Matteo Corti.
Advertisements

Data-Flow Analysis II CS 671 March 13, CS 671 – Spring Data-Flow Analysis Gather conservative, approximate information about what a program.
1 CS 201 Compiler Construction Lecture 3 Data Flow Analysis.
Modeling shared cache and bus in multi-core platforms for timing analysis Sudipta Chattopadhyay Abhik Roychoudhury Tulika Mitra.
Static Single Assignment CS 540. Spring Efficient Representations for Reachability Efficiency is measured in terms of the size of the representation.
Data-Flow Analysis Framework Domain – What kind of solution is the analysis looking for? Ex. Variables have not yet been defined – Algorithm assigns a.
1 IIES 2008 Thomas Heinz (Saarland University, CR/AEA3) | 22/03/2008 | © Robert Bosch GmbH All rights reserved, also regarding any disposal, exploitation,
Constraint Systems used in Worst-Case Execution Time Analysis Andreas Ermedahl Dept. of Information Technology Uppsala University.
A survey of techniques for precise program slicing Komondoor V. Raghavan Indian Institute of Science, Bangalore.
Repeating Structures Do While Loops. Do While Loop While loops have a test condition before the loop –This means that java will test the condition before.
Example in SSA X := Y op Z in out F X := Y op Z (in) = in [ { X ! Y op Z } X :=  (Y,Z) in 0 out F X :=   (in 0, in 1 ) = (in 0 Å in 1 ) [ { X ! E |
Common Sub-expression Elim Want to compute when an expression is available in a var Domain:
Global optimization. Data flow analysis To generate better code, need to examine definitions and uses of variables beyond basic blocks. With use- definition.
 2006 Pearson Education, Inc. All rights reserved Control Statements: Part 2.
1 CS 201 Compiler Construction Lecture 3 Data Flow Analysis.
Data Flow Analysis Compiler Design October 5, 2004 These slides live on the Web. I obtained them from Jeff Foster and he said that he obtained.
CS 412/413 Spring 2007Introduction to Compilers1 Lecture 29: Control Flow Analysis 9 Apr 07 CS412/413 Introduction to Compilers Tim Teitelbaum.
Recap from last time: live variables x := 5 y := x + 2 x := x + 1 y := x y...
Global optimization. Data flow analysis To generate better code, need to examine definitions and uses of variables beyond basic blocks. With use- definition.
Data Flow Analysis Compiler Design Nov. 8, 2005.
Direction of analysis Although constraints are not directional, flow functions are All flow functions we have seen so far are in the forward direction.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved The switch Multiple-Selection Statement switch.
Part II: Addressing Modes
Precision Going back to constant prop, in what cases would we lose precision?
1 CS 201 Compiler Construction Data Flow Analysis.
Design Space Exploration
Lecture 4 C Program Control Acknowledgment The notes are adapted from those provided by Deitel & Associates, Inc. and Pearson Education Inc.
Dataflow Analysis Topic today Data flow analysis: Section 3 of Representation and Analysis Paper (Section 3) NOTE we finished through slide 30 on Friday.
Timing Analysis of Embedded Software for Speculative Processors Tulika Mitra Abhik Roychoudhury Xianfeng Li School of Computing National University of.
Cleaning up the CFG Eliminating useless nodes & edges C OMP 512 Rice University Houston, Texas Fall 2003 Copyright 2003, Keith D. Cooper & Linda Torczon,
1 Data Flow Analysis Data flow analysis is used to collect information about the flow of data values across basic blocks. Dominator analysis collected.
A Unified WCET Analysis Framework for Multi-core Platforms Sudipta Chattopadhyay, Chong Lee Kee, Abhik Roychoudhury National University of Singapore Timon.
CS241 PASCAL I - Control Structures1 PASCAL Control Structures Modified Slides of Philip Fees.
Program Representations. Representing programs Goals.
 Control Flow statements ◦ Selection statements ◦ Iteration statements ◦ Jump statements.
CS412/413 Introduction to Compilers Radu Rugina Lecture 18: Control Flow Graphs 29 Feb 02.
1 Control Flow Graphs. 2 Optimizations Code transformations to improve program –Mainly: improve execution time –Also: reduce program size Can be done.
Cleaning up the CFG Eliminating useless nodes & edges This lecture describes the algorithm Clean, presented in Chapter 10 of EaC2e. The algorithm is due.
CSE 522 WCET Analysis Computer Science & Engineering Department Arizona State University Tempe, AZ Dr. Yann-Hang Lee (480)
 2006 Pearson Education, Inc. All rights reserved Control Statements: Part 2.
C Program Control September 15, OBJECTIVES The essentials of counter-controlled repetition. To use the for and do...while repetition statements.
WCET 2007, Pisa, page 1 of 27 Tid rum WCET'2007 Analysing Switch-Case Tables by Partial Evaluation Niklas Holsti Tidorum Ltd
Program design Program Design Process has 2 phases:
Code Optimization Overview and Examples
Chapter 4 – C Program Control
Fundamentals of PL/SQL part 2 (Basics)
UNIT 5 Lesson 15 Looping.
Control Flow Testing Handouts
Handouts Software Testing and Quality Assurance Theory and Practice Chapter 4 Control Flow Testing
Lecture 7: Repeating a Known Number of Times
Program Representations
Chapter 4 - Program Control
Princeton University Spring 2016
CSCI1600: Embedded and Real Time Software
Machine-Independent Optimization
Chapter 6. Large Scale Optimization
Control statements Simple statements Basic structured statements
Another example: constant prop
1. Reaching Definitions Definition d of variable v: a statement d that assigns a value to v. Use of variable v: reference to value of v in an expression.
Chapter 4 - Program Control
Chapter (3) - Looping Questions.
Chapter 8: More on the Repetition Structure
Optimizations using SSA
Data Flow Analysis Compiler Design
Chapter8: Statement-Level Control Structures April 9, 2019
Loop Construct.
Chapter 4 - Program Control
CSCI1600: Embedded and Real Time Software
Chapter 6. Large Scale Optimization
Code Optimization.
Presentation transcript:

WCET 2008, Prague, slide 1 of 15 Tid rum WCET'2008 Computing Time as a Program Variable: Niklas Holsti Tidorum Ltd a way around infeasible paths

WCET 2008, Prague, slide 2 of 15 Tid rum Example: Saturating a value ● Make sure that x is between 1 and 10: if x < 1 then x := 1; end if; if x > 10 then x := 10; end if; if x < 1x := 1 end if; x := 10 end if; if x > 10 Infeasible combination of - (new) value of x and - value of condition x > 10 ● The path that executes both assignments x := 1 and x := 10 is infeasible ● This is the longest path  overestimated WCET

WCET 2008, Prague, slide 3 of 15 Tid rum Reasoning ● Infeasible paths arise from dependencies (correlations) between variable values/assignments and values of branch conditions ● Some analysis of such dependencies is necessary ● Earlier work: “path-oriented” analysis – find (in-) feasible combinations of CFG blocks/edges – use “flow facts” to constrain eg. IPET ● Suggestion: “value-oriented” analysis – find (in-) feasible combinations of variable values – make execution time a variable, T – thus, find (in-) feasible execution times = values of T infeasible pathinfeasible value of T

WCET 2008, Prague, slide 4 of 15 Tid rum From values to feasible WCET ● Path-oriented: dependencies between values of vars/conds feasible paths WCET for feasible paths ● Value-oriented: dependencies between values of vars/conds including T feasible values of T specific analysis of (in)feasible paths bounds calculation eg. by IPET dependency-sensitive value analysis

WCET 2008, Prague, slide 5 of 15 Tid rum Adding the T variable (in a real tool) ● Add T to the internal representation (CFG) of the machine-code program ● Add T := 0 at the start of the program/subprogram ● Add T := T + t(b) in each basic block b – t(b) comes from processor-behaviour analysis ● using all structural paths in the CFG ● may include infeasible paths ● Ditto for control-flow edges that take some time ● Use interval arithmetic if t(b) is not a single value – eg. context-dependent pipeline or cache effects

WCET 2008, Prague, slide 6 of 15 Tid rum Adding T to the “saturation” example ● Add T as a variable in the (pseudo-) source code ● Add else-parts to model the condition-evaluation time. T := 0; if x < 1 then x := 1; T := T + 3; else T := T + 1; end if; if x > 10 then x := 10; T := T + 3; else T := T + 1; end if; ● ET of program = final value of T – Infeasible path ET is = 6 cycles. – WCET is = 4 cycles. – BCET is = 2 cycles.

WCET 2008, Prague, slide 7 of 15 Tid rum A dependency-sensitive value-analysis ● This is just one method/domain; others are possible – similar to the analysis in the Bound-T WCET tool, – which Bound-T currently uses mainly for loop bounds – implemented with the Omega Calculator (Pugh et al.) ● Models: – value of one variable : integer  Z – combined values of n variables : n-tuple  Z n – all combined values of n variables : n-tuple set  Z n – instruction : transfer relation  Z n  Z n = Z 2n ● Set : { [v 1,v 2,...,v n ] | constraints } ● Relation : { [v 1,v 2,...,v n ]  [v' 1,v' 2,...,v' n ] | constraints } ● Constraints in Presburger Arithmetic form: Presburger sets

WCET 2008, Prague, slide 8 of 15 Tid rum Presburger-set analysis of the example T := 0; {[x,T]} {[x,0]} x := 1; T := T + 3; {[x,0] | x < 1} {[1, 3]} x < 1 T := T + 1; {[x,0] | x ≥ 1} {[x, 1] | x ≥ 1} if x < 1... x ≥ 1 {[x,1] | x ≥ 1}  {[1,3]} x := 10; T := T + 3; 3; {[x,1] | x > 10} {[10, 4]} x > 10 T := T + 1; {[x,1] | 1 ≤ x ≤ 10}  {[1,3]} {[x,2] | 1 ≤ x ≤ 10}  {[1,4]} if x > x ≤ 10 {[x, 2 ] | 1 ≤ x ≤ 10}  {[1, 4 ]}  {[10, 4 ]} pre-value set instruction post-value set

WCET 2008, Prague, slide 9 of 15 Tid rum What about loops? ● Three different things: – finding loop bounds (bounds on # of iterations) – finding the effect of loops on variable values – handling infeasible paths involving loops. ● Presburger-set analysis can be used for all three things ● Focus: how T -variable works in infeasible looping paths loop head initial values post-loop (exit) values repetition values

WCET 2008, Prague, slide 10 of 15 Tid rum The repetition relation of a loop ● The repetition relation of a loop shows how variable values change in one repetition of the loop – from the transfer relations of the instructions in the loop – exit from loop is treated separately (as normal flow) ● Example: Reverse order of vec[n.. n + 9]: i := n; j := n + 9; while i < j loop z := vec[i]; vec[i] := vec[j]; vec[j] := z; i := i + 1; j := j – 1; end loop; ● Ignore the vec[] values (pointer analysis...) ● The repetition relation R for i, j, n, z is: R = { [ i, j, n, z ]  [ i + 1, j – 1, n, z' ] | i < j }

WCET 2008, Prague, slide 11 of 15 Tid rum Invariant, induction, and fuzzy variables ● Use the repetition relation R to classify each variable v as: – invariant:R does not change v – induction:R sets v := v + dv, where dv is constant  Z \{0} – fuzzy:R changes v in other (unknown) ways ● Computation: see paper – intersect R with { [v, dv]  [v + dv] } – project to dv – take convex hull  interval of possible dv ● Example above: – i and j are induction variables; di = 1, dj = -1 – n is invariant; in other words dn = 0 – z is fuzzy.

WCET 2008, Prague, slide 12 of 15 Tid rum Induction model of loop ● Add iteration counter c = 0, 1,... ● Induction model: Value of v at start of iteration c is – if invariant:v = v 0 = initial value of v – if induction:v = v 0 + c  dv – if fuzzy:v is unconstrained (unknown) ● Loop bound N: see paper – propagate the induction model to the back edge: { [i, j, n, z] | i – 1 < j+1 and i = n+1+c and j = n+8+c } – project to c – take convex hull  bounds on c that allow repetition – example: c  4. ● Post-loop values: Propagate induction model to exit – effect on induction variable: v := v + N  dv, N constant ● plus possible effect of the loop-exit path

WCET 2008, Prague, slide 13 of 15 Tid rum T is an induction variable ● Effect of loop is T := T + N  dT – dT is the execution time of one loop repetition – N is a constant (range) ● dT from dependency-sensitive analysis of loop body – excludes infeasible paths contained in the loop body ● when infeasibility is iteration-independent ● dT is a Presburger variable – can depend on other variables – shows dependency between paths inside and outside loop – final T excludes infeasible combinations of such paths ● when infeasibility is iteration-independent ● Hard to handle iteration-specific infeasibility ● Fails for infeasible “path – loop-bound” combinations

WCET 2008, Prague, slide 14 of 15 Tid rum Example iteration-independent case ● No path can take the slow case of both branches – infeasible longest path =  200 = 1500 cycles – longest feasible path =  200 = 1410 cycles ● T-analysis works; final T = T := 0; if x < 1 then T := T + 100; else T := T + 10; end if; for i in loop if x > 3 then T := T + 200; else T := T + 20; end if; end loop; contradictory conditions ● apply in the same way on each loop iteration ● x is invariant

WCET 2008, Prague, slide 15 of 15 Tid rum Summary ● Add execution-time variable T – T becomes “entangled” with other variables/conditions ● Use dependency-sensitive value-analysis – final value of T is “entangled” with feasible paths ● Good: – no specific analysis and representation of infeasible paths – handles many kinds of infeasible paths ● Bad: – history-sensitive t(b) may be over-estimated – Presburger-set analysis is costly; hard to scale up ● Possible future work: – implementation and evaluation – other, cheaper dependency-sensitive value-analyses ● but non-convexity (disjunction) is probably desirable