Register Allocation. Maryam Siahbani CMPT 379 4/5/2016 1
|
|
- Clarence Wells
- 5 years ago
- Views:
Transcription
1 Register Allocation Maryam Siahbani CMPT 379 4/5/2016 1
2 Register Allocation Intermediate code uses unlimited temporaries Simplifying code generation and optimization Complicates final translation to assembly Intermediate code uses too many temporaries 4/5/2016 2
3 Register Allocation The problem: Rewrite the intermediate code to use no more temporaries than there are machine registers Method: Assign multiple temporaries to each register But without changing the program behavior 4/5/2016 3
4 Example Consider the program a = c + d e = a + b f = e - 1 Assume a & e dead after use A dead temporary can be reused Can allocate a, e and f all to one register (r1) r1 = r 2 + r 3 r 1 = r 1 + r 4 r 1 = r 1-1 4/5/2016 4
5 History Register allocation is as old as compilers Register allocation was used in the original FORTRAN compiler in 1950 s Very crude algorithm A breakthrough came in 1980 Register allocation scheme based on graph coloring Relatively simple, global and works well in practice 4/5/2016 5
6 Principles of Register Allocation Temporaries t 1 can t 2 can share the same register if at any point in the program at most one of t 1 or t 2 is live If t 1 and t 2 are live at the same time, they cannot share a register We need liveness analysis 4/5/2016 6
7 Live Variables Compute live variables for each point {a,c,f} {c,d,f} {c,e} f = 2*e {f,c} {b} a = b+c d = -a e = d+f {f,c} b = f+c {c,d,e,f} b = d+e e = e-1 {b} {b,c,f} {b,c,e,f} {b,c,f} 4/5/2016 7
8 Register Interference Graph Construct an undirected graph A node for each temporary An edge between t 1 and t 2 if they are live simultaneously at some point in the program This is the register interference graph (RIG) Two temporaries can be allocated to the same register if there is no edge connecting them 4/5/2016 8
9 Register Interference Graph For our example f a b e c a and c cannot be in the same register a and d could be in the same register 4/5/ d
10 Register Interference Graph Extracts exactly the information we need to characterize legal register allocation Gives the global view (i.e., over the entire control flow graph) picture of the register requirements After RIG construction the register allocation algorithm is architecture independent 4/5/
11 Graph Coloring A coloring of a graph is an assignment of colors to nodes, such that nodes connected by an edge have different a colors A graph is k-colorable if it has a coloring with k colors f c 4/5/
12 Register Allocation as Graph Coloring In our problem, colors = registers We need to assign colors (registers) to graph nodes (temporaries) Let k = number of machine registers If the RIG is k-colorable then there is a register assignment that uses no more than k registers 4/5/
13 Example For our example r 2 a r 1 f b r 3 r 2 e c r 4 d r 3 There is no coloring with less than 4 colors There is a 4-coloring of this graph 4/5/
14 Control Flow Graph a = b+c d = -a e = d+f f = 2*e b = d+e e = e-1 b = f+c 4/5/
15 Register Allocation r 2 = r 3 +r 4 r 3 = -r 2 r 2 = r 3 + r 1 r 1 = 2* r 2 r 3 = r 3 + r 2 r 2 = r 2-1 r 3 = r 1 + r 4 4/5/
16 Graph Coloring How do we compute graph coloring? It is not easy : The problem is NP-hard. No efficient algorithms are known Solution: use heuristics A coloring might not exist for a given number of registers Solution: register spilling 4/5/
17 Register Allocation as Graph Coloring Main idea for solving whether a graph G is k- colorable: Pick any node t with fewer than k neighbor's Remove n and adjacent edges to create a new graph G If G is k-colorable, then so is G (the original graph) Let c 1,,c n be the colors assigned to the neighbors of t in G Since n<k we can pick some color for t that is different from its neighbors 4/5/
18 Register Allocation as Graph Coloring Heuristic for graph coloring: Ordering nodes (in an stack) 1. Pick a node t with fewer than k neighbors 2. Put t on a stack and remove it from the graph (RIG) 3. Repeat until the graph is empty Assigning color to nodes on the stack: 1. Start with the last node added 2. At each step pick a color different from those assigned to already colored neighbors 4/5/
19 Example Assume k=4 a Remove a f b stack={} e c d 4/5/
20 Example Assume k=4 Remove d f b stack={a} e c d 4/5/
21 Example Assume k=4 Note: All nodes now have fewer than 4 neighbors The graph coloring is guaranteed to succeed f e b c Remove c stack={d,a} 4/5/
22 Example Assume k=4 Remove b stack={c,d,a} f e b 4/5/
23 Example Assume k=4 Remove e stack={b,c,d,a} f e 4/5/
24 Example Assume k=4 Remove f f stack={e,b,c,d,a} 4/5/
25 Example Assume k=4 Empty graph done with the first part Now we have the order for assigning colors to nodes, start coloring the nodes (from the top of the stack) stack={f,e,b,c,d,a} 4/5/
26 Example Assume k=4 stack={e,b,c,d,a} r 1 f 4/5/
27 Example Assume k=4 e must be in a different register from f r 1 f stack={b,c,d,a} r 2 e 4/5/
28 Example Assume k=4 stack={c,d,a} r 1 f b r 3 r 2 e 4/5/
29 Example Assume k=4 No worries! The ordering insures we can find a color for all nodes r 1 f b r 3 stack={d,a} r 2 e c r 4 4/5/
30 Example Assume k=4 d can be in the same register as b r 1 f b r 3 stack={a} r 2 e c r 4 d r 3 4/5/
31 Example Assume k=4 stack={} a r 2 r 1 f b r 3 r 2 e c r 4 d r 3 4/5/
32 Register Allocation as Graph Coloring What happens if the graph coloring heuristic fails to find a coloring? In this case we cannot hold all values in the registers Some values should be spilled to memory 4/5/
33 K-coloring fails What if all nodes have k or more neighbors? Try to find a 3 coloring of this graph Remove a f a b e c 4/5/ d
34 Example of 3-coloring Gut stuck here! There is no node that if we remove it is guaranteed to find 3-coloring for the graph f e b c d 4/5/
35 Optimistic Coloring If every node in G has more than k neighbors, k-coloring of G might not be possible Pick a node as candidate for spilling, remove it from the graph and continue k-coloring 4/5/
36 Optimistic Coloring Remove f and continue: The ordering: {c,e,d,b,f,a} b e c 4/5/ d
37 Optimistic Coloring Color the nodes {c,e,d,b,f,a} Try to assign a color to f We hope that among 4 neighbors of f we use less than 3 colors (optimistic coloring) f b r 3 r 2 e c r 1 d r 3 4/5/
38 Spilling If optimistic coloring fails, we spill f Allocate a memory location for f Typically in the current stack frame Call this address fa Before each operation that reads f, insert f = load fa After each operation that writes f, insert store f, fa Spilling is slow but sometimes necessary. 4/5/
39 Original Code a = b+c d = -a e = d+f f = 2*e b = d+e e = e-1 b = f+c 4/5/
40 Code after Spilling f a = b+c d = -a f1 = load fa e = d+f1 f2 = 2*e store f2, fa b = d+e e = e-1 f3 = load fa b = f3+c 4/5/
41 Recompute the Liveness {a, c, f} {c, d, f} {c, e} f2 = 2*e store f2, fa {f, c} {b} a = b+c d = -a f1 = load fa e = d+f1 {f, c} f3 = load fa b = f3+c b = d+e e = e-1 {c, d, e, f} {b} {b, c, f} {b, c, f} {b, c, e, f} 4/5/
42 Recompute the Liveness {c, f2} {a, c, f} {c, d, f} {c, d, f1} {c, e} f2 = 2*e store f2, fa {f, c} {c, f3} {b} a = b+c d = -a f1 = load fa e = d+f1 {f, c} f3 = load fa b = f3+c b = d+e e = e-1 {c, d, e, f} {b} {b, c, f} {b, c, f} {b, c, e, f} 4/5/
43 Rebuild the Interference Graph New liveness information is almost as before Note f has been split into three temporaries fi is live only Between a fi = load fa and the next instruction Between a store fi, fa and the preceding instr. Spilling reduces the live range of f And thus reduces its interferences Which results in fewer RIG neighbors 4/5/
44 Rebuild the Interference Graph Some edges of the spilled nodes are removed In our case f still interferes only with c and d And the new RIG is 3-colorable a f1 b f3 e c f2 d 4/5/
45 Spilling Additional spilling might be required before a coloring is found 4/5/
46 Example K=3 remove a a Stack: {} f e b c d 4/5/
47 Example K=3 remove c Stack: {a} f e b c d 4/5/
48 Example K=3 remove b Stack: {c,a} f e b d 4/5/
49 Example K=3 remove e Stack: {b,c,a} f e d 4/5/
50 Example K=3 remove f Stack: {e,b,c,a} f d 4/5/
51 Example K=3 remove d Stack: {f,e,b,c,a} d 4/5/
52 Example K=3 Stack: {d,f,e,b,c,a} 4/5/
53 Example K=3 Stack: {f,e,b,c,a} d r1 4/5/
54 Example K=3 Stack: {e,b,c,a} r2 f d r1 4/5/
55 Example K=3 Stack: {b,c,a} r2 f r3 e d r1 4/5/
56 Example K=3 Stack: {c,a} r2 f r3 e b r3 d r1 4/5/
57 Example K=3 Stack: {a} r2 f r3 e b r3 c Spilled! d r1 4/5/
58 Example K=3 Stack: {} r2 f r3 e a Spilled! b r3 c Spilled! d r1 4/5/
59 Example K=3 Stack: {d,f,e,b,c,a} 4/5/
60 Example K=3 Stack: {f,e,b,c,a} d r1 4/5/
61 Example K=3 Stack: {e,b,c,a} r1 f d r1 4/5/
62 Example K=3 Stack: {b,c,a} r1 f r2 e d r1 4/5/
63 Example K=3 Stack: {c,a} r1 f r2 e b r2 d r1 4/5/
64 Example K=3 Stack: {a} r1 f r2 e b r2 c r3 d r1 4/5/
65 Example K=3 a r3 Stack: {} r1 f r2 e b r2 c r3 d r1 4/5/
66 Spilling Many different heuristics for picking a node to spill Spill temporaries with most conflicts Spill temporaries with few definitions and uses Avoid spilling in inner loops (heavily visited regions of the code) C allows a register keyword to direct the compiler whether a variable contains a value that is heavily used. 4/5/
67 Live Ranges and Live Intervals The live range for a variable is the set of program points at which that variable is live. The live interval for a variable is the smallest subrange of the IR code containing all a variable's live ranges. A property of the IR code, not CFG. Less precise than live ranges, but simpler to work with 4/5/
68 Live Intervals {a,b,c,d} e = d + a f = b + c f = f + b if e==0 goto _L0 d = e + f goto _L1 {b,c,e} {b,c,e} {b,e,f} {b,e,f} {e,f} _L0: d = e - f _L1: g = d {e,f} {d} {e,f} {d} 4/5/ {d} {g}
69 Live Intervals e = d + a f = b + c f = f + b if e==0 goto _L0 d = e + f goto _L1 a {a,b,c,d} {b,c,e} {b,c,e} {b,e,f} {b,e,f} {e,f} _L0: d = e - f _L1: g = d {e,f} {d} {e,f} {d} 4/5/ {d} {g}
70 Live Intervals e = d + a f = b + c f = f + b if e==0 goto _L0 d = e + f goto _L1 a b {a,b,c,d} {b,c,e} {b,c,e} {b,e,f} {b,e,f} {e,f} _L0: d = e - f _L1: g = d {e,f} {d} {e,f} {d} 4/5/ {d} {g}
71 Live Intervals e = d + a f = b + c f = f + b if e==0 goto _L0 d = e + f goto _L1 a b c {a,b,c,d} {b,c,e} {b,c,e} {b,e,f} {b,e,f} {e,f} _L0: d = e - f _L1: g = d {e,f} {d} {e,f} {d} 4/5/ {d} {g}
72 Live Intervals e = d + a f = b + c f = f + b if e==0 goto _L0 d = e + f goto _L1 a b c d {a,b,c,d} {b,c,e} {b,c,e} {b,e,f} {b,e,f} {e,f} _L0: d = e - f _L1: g = d {e,f} {d} {e,f} {d} 4/5/ {d} {g}
73 Live Intervals e = d + a f = b + c f = f + b if e==0 goto _L0 d = e + f goto _L1 a b c d {a,b,c,d} {b,c,e} {b,c,e} {b,e,f} {b,e,f} {e,f} _L0: d = e - f _L1: g = d {e,f} {d} {e,f} {d} 4/5/ {d} {g}
74 Live Intervals e = d + a f = b + c f = f + b if e==0 goto _L0 d = e + f goto _L1 a b c d e {a,b,c,d} {b,c,e} {b,c,e} {b,e,f} {b,e,f} {e,f} _L0: d = e - f _L1: g = d {e,f} {d} {e,f} {d} 4/5/ {d} {g}
75 Live Intervals e = d + a f = b + c f = f + b if e==0 goto _L0 d = e + f goto _L1 a b c d e f {a,b,c,d} {b,c,e} {b,c,e} {b,e,f} {b,e,f} {e,f} _L0: d = e - f _L1: g = d {e,f} {d} {e,f} {d} 4/5/ {d} {g}
76 Live Intervals e = d + a f = b + c f = f + b if e==0 goto _L0 d = e + f goto _L1 a b c d e f g {a,b,c,d} {b,c,e} {b,c,e} {b,e,f} {b,e,f} {e,f} _L0: d = e - f _L1: g = d {e,f} {d} {e,f} {d} 4/5/ {d} {g}
77 Register Allocation with Live Intervals Given the live intervals for all the variables in the program, we can allocate registers using a simple greedy algorithm. Idea: Track which registers are free at each point. When a live interval begins, give that variable a free register. When a live interval ends, the register is once again free. a b c d e f g 4/5/
78 Register Allocation with Live a b c d e f g Intervals r1 r2 r3 r4 4/5/
79 Register Allocation with Live a b c d e f g Intervals r1 r2 r3 r4 4/5/
80 Register Allocation with Live a b c d e f g Intervals r1 r2 r3 r4 4/5/
81 Register Allocation with Live a b c d e f g Intervals r1 r2 r3 r4 4/5/
82 Register Allocation with Live a b c d e f g Intervals r1 r2 r3 r4 4/5/
83 Register Allocation with Live a b c d e f g Intervals r1 r2 r3 r4 4/5/
84 Register Allocation with Live a b c d e f g Intervals r1 r2 r3 r4 4/5/
85 Register Allocation with Live a b c d e f g Intervals r1 r2 r3 r4 4/5/
86 Register Allocation with Live a b c d e f g Intervals r1 r2 r3 r4 4/5/
87 Register Allocation with Live a b c d e f g Intervals r1 r2 r3 r4 4/5/
88 Register Allocation with Live a b c d e f g Intervals r1 r2 r3 r4 4/5/
89 Register Allocation with Live a b c d e f g Intervals r1 r2 r3 r4 4/5/
90 Linear Scan Register Allocation If a register cannot be found for a variable v, we may need to spill a variable. This algorithm is called linear scan register allocation and is a comparatively new algorithm. Pros: Very efficient Works well in many cases Allocation needs one pass, the code can be generated simultaneously Used in JIT compilers like Java HotSpot Cons: Not as good as graph coloring approach 4/5/
91 Summary Register allocation is a must have in compilers, because: Intermediate code uses too many temporaries It makes a big difference in performance The liveness at each location can be used for register allocation Register allocation as heuristic graph coloring uses live ranges The basis for the technique used in GCC Linear scan register allocation uses live intervals Often used in JIT compilers due to efficiency 4/5/
Register Alloca.on. CMPT 379: Compilers Instructor: Anoop Sarkar. anoopsarkar.github.io/compilers-class
Register Alloca.on CMPT 379: Compilers Instructor: Anoop Sarkar anoopsarkar.github.io/compilers-class 1 Register Alloca.on Intermediate code uses unlimited temporaries Simplifying code genera.on and op.miza.on
More informationCompiling Techniques
Lecture 11: Introduction to 13 November 2015 Table of contents 1 Introduction Overview The Backend The Big Picture 2 Code Shape Overview Introduction Overview The Backend The Big Picture Source code FrontEnd
More informationAdvanced topic: Space complexity
Advanced topic: Space complexity CSCI 3130 Formal Languages and Automata Theory Siu On CHAN Chinese University of Hong Kong Fall 2016 1/28 Review: time complexity We have looked at how long it takes to
More informationLecture 10: Data Flow Analysis II
CS 515 Programming Language and Compilers I Lecture 10: Data Flow Analysis II (The lectures are based on the slides copyrighted by Keith Cooper and Linda Torczon from Rice University.) Zheng (Eddy) Zhang
More information3/11/18. Final Code Generation and Code Optimization
Final Code Generation and Code Optimization 1 2 3 for ( i=0; i < N; i++) { base = &a[0]; crt = *(base + i); } original code base = &a[0]; for ( i=0; i < N; i++) { crt = *(base + i); } optimized code e1
More informationAlgorithm Design Strategies V
Algorithm Design Strategies V Joaquim Madeira Version 0.0 October 2016 U. Aveiro, October 2016 1 Overview The 0-1 Knapsack Problem Revisited The Fractional Knapsack Problem Greedy Algorithms Example Coin
More informationData Structures in Java
Data Structures in Java Lecture 21: Introduction to NP-Completeness 12/9/2015 Daniel Bauer Algorithms and Problem Solving Purpose of algorithms: find solutions to problems. Data Structures provide ways
More informationParsing with Context-Free Grammars
Parsing with Context-Free Grammars Berlin Chen 2005 References: 1. Natural Language Understanding, chapter 3 (3.1~3.4, 3.6) 2. Speech and Language Processing, chapters 9, 10 NLP-Berlin Chen 1 Grammars
More informationAnnouncements. Project #1 grades were returned on Monday. Midterm #1. Project #2. Requests for re-grades due by Tuesday
Announcements Project #1 grades were returned on Monday Requests for re-grades due by Tuesday Midterm #1 Re-grade requests due by Monday Project #2 Due 10 AM Monday 1 Page State (hardware view) Page frame
More informationMaterial Covered on the Final
Material Covered on the Final On the final exam, you are responsible for: Anything covered in class, except for stories about my good friend Ken Kennedy All lecture material after the midterm ( below the
More informationConstruction of Mixed-Level Orthogonal Arrays for Testing in Digital Marketing
Construction of Mixed-Level Orthogonal Arrays for Testing in Digital Marketing Vladimir Brayman Webtrends October 19, 2012 Advantages of Conducting Designed Experiments in Digital Marketing Availability
More informationCS 374: Algorithms & Models of Computation, Spring 2017 Greedy Algorithms Lecture 19 April 4, 2017 Chandra Chekuri (UIUC) CS374 1 Spring / 1
CS 374: Algorithms & Models of Computation, Spring 2017 Greedy Algorithms Lecture 19 April 4, 2017 Chandra Chekuri (UIUC) CS374 1 Spring 2017 1 / 1 Part I Greedy Algorithms: Tools and Techniques Chandra
More informationCMSC 631 Program Analysis and Understanding. Spring Data Flow Analysis
CMSC 631 Program Analysis and Understanding Spring 2013 Data Flow Analysis Data Flow Analysis A framework for proving facts about programs Reasons about lots of little facts Little or no interaction between
More informationFractional Replications
Chapter 11 Fractional Replications Consider the set up of complete factorial experiment, say k. If there are four factors, then the total number of plots needed to conduct the experiment is 4 = 1. When
More informationGeneralizing Data-flow Analysis
Generalizing Data-flow Analysis Announcements PA1 grades have been posted Today Other types of data-flow analysis Reaching definitions, available expressions, reaching constants Abstracting data-flow analysis
More informationThe One-Quarter Fraction
The One-Quarter Fraction ST 516 Need two generating relations. E.g. a 2 6 2 design, with generating relations I = ABCE and I = BCDF. Product of these is ADEF. Complete defining relation is I = ABCE = BCDF
More informationNP-Completeness I. Lecture Overview Introduction: Reduction and Expressiveness
Lecture 19 NP-Completeness I 19.1 Overview In the past few lectures we have looked at increasingly more expressive problems that we were able to solve using efficient algorithms. In this lecture we introduce
More informationInformatique Fondamentale IMA S8
Informatique Fondamentale IMA S8 Cours 4 : graphs, problems and algorithms on graphs, (notions of) NP completeness Laure Gonnord http://laure.gonnord.org/pro/teaching/ Laure.Gonnord@polytech-lille.fr Université
More informationSpecial Nodes for Interface
fi fi Special Nodes for Interface SW on processors Chip-level HW Board-level HW fi fi C code VHDL VHDL code retargetable compilation high-level synthesis SW costs HW costs partitioning (solve ILP) cluster
More informationDataflow Analysis. A sample program int fib10(void) { int n = 10; int older = 0; int old = 1; Simple Constant Propagation
-74 Lecture 2 Dataflow Analysis Basic Blocks Related Optimizations SSA Copyright Seth Copen Goldstein 200-8 Dataflow Analysis Last time we looked at code transformations Constant propagation Copy propagation
More informationCA Compiler Construction
CA4003 - Compiler Construction Code Generation to MIPS David Sinclair Code Generation The generation o machine code depends heavily on: the intermediate representation;and the target processor. We are
More informationCSCI3390-Lecture 14: The class NP
CSCI3390-Lecture 14: The class NP 1 Problems and Witnesses All of the decision problems described below have the form: Is there a solution to X? where X is the given problem instance. If the instance is
More information1 Reductions and Expressiveness
15-451/651: Design & Analysis of Algorithms November 3, 2015 Lecture #17 last changed: October 30, 2015 In the past few lectures we have looked at increasingly more expressive problems solvable using efficient
More informationTuring Machines. 22c:135 Theory of Computation. Tape of a Turing Machine (TM) TM versus FA, PDA
Turing Machines A Turing machine is similar to a finite automaton with supply of unlimited memory. A Turing machine can do everything that any computing device can do. There exist problems that even a
More informationVariable Elimination (VE) Barak Sternberg
Variable Elimination (VE) Barak Sternberg Basic Ideas in VE Example 1: Let G be a Chain Bayesian Graph: X 1 X 2 X n 1 X n How would one compute P X n = k? Using the CPDs: P X 2 = x = x Val X1 P X 1 = x
More informationInformed Search. Chap. 4. Breadth First. O(Min(N,B L )) BFS. Search. have same cost BIBFS. Bi- Direction. O(Min(N,2B L/2 )) BFS. have same cost UCS
Informed Search Chap. 4 Material in part from http://www.cs.cmu.edu/~awm/tutorials Uninformed Search Complexity N = Total number of states B = Average number of successors (branching factor) L = Length
More informationECE 5775 (Fall 17) High-Level Digital Design Automation. Scheduling: Exact Methods
ECE 5775 (Fall 17) High-Level Digital Design Automation Scheduling: Exact Methods Announcements Sign up for the first student-led discussions today One slot remaining Presenters for the 1st session will
More informationCOSE312: Compilers. Lecture 17 Intermediate Representation (2)
COSE312: Compilers Lecture 17 Intermediate Representation (2) Hakjoo Oh 2017 Spring Hakjoo Oh COSE312 2017 Spring, Lecture 17 May 31, 2017 1 / 19 Common Intermediate Representations Three-address code
More informationInformed Search. Day 3 of Search. Chap. 4, Russel & Norvig. Material in part from
Informed Search Day 3 of Search Chap. 4, Russel & Norvig Material in part from http://www.cs.cmu.edu/~awm/tutorials Uninformed Search Complexity N = Total number of states B = Average number of successors
More informationQuiz 2. Due November 26th, CS525 - Advanced Database Organization Solutions
Name CWID Quiz 2 Due November 26th, 2015 CS525 - Advanced Database Organization s Please leave this empty! 1 2 3 4 5 6 7 Sum Instructions Multiple choice questions are graded in the following way: You
More informationCS 553 Compiler Construction Fall 2006 Homework #2 Dominators, Loops, SSA, and Value Numbering
CS 553 Compiler Construction Fall 2006 Homework #2 Dominators, Loops, SSA, and Value Numbering Answers Write your answers on another sheet of paper. Homework assignments are to be completed individually.
More informationSaturday, April 23, Dependence Analysis
Dependence Analysis Motivating question Can the loops on the right be run in parallel? i.e., can different processors run different iterations in parallel? What needs to be true for a loop to be parallelizable?
More informationCMSC 451: Lecture 7 Greedy Algorithms for Scheduling Tuesday, Sep 19, 2017
CMSC CMSC : Lecture Greedy Algorithms for Scheduling Tuesday, Sep 9, 0 Reading: Sects.. and. of KT. (Not covered in DPV.) Interval Scheduling: We continue our discussion of greedy algorithms with a number
More informationInstruction Selection
Compiler Design Instruction Selection Hwansoo Han Structure of a Compiler O(n) O(n) O(n log n) Scanner words Parser IR Analysis & Optimization IR Instruction Selection Either fast or NP-Complete asm asm
More informationFRACTIONAL REPLICATION
FRACTIONAL REPLICATION M.L.Agarwal Department of Statistics, University of Delhi, Delhi -. In a factorial experiment, when the number of treatment combinations is very large, it will be beyond the resources
More informationLECTURE 10: LINEAR MODEL SELECTION PT. 1. October 16, 2017 SDS 293: Machine Learning
LECTURE 10: LINEAR MODEL SELECTION PT. 1 October 16, 2017 SDS 293: Machine Learning Outline Model selection: alternatives to least-squares Subset selection - Best subset - Stepwise selection (forward and
More informationClock-driven scheduling
Clock-driven scheduling Also known as static or off-line scheduling Michal Sojka Czech Technical University in Prague, Faculty of Electrical Engineering, Department of Control Engineering November 8, 2017
More informationLexical Analysis: DFA Minimization & Wrap Up
Lexical Analysis: DFA Minimization & Wrap Up Automating Scanner Construction PREVIOUSLY RE NFA (Thompson s construction) Build an NFA for each term Combine them with -moves NFA DFA (subset construction)
More informationNP Completeness. CS 374: Algorithms & Models of Computation, Spring Lecture 23. November 19, 2015
CS 374: Algorithms & Models of Computation, Spring 2015 NP Completeness Lecture 23 November 19, 2015 Chandra & Lenny (UIUC) CS374 1 Spring 2015 1 / 37 Part I NP-Completeness Chandra & Lenny (UIUC) CS374
More informationMethods for finding optimal configurations
CS 1571 Introduction to AI Lecture 9 Methods for finding optimal configurations Milos Hauskrecht milos@cs.pitt.edu 5329 Sennott Square Search for the optimal configuration Optimal configuration search:
More informationMTAT Complexity Theory September 15th, Lecture 3
MTAT.07.004 Complexity Theory September 15th, 2011 Lecturer: Peeter Laud Lecture 3 Scribe(s): Ilya Kuzovkin Introduction During this lecture we went through proofs for four theorems. Multi-tape Turing
More informationDataflow Analysis Lecture 2. Simple Constant Propagation. A sample program int fib10(void) {
-4 Lecture Dataflow Analysis Basic Blocks Related Optimizations Copyright Seth Copen Goldstein 00 Dataflow Analysis Last time we looked at code transformations Constant propagation Copy propagation Common
More informationI may not have gone where I intended to go, but I think I have ended up where I needed to be. Douglas Adams
Disclaimer: I use these notes as a guide rather than a comprehensive coverage of the topic. They are neither a substitute for attending the lectures nor for reading the assigned material. I may not have
More informationIntroduction to Theory of Computing
CSCI 2670, Fall 2012 Introduction to Theory of Computing Department of Computer Science University of Georgia Athens, GA 30602 Instructor: Liming Cai www.cs.uga.edu/ cai 0 Lecture Note 3 Context-Free Languages
More informationLexical Analysis Part II: Constructing a Scanner from Regular Expressions
Lexical Analysis Part II: Constructing a Scanner from Regular Expressions CS434 Spring 2005 Department of Computer Science University of Alabama Joel Jones Copyright 2003, Keith D. Cooper, Ken Kennedy
More informationCS 6301 PROGRAMMING AND DATA STRUCTURE II Dept of CSE/IT UNIT V GRAPHS
UNIT V GRAPHS Representation of Graphs Breadth-first search Depth-first search Topological sort Minimum Spanning Trees Kruskal and Prim algorithm Shortest path algorithm Dijkstra s algorithm Bellman-Ford
More informationExploring the Potential of Instruction-Level Parallelism of Exposed Datapath Architectures with Buffered Processing Units
Exploring the Potential of Instruction-Level Parallelism of Exposed Datapath Architectures with Buffered Processing Units Anoop Bhagyanath and Klaus Schneider Embedded Systems Chair University of Kaiserslautern
More informationCODE GENERATION REGISTER ALLOCATION. Goal. Interplay between. Translate intermediate code into target code
CODE GENERATION Goal Translate intermediate code into target code Interplay between Register Allocation Instruction Selection Instruction Scheduling 1 REGISTER ALLOCATION 1 REGISTER ALLOCATION Motivation
More informationCSCB63 Winter Week 11 Bloom Filters. Anna Bretscher. March 30, / 13
CSCB63 Winter 2019 Week 11 Bloom Filters Anna Bretscher March 30, 2019 1 / 13 Today Bloom Filters Definition Expected Complexity Applications 2 / 13 Bloom Filters (Specification) A bloom filter is a probabilistic
More informationCS 301: Complexity of Algorithms (Term I 2008) Alex Tiskin Harald Räcke. Hamiltonian Cycle. 8.5 Sequencing Problems. Directed Hamiltonian Cycle
8.5 Sequencing Problems Basic genres. Packing problems: SET-PACKING, INDEPENDENT SET. Covering problems: SET-COVER, VERTEX-COVER. Constraint satisfaction problems: SAT, 3-SAT. Sequencing problems: HAMILTONIAN-CYCLE,
More informationTWO-LEVEL FACTORIAL EXPERIMENTS: REGULAR FRACTIONAL FACTORIALS
STAT 512 2-Level Factorial Experiments: Regular Fractions 1 TWO-LEVEL FACTORIAL EXPERIMENTS: REGULAR FRACTIONAL FACTORIALS Bottom Line: A regular fractional factorial design consists of the treatments
More informationModels of Computation. by Costas Busch, LSU
Models of Computation by Costas Busch, LSU 1 Computation CPU memory 2 temporary memory input memory CPU output memory Program memory 3 Example: f ( x) x 3 temporary memory input memory Program memory compute
More informationLoop Scheduling and Software Pipelining \course\cpeg421-08s\topic-7.ppt 1
Loop Scheduling and Software Pipelining 2008-04-24 \course\cpeg421-08s\topic-7.ppt 1 Reading List Slides: Topic 7 and 7a Other papers as assigned in class or homework: 2008-04-24 \course\cpeg421-08s\topic-7.ppt
More informationCS 410/584, Algorithm Design & Analysis: Lecture Notes 3
CS 410/584, : Lecture Notes 3 Amortized Cost Not an algorithm design mechanism per se For analyzing cost of algorithms - - Example: Exercise 17.3-6 Implement a queue with two stacks Why? 1 enqueue(x, Q)
More informationCSE 417T: Introduction to Machine Learning. Final Review. Henry Chai 12/4/18
CSE 417T: Introduction to Machine Learning Final Review Henry Chai 12/4/18 Overfitting Overfitting is fitting the training data more than is warranted Fitting noise rather than signal 2 Estimating! "#$
More informationICS 252 Introduction to Computer Design
ICS 252 fall 2006 Eli Bozorgzadeh Computer Science Department-UCI References and Copyright Textbooks referred [Mic94] G. De Micheli Synthesis and Optimization of Digital Circuits McGraw-Hill, 1994. [CLR90]
More informationClass 5. Review; questions. Data-flow Analysis Review. Slicing overview Problem Set 2: due 9/3/09 Problem Set 3: due 9/8/09
Class 5 Review; questions Assign (see Schedule for links) Slicing overview Problem Set 2: due 9/3/09 Problem Set 3: due 9/8/09 1 Data-flow Analysis Review Start at slide 21 of Basic Analysis 3 1 Static
More informationCMSC 722, AI Planning. Planning and Scheduling
CMSC 722, AI Planning Planning and Scheduling Dana S. Nau University of Maryland 1:26 PM April 24, 2012 1 Scheduling Given: actions to perform set of resources to use time constraints» e.g., the ones computed
More informationDataflow analysis. Theory and Applications. cs6463 1
Dataflow analysis Theory and Applications cs6463 1 Control-flow graph Graphical representation of runtime control-flow paths Nodes of graph: basic blocks (straight-line computations) Edges of graph: flows
More information4/20/11. NP-complete problems. A variety of NP-complete problems. Hamiltonian Cycle. Hamiltonian Cycle. Directed Hamiltonian Cycle
A variety of NP-complete problems NP-complete problems asic genres. Packing problems: SE-PACKING, INDEPENDEN SE. Covering problems: SE-COVER, VEREX-COVER. Constraint satisfaction problems: SA, 3-SA. Sequencing
More informationCMP 334: Seventh Class
CMP 334: Seventh Class Performance HW 5 solution Averages and weighted averages (review) Amdahl's law Ripple-carry adder circuits Binary addition Half-adder circuits Full-adder circuits Subtraction, negative
More informationPengju
Introduction to AI Chapter04 Beyond Classical Search Pengju Ren@IAIR Outline Steepest Descent (Hill-climbing) Simulated Annealing Evolutionary Computation Non-deterministic Actions And-OR search Partial
More informationUC Berkeley CS 170: Efficient Algorithms and Intractable Problems Handout 22 Lecturer: David Wagner April 24, Notes 22 for CS 170
UC Berkeley CS 170: Efficient Algorithms and Intractable Problems Handout 22 Lecturer: David Wagner April 24, 2003 Notes 22 for CS 170 1 NP-completeness of Circuit-SAT We will prove that the circuit satisfiability
More informationTrees/Intro to counting
Trees/Intro to counting Russell Impagliazzo and Miles Jones Thanks to Janine Tiefenbruck http://cseweb.ucsd.edu/classes/sp16/cse21-bd/ April 29, 2016 Equivalence between rooted and unrooted trees Goal
More informationCOL 352 Introduction to Automata and Theory of Computation Major Exam, Sem II , Max 80, Time 2 hr. Name Entry No. Group
COL 352 Introduction to Automata and Theory of Computation Major Exam, Sem II 2015-16, Max 80, Time 2 hr Name Entry No. Group Note (i) Write your answers neatly and precisely in the space provided with
More informationCMPSCI611: Three Divide-and-Conquer Examples Lecture 2
CMPSCI611: Three Divide-and-Conquer Examples Lecture 2 Last lecture we presented and analyzed Mergesort, a simple divide-and-conquer algorithm. We then stated and proved the Master Theorem, which gives
More informationAnnouncements. Problem Set 7 graded; will be returned at end of lecture. Unclaimed problem sets and midterms moved!
N P NP Announcements Problem Set 7 graded; will be returned at end of lecture. Unclaimed problem sets and midterms moved! Now in cabinets in the Gates open area near the drop-off box. The Complexity Class
More informationAutomata Theory CS S-12 Turing Machine Modifications
Automata Theory CS411-2015S-12 Turing Machine Modifications David Galles Department of Computer Science University of San Francisco 12-0: Extending Turing Machines When we added a stack to NFA to get a
More informationCS 580: Algorithm Design and Analysis
CS 580: Algorithm Design and Analysis Jeremiah Blocki Purdue University Spring 2018 Homework 5 due tonight at 11:59 PM (on Blackboard) Midterm 2 on April 4 th at 8PM (MATH 175) Practice Midterm Released
More informationApproximation Algorithms (Load Balancing)
July 6, 204 Problem Definition : We are given a set of n jobs {J, J 2,..., J n }. Each job J i has a processing time t i 0. We are given m identical machines. Problem Definition : We are given a set of
More informationCompilers. Lexical analysis. Yannis Smaragdakis, U. Athens (original slides by Sam
Compilers Lecture 3 Lexical analysis Yannis Smaragdakis, U. Athens (original slides by Sam Guyer@Tufts) Big picture Source code Front End IR Back End Machine code Errors Front end responsibilities Check
More informationLocal Search and Optimization
Local Search and Optimization Outline Local search techniques and optimization Hill-climbing Gradient methods Simulated annealing Genetic algorithms Issues with local search Local search and optimization
More informationFinding optimal configurations ( combinatorial optimization)
CS 1571 Introduction to AI Lecture 10 Finding optimal configurations ( combinatorial optimization) Milos Hauskrecht milos@cs.pitt.edu 539 Sennott Square Constraint satisfaction problem (CSP) Constraint
More informationAlpha-Beta Pruning: Algorithm and Analysis
Alpha-Beta Pruning: Algorithm and Analysis Tsan-sheng Hsu tshsu@iis.sinica.edu.tw http://www.iis.sinica.edu.tw/~tshsu 1 Introduction Alpha-beta pruning is the standard searching procedure used for 2-person
More informationCSE 4502/5717 Big Data Analytics Spring 2018; Homework 1 Solutions
CSE 502/5717 Big Data Analytics Spring 2018; Homework 1 Solutions 1. Consider the following algorithm: for i := 1 to α n log e n do Pick a random j [1, n]; If a[j] = a[j + 1] or a[j] = a[j 1] then output:
More informationWhat is SSA? each assignment to a variable is given a unique name all of the uses reached by that assignment are renamed
Another Form of Data-Flow Analysis Propagation of values for a variable reference, where is the value produced? for a variable definition, where is the value consumed? Possible answers reaching definitions,
More informationAdvanced Implementations of Tables: Balanced Search Trees and Hashing
Advanced Implementations of Tables: Balanced Search Trees and Hashing Balanced Search Trees Binary search tree operations such as insert, delete, retrieve, etc. depend on the length of the path to the
More informationCS168: The Modern Algorithmic Toolbox Lectures #11 and #12: Spectral Graph Theory
CS168: The Modern Algorithmic Toolbox Lectures #11 and #12: Spectral Graph Theory Tim Roughgarden & Gregory Valiant May 2, 2016 Spectral graph theory is the powerful and beautiful theory that arises from
More informationUndecidable Problems. Z. Sawa (TU Ostrava) Introd. to Theoretical Computer Science May 12, / 65
Undecidable Problems Z. Sawa (TU Ostrava) Introd. to Theoretical Computer Science May 12, 2018 1/ 65 Algorithmically Solvable Problems Let us assume we have a problem P. If there is an algorithm solving
More information- Why aren t there more quantum algorithms? - Quantum Programming Languages. By : Amanda Cieslak and Ahmana Tarin
- Why aren t there more quantum algorithms? - Quantum Programming Languages By : Amanda Cieslak and Ahmana Tarin Why aren t there more quantum algorithms? there are only a few problems for which quantum
More informationA.I.: Beyond Classical Search
A.I.: Beyond Classical Search Random Sampling Trivial Algorithms Generate a state randomly Random Walk Randomly pick a neighbor of the current state Both algorithms asymptotically complete. Overview Previously
More informationStatistical Machine Translation. Part III: Search Problem. Complexity issues. DP beam-search: with single and multi-stacks
Statistical Machine Translation Marcello Federico FBK-irst Trento, Italy Galileo Galilei PhD School - University of Pisa Pisa, 7-19 May 008 Part III: Search Problem 1 Complexity issues A search: with single
More informationECEN 651: Microprogrammed Control of Digital Systems Department of Electrical and Computer Engineering Texas A&M University
ECEN 651: Microprogrammed Control of Digital Systems Department of Electrical and Computer Engineering Texas A&M University Prof. Mi Lu TA: Ehsan Rohani Laboratory Exercise #4 MIPS Assembly and Simulation
More informationChapter 6 Constraint Satisfaction Problems
Chapter 6 Constraint Satisfaction Problems CS5811 - Artificial Intelligence Nilufer Onder Department of Computer Science Michigan Technological University Outline CSP problem definition Backtracking search
More informationCMPSCI611: The Matroid Theorem Lecture 5
CMPSCI611: The Matroid Theorem Lecture 5 We first review our definitions: A subset system is a set E together with a set of subsets of E, called I, such that I is closed under inclusion. This means that
More informationCSCE 551: Chin-Tser Huang. University of South Carolina
CSCE 551: Theory of Computation Chin-Tser Huang huangct@cse.sc.edu University of South Carolina Church-Turing Thesis The definition of the algorithm came in the 1936 papers of Alonzo Church h and Alan
More informationCS 161 Summer 2009 Homework #2 Sample Solutions
CS 161 Summer 2009 Homework #2 Sample Solutions Regrade Policy: If you believe an error has been made in the grading of your homework, you may resubmit it for a regrade. If the error consists of more than
More informationComputer Science. Questions for discussion Part II. Computer Science COMPUTER SCIENCE. Section 4.2.
COMPUTER SCIENCE S E D G E W I C K / W A Y N E PA R T I I : A L G O R I T H M S, T H E O R Y, A N D M A C H I N E S Computer Science Computer Science An Interdisciplinary Approach Section 4.2 ROBERT SEDGEWICK
More informationMIT Loop Optimizations. Martin Rinard
MIT 6.035 Loop Optimizations Martin Rinard Loop Optimizations Important because lots of computation occurs in loops We will study two optimizations Loop-invariant code motion Induction variable elimination
More informationAlgorithms. Grad Refresher Course 2011 University of British Columbia. Ron Maharik
Algorithms Grad Refresher Course 2011 University of British Columbia Ron Maharik maharik@cs.ubc.ca About this talk For those incoming grad students who Do not have a CS background, or Have a CS background
More informationPrinciples of AI Planning
Principles of 5. Planning as search: progression and regression Malte Helmert and Bernhard Nebel Albert-Ludwigs-Universität Freiburg May 4th, 2010 Planning as (classical) search Introduction Classification
More informationWorst-Case Execution Time Analysis. LS 12, TU Dortmund
Worst-Case Execution Time Analysis Prof. Dr. Jian-Jia Chen LS 12, TU Dortmund 09/10, Jan., 2018 Prof. Dr. Jian-Jia Chen (LS 12, TU Dortmund) 1 / 43 Most Essential Assumptions for Real-Time Systems Upper
More informationLecture 4: An FPTAS for Knapsack, and K-Center
Comp 260: Advanced Algorithms Tufts University, Spring 2016 Prof. Lenore Cowen Scribe: Eric Bailey Lecture 4: An FPTAS for Knapsack, and K-Center 1 Introduction Definition 1.0.1. The Knapsack problem (restated)
More informationAdministrivia. Test I during class on 10 March. Bottom-Up Parsing. Lecture An Introductory Example
Administrivia Test I during class on 10 March. Bottom-Up Parsing Lecture 11-12 From slides by G. Necula & R. Bodik) 2/20/08 Prof. Hilfinger CS14 Lecture 11 1 2/20/08 Prof. Hilfinger CS14 Lecture 11 2 Bottom-Up
More informationComplexity Theory Part II
Complexity Theory Part II Time Complexity The time complexity of a TM M is a function denoting the worst-case number of steps M takes on any input of length n. By convention, n denotes the length of the
More information10.3 Matroids and approximation
10.3 Matroids and approximation 137 10.3 Matroids and approximation Given a family F of subsets of some finite set X, called the ground-set, and a weight function assigning each element x X a non-negative
More informationIntroduction to Quantum Computing
Introduction to Quantum Computing The lecture notes were prepared according to Peter Shor s papers Quantum Computing and Polynomial-Time Algorithms for Prime Factorization and Discrete Logarithms on a
More informationData-Flow Analysis. Compiler Design CSE 504. Preliminaries
Data-Flow Analysis Compiler Design CSE 504 1 Preliminaries 2 Live Variables 3 Data Flow Equations 4 Other Analyses Last modifled: Thu May 02 2013 at 09:01:11 EDT Version: 1.3 15:28:44 2015/01/25 Compiled
More informationLecture 11: Data Flow Analysis III
CS 515 Programming Language and Compilers I Lecture 11: Data Flow Analysis III (The lectures are based on the slides copyrighted by Keith Cooper and Linda Torczon from Rice University.) Zheng (Eddy) Zhang
More information1.10 Continuity Brian E. Veitch
1.10 Continuity Definition 1.5. A function is continuous at x = a if 1. f(a) exists 2. lim x a f(x) exists 3. lim x a f(x) = f(a) If any of these conditions fail, f is discontinuous. Note: From algebra
More information