Register Alloca.on. CMPT 379: Compilers Instructor: Anoop Sarkar. anoopsarkar.github.io/compilers-class
|
|
- Kenneth Spencer
- 5 years ago
- Views:
Transcription
1 Register Alloca.on CMPT 379: Compilers Instructor: Anoop Sarkar anoopsarkar.github.io/compilers-class 1
2 Register Alloca.on Intermediate code uses unlimited temporaries Simplifying code genera.on and op.miza.on Complicates final transla.on to assembly 2
3 Register Alloca.on The problem: Rewrite the intermediate code to use no more temporaries than there are machine registers Method: Assign mul.ple temporaries to each register But without changing the program behavior 3
4 Example Consider the program a = c + d e = a + b f = e - 1 Assume a & e dead ater 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 History Register alloca.on is as old as compilers Register alloca.on was used in the original FORTRAN compiler in 1950 s Very crude algorithm A breakthrough came in 1980 Register alloca.on scheme based on graph coloring Rela.vely simple, global and works well in prac.ce 5
6 Principles of Register Alloca.on 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 8me, they cannot share a register We need liveness analysis 6
7 Live Variables Compute live variables for each point {a,f,c} {d,f,c} {c,e} f = 2*e {f,c} a = b+c d = -a e = d+f {f,c} {d,e,f,c} b = d+e e = e-1 {b,c,f} {b,e,f,c} {b} b = f+c 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 connec.ng them 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 d 9
10 Register Interference Graph Extracts exactly the informa.on we need to characterize legal register alloca.on Gives the global view (i.e., over the en.re control flow graph) picture of the register requirements ATer RIG construc.on the register alloca.on algorithm is architecture independent 10
11 Graph Coloring A coloring of a graph is an assignment of colors to nodes, such that nodes connected by an edge have different colors A graph is k-colorable if it has a coloring with k colors f a c 11
12 Register Alloca.on 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 12
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 13
14 Control Flow Graph a = b+c d = -a e = d+f f = 2*e b = d+e e = e-1 b = f+c 14
15 Register Alloca.on 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 15
16 Graph Coloring How do we compute graph coloring? It is not easy : The problem is NP-hard. No efficient algorithms are known Solu.on: use heuris.cs A coloring might not exist for a given number of registers Solu.on: register spilling 16
17 Register Alloca.on as Graph Coloring Main idea for solving whether a graph G is k- colorable: Pick any node t with fewer than k neighbors Remove n 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 17
18 Register Alloca.on as Graph Coloring Heuris.c 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 register interference graph (RIG) 3. Repeat un.l 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 18
19 Example Assume k=4 a Remove a f b stack={} e c d 19
20 Example Assume k=4 Remove d f b stack={a} e c d 20
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} 21
22 Example Assume k=4 Remove b stack={c,d,a} f e b 22
23 Example Assume k=4 Remove e stack={b,c,d,a} f e 23
24 Example Assume k=4 Remove f f stack={e,b,c,d,a} 24
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} 25
26 Example Assume k=4 stack={e,b,c,d,a} r 1 f 26
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 27
28 Example Assume k=4 stack={c,d,a} r 1 f b r 3 r 2 e 28
29 Example Assume k=4 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 29
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 30
31 Example Assume k=4 stack={} a r 2 r 1 f b r 3 r 2 e c r 4 d r 3 31
32 Register Alloca.on as Graph Coloring What happens if the graph coloring heuris.c fails to find a coloring? In this case we cannot hold all values in the registers Some values should be spilled to memory 32
33 K-coloring fails What if all nodes have k or more neighbors? Try to find a 3 coloring of this graph a Remove a f b e c d 33
34 Example of 3-coloring There is no node such that if we remove it then 3-coloring for the graph is available f b e c d 34
35 Op.mis.c 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 con.nue k-coloring 35
36 Op.mis.c Coloring Remove f and con.nue: The ordering: {c,e,d,b,f,a} b e c d 36
37 Op.mis.c 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 (op8mis8c coloring) f b r 3 r 2 e c r 1 d r 3 37
38 Spilling If op.mis.c coloring fails, we spill f Allocate a memory loca.on for f Typically in the current stack frame Call this address fa Before each opera.on that reads f, insert f = load fa ATer each opera.on that writes f, insert store f, fa Spilling is slow but some.mes necessary. 38
39 Original Code a = b+c d = -a e = d+f f = 2*e b = d+e e = e-1 b = f+c 39
40 Code ater 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 40
41 Recompute the Liveness {a, c, f} {c, d, f} f2 = 2*e store f2, fa a = b+c d = -a f1 = load fa e = d+f1 {c, e} {c, d, e, f} {f, c} {b} {f, c} f3 = load fa b = f3+c b = d+e e = e-1 {b, c, f} {b, c, e, f} 41
42 Recompute the Liveness {c, f2} a = b+c {a, c, f} {c, d, f} d = -a f1 = load fa {c, d, f1} e = d+f1 {c, e} {c, d, e, f} f2 = 2*e store f2, fa {f, c} {c, f3} {b} {f, c} f3 = load fa b = f3+c b = d+e e = e-1 {b, c, f} {b, c, e, f} 42
43 Rebuild the Interference Graph New liveness informa.on is almost as before Note f has been split into three temporaries fi is live only Between a fi = load fa and the next instruc.on 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 43
44 Rebuild the Interference Graph Some edges of the spilled nodes are removed In our case f s.ll interferes only with c and d And the new RIG is 3-colorable a f1 b f3 e d c f2 44
45 Spilling Addi.onal spilling might be required before a coloring is found 45
46 Example K=3 remove a a Stack: {} f e b c d 46
47 Example K=3 remove c Stack: {a} f e b c d 47
48 Example K=3 remove b Stack: {c,a} f e b d 48
49 Example K=3 remove e Stack: {b,c,a} f e d 49
50 Example K=3 remove f Stack: {e,b,c,a} f d 50
51 Example K=3 remove d Stack: {f,e,b,c,a} d 51
52 Example K=3 Stack: {d,f,e,b,c,a} 52
53 Example K=3 Stack: {f,e,b,c,a} d r1 53
54 Example K=3 Stack: {e,b,c,a} r2 f d r1 54
55 Example K=3 Stack: {b,c,a} r2 f r3 e d r1 55
56 Example K=3 Stack: {c,a} r2 f r3 e b r3 d r1 56
57 Example K=3 Stack: {a} r2 f r3 e b r3 c Spilled! d r1 57
58 Example K=3 Stack: {} r2 f r3 e a Spilled! b r3 c Spilled! d r1 58
59 Example K=3 Stack: {d,f,e,b,c,a} 59
60 Example K=3 Stack: {f,e,b,c,a} d r1 60
61 Example K=3 Stack: {e,b,c,a} r1 f d r1 61
62 Example K=3 Stack: {b,c,a} r1 f r2 e d r1 62
63 Example K=3 Stack: {c,a} r1 f r2 e b r2 d r1 63
64 Example K=3 Stack: {a} r1 f r2 e b r2 c r3 d r1 64
65 Example K=3 a r3 Stack: {} r1 f r2 e b r2 c r3 d r1 65
66 Spilling Many different heuris.cs for picking a node to spill Spill temporaries with most conflicts Spill temporaries with few defini.ons 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. 66
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 67
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} {d} {g} 68
69 e = d + a f = b + c f = f + b if e==0 goto _L0 d = e + f goto _L1 a Live Intervals {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} {d} {g} 69
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} {d} {g} 70
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} {d} {g} 71
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} {d} {g} 72
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} {d} {g} 73
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} {d} {g} 74
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} {d} {g} 75
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} {d} {g} 76
77 Register Alloca.on 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 77
78 Register Alloca.on with Live a b c d e f g Intervals r1 r2 r3 r4 78
79 Register Alloca.on with Live a b c d e f g Intervals r1 r2 r3 r4 79
80 Register Alloca.on with Live a b c d e f g Intervals r1 r2 r3 r4 80
81 Register Alloca.on with Live a b c d e f g Intervals r1 r2 r3 r4 81
82 Register Alloca.on with Live a b c d e f g Intervals r1 r2 r3 r4 82
83 Register Alloca.on with Live a b c d e f g Intervals r1 r2 r3 r4 83
84 Register Alloca.on with Live a b c d e f g Intervals r1 r2 r3 r4 84
85 Register Alloca.on with Live a b c d e f g Intervals r1 r2 r3 r4 85
86 Register Alloca.on with Live a b c d e f g Intervals r1 r2 r3 r4 86
87 Register Alloca.on with Live a b c d e f g Intervals r1 r2 r3 r4 87
88 Register Alloca.on with Live a b c d e f g Intervals r1 r2 r3 r4 88
89 Register Alloca.on with Live a b c d e f g Intervals r1 r2 r3 r4 89
90 Linear Scan Register Alloca.on If a register cannot be found for a variable v, we may need to spill a variable. This algorithm is called linear scan register alloca.on and is a compara.vely new algorithm. Pros: Very efficient Works well in many cases Alloca.on needs one pass, the code can be generated simultaneously Used in JIT compilers like Java HotSpot Cons: Not as good as graph coloring approach 90
91 Summary Register alloca.on is a must have in compilers, because: Intermediate code uses too many temporaries It makes a big difference in performance The liveness at each loca.on can be used for register alloca.on Register alloca.on as heuris.c graph coloring uses live ranges The basis for the technique used in GCC Linear scan register alloca.on uses live intervals OTen used in JIT compilers due to efficiency 91
Register Allocation. Maryam Siahbani CMPT 379 4/5/2016 1
Register Allocation Maryam Siahbani CMPT 379 4/5/2016 1 Register Allocation Intermediate code uses unlimited temporaries Simplifying code generation and optimization Complicates final translation to assembly
More informationCSE P 501 Compilers. Value Numbering & Op;miza;ons Hal Perkins Winter UW CSE P 501 Winter 2016 S-1
CSE P 501 Compilers Value Numbering & Op;miza;ons Hal Perkins Winter 2016 UW CSE P 501 Winter 2016 S-1 Agenda Op;miza;on (Review) Goals Scope: local, superlocal, regional, global (intraprocedural), interprocedural
More informationLecture 4 Introduc-on to Data Flow Analysis
Lecture 4 Introduc-on to Data Flow Analysis I. Structure of data flow analysis II. Example 1: Reaching defini?on analysis III. Example 2: Liveness analysis IV. Generaliza?on 15-745: Intro to Data Flow
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 informationUnit 1 Part 1. Order of Opera*ons Factoring Frac*ons
Unit 1 Part 1 Order of Opera*ons Factoring Frac*ons Order of Opera0ons For more informa*on and prac*ce see h4p://www.purplemath.com/modules/orderops.htm Introduc0on Evaluate the expression: 2+3*4 =? Some
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 informationENEE350 Lecture Notes-Weeks 14 and 15
Pipelining & Amdahl s Law ENEE350 Lecture Notes-Weeks 14 and 15 Pipelining is a method of processing in which a problem is divided into a number of sub problems and solved and the solu8ons of the sub problems
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 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 information: Advanced Compiler Design Compu=ng DF(X) 3.4 Algorithm for inser=on of φ func=ons 3.5 Algorithm for variable renaming
263-2810: Advanced Compiler Design 3.3.2 Compu=ng DF(X) 3.4 Algorithm for inser=on of φ func=ons 3.5 Algorithm for variable renaming Thomas R. Gross Computer Science Department ETH Zurich, Switzerland
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 informationCSCI 360 Introduc/on to Ar/ficial Intelligence Week 2: Problem Solving and Op/miza/on. Instructor: Wei-Min Shen
CSCI 360 Introduc/on to Ar/ficial Intelligence Week 2: Problem Solving and Op/miza/on Instructor: Wei-Min Shen Today s Lecture Search Techniques (review & con/nue) Op/miza/on Techniques Home Work 1: descrip/on
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 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 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 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 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 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 informationGraphical Models. Lecture 10: Variable Elimina:on, con:nued. Andrew McCallum
Graphical Models Lecture 10: Variable Elimina:on, con:nued Andrew McCallum mccallum@cs.umass.edu Thanks to Noah Smith and Carlos Guestrin for some slide materials. 1 Last Time Probabilis:c inference is
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 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 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 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 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 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 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 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 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 informationSyntax Directed Transla1on
Syntax Directed Transla1on Syntax Directed Transla1on CMPT 379: Compilers Instructor: Anoop Sarkar anoopsarkar.github.io/compilers-class Syntax directed Translation Models for translation from parse trees
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 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 informationTainted Flow Analysis on e-ssaform
Tainted Flow Analysis on e-ssaform Programs Andrei Rimsa, Marcelo d Amorim and Fernando M. Q. Pereira The Objective of this work is to detect security vulnerabilities in programs via static analysis Vulnerabilities
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 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 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 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 informationParallelizing Gaussian Process Calcula1ons in R
Parallelizing Gaussian Process Calcula1ons in R Christopher Paciorek UC Berkeley Sta1s1cs Joint work with: Benjamin Lipshitz Wei Zhuo Prabhat Cari Kaufman Rollin Thomas UC Berkeley EECS (formerly) IBM
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 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 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 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 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 informationPar$$oned Elias- Fano indexes. Giuseppe O)aviano Rossano Venturini
Par$$oned Elias- Fano indexes Giuseppe O)aviano Rossano Venturini Inverted indexes Core data structure of Informa$on Retrieval Documents are sequences of terms 1: [it is what it is not] 2: [what is a]
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 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 informationCSE546: SVMs, Dual Formula5on, and Kernels Winter 2012
CSE546: SVMs, Dual Formula5on, and Kernels Winter 2012 Luke ZeClemoyer Slides adapted from Carlos Guestrin Linear classifiers Which line is becer? w. = j w (j) x (j) Data Example i Pick the one with the
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 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 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 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 informationSpace and Nondeterminism
CS 221 Computational Complexity, Lecture 5 Feb 6, 2018 Space and Nondeterminism Instructor: Madhu Sudan 1 Scribe: Yong Wook Kwon Topic Overview Today we ll talk about space and non-determinism. For some
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 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 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 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 informationIntroduc)on to Ar)ficial Intelligence
Introduc)on to Ar)ficial Intelligence Lecture 13 Approximate Inference CS/CNS/EE 154 Andreas Krause Bayesian networks! Compact representa)on of distribu)ons over large number of variables! (OQen) allows
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 information8.5 Sequencing Problems
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 informationCSCI 1010 Models of Computa3on. Lecture 17 Parsing Context-Free Languages
CSCI 1010 Models of Computa3on Lecture 17 Parsing Context-Free Languages Overview BoCom-up parsing of CFLs. BoCom-up parsing via the CKY algorithm An O(n 3 ) algorithm John E. Savage CSCI 1010 Lect 17
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 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 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 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 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 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 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 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 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 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 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 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 informationNP, polynomial-time mapping reductions, and NP-completeness
NP, polynomial-time mapping reductions, and NP-completeness In the previous lecture we discussed deterministic time complexity, along with the time-hierarchy theorem, and introduced two complexity classes:
More informationNetworks. Can (John) Bruce Keck Founda7on Biotechnology Lab Bioinforma7cs Resource
Networks Can (John) Bruce Keck Founda7on Biotechnology Lab Bioinforma7cs Resource Networks in biology Protein-Protein Interaction Network of Yeast Transcriptional regulatory network of E.coli Experimental
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 informationFriday Four Square! Today at 4:15PM, Outside Gates
P and NP Friday Four Square! Today at 4:15PM, Outside Gates Recap from Last Time Regular Languages DCFLs CFLs Efficiently Decidable Languages R Undecidable Languages Time Complexity A step of a Turing
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 informationTime Complexity (1) CSCI Spring Original Slides were written by Dr. Frederick W Maier. CSCI 2670 Time Complexity (1)
Time Complexity (1) CSCI 2670 Original Slides were written by Dr. Frederick W Maier Spring 2014 Time Complexity So far we ve dealt with determining whether or not a problem is decidable. But even if it
More informationDijkstra s Single Source Shortest Path Algorithm. Andreas Klappenecker
Dijkstra s Single Source Shortest Path Algorithm Andreas Klappenecker Single Source Shortest Path Given: a directed or undirected graph G = (V,E) a source node s in V a weight function w: E -> R. Goal:
More informationCSE 473: Ar+ficial Intelligence
CSE 473: Ar+ficial Intelligence Hidden Markov Models Luke Ze@lemoyer - University of Washington [These slides were created by Dan Klein and Pieter Abbeel for CS188 Intro to AI at UC Berkeley. All CS188
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 informationScalar Optimisation Part 1
calar Optimisation Part 1 Michael O Boyle January, 2014 1 Course tructure L1 Introduction and Recap 4/5 lectures on classical optimisation 2 lectures on scalar optimisation Today example optimisations
More informationP and NP. Or, how to make $1,000,000.
P and NP Or, how to make $1,000,000. http://www.claymath.org/millennium-problems/p-vs-np-problem Review: Polynomial time difference between single-tape and multi-tape TMs Exponential time difference between
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 informationNETWORK CALCULATIONS updated 11/5/13 1:02 PM
NETWORK CALCULATIONS updated 11/5/13 1:02 PM 11/5/13 Network Calcula2ons (c) 2013 H. Zmuda 1 Introductory Comments The typical power transmission network span a large geographic area and involve a large
More informationClairvoyant scheduling of random walks
Clairvoyant scheduling of random walks Péter Gács Boston University April 25, 2008 Péter Gács (BU) Clairvoyant demon April 25, 2008 1 / 65 Introduction The clairvoyant demon problem 2 1 Y : WAIT 0 X, Y
More information4 : Exact Inference: Variable Elimination
10-708: Probabilistic Graphical Models 10-708, Spring 2014 4 : Exact Inference: Variable Elimination Lecturer: Eric P. ing Scribes: Soumya Batra, Pradeep Dasigi, Manzil Zaheer 1 Probabilistic Inference
More informationProving languages to be nonregular
Proving languages to be nonregular We already know that there exist languages A Σ that are nonregular, for any choice of an alphabet Σ. This is because there are uncountably many languages in total and
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 informationMore on NP and Reductions
Indian Institute of Information Technology Design and Manufacturing, Kancheepuram Chennai 600 127, India An Autonomous Institute under MHRD, Govt of India http://www.iiitdm.ac.in COM 501 Advanced Data
More informationCSE 331 Winter 2018 Homework 1
Directions: - Due Wednesday, January 10 by 11 pm. - Turn in your work online using gradescope. You should turn in a single pdf file. You can have more than one answer per page, but please try to avoid
More informationCS 161: Design and Analysis of Algorithms
CS 161: Design and Analysis of Algorithms Greedy Algorithms 1: Shortest Paths In Weighted Graphs Greedy Algorithm BFS as a greedy algorithm Shortest Paths in Weighted Graphs Dijsktra s Algorithm Greedy
More informationBreadth First Search, Dijkstra s Algorithm for Shortest Paths
CS 374: Algorithms & Models of Computation, Spring 2017 Breadth First Search, Dijkstra s Algorithm for Shortest Paths Lecture 17 March 1, 2017 Chandra Chekuri (UIUC) CS374 1 Spring 2017 1 / 42 Part I Breadth
More information