History Rgistr Allotion Exmpl As ol s intrmit o Consir this progrm with six vrils: := + := + := - 1 Us in th originl FORTRAN ompilr (1950 s) Vry ru lg

Similar documents
Lecture Outline. Memory Hierarchy Management. Register Allocation. Register Allocation. Lecture 19. Cache Management. The Memory Hierarchy

Global Register Allocation

Lecture Outline. Memory Hierarchy Management. Register Allocation. Register Allocation. Lecture 38. Cache Management. Managing the Memory Hierarchy

CSE P 501 Compilers. Register Allocation Hal Perkins Spring UW CSE P 501 Spring 2018 P-1

Lecture 39: Register Allocation. The Memory Hierarchy. The Register Allocation Problem. Managing the Memory Hierarchy

Outline. Graphs Describing Precedence. Graphs Describing Precedence. Topological SorFng of DAGs. Graphs Describing Precedence 4/25/12. Part 10.

Reachability. Directed DFS. Strong Connectivity Algorithm. Strong Connectivity. DFS tree rooted at v: vertices reachable from v via directed paths

Interference graph. Register Allocation. A bigger example. Units of allocation

Review: Binary Trees. CSCI 262 Data Structures. Search Trees. In Order Traversal. Binary Search Trees 4/10/2018. Review: Binary Tree Implementation

Register Allocation. Register Allocation

CSE 401/M501 Compilers

Compiling: Examples and Sample Problems

CS 331: Artificial Intelligence Bayesian Networks (Inference) Inference

WORKSHOP 2 Solid Shell Composites Modeling

Finding a Funicular Curve Through Two Points

CS553 Lecture Introduction to Data-flow Analysis 1

12/3/2008. Schedule. Target Code Generation. Target Code Generation. Gap: machine code. Tasks of Code Generator. These tasks interact

Portability, Scalability, and Numerical Stability in Accelerated Kernels

1⅝" - 3¾" (40-95mm) FIXTURE BASE. 3/4" (19mm) 4" - 6¾" ( mm) ALLEN KEY (INCLUDED)

CS453 INTRODUCTION TO DATAFLOW ANALYSIS

Graph Theory & Applications. Boundaries Using Graphs. Graph Search. Find the route that minimizes. cost

WORKSHOP 12 ANCHOR LOADS AND BOUNDARY CONDITIONS USING A FIELD

Lesson 4.4. Euler Circuits and Paths. Explore This

Reading. K-D Trees and Quad Trees. Geometric Data Structures. k-d Trees. Range Queries. Nearest Neighbor Search. Chapter 12.6

Overview Linear Algebra Review Linear Algebra Review. What is a Matrix? Additional Resources. Basic Operations.

Definition of Regular Expression

S675, S750 Stretchair Parts List A D

Software Pipelining Can we decrease the latency? Goal of SP Lecture. Seth Copen Goldstein Software Pipelining

CS153: Compilers Lecture 20: Register Allocation I

Tiling the plane with equilateral convex pentagons

8.3 INTEGRATION BY PARTS

WORKSHOP 17 BOX BEAM WITH TRANSIENT LOAD

Store Tours Washington DC

Below, are instructions about how to set each goal and report achievements in Your Club, Service, and Foundation Giving.

VAT GX - IP VIDEO FIELD ADD-ON/RETROFIT SPECIFICATIONS PERSPECTIVE SIDE VIEW MOUNTING CONNECTIONS CALL SINGLE CHANNEL ENCODER

Quadrilateral Decomposition by Two-Ear Property Resulting in CAD Segmentation

VAT GX - IP VIDEO FIELD ADD-ON/RETROFIT SINGLE CHANNEL ENCODER

The Network Layer: Routing Algorithms. The Network Layer: Routing & Addressing Outline

Characteristics of Fault Simulation. Fault Simulation Techniques. Parallel Fault Simulation. Parallel Fault Simulation

CPSC 826 Internetworking. The Network Layer: Routing & Addressing Outline. The Network Layer: Routing Algorithms. Routing Algorithms Taxonomy

CMPUT101 Introduction to Computing - Summer 2002

Greedy Algorithm. Algorithm Fall Semester

Shift. Reduce. Review: Shift-Reduce Parsing. Bottom-up parsing uses two actions: Bottom-Up Parsing II. ABC xyz ABCx yz. Lecture 8.

Paradigm 5. Data Structure. Suffix trees. What is a suffix tree? Suffix tree. Simple applications. Simple applications. Algorithms

2018 How to Apply. Application Guide. BrandAdvantage

Midterm 2 - Solutions 1

SJ QUINNEY COLLEGE OF LAW

Greedy Algorithms. Interval Scheduling. Greedy Algorithm. Optimality. Greedy Algorithm (cntd) Greed is good. Greed is right. Greed works.

In the last lecture, we discussed how valid tokens may be specified by regular expressions.

CMST 220 PUBLIC SPEAKING

" dx v(x) $ % You may also have seen this written in shorthand form as. & ' v(x) + u(x) '# % ! d

CS311H: Discrete Mathematics. Graph Theory IV. A Non-planar Graph. Regions of a Planar Graph. Euler s Formula. Instructor: Işıl Dillig

THE OTTAWA CHINESE ALLIANCE CHURCH

10.2 Graph Terminology and Special Types of Graphs

How to fix your 260Z or 280Z clock.

Chapter 9. Greedy Technique. Copyright 2007 Pearson Addison-Wesley. All rights reserved.

Internet Routing. IP Packet Format. IP Fragmentation & Reassembly. Principles of Internet Routing. Computer Networks 9/29/2014.

FLASHING CHRISTMAS TREE KIT

Presentation for use with the textbook, Algorithm Design and Applications, by M. T. Goodrich and R. Tamassia, Wiley, Directed Graphs BOS SFO

MTH 146 Conics Supplement

Homework. Context Free Languages III. Languages. Plan for today. Context Free Languages. CFLs and Regular Languages. Homework #5 (due 10/22)

Fig.25: the Role of LEX

On Some Maximum Area Problems I

CS412/413. Introduction to Compilers Tim Teitelbaum. Lecture 4: Lexical Analyzers 28 Jan 08

Minimal Memory Abstractions

Performance, Scalability, and Numerical Stability of Manycore. Wen-mei Hwu University of Illinois at Urbana-Champaign

Compression Outline :Algorithms in the Real World. Lempel-Ziv Algorithms. LZ77: Sliding Window Lempel-Ziv

To Do. Mesh Data Structures. Mesh Data Structures. Motivation. Outline. Advanced Computer Graphics (Fall 2010) Desirable Characteristics 1

This module calculates the motor speed based on a rotor position measurement when the direction information is available.

If you are at the university, either physically or via the VPN, you can download the chapters of this book as PDFs.

Lexical Analysis: Constructing a Scanner from Regular Expressions

Advertising Rates for the L.A. Roadster s 46th Annual Show Program. Deadline May 1, 2010 Contact Don Wilson (818)

i e ai E ig e v / gh E la ES h E A X h ES va / A SX il E A X a S

10.5 Graphing Quadratic Functions

Distance vector protocol

CS321 Languages and Compiler Design I. Winter 2012 Lecture 5

EE 231 Fall EE 231 Homework 10 Due November 5, 2010

A Brief Summary of Draw Tools in MS Word with Examples! ( Page 1 )

COMP 423 lecture 11 Jan. 28, 2008

Dynamic Programming. Andreas Klappenecker. [partially based on slides by Prof. Welch] Monday, September 24, 2012

MERGE-BASED SpMV PERFECT WORKLOAD BALANCE. GUARANTEED. Duane Merrill, NVIDIA Research

Duality in linear interval equations

2 Computing all Intersections of a Set of Segments Line Segment Intersection

What are suffix trees?

Model Intelli-INCH. Miniature Stepper Motor Controllers/Drivers. Electrical Specifications. Models. Key Features. i/o connector, Intelli-inch-lr

Type Checking. Roadmap (Where are we?) Last lecture Context-sensitive analysis. This lecture Type checking. Symbol tables

Felony Sentences in State Courts, 2002

Correcting the Dynamic Call Graph Using Control Flow Constraints

ISO VIEW COVER, EXPRESS EXIT 4X4 FLIP COVER OPEN VIEW EXPRESS EXIT ON TROUGH VIEW

Math 227 Problem Set V Solutions. f ds =

cisc1110 fall 2010 lecture VI.2 call by value function parameters another call by value example:

CS 551 Computer Graphics. Hidden Surface Elimination. Z-Buffering. Basic idea: Hidden Surface Removal

Class Overview. Database Design. Database Design Process. Database Design. Introduction to Data Management CSE 414

H SERIES. Percentage Basics. Curriculum Ready.

3 4. Answers may vary. Sample: Reteaching Vertical s are.

TYPICAL RAISED POSITION

About Notes And Symbols

Typing with Weird Keyboards Notes

Tries. Yufei Tao KAIST. April 9, Y. Tao, April 9, 2013 Tries

Systems in Three Variables. No solution No point lies in all three planes. One solution The planes intersect at one point.

Transcription:

Th Mmory Hirrhy Avn Compilrs CMPSCI 710 Spring 2003 Highr = smllr, str, losr to CPU A rl sktop mhin (min) Rgistr Allotion Emry Brgr rgistrs 8 intgr, 8 loting-point; 1-yl ltny L1 h 8K t & instrutions; 2-yl ltny L2 h 512K; 7-yl ltny Univrsity o Msshustts, Amhrst Min mmory (stors & los) Disk (il I/O) Two things mintin this strtion: Hrwr Movs t twn mmory n hs Compilr Movs t twn mmory n rgistrs Cnit vlus: Vrils Tmporris Lrg onstnts Whn n, spill rgistrs to mmory Expliit nms Unlik ll othr lvls o hirrhy Sr Smll rgistr ils (st o ll rgistrs) Som rsrv y oprting systm Importnt low-lvl optimiztion Rgistrs r 2x 7x str thn h ¾ Juiious us ig prormn improvmnts 4 Rgistr Allotion: Complitions Rgistr llotion ssigns rgistrs to vlus 2 Dinition History Intrrn grphs Grph oloring Rgistr spilling 3 Rgistr Allotion: Dinition 40 GB; 38,000,000 yl ltny (!) Introution Rgistr Allotion Disk Ovrviw Progrmmr viw: only two lvls o mmory 1GB; 100 yl ltny Mnging th Mmory Hirrhy RAM 5.g., BP, SP Complit Wir onstrints, sp. on CISC rhitturs Spil rgistrs: zro-lo 6 1

History Rgistr Allotion Exmpl As ol s intrmit o Consir this progrm with six vrils: := + := + := - 1 Us in th originl FORTRAN ompilr (1950 s) Vry ru lgorithms with th ssumption tht n i tr us No rkthroughs until 1981! Chitin invnt rgistr llotion shm s on grph oloring ¾ Equivln irst not y Cok t l., 1971 r1 := r2 + r3 r1 := r1 + r4 r1 := r1-1 7 Bsi Rgistr Allotion I 8 Algorithm: Prt I Vlu in tmporry not n or rst o th omputtion Cn llot,, n ll to on rgistr (r1): Simpl huristi, works wll in prti Tmporry n rus tr := + Sm with tmporry Comput liv vrils or h point: {,,} {,,} D tmporry n rus {,,} := + := - := + {,,,} {,} Bsi rul: Tmporris t1 n t2 n shr sm rgistr i t ny point in th progrm t most on o t1 or t2 is liv! := + := 2 * {,} {,,,} := - 1 {,} {} := + {} Two tmporris liv simultnously ¾ I liv simultnously t som point in th progrm Two tmporris n llot to sm rgistr i no g onnts thm For our xmpl: {,,} {,,} {,,} {,,,} {,} {,,,} {,} {} No or h tmporry Unirt g twn t1 n t2 Cnnot llot in th sm rgistr Construt rgistr intrrn grph 10 Rgistr Intrrn Grph: Exmpl Rgistr Intrrn Grph 9 n nnot in th sm rgistr n n in th sm rgistr 11 12 2

Rgistr Intrrn Grph: Proprtis Extrts xtly th inormtion n to hrtriz lgl rgistr ssignmnts Givs glol pitur o rgistr rquirmnts A itionl gs in RIG to no rhitturl intriis Nos onnt y g hv irnt olors Equivlntly: no jnt nos hv sm olor Grph k-olorl = n olor with k olors Now wht o w o with this grph? Consir th xmpl RIG r2 W n to ssign olors (rgistrs) to grph nos (tmporris) Lt k = numr o mhin rgistrs r3 r1 r4 r2 I th RIG is k-olorl, thr s rgistr ssignmnt tht uss no mor thn k rgistrs 15 16 Computing Grph Colorings Unr this oloring th o oms: r2 := r3 + r4 r3 := -r2 r2 := r3 + r1 How o w omput oloring or intrrn grph? r3 := r3 + r2 r1 := 2 * r2 r3 Thr is no oloring with wr thn 4 olors Thr r 4-olorings o this grph Grph Coloring Exmpl, Continu 14 Grph Coloring Exmpl In our prolm, olors = rgistrs 13 Rgistr Allotion Through Grph Coloring Grph oloring: ssignmnt o olors to nos Ovr th ntir low grph Atr RIG onstrution, rgistr llotion is rhittur-inpnnt Grph Coloring NP-hr! For givn # o rgistrs, oloring my not xist r2 := r2-1 r3 := r1 + r4 Solution 17 Us huristis (hr, Briggs) 18 3

Grph Coloring Huristi Osrvtion: gr < k rul Ru grph: Pik no t with < k nighors in RIG Elimint t n its gs rom RIG I th rsulting grph hs k-oloring, so os th originl grph Why? Lt 1,, n olors ssign to nighors o t in ru grph Sin n < k, w n pik som olor or t irnt rom thos o its nighors Grph Coloring Huristi, Continu Huristi: Pik no t with wr thn k nighors Put t on stk n rmov it rom th RIG Rpt until th grph hs on no Strt ssigning olors to nos on th stk (strting with th lst no ) At h stp, pik olor irnt rom thos ssign to lry-olor nighors Dprtmnt o Computr Sin 19 Dprtmnt o Computr Sin 20 Grph Coloring Exmpl (1) Strt with th RIG n with k = 4: Stk: {} Rmov n thn Grph Coloring Exmpl (2) Now ll nos hv wr thn 4 nighors n n rmov:,,, Stk: {, } Dprtmnt o Computr Sin 21 Dprtmnt o Computr Sin 22 Grph Coloring Exmpl (2) Strt ssigning olors to:,,,,, r 1 r 2 r 2 r 3 r 3 r 4 Dprtmnt o Computr Sin 23 Wht i th Huristi Fils? Wht i uring simpliition w gt to stt whr ll nos hv k or mor nighors? Exmpl: try to in 3-oloring o th RIG: Dprtmnt o Computr Sin 24 4

Wht i th Huristi Fils? Wht i th Huristi Fils? Rmov n gt stuk (s shown low) Pik no s nit or spilling Assum tht is pik Rmov n ontinu th simpliition Simpliition now sus:,,, 25 Wht i th Huristi Fils? Optimisti oloring il must spill tmporry Allot mmory lotion s hom o r3 r2 Typilly in urrnt stk rm Cll this rss Bor h oprtion tht uss, insrt Atr h oprtion tht ins, insrt := lo r1 stor, r3 28 Romputing Livnss Inormtion Nw o tr spilling Nw livnss inormtion tr spilling: {,,} {,,} := + := - := lo := + {,,} := + := 2 * stor, 27 Spilling Exmpl 26 Spilling During ssignmnt phs, w gt to th point whn w hv to ssign olor to Hop: mong th 4 nighors o, w us lss thn 3 olors optimisti oloring? := 2 * stor, {,} := - 1 {,} {,} := lo := + {,} := + := - := lo := + {,,} {,,,} := + {,} := lo := + {,,,} := - 1 {} {} 29 30 5

Romputing Livnss Inormtion Nw livnss ino lmost s or, ut: is liv only Btwn := lo n th nxt instrution Btwn stor, n th pring instrution Spilling rus th liv rng o Rus its intrrns Rsults in wr nighors in RIG or Dprtmnt o Computr Sin 31 Romput RIG Atr Spilling Rmov som gs o spill no Hr, still intrrs only with n Rsulting RIG is 3-olorl Dprtmnt o Computr Sin 32 Spilling, Continu Aitionl spills might rquir or oloring is oun Triky prt: iing wht to spill Possil huristis: Spill tmporris with most onlits Spill tmporris with w initions n uss Avoi spilling in innr loops All r orrt Conlusion Rgistr llotion: must hv optimiztion in most ompilrs: Intrmit o uss too mny tmporris Mks ig irn in prormn Grph oloring: Powrul rgistr llotion shm Dprtmnt o Computr Sin 33 Dprtmnt o Computr Sin 34 Nxt Tim Shuling R ACDI Chptr 17 Dprtmnt o Computr Sin 35 6