Jaewook Shin, Priyadarshini Malusare and Paul D. Hovland Mathematics and Computer Science Division Argonne National Laboratory Design and Implementation.

Slides:



Advertisements
Similar presentations
Register Allocation Consists of two parts: Goal : minimize spills
Advertisements

The Chain Rule Section 3.6c.
A Survey of Program Slicing Techniques A Survey of Program Slicing Techniques Sections 3.1,3.6 Swathy Shankar
Automatic Differentiation Tutorial
Partial Derivatives Definitions : Function of n Independent Variables: Suppose D is a set of n-tuples of real numbers (x 1, x 2, x 3, …, x n ). A real-valued.
Data-Flow Analysis II CS 671 March 13, CS 671 – Spring Data-Flow Analysis Gather conservative, approximate information about what a program.
Course Outline Traditional Static Program Analysis –Theory Compiler Optimizations; Control Flow Graphs Data-flow Analysis – today’s class –Classic analyses.
Python Programming Chapter 5: Fruitful Functions Saad Bani Mohammad Department of Computer Science Al al-Bayt University 1 st 2011/2012.
Lecture 11: Code Optimization CS 540 George Mason University.
Chapter 9 Code optimization Section 0 overview 1.Position of code optimizer 2.Purpose of code optimizer to get better efficiency –Run faster –Take less.
Data Flow Coverage. Reading assignment L. A. Clarke, A. Podgurski, D. J. Richardson and Steven J. Zeil, "A Formal Evaluation of Data Flow Path Selection.
1 CS 201 Compiler Construction Lecture 3 Data Flow Analysis.
Context-Sensitive Interprocedural Points-to Analysis in the Presence of Function Pointers Presentation by Patrick Kaleem Justin.
Course Outline Traditional Static Program Analysis –Theory Compiler Optimizations; Control Flow Graphs Data-flow Analysis – today’s class –Classic analyses.
SSA.
Data-Flow Analysis Framework Domain – What kind of solution is the analysis looking for? Ex. Variables have not yet been defined – Algorithm assigns a.
CS412/413 Introduction to Compilers Radu Rugina Lecture 37: DU Chains and SSA Form 29 Apr 02.
Some Properties of SSA Mooly Sagiv. Outline Why is it called Static Single Assignment form What does it buy us? How much does it cost us? Open questions.
1 Code Optimization. 2 The Code Optimizer Control flow analysis: control flow graph Data-flow analysis Transformations Front end Code generator Code optimizer.
1 Introduction to Data Flow Analysis. 2 Data Flow Analysis Construct representations for the structure of flow-of-data of programs based on the structure.
SOFTWARE TESTING. INTRODUCTION  Software Testing is the process of executing a program or system with the intent of finding errors.  It involves any.
Program Slicing Mark Weiser and Precise Dynamic Slicing Algorithms Xiangyu Zhang, Rajiv Gupta & Youtao Zhang Presented by Harini Ramaprasad.
1 Program Slicing Purvi Patel. 2 Contents Introduction What is program slicing? Principle of dependences Variants of program slicing Slicing classifications.
1 Cost Effective Dynamic Program Slicing Xiangyu Zhang Rajiv Gupta The University of Arizona.
Program Analysis with Set Constraints Ravi Chugh.
Global optimization. Data flow analysis To generate better code, need to examine definitions and uses of variables beyond basic blocks. With use- definition.
Speeding Up Dataflow Analysis Using Flow- Insensitive Pointer Analysis Stephen Adams, Tom Ball, Manuvir Das Sorin Lerner, Mark Seigle Westley Weimer Microsoft.
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.
Machine-Independent Optimizations Ⅰ CS308 Compiler Theory1.
Global optimization. Data flow analysis To generate better code, need to examine definitions and uses of variables beyond basic blocks. With use- definition.
In conclusion our tool: can be used with any operator overloading AD package replaces the manual process, which is slow and overestimates the number active.
Composing Dataflow Analyses and Transformations Sorin Lerner (University of Washington) David Grove (IBM T.J. Watson) Craig Chambers (University of Washington)
Differentials, Estimating Change Section 4.5b. Recall that we sometimes use the notation dy/dx to represent the derivative of y with respect to x  this.
1 CS 201 Compiler Construction Data Flow Analysis.
1 ECE 453 – CS 447 – SE 465 Software Testing & Quality Assurance Instructor Kostas Kontogiannis.
PRESTO: Program Analyses and Software Tools Research Group, Ohio State University STATIC ANALYSES FOR JAVA IN THE PRESENCE OF DISTRIBUTED COMPONENTS AND.
Michelle Mills Strout OpenAnalysis: Representation- Independent Program Analysis CCA Meeting January 17, 2008.
Identifying Reversible Functions From an ROBDD Adam MacDonald.
Dataflow Analysis Topic today Data flow analysis: Section 3 of Representation and Analysis Paper (Section 3) NOTE we finished through slide 30 on Friday.
1 CPSC 320: Intermediate Algorithm Design and Analysis July 28, 2014.
Λλ Fernando Magno Quintão Pereira P ROGRAMMING L ANGUAGES L ABORATORY Universidade Federal de Minas Gerais - Department of Computer Science P ROGRAM A.
1 Program Slicing Amir Saeidi PhD Student UTRECHT UNIVERSITY.
Model construction and verification for dynamic programming languages Radu Iosif
CHAPTER Continuity Implicit Differentiation.
3.1 Definition of the Derivative & Graphing the Derivative
Compiler Principles Fall Compiler Principles Lecture 0: Local Optimizations Roman Manevich Ben-Gurion University.
CHAPTER Continuity Fundamental Theorem of Calculus In this lecture you will learn the most important relation between derivatives and areas (definite.
Texas A&M University, Department of Aerospace Engineering AN EMBEDDED FUNCTION TOOL FOR MODELING AND SIMULATING ESTIMATION PROBLEMS IN AEROSPACE ENGINEERING.
PRESTO: Program Analyses and Software Tools Research Group, Ohio State University Merging Equivalent Contexts for Scalable Heap-cloning-based Points-to.
Chapter 3 Response Charts.
Pointer Analysis for Multithreaded Programs Radu Rugina and Martin Rinard M I T Laboratory for Computer Science.
Comparison of Tarry’s Algorithm and Awerbuch’s Algorithm CS 6/73201 Advanced Operating System Presentation by: Sanjitkumar Patel.
Chapter 15: Recursion. Objectives In this chapter, you will: – Learn about recursive definitions – Explore the base case and the general case of a recursive.
Efficient Method of Solution of Large Scale Engineering Problems with Interval Parameters Based on Sensitivity Analysis Andrzej Pownuk Silesian University.
NETWORK FLOWS Shruti Aggrawal Preeti Palkar. Requirements 1.Implement the Ford-Fulkerson algorithm for computing network flow in bipartite graphs. 2.For.
1 Radiative Transfer Models and their Adjoints Paul van Delst.
Chapter 15: Recursion. Objectives In this chapter, you will: – Learn about recursive definitions – Explore the base case and the general case of a recursive.
Derivation of the 2D Rotation Matrix Changing View from Global to Local X Y X’ Y’  P Y Sin  X Cos  X’ = X Cos  + Y Sin  Y Cos  X Sin  Y’ = Y Cos.
CHAPTER 9.10~9.17 Vector Calculus.
Inter-procedural analysis
Modelling Complex Systems Video 4: A simple example in a complex way.
High-level optimization Jakub Yaghob
Generating Automated Tests from Behavior Models
Iterative Dataflow Problems
Structural testing, Path Testing
Machine-Independent Optimization
Program Slicing Baishakhi Ray University of Virginia
Data Flow Analysis Compiler Design
Static Single Assignment
Errors and Error Analysis Lecture 2
Presentation transcript:

Jaewook Shin, Priyadarshini Malusare and Paul D. Hovland Mathematics and Computer Science Division Argonne National Laboratory Design and Implementation of a Context-Sensitive, Flow-Sensitive Activity Analysis Algorithm for Automatic Differentiation The 5th International Conference on Automatic Differentiation, Bonn, Germany, August 15, 2008

2 Outline 1.Activity Analysis 2.Previous work: CSFI 3.New CSFS Algorithm 4.Experimental Results 5.Conclusion

3 Activity Analysis AD is applied to a function with a set of input variables and a set of output variables. Sometimes, we are interested in the derivatives –of a subset of the output variables  dependent –with respect to a subset of the input variables  independent An intermediate variable is –varied if it is transitively dependent on any independent variable –useful if any dependent variable is transitively dependent on it –active if it is both varied and useful. Partial derivatives need to be computed only for active variables. Activity analysis is nonseparable.

4 Activity Analysis: Given f, compute dy1/dx1 f(x1, x2, x3, y1, y2, y3){ t1 = sin(x1) y1 = t1*2 t2 = cos(x2) y2 = t2*3 y3 = x3*t1 } f(x1, x2, x3, y1, y2, y3){ t1 = sin(x1) dt1/dx1 = cos(x1) y1 = t1*2 dy1/dt1 = 2 t2 = cos(x2) y2 = t2*3 y3 = x3*t1 dy1/dx1 = (dy1/dt1)*(dt1/dx1) }

5 Activity Analysis: Given f, compute dy1/dx1 f(x1, x2, x3, y1, y2, y3){ t1 = sin(x1) y1 = t1*2 t2 = cos(x2) y2 = t2*3 y3 = x3*t1 } f(x1, x2, x3, y1, y2, y3){ t1 = sin(x1) dt1/dx1 = cos(x1) y1 = t1*2 dy1/dt1 = 2 t2 = cos(x2) dt2/dx2 = -sin(x2) y2 = t2*3 dy2/dt2 = 3 y3 = x3*t1 dy3/dx3 = t1 dy3/dt1 = x3 dy1/dx1 = (dy1/dt1)*(dt1/dx1) dy2/dx2 = (dt2/dx2)*(dy2/dt2) dy3/dx1 = (dt1/dx1)*(dy3/dt1) }

6 Activity Analysis: varied + useful = active f(x1, x2, x3, y1, y2, y3){ t1 = sin(x1); y1 = t1*2; t2 = cos(x2); y2 = t2*3; y3 = x3*t1; } f(x1, x2, x3, y1, y2, y3){ t1 = sin(x1); y1 = t1*2; t2 = cos(x2); y2 = t2*3; y3 = x3*t1; } f(x1, x2, x3, y1, y2, y3){ t1 = sin(x1); y1 = t1*2; t2 = cos(x2); y2 = t2*3; y3 = x3*t1; } f(x1, x2, x3, y1, y2, y3){ t1 = sin(x1); y1 = t1*2; t2 = cos(x2); y2 = t2*3; y3 = x3*t1; } varied useful varied useful active

7 Previous work: Context-Sensitive, Flow-Insensitive Activity Analysis (VDGAA) Graph reachability problem Variable Dependence Graph (VDG) Two separate (color) propagations: –Forward (coloring red) for “varied” variables –Backward (coloring yellow) for “useful” variables Context sensitivity is supported by a stack of contexts. Run time –Very fast in practice Small overestimations of active variables due to –the way programs are usually written –the property of activity analysis

8 VDGAA on the run: 1. build VDGAA f(x1, x2, x3, y1, y2, y3){ t1 = sin(x1); y1 = t1*2; t2 = cos(x2); y2 = t2*3; y3 = x3*t1; } x1 x2 x3 t2 y1 y2 y3 t1 Variable Dependence Graph (VDG)

9 VDGAA on the run: 2. Find ‘varied’ variables f(x1, x2, x3, y1, y2, y3){ t1 = sin(x1); y1 = t1*2; t2 = cos(x2); y2 = t2*3; y3 = x3*t1; } x1 x2 x3 t2 y1 y2 y3 t1 Forward propagation

10 VDGAA on the run: 3. Find ‘useful’ variables f(x1, x2, x3, y1, y2, y3){ t1 = sin(x1); y1 = t1*2; t2 = cos(x2); y2 = t2*3; y3 = x3*t1; } x1 x2 x3 t2 y1 y2 y3 t1 Backward propagation

11 VDGAA on the run: Context Sensitivity foo(a, b){ b = a; } xp1 p2y ba Forward propagation call foo(x, p1); call foo(p2, y);

12 VDGAA on the run: Context Sensitivity foo(a, b){ b = a; } xp1 p2y ba Backward propagation call foo(x, p1); call foo(p2, y);

13 f(x1, x2, x3, y1, y2, y3){ t1 = sin(x1); y1 = t1*2; y3 = x3*t1; t1 = cos(x2); y2 = t1*3; } VDGAA : Flow Insensitivity x1 x2 x3 y1 y2 y3 t1 Forward propagation

14 VDGAA : Flow Insensitivity f(x1, x2, x3, y1, y2, y3){ t1 = sin(x1); y1 = t1*2; y3 = x3*t1; t1 = cos(x2); y2 = t1*3; } x1 x2 x3 y1 y2 y3 t1 Backward propagation

15 Context-Sensitive, Flow-Sensitive Activity Analysis (DUGAA) Graph reachability problem Two separate (color) propagations: –Forward for “varied” variables –Backward for “useful” variables Context sensitivity is supported by a stack of contexts. Definition-Use Graph (DUG) Flow sensitivity is supported by the use of reaching definitions for nodes. Algorithm: UD-DU Chains Build a def-use graph Forward propagation Backward propagation

16 DUGAA on the run: 1. build a DUG 1:f(x1, x2, x3, y1, y2, y3){ 2: t1 = sin(x1); 3: y1 = t1*2; 4: y3 = x3*t1; 5: t1 = cos(x2); 6: y2 = t1*3; 7:} Def-Use Graph (DUG)

17 DUGAA on the run: 2. Forward propagation 1:f(x1, x2, x3, y1, y2, y3){ 2: t1 = sin(x1); 3: y1 = t1*2; 4: y3 = x3*t1; 5: t1 = cos(x2); 6: y2 = t1*3; 7:} Forward propagation

18 DUGAA on the run: 3. Backward propagation 1:f(x1, x2, x3, y1, y2, y3){ 2: t1 = sin(x1); 3: y1 = t1*2; 4: y3 = x3*t1; 5: t1 = cos(x2); 6: y2 = t1*3; 7:} Backward propagation

19 Implementation OpenAnalysis VDGAA DUGAA OpenAD: AD Transformation Open64 Unparser Open64 Front end Input (Fortran) Output (Fortran)

20 Benchmarks DescriptionSource#lines MITgcmMIT General Circulation ModelMIT27376 LULower-upper symmetric Gauss-SeidelNASPB5951 CGConjugate gradientNASPB2480 newtonNewton’s method + Rosenbrock functionANL2189 adiabaticAdiabatic flow model in chemical engineeringCMU1009 msaMinimal surface area problemMINPACK-2461 swirlSwirling flow problemMINPACK-2355 c2Ordinary differential equation solverANL64

21 Slowdowns in analysis run time: DUGAA vs. VDGAA

22 Analysis run time

23 Analysis run-time breakdown on MITgcm

24 Reduction in active variables

25 Conclusion A new context-sensitive, flow-sensitive (CSFS) activity analysis algorithm: Def- Use Graph Activity Analysis (DUGAA) Comparison of two activity analyses: DUGAA (CSFS) vs. VDGAA (CSFI) Slower than VDGAA for all 8 benchmarks –by a factor > 27 –but takes less than one minute for a code larger than 27k lines Makes fewer overestimations than VDGAA for two of the eight benchmarks. May save human effort in managing AD code. Future work –Comparison among CIFS, CSFI, and CSFS activity analyses –Dealing with pointers and recursion

26 PARAM Edges Edges between formal parameters Summarize the connectivity among formal parameters Transitive closure is applied to the dependence matrix of local variables Checking for connectivity through global variables: A PARAM edge is generated from formal variable node F1 to formal variable node F2 by traversing the entire graph only when –F1 has a value flow path to a global variable node AND –F2 has a value flow path from a global variable node.

27 Context-Insensitive, Flow-Sensitive Activity Analysis (ICFGAA) Interprocedural Control Flow Graph (ICFG) Iterative data-flow analysis (DFA) Two separate DFAs: –Forward for “varied” variables –Backward for “useful” variables Long run time –Large number of iterations –Nonseparability of activity analysis: data-flow analysis values depend on other data-flow values Large overestimation –Due to context-insensitivity –Value propagation through unrealizable control paths