1 / 16

A Framework for Unrestricted Whole-Program Optimization

A Framework for Unrestricted Whole-Program Optimization. Spyridon Triantafyllis, Matthew J. Bridges , Easwaran Raman, Guilherme Ottoni, David I. August The Liberty Research Group Department of Computer Science Princeton University. Procedure-Based Compilation. Procedure-Based Compilation

yoko
Download Presentation

A Framework for Unrestricted Whole-Program Optimization

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. A Framework for UnrestrictedWhole-Program Optimization Spyridon Triantafyllis, Matthew J. Bridges, Easwaran Raman, Guilherme Ottoni, David I. August The Liberty Research Group Department of Computer Science Princeton University

  2. Procedure-Based Compilation Procedure-Based Compilation Pros: • Well Known Cons: • Can not exploit opportunities that cross procedures g() f(a,b,c) h() if (EOB) z=x*y f(x,y,5) f(1,2,3) fill B d=a*b …=z ret

  3. Interprocedural Analysis Interprocedural Analysis [Sharir’78] [Morel’78] [Reps’95] Pros: • Increases available information • Enables some optimization across procedure boundaries Cons: • Has to analyze the entire program • Optimizations need to respect the procedure boundary g() f(a,b,c) h() if (EOB) z=x*y f(x,y,5) f(1,2,3) fill B d=a*b …=z ret

  4. Interprocedural Analysis & Interprocedural Opti Interprocedural Analysis [Sharir’78] [Morel’78] [Reps’95] Pros: • Increases available information • Enables some optimization across procedure boundaries Cons: • Has to analyze the entire program • Optimizations need to respect the procedure boundary • Most optimizations will still be intraprocedural g() f(a,b,c,z) h() if (EOB) z=x*y f(x,y,5,z) f(1,2,3,2) fill B d=z …=z ret

  5. Inlining Inlining [Scheifler ‘77] [Hwu’89] [Chang’92] Pros: • Increases optimization scope • Enables specialization • Doesn’t require opti to understand interprocedural concerns Cons: • Hard limit on procedure size • Unnecessary code growth g’() z=x*y if (EOB) fill B f(a,b,c) if (EOB) d=z fill B h() d=a*b jump f(1,2,3) …=z ret

  6. Partial Inlining Partial Inlining [Suganuma’03][Way’00] Pros: • Can alleviate some code growth Cons: • Gains are limited g() z=x*y f’() fill B if (EOB) f’() return f(a,b,c) if (EOB) d=z h() fill B d=a*b jump f(1,2,3) ret …=z

  7. g() f(a,b,c) h() z=x*yf(x,y,5) f(1,2,3) Why Procedures? Procedures • Calling convention boundary • Single-Entry, Single-Exit Pros: • Implicit correlated edges - context sensitivity • Natural unit for divide & conquer compilation Cons: • Optimized for software-engineering • Restricts optimization if (EOB) z=x*y fill B d=a*b d=z …=z ret We don’t have to use procedures!

  8. The Whole-Program CFG Retain useful traits of procedures • Correlated edges • Compilation unit Goal: Obtain an optimizable whole-program representation • Increase optimization scope • Allow all opti to operate on increased scope without change • Targeted code growth if (EOB) z=x*y fill B d=a*b …=z jump

  9. B (1 (2 A G D C The Whole-Program CFG F H )1 )2 E Retain useful traits of procedures • Correlated edges • Compilation unit Goal: Obtain an optimizable whole-program representation • Increase optimization scope • Allow all opti to operate on increased scope without change • Targeted code growth Represent calls and returns as special control-flow transitions [Sharir’78]

  10. Whole-Program Optimizations Optimization destroys the program’s procedural structure! • Example: Superblock Formation [Hwu’92] Unconventional call structures! • Many-to-many call <-> return relation • Must rediscover structure for summary edges A (1 B B (2 G D C’ C H )2 E’ E )1 )1 F’ F

  11. Analyzing the Whole-Program CFG (BE) B’ C’ E’ (BF’) B’ C E D (B’F’) B C E D Context-Sensitive Interprocedural Analysis[Sharir‘78] meet over all realizable paths Identify Entry-Exit Pairs (EEP): • Correlated call & return arcs • Allows use of summary edges • Blocks may belong to more than one EEP A (1 B’ B (2 G D C’ C H )2 E’ E )1 )1 F’ F

  12. Determining a Compilation Unit: Region Formation Region Formation [Hank’95] • arbitrarily shaped, compiler-selected compilation unit A (1 B’ Region Selection • Select seed & add neighbors (profile, structure, dataflow …) B (2 G D Success Criteria • Optimizability vs.compile time • Few too small or too big regions • Intra-region transitions » inter-region transitions Encapsulation • Make regions independently optimizable C’ C H )2 E’ E )1 )1 F’ F Compiler is free to select its own optimization units!

  13. Evaluation Framework: The Velocity Compiler Frontend Frontend Frontend • Evaluation: • Inliner & Opti. ported from IMPACT • Targeting Itanium 2 Procedures Procedures Procedures Inlining WCFG DetermineCompilation Unit Region Form. Procedures Regions Superblock Superblock Superblock Classical & ILP Optimizer Classical & ILP Optimizer Classical & ILP Optimizer Optimize Compilation Unit Scheduling Scheduling Scheduling Executable Executable Executable Baseline Inlining PBE

  14. Code Growth 1.45 1.23 Code Size

  15. Speedup - Train Input 1.07

  16. Conclusion Procedure boundaries restrict optimization! Ways to deal with procedures exist, but limited • Interprocedural analysis & opti: Scales badly, not always possible • Inlining: Unnecessary Code growth • Procedures are not the right compilation unit PBE offers unrestricted and practical whole-program optimization • An expanded form of interprocedural analysis • New region formation framework and heuristics • An interprocedural region encapsulation method

More Related