Value Range Analysis with Modulo Interval Arithmetic

Slides:



Advertisements
Similar presentations
2.1 Program Construction In Java
Advertisements

Continuing Abstract Interpretation We have seen: 1.How to compile abstract syntax trees into control-flow graphs 2.Lattices, as structures that describe.
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.
Chair of Software Engineering From Program slicing to Abstract Interpretation Dr. Manuel Oriol.
Optimizing Compilers for Modern Architectures More Interprocedural Analysis Chapter 11, Sections to end.
CENG536 Computer Engineering Department Çankaya University.
Congruence class arithmetic. Definitions: a ≡ b mod m iff a mod m = b mod m. a  [b] iff a ≡ b mod m.
Reduction in Strength CS 480. Our sample calculation for i := 1 to n for j := 1 to m c [i, j] := 0 for k := 1 to p c[i, j] := c[i, j] + a[i, k] * b[k,
Data Flow Analysis Compiler Design Nov. 8, 2005.
BASIS PATH TESTING ● By Tom McCabe ● McCabe, T., "A Software Complexity Measure," IEEE Trans. Software Engineering, vol. SE-2, December 1976, pp
Carnegie Mellon Adaptive Mapping of Linear DSP Algorithms to Fixed-Point Arithmetic Lawrence J. Chang Inpyo Hong Yevgen Voronenko Markus Püschel Department.
Machine-Independent Optimizations Ⅰ CS308 Compiler Theory1.
Computer Science: A Structured Programming Approach Using C1 Objectives ❏ To understand the structure of a C-language program. ❏ To write your first C.
Data Flow Analysis Compiler Design Nov. 8, 2005.
Program Analysis Mooly Sagiv Tel Aviv University Sunday Scrieber 8 Monday Schrieber.
VB .NET Programming Fundamentals
1.7 – Linear Inequalities and Compound Inequalities
Fundamentals of Python: From First Programs Through Data Structures
Abstract Interpretation (Cousot, Cousot 1977) also known as Data-Flow Analysis.
Chapter 1 Algorithm Analysis
Topic #10: Optimization EE 456 – Compiling Techniques Prof. Carl Sable Fall 2003.
Analysis of Algorithm Lecture 3 Recurrence, control structure and few examples (Part 1) Huma Ayub (Assistant Professor) Department of Software Engineering.
Mathematics Review Exponents Logarithms Series Modular arithmetic Proofs.
Lecture 2 Computational Complexity
U NIVERSITY OF M ASSACHUSETTS, A MHERST D EPARTMENT OF C OMPUTER S CIENCE Emery Berger University of Massachusetts, Amherst Advanced Compilers CMPSCI 710.
Data Representation in Computer Systems
Array Dependence Analysis COMP 621 Special Topics By Nurudeen Lameed
Toward Efficient Flow-Sensitive Induction Variable Analysis and Dependence Testing for Loop Optimization Yixin Shou, Robert A. van Engelen, Johnnie Birch,
Round-off Errors.
Dataflow Analysis Topic today Data flow analysis: Section 3 of Representation and Analysis Paper (Section 3) NOTE we finished through slide 30 on Friday.
Practical Considerations When t , the supp, then there will be a value of t when supp folds, it becomes multi-w-to-one-x mapping.
Fixed & Floating Number Format Dr. Hugh Blanton ENTC 4337/5337.
Program Development C# Programming January 30, 2007 Professor J. Sciame.
School of Computer Science & Information Technology G6DICP - Lecture 4 Variables, data types & decision making.
More on Loop Optimization Data Flow Analysis CS 480.
Sum of Arithmetic Sequences. Definitions Sequence Series.
Chad’s C++ Tutorial Demo Outline. 1. What is C++? C++ is an object-oriented programming (OOP) language that is viewed by many as the best language for.
Single Static Assignment Intermediate Representation (or SSA IR) Many examples and pictures taken from Wikipedia.
An Optimized Hardware Architecture for the Montgomery Multiplication Algorithm Miaoqing Huang Nov. 5, 2010.
Floating Point Arithmetic – Part I
Code Optimization Overview and Examples
CMPT 120 Topic: Python’s building blocks -> More Statements
Code Optimization.
Computation of the solutions of nonlinear polynomial systems
TK3043 Analysis and Design of Algorithms
Control Flow Testing Handouts
Handouts Software Testing and Quality Assurance Theory and Practice Chapter 4 Control Flow Testing
The Design and Analysis of Algorithms
Analysis of Algorithms
Chapter 2 - Introduction to C Programming
CS314 – Section 5 Recitation 13
Congruence class arithmetic
Programming For Nuclear Engineers Lecture 6 Arrays
Lecture 3 of Computer Science II
Outline of the Chapter Basic Idea Outline of Control Flow Testing
Chapter 2 - Introduction to C Programming
Dataflow Testing G. Rothermel.
Introduction to the C Language
What Is a Program? A program is like an algorithm, but describes a process that is ready or can be made ready to run on a real computer Retrieved from:
Preliminary Transformations
Register Pressure Guided Unroll-and-Jam
C Operators, Operands, Expressions & Statements
Compiler Code Optimizations
Recent from Dr. Dan Lo regarding 12/11/17 Dept Exam
Lecture 14: Problems with Lots of Similar Data
An Overview of C.
OPERATORS in C Programming
DATA TYPES AND OPERATIONS
OPERATORS in C Programming
Presentation transcript:

Value Range Analysis with Modulo Interval Arithmetic Tsuneo Nakanishi and Akira Fukuda Nara Institute of Science and Technology, Japan

Topics Research Background Modulo Interval Arithmetic Modulo Interval Propagation Conclusion

Research Background

Research Background (1) Value ranges taken by variables and expressions of a given program is often required for Code Analyzing and Optimization by Compilers Debugging and Testing by Programmers What values does this variable take? DO I=1, 1000, 2 S1: TMP = A(3I-1)+A(3I)+A(3I+1) S2: A(I) = TMP / 3 EndDO What values does this expression take?

Research Background (2) Most general value range representation is the interval. R a b [a, b] The interval is a sufficient representation as value range representation for compilers and programmers? Absolutely NO. For example, integers taken by loop indices and array subscripts have some strides. The interval cannot represent strides.  We proposed the modulo interval and modulo interval arithmetic.

Modulo Interval Arithmetic

Interval Arithmetic (1) Interval on R R a b [a, b] [a, b] = { x  R | a  x  b } Interval Arithmetic Arithmetic defined on intervals of R, which was invented by Sunaga (Japan) in 50s and well-organized by Moore (US) in 60s. Used for floating-point error estimation.

Interval Arithmetic (2) Arithmetic Operations Addition [a, b] + [c, d] = [a + b, c + d] [ 3, 8 ] + [ 5, 10 ] = [ 8, 18 ] Subtraction [a, b] – [c, d] = [a – d, b – c] [ 2, 9 ] – [ 4, 8 ] = [ –6, 5 ] Multiplication [a, b] * [c, d] = [min{ac, ad, bc, bd}, max{ac, ad, bc, bd}] [ 2, 3 ] * [ 3, 5 ] = [ 6, 15 ] Division, Exponentiation, etc.

Modulo Interval Arithmetic (1) Modulo Interval on Z R [a, b] n r [a, b]n(r) [a, b]n(r) = { x  Z | a  x  b, x = nm + r, m  Z } [2, 17]5(2) = { 2, 7, 12, 17 } [7, 21]7(0) = { 7, 14, 21 }

Modulo Interval Arithmetic (2) Arithmetic Operations Addition [a, b]m(r) + [c, d]n(s)  [a + c, b + d]gcd(m, n)(r + s) [ 2, 10 ]4(2) + [ 3, 23 ]4(3)  [ 5, 33 ]4(5) = [ 5, 33 ]4(1) Subtraction [a, b]m(r) – [c, d]n(s)  [a – d, b – c]gcd(m, n)(r – s) [ 2, 10 ]4(2) – [ 3, 21 ]6(3)  [ –19, 7 ]2(–1) = [ –19, 7 ]2(1) Multiplication [a, b]m(r) * [c, d]n(s)  [min{ac, ad, bc, bd}, max{ac, ad, bc, bd}]gcd(m, n)(rs) [ 2, 10 ]4(2) * [ 3, 21 ]4(3)  [ 6, 210 ]4(6) = [ 6, 210 ]4(2)

Modulo Interval Arithmetic (3) Arithmetic Operations with Integers Addition [a, b]m(r) + z = [a + z, b + z]m(r + z) [ 2, 10 ]4(2) + 3 = [ 5, 13 ]4(5) = [ 5, 13 ]4(1) z + [a, b]m(r) = [z + a, z + b]m(z + r) 3 + [ 2, 10 ]4(2) = [ 5, 13 ]4(5) = [ 5, 13 ]4(1) Subtraction [a, b]m(r) – z = [a – z, b – z]m(r – z) [ 2, 10 ]4(2) – 3 = [ –1, 7 ]4(–1) = [ –1, 7 ]4(3) z – [a, b]m(r) = [z – b, z – a]m(z – r) 3 – [ 2, 10 ]4(2) = [ –7, 1 ]4(1) = [ –7, 1 ]4(1)

Modulo Interval Arithmetic (4) Arithmetic Operations with Integers Multiplication [a, b]m(r) * z = [az, bz]mz(rz) [ 2, 10 ]4(2) * 3 = [ 6, 30 ]12(6) z * [a, b]m(r) = [az, bz]zm(zr) 3 * [ 2, 10 ]4(2) = [ 6, 30 ]12(6)

Modulo Interval Arithmetic (5) Set Operations: Intersection [a, b]m(r)  [c, d]n(s) If b – c is divisible by gcd(m, n), [a, b]m(r)  [c, d]n(s) = [max{a, c}, min{b, d}]lcm(m, n)(z) z is an integer such that z  r (mod m), z  s (mod n). If b – c is not divisible by gcd(m, n), [a, b]m(r)  [c, d]n(s) =  Set Operations: Union [a, b]n(r) = [a, b]nm(r)  [a, b]nm(n+r)  …  [a, b]nm(n(m1) + r) [ 2, 17 ]5(2) = [ 2, 17 ]10(2)  [ 2, 17 ]10(7)

Modulo Interval Propagation

Monotonic Data Flow System A unified algorithm for data flow analysis and optimization problems: Constant Propagation, Live Variable Analysis, Definition Reachability Analysis, etc. Propagating and processing data flow information held at each node of a given control flow graph until convergence.

Data Flow Information Data Flow Information for Modulo Interval Propagation: A set of tuples consisting of variable names and modulo intervals representing the value ranges of the variables. (x, [1, 99]2(1)) (y, [–32, 32]2(0)) …

Modulo Interval Propagation (1) Assignment Statement (x1, X1), (x2, X2), … y = g(x1, x2, …) (x1, X1), (x2, X2), …, (y, g(X1, X2, …))

Modulo Interval Propagation (2) Assignment Statement (ex.) (x, [1, 99]2(1)) (y, [–32, 32]2(0)) z = x + y * 2 z = [1, 99]2(1) + [–32, 32]2(0) * 2 (x, [1, 99]2(1)) (y, [–32, 32]2(0)) (z, [–63, 163]4(1))

Modulo Interval Propagation (3) Conditional Branch (x1, X1), (x2, X2), … if (p(x, y)) T F {(x1, X1), (x2, X2), …,}  {(x, Xi): p(X1, X2, …) = true} {(x1, X1), (x2, X2), …,}  {(xi, Xi): p(X1, X2, …) = false}

Modulo Interval Propagation (4) Conditional Branch (x, [1, 99]2(1)) (y, [1, 99]2(1)) if (x + y  100) {(x, [1, 99]2(1)), (y, [1, 99]2(1)), …,}  {(x, X)  (y, Y): x  X, y  Y, x + y  100} T F {(x, [1, 99]2(1)), (y, [1, 99]2(1)), …,}  {(x, X)  (y, Y): x  X, y  Y, not x + y  100}

Modulo Interval Propagation (5) Condition: x + y  100 Input Data Flow Information: (x, [1, 99]2(1)), (y, [1, 99]2(1)) Bound x to [1, 99]2(1) . y  100 – [1, 99]2(1) y  [–∞, 99]1(0) Bound y to [1, 99]2(1) . x  [–∞, 99]1(0) Output Data Flow Information of True Clause:

Induction Variable Problem (1) for (i = 1, sum=0; i <= 100; i++) { sum = sum + i; } Induction variables require considerable computation time to obtain their value ranges by modulo interval propagation. Value ranges of induction variables can be too overestimated by modulo interval propagation. (In the above example, tha value range of sum is estimated as [0, 10000]1(0) , whereas it is [0, 5050]1(0).)

Induction Variable Propagation (2) Apply modulo interval propagation after eliminating induction variables (or with supposing that induction variable was eliminated). Before elimination sum = sum + i After elimination sum = (i + 1) * i / 2 Make special treatment for some typical inductive operations such as summation, minimum, and maximum.

Related Works W. H. Harrison, “Compiler Analysis of the Value Ranges for Variables,” IEEE Trans. on Software Engineering, Vol.SE-3, No.3, pp.243–250, May 1977. O. Ogawa et al., “Hardware Synthesis from C Programs with Elimination of Bit Length of Variables,” IEICE Trans. On Fundamentals, Vol.E82-A, No.11, pp.2338–2346, Nov. 1999. A monotone data flow system based algorithm A value range analysis with intervals ( modulo intervals) Simple conditional expressions only ( complicated conditional expressions) Induction variable problem (= not be solved yet)

Conclusion

Conclusion Introduce Modulo Interval Arithmetic An extension of Interval Arithmetic Simple representation of a set of integers for program analysis Concrete arithmetic system on a set of integers Propose Modulo Interval Propagation A value range analysis technique with modulo interval arithmetic A monotone data flow system based algorithm Induction variable problem