DOC PREVIEW
UCSD CSE 231 - Linear Scan Register Allocation

This preview shows page 1-2-20-21 out of 21 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 21 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 21 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 21 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 21 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 21 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Linear Scan Register AllocationIntroductionMotivationDefinitionsYe Olde Graph ColoringLinear Scan AlgorithmExample With Two RegistersSlide 8Slide 9Slide 10Slide 11Evaluation OverviewCompile-Time on ICODE ‘CCompile-Time on SUIFPathological CasesCompile-Time Bottom LineRun-Time on ICODE ‘CRun-Time on SUIF / SPECEvaluation SummaryConclusionsQuestions?November 29, 2005 Christopher Tuttle 1Linear Scan Register AllocationMassimiliano Poletto (MIT)and Vivek Sarkar (IBM Watson)November 29, 2005 Christopher Tuttle 2Introduction•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 intervalsNovember 29, 2005 Christopher Tuttle 3Motivation•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 algorithmsNovember 29, 2005 Christopher Tuttle 4Definitions•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, 2005 Christopher Tuttle 5Ye Olde Graph Coloring•Model allocation as a graph coloring problem•Nodes represent live ranges•Edges represent interferences•Colorings are safe allocations•Order V2 in live variables•(See Chaitin82 on PLDI list)November 29, 2005 Christopher Tuttle 6Linear 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 registersNovember 29, 2005 Christopher Tuttle 7Example With Two Registers•1. Active = < A >November 29, 2005 Christopher Tuttle 8Example With Two Registers•1. Active = < A >•2. Active = < A, B >November 29, 2005 Christopher Tuttle 9Example With Two Registers•1. Active = < A >•2. Active = < A, B >•3. Active = < A, B > ; Spill = < C >November 29, 2005 Christopher Tuttle 10Example With Two Registers•1. Active = < A >•2. Active = < A, B >•3. Active = < A, B > ; Spill = < C >•4. Active = < D, B > ; Spill = < C >November 29, 2005 Christopher Tuttle 11Example With Two Registers•1. Active = < A >•2. Active = < A, B >•3. Active = < A, B > ; Spill = < C >•4. Active = < D, B > ; Spill = < C >•5. Active = < D, E > ; Spill = < C >November 29, 2005 Christopher Tuttle 12Evaluation 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 implementationsNovember 29, 2005 Christopher Tuttle 13Compile-Time on ICODE ‘C•Usage Counts, Linear Scan, and Graph Coloring shown•Linear Scan allocation is always faster than Graph ColoringNovember 29, 2005 Christopher Tuttle 14Compile-Time on SUIF•Linear Scan allocation is around twice as fast than Binpacking–(Binpacking is known to be slower than Graph Coloring)November 29, 2005 Christopher Tuttle 15Pathological Cases•N live variable ranges interfering over the entire program execution•Other pathological cases omitted for brevity; see Figure 6.November 29, 2005 Christopher Tuttle 16Compile-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, 2005 Christopher Tuttle 17Run-Time on ICODE ‘C•Usage Counts, Linear Scan, and Graph Coloring shown•Dynamic kernels do not have enough register pressure to illustrate differencesNovember 29, 2005 Christopher Tuttle 18Run-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, 2005 Christopher Tuttle 19Evaluation 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 HueristicsNovember 29, 2005 Christopher Tuttle 20Conclusions•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 registersNovember 29, 2005 Christopher Tuttle


View Full Document

UCSD CSE 231 - Linear Scan Register Allocation

Download Linear Scan Register Allocation
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Linear Scan Register Allocation and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Linear Scan Register Allocation 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?