Solving the Live-out Iterator Problem, Part I

Similar documents
Polyhedral Compilation Foundations

Polyhedral Compilation Foundations

Polyhedral-Based Data Reuse Optimization for Configurable Computing

CS671 Parallel Programming in the Many-Core Era

Computing the Integer Points of a Polyhedron

The Polyhedral Model Is More Widely Applicable Than You Think

CSE 417 Network Flows (pt 4) Min Cost Flows

Investigating Mixed-Integer Hulls using a MIP-Solver

1 i n (p i + r n i ) (Note that by allowing i to be n, we handle the case where the rod is not cut at all.)

Ranking Functions. Linear-Constraint Loops

AXIOMS OF AN IMPERATIVE LANGUAGE PARTIAL CORRECTNESS WEAK AND STRONG CONDITIONS. THE AXIOM FOR nop

Legal and impossible dependences

Compact Sets. James K. Peterson. September 15, Department of Biological Sciences and Department of Mathematical Sciences Clemson University

Review: Hoare Logic Rules

CS173 Longest Increasing Substrings. Tandy Warnow

CS 229 Midterm Review

DM545 Linear and Integer Programming. Lecture 2. The Simplex Method. Marco Chiarandini

On Clarkson s Las Vegas Algorithms for Linear and Integer Programming When the Dimension is Small

Lecture notes on the simplex method September We will present an algorithm to solve linear programs of the form. maximize.

Lesson 18: There is Only One Line Passing Through a Given Point with a Given

Cantor s Diagonal Argument for Different Levels of Infinity

PolyOpt/C. A Polyhedral Optimizer for the ROSE compiler Edition 0.2, for PolyOpt/C March 12th Louis-Noël Pouchet

Face Width and Graph Embeddings of face-width 2 and 3

Static and Dynamic Frequency Scaling on Multicore CPUs

The Polyhedral Model (Dependences and Transformations)

Outline. Computer Science 331. Three Classical Algorithms. The Sorting Problem. Classical Sorting Algorithms. Mike Jacobson. Description Analysis

2D rendering takes a photo of the 2D scene with a virtual camera that selects an axis aligned rectangle from the scene. The photograph is placed into

Loop Transformations, Dependences, and Parallelization

Goal of the course: The goal is to learn to design and analyze an algorithm. More specifically, you will learn:

The Ascendance of the Dual Simplex Method: A Geometric View

Programming Languages 3. Definition and Proof by Induction

Lecture 2 September 3

Counting Affine Calculator and Applications

Lecture 1 Contracts. 1 A Mysterious Program : Principles of Imperative Computation (Spring 2018) Frank Pfenning

Neural Network Assisted Tile Size Selection

Figure 2.1: An example of a convex set and a nonconvex one.

The Challenges of Non-linear Parameters and Variables in Automatic Loop Parallelisation

CS675: Convex and Combinatorial Optimization Spring 2018 The Simplex Algorithm. Instructor: Shaddin Dughmi

The Simplex Algorithm

Merge Sort. Yufei Tao. Department of Computer Science and Engineering Chinese University of Hong Kong

/633 Introduction to Algorithms Lecturer: Michael Dinitz Topic: Priority Queues / Heaps Date: 9/27/17

Basic Algorithms for Periodic-Linear Inequalities and Integer Polyhedra

To begin this textbook, we need to start with a refresher of the topics of numbers and numbering systems.

Week 7 Convex Hulls in 3D

Lecture 1 Contracts : Principles of Imperative Computation (Fall 2018) Frank Pfenning

Analyze the obvious algorithm, 5 points Here is the most obvious algorithm for this problem: (LastLargerElement[A[1..n]:

Introduction to ANSYS DesignXplorer

Convex Optimization CMU-10725

PRAM Divide and Conquer Algorithms

Lecture 10 Notes Linked Lists

Outline. What is semantics? Denotational semantics. Semantics of naming. What is semantics? 2 / 21

Discrete Optimization 2010 Lecture 5 Min-Cost Flows & Total Unimodularity

Lecture Notes on Spanning Trees

Submodularity Reading Group. Matroid Polytopes, Polymatroid. M. Pawan Kumar

Last time. Reasoning about programs. Coming up. Project Final Presentations. This Thursday, Nov 30: 4 th in-class exercise

Reasoning about programs

SEQUENCES, MATHEMATICAL INDUCTION, AND RECURSION

Curve and Surface Basics

CSCI-1200 Data Structures Spring 2018 Lecture 14 Associative Containers (Maps), Part 1 (and Problem Solving Too)

Fundamental Graph Algorithms Part Three

Lecture 10 Notes Linked Lists

CS 381: Programming Language Fundamentals

Advanced Operations Research Techniques IE316. Quiz 1 Review. Dr. Ted Ralphs

Solving lexicographic multiobjective MIPs with Branch-Cut-Price

How invariants help writing loops Author: Sander Kooijmans Document version: 1.0

CSE 373: Data Structures and Algorithms

Hierarchical Composition and Abstraction In Architecture Models

Ellipsoid Algorithm :Algorithms in the Real World. Ellipsoid Algorithm. Reduction from general case

CSE 373: Data Structures and Algorithms

Iterative Optimization in the Polyhedral Model: Part I, One-Dimensional Time

Lecture 25 Notes Spanning Trees

Induction and Recursion

Design and Analysis of Algorithms Prof. Madhavan Mukund Chennai Mathematical Institute. Week 02 Module 06 Lecture - 14 Merge Sort: Analysis

Softwaretechnik. Program verification. Albert-Ludwigs-Universität Freiburg. June 28, Softwaretechnik June 28, / 24

Integer Programming ISE 418. Lecture 1. Dr. Ted Ralphs

Outline. Introduction. 2 Proof of Correctness. 3 Final Notes. Precondition P 1 : Inputs include

MAT 243 Test 2 SOLUTIONS, FORM A

Lecture Notes on Quicksort

Previously Local sensitivity analysis: having found an optimal basis to a problem in standard form,

CS521 \ Notes for the Final Exam

Recall our recursive multiply algorithm:

Lecture 7 Quicksort : Principles of Imperative Computation (Spring 2018) Frank Pfenning

BACK TO MATH LET S START EASY.

60 2 Convex sets. {x a T x b} {x ã T x b}

Lecture 3. Corner Polyhedron, Intersection Cuts, Maximal Lattice-Free Convex Sets. Tepper School of Business Carnegie Mellon University, Pittsburgh

CMSC 754 Computational Geometry 1

Tiling: A Data Locality Optimizing Algorithm

Computing and Informatics, Vol. 36, 2017, , doi: /cai

11.1 Facility Location

1. Lecture notes on bipartite matching

Linear Programming Motivation

Lecture Notes on Quicksort

ONLY AVAILABLE IN ELECTRONIC FORM

Control flow graphs and loop optimizations. Thursday, October 24, 13

CSE 331 Introduction to Algorithm Analysis and Design. Sample Mid-term Exam-I: Fall 2018

Lecture 4: Linear Programming

Lecture 4: Rational IPs, Polyhedron, Decomposition Theorem

Math Models of OR: The Simplex Algorithm: Practical Considerations

Java Software Solutions for AP Computer Science 3rd Edition, Lewis et al. 2011

ISE203 Optimization 1 Linear Models. Dr. Arslan Örnek Chapter 4 Solving LP problems: The Simplex Method SIMPLEX

Transcription:

Louis-Noël Pouchet pouchet@cse.ohio-state.edu Dept. of Computer Science and Engineering, the Ohio State University September 2010 888.11

Outline: Reminder: step-by-step methodology 1 Problem definition: Understand and define the problem 2 Examples: Find various example, and compute the desired output by hand 3 Restriction: Find an algorithm, maybe restricted to simpler cases 4 Generalization: Generalize the algorithm to work on all cases 5 Proof: Prove the algorithm is complete and correct 6 Complexity: Study the complexity of the algorithm OSU 2

Outline: Outline for today Find a useful restriction of the problem Typically, add extra properties on the input And/or remove some properties on the output Build and solve the problem for it Maximal reuse of existing solutions Keep in mind the general problem OSU 3

Live-out Iterators: problems: Summary of the problems List the problems to solve Multiple statements Which loop executes last? Min/max expressions The value depends on the expressions Need to substitute surrounding iterators with the last value for which the loop test is true, not necessarily the exit value of the loop iterator Conditionals a loop may not execute, how to determine its last execution? Parametric loop bounds The loop may not execute at all! What is the value to use in the substitution? The exit value? Loop iterator symbols being assigned after the loop execution How to compute the exit value in this case? OSU 4

Live-out Iterators: problems: Another view: Solution-driven Order the problems starting with the simplest solution 1 Start from the set of programs with: no conditional, no min/max, no parameter, no iterator symbol assigned in the loop body, a single statement 2 Adding multiple statement support 3 Adding parameters 4 Adding conditionals 5 Adding min/max 6 Adding iterator symbol assigned in the loop body OSU 5

Finding a good restriction: A useful restriction of the problem What if a loop always iterates at least once? Property: lb Ub The exit value is the last value for which the test is true + 1 Impact on conditionals, min/max, iterator assigned in body? What if a conditional is always true? Property: the conditional is an affine form of the parameters only Under these assumptions, what about min/max expressions? OSU 6

Finding a good restriction: Overview of the approach 1 Find a good, general algorithm for our restricted case 2 Modify it to generalize to: arbitrary conditionals arbitrary loop bounds 3 Modify the input specification to cover only programs where iterator symbols are never assigned outside the loop OSU 7

Designing the algorithm: Reminder: algorithm writing 101 1 Determine the input and output 2 Find a correct data structure to represent the problem Don t hesitate to convert the input to a suitable form, and to preprocess it 3 Try to reduce your problem to a variation of a well-known one Sorting? Path discovery/reachability? etc. Look in the litterature if a solution to this problem exists 4 Decide wheter you look for a recursive algorithm or an imperative one, or a mix Depends on how you think, how easy it is to exhibit invariants, what is the decomposition in sub-problems,... 5 Write the algorithm :-) 6 Run all your examples on it, manually, before trying to prove it OSU 8

Designing the algorithm: Determine the input and output Input: an AST A of a program such that: A represents a Static Control Part For each loop in A, the lower bound is always smaller than the upper bound Conditionals are always true There is no loop iterator symbol assigned outside its defining loop Output: an AST B containing A which is appended another AST that assigns to each loop iterator in A the value it takes when A is executed OSU 9

Designing the algorithm: Find a good representation for the problem Example for (i = 0; i <= N; ++i) for (j = 0; j <= min(m, 4 * i - 4); ++j) if (3 * j >= - 2 * i + 8) S(i, j); OSU 10

Designing the algorithm: Polyhedral representation Model iteration domains using inequalities inequalities for lower bounds, upper bounds, conditionals min/max simply produces multiple inequalities Warning: only executed instances are part of the iteration domain Using this representation, what is the geometric intuition of the exit value of iterators? It is simply the lexicographic maximum of the iteration domain + 1! Can we reuse existing algorithms to compute the lexicographic maximum of the iteration domain? OSU 11

Designing the algorithm: Reducing to a variation of a well-known problem PIP: Parametric Integer Programming [Fea88] In a nutshell: PIP input: A system of inequalities defining a parametric polyhedron i 0 i N j 0 Example: j M j 4 i 4 3 j 2 i + 8 PIP output: the lexicographic minimum of the system Example: if (7*n >= 10) { if (7*m >= 12) (i = 2, j = 2) if (2*n+3*m >= 8) (i = -m-(m div 2)+4, j = m) } OSU 12

Designing the algorithm: Problems to solve PIP outputs the lexicographic minimum, we want the maximum Simple: max(x) = min( x) Need to insert variables x = x, y = y, etc. as the first variables of the system, and compute the lexmin of the new system PIP does not produce an AST explicitly, it uses its internal representation Need to convert PIPLib internal representation into an AST Need to dig into PIPLib documentation, should not be difficult OSU 13

Designing the algorithm: On the road to write the algorithm In a nutshell: 1 Convert the AST into its polyhedral representation 2 For a given statement, create the PIP problem for the lexmax 3 Convert the solution to the system into an AST OSU 14

Designing the algorithm: Data structures [1/2] Polyhedral representation: It is a array of elements of type Statement A Statement is a structure containing: Matrix : domain, for the iteration domain, using the same representation as PIP input Matrix : schedule, for the schedule integer : nbiter, for the number of loops surrounding the statement (and more, but not useful here) Available functions: Statement[] : extractpolyhedralrepresentation(ast : A) Statement[] : orderinexecutionorder(statement[] : statementarray) OSU 15

Designing the algorithm: Data structures [2/2] PIP / PIPLib: PIPLib uses as an input a Matrix Calling PIPLib outputs a QUAST (quasi-affine solution tree) It is a tree where the leaves are all possible values for the lexicographic minimum of the input system, the other nodes are conditions on parameters Available functions: QUAST : computelexicographicminimum(matrix : system) AST : convertquasttoast(quast : solution) OSU 16

Exercise: Exercise Input: an AST A of a program such that: A represents a Static Control Part For each loop in A, the lower bound is always smaller than the upper bound Conditionals are always true There is no loop iterator symbol assigned outside its defining loop Output: an AST B containing A which is appended another AST that assigns to each loop iterator in A the value it takes when A is executed Exercise: write an algorithm which implements the above description OSU 17

Exercise: Algorithm to create a Lexmax system Algorithm Algorithm extendsystemforlexmax Input: Matrix: A, in PIPLib format integer: nbvars Output: Matrix: in PIPLib format, with extra columns and equalities such that lexmin(b) = lexmax(a) for the nbvars first variables B duplicatematrix(a) for i 1 to nbvars do B insertcolumnatposition(b, 1) end for for i 1 to nbvars do B insertrowatposition(b, B.NbRows) B[B.NbRows - 1][i] -1 B[B.NbRows - 1][i + nbvars] 1 end for return B OSU 18