November 29, 2005Christopher Tuttle1 Linear Scan Register Allocation Massimiliano Poletto (MIT) and Vivek Sarkar (IBM Watson)

Slides:



Advertisements
Similar presentations
Garbage collection David Walker CS 320. Where are we? Last time: A survey of common garbage collection techniques –Manual memory management –Reference.
Advertisements

Register Allocation COS 320 David Walker (with thanks to Andrew Myers for many of these slides)
Target Code Generation
Compiler Support for Superscalar Processors. Loop Unrolling Assumption: Standard five stage pipeline Empty cycles between instructions before the result.
Comparison and Evaluation of Back Translation Algorithms for Static Single Assignment Form Masataka Sassa #, Masaki Kohama + and Yo Ito # # Dept. of Mathematical.
Register Usage Keep as many values in registers as possible Register assignment Register allocation Popular techniques – Local vs. global – Graph coloring.
P3 / 2004 Register Allocation. Kostis Sagonas 2 Spring 2004 Outline What is register allocation Webs Interference Graphs Graph coloring Spilling Live-Range.
Register allocation Morgensen, Torben. "Register Allocation." Basics of Compiler Design. pp from (
Register Allocation Zach Ma.
Register Allocation CS 320 David Walker (with thanks to Andrew Myers for most of the content of these slides)
Coalescing Register Allocation CS153: Compilers Greg Morrisett.
COMPILERS Register Allocation hussein suleman uct csc305w 2004.
1 CS 201 Compiler Construction Machine Code Generation.
Graph-Coloring Register Allocation CS153: Compilers Greg Morrisett.
Stanford University CS243 Winter 2006 Wei Li 1 Register Allocation.
Register Allocation CS 671 March 27, CS 671 – Spring Register Allocation - Motivation Consider adding two numbers together: Advantages: Fewer.
Extensibility, Safety and Performance in the SPIN Operating System Presented by Allen Kerr.
1 CS 201 Compiler Construction Lecture 12 Global Register Allocation.
Improving code generation. Better code generation requires greater context Over expressions: optimal ordering of subtrees Over basic blocks: Common subexpression.
Register Allocation (Slides from Andrew Myers). Main idea Want to replace temporary variables with some fixed set of registers First: need to know which.
Code Generation Simple Register Allocation Mooly Sagiv html:// Chapter
Prof. Bodik CS 164 Lecture 171 Register Allocation Lecture 19.
Code Generation for Basic Blocks Introduction Mooly Sagiv html:// Chapter
Register Allocation (via graph coloring)
U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science Emery Berger University of Massachusetts, Amherst Advanced Compilers CMPSCI 710.
Register Allocation (via graph coloring). Lecture Outline Memory Hierarchy Management Register Allocation –Register interference graph –Graph coloring.
1 Liveness analysis and Register Allocation Cheng-Chia Chen.
Improving Code Generation Honors Compilers April 16 th 2002.
4/29/09Prof. Hilfinger CS164 Lecture 381 Register Allocation Lecture 28 (from notes by G. Necula and R. Bodik)
Register Allocation and Spilling via Graph Coloring G. J. Chaitin IBM Research, 1982.
Source Code Basics. Code For a computer to execute instructions, it needs to be in binary Each instruction is given a number Known as “operation code”
Linear Scan Register Allocation POLETTO ET AL. PRESENTED BY MUHAMMAD HUZAIFA (MOST) SLIDES BORROWED FROM CHRISTOPHER TUTTLE 1.
Applying Data Copy To Improve Memory Performance of General Array Computations Qing Yi University of Texas at San Antonio.
Just-In-Time Java Compilation for the Itanium Processor Tatiana Shpeisman Guei-Yuan Lueh Ali-Reza Adl-Tabatabai Intel Labs.
Operating System Chapter 7. Memory Management Lynn Choi School of Electrical Engineering.
Fast, Effective Code Generation in a Just-In-Time Java Compiler Rejin P. James & Roshan C. Subudhi CSE Department USC, Columbia.
JIT in webkit. What’s JIT See time_compilation for more info. time_compilation.
Research in Compilers and How it Relates to Software Engineering Part I: Compiler Research Tomofumi Yuki EJCP 2015 June 22, Nancy.
Java Virtual Machine Case Study on the Design of JikesRVM.
1 Instruction Sets and Beyond Computers, Complexity, and Controversy Brian Blum, Darren Drewry Ben Hocking, Gus Scheidt.
U NIVERSITY OF D ELAWARE C OMPUTER & I NFORMATION S CIENCES D EPARTMENT Optimizing Compilers CISC 673 Spring 2009 Register Allocation John Cavazos University.
CMPE 511 Computer Architecture A Faster Optimal Register Allocator Betül Demiröz.
Chapter 8 – Main Memory (Pgs ). Overview  Everything to do with memory is complicated by the fact that more than 1 program can be in memory.
Interference Graphs for Programs in Static Single Information Form are Interval Graphs Philip Brisk Processor Architecture Laboratory (LAP) EPFL Lausanne,
Chapter 4 Memory Management Virtual Memory.
Garbage Collection and Memory Management CS 480/680 – Comparative Languages.
1 Compiler Construction (CS-636) Muhammad Bilal Bashir UIIT, Rawalpindi.
Basic Memory Management 1. Readings r Silbershatz et al: chapters
Register Usage Keep as many values in registers as possible Keep as many values in registers as possible Register assignment Register assignment Register.
Register Allocation CS 471 November 12, CS 471 – Fall 2007 Register Allocation - Motivation Consider adding two numbers together: Advantages: Fewer.
Searching Topics Sequential Search Binary Search.
2/22/2016© Hal Perkins & UW CSEP-1 CSE P 501 – Compilers Register Allocation Hal Perkins Winter 2008.
Sunpyo Hong, Hyesoon Kim
CS412/413 Introduction to Compilers and Translators April 2, 1999 Lecture 24: Introduction to Optimization.
©SoftMoore ConsultingSlide 1 Code Optimization. ©SoftMoore ConsultingSlide 2 Code Optimization Code generation techniques and transformations that result.
Eliminating External Fragmentation in a Non-Moving Garbage Collector for Java Author: Fridtjof Siebert, CASES 2000 Michael Sallas Object-Oriented Languages.
More Code Generation and Optimization Pat Morin COMP 3002.
Code Optimization.
Register Allocation Hal Perkins Autumn 2009
Chapter 9 – Real Memory Organization and Management
Topic Register Allocation
Linear Scan Register Allocation Massimiliano Poletto, Vivek Sarkar A Fast, Memory-Efficient Register Allocation Framework for Embedded Systems Sathyanarayanan.
Optimization Code Optimization ©SoftMoore Consulting.
Register Allocation Hal Perkins Autumn 2011
Register Allocation Hal Perkins Summer 2004
Register Allocation Hal Perkins Autumn 2005
Lecture 16: Register Allocation
Lecture 17: Register Allocation via Graph Colouring
(via graph coloring and spilling)
Presentation transcript:

November 29, 2005Christopher Tuttle1 Linear Scan Register Allocation Massimiliano Poletto (MIT) and Vivek Sarkar (IBM Watson)

November 29, 2005Christopher Tuttle2 Introduction Register Allocation: The problem of mapping an unbounded number of virtual registers to physical ones Good register allocation is necessary for performance –Several SPEC benchmarks benefit an order of magnitude from good allocation –Core memory (and even caches) are slow relative to registers Register allocation is expensive –Most algorithms are variations on Graph Coloring –Non-trivial algorithms require liveness analysis –Allocators can be quadratic in the number of live intervals

November 29, 2005Christopher Tuttle3 Motivation On-line compilers need generate code quickly –Just-In-Time compilation –Dynamic code generation in language extensions (‘C) –Interactive environments (IDEs, etc.) Sacrifice code speed for a quicker compile. –Find a faster allocation algorithm –Compare it to the best allocation algorithms

November 29, 2005Christopher Tuttle4 Definitions Live interval: A sequence of instructions, outside of which a variable v is never live. (For this paper, intervals are assumed to be contiguous) Spilling: Variables are spilled when they are stored on the stack Interference: Two live ranges interfere if they are simultaneously live in a program.

November 29, 2005Christopher Tuttle5 Ye Olde Graph Coloring Model allocation as a graph coloring problem Nodes represent live ranges Edges represent interferences Colorings are safe allocations Order V 2 in live variables (See Chaitin82 on PLDI list)

November 29, 2005Christopher Tuttle6 Linear Scan Algorithm Compute live variable analysis Walk through intervals in order: –Throw away expired live intervals. –If there is contention, spill the interval that ends furthest in the future. –Allocate new interval to any free register Complexity: O(V log R) for V vars and R registers

November 29, 2005Christopher Tuttle7 Example With Two Registers 1. Active =

November 29, 2005Christopher Tuttle8 Example With Two Registers 1. Active = 2. Active =

November 29, 2005Christopher Tuttle9 Example With Two Registers 1. Active = 2. Active = 3. Active = ; Spill =

November 29, 2005Christopher Tuttle10 Example With Two Registers 1. Active = 2. Active = 3. Active = ; Spill = 4. Active = ; Spill =

November 29, 2005Christopher Tuttle11 Example With Two Registers 1. Active = 2. Active = 3. Active = ; Spill = 4. Active = ; Spill = 5. Active = ; Spill =

November 29, 2005Christopher Tuttle12 Evaluation Overview Evaluate both compile-time and run-time performance Two Implementations –ICODE dynamic ‘C compiler; (already had efficient allocators) Benchmarks from the previously used ICODE suite (all small) Compare against tuned graph-coloring and usage counts Also evaluate a few pathological program examples –Machine SUIF Selected benchmarks from SPEC92 and SPEC95 Compare against graph-coloring, usage counts, and second-chance binpacking Compare both metrics on both implementations

November 29, 2005Christopher Tuttle13 Compile-Time on ICODE ‘C Usage Counts, Linear Scan, and Graph Coloring shown Linear Scan allocation is always faster than Graph Coloring

November 29, 2005Christopher Tuttle14 Compile-Time on SUIF Linear Scan allocation is around twice as fast than Binpacking –(Binpacking is known to be slower than Graph Coloring)

November 29, 2005Christopher Tuttle15 Pathological Cases N live variable ranges interfering over the entire program execution Other pathological cases omitted for brevity; see Figure 6.

November 29, 2005Christopher Tuttle16 Compile-Time Bottom Line Linear Scan –is faster than Binpacking and Graph Coloring –works in dynamic code generation (ICODE) –scales more gracefully than Graph Coloring … but does it generate good code?

November 29, 2005Christopher Tuttle17 Run-Time on ICODE ‘C Usage Counts, Linear Scan, and Graph Coloring shown Dynamic kernels do not have enough register pressure to illustrate differences

November 29, 2005Christopher Tuttle18 Run-Time on SUIF / SPEC Usage Counts, Linear Scan, Graph Coloring and Binpacking shown Linear Scan makes a fair performance trade-off (5% - 10% slower than G.C.)

November 29, 2005Christopher Tuttle19 Evaluation Summary Linear Scan –is faster than Binpacking and Graph Coloring –works in dynamic code generation (ICODE) –scales more gracefully than Graph Coloring –generates code within 5-10% of Graph Coloring Implementation alternatives evaluated in paper –Fast Live Variable Analysis –Spilling Hueristics

November 29, 2005Christopher Tuttle20 Conclusions Linear Scan is a faster alternative to Graph Coloring for register allocation Linear Scan generates faster code than similar algorithms (Binpacking, Usage Counts) Where can we go from here? –Reduce register interference with live range splitting –Use register move coalescing to free up extra registers

November 29, 2005Christopher Tuttle21 Questions?