200 likes | 320 Views
An Evaluation of Staged Run-Time Optimizations in DyC. Brian Grant, Matthai Philipose, Markus Mock, Craig Chambers, and Susan J. Eggers presented by Laura Hiatt April 28, 2006. Run-Time Optimizations Motivation. In static optimizations, optimize based on static invariants
E N D
An Evaluation of Staged Run-Time Optimizations in DyC Brian Grant, Matthai Philipose, Markus Mock, Craig Chambers, and Susan J. Eggers presented by Laura Hiatt April 28, 2006
Run-Time Optimizations Motivation • In static optimizations, optimize based on static invariants • But - code often has invariants that aren’t known until run-time • Run-time optimizations can take advantage of these
Selective, value-specific dynamic compilation • Selective dynamic compilation • Dynamically compile selected regions at run-time • Value-specific compilation • Run-time dynamic constant propagation and folding
DyC in a nutshell • Programmer annotates code • Static variables • Other policies as well • DyC isolates ‘dynamic regions’ based on these variables • Compiles non-dynamic regions statically
DyC in a nutshell • Compiles dynamic regions in stages • Does as much as possible statically (analysis, etc.) • Compilation is at run time when the static variable values are known • Creates compiler for each dynamic region • Generates code where the static variables are constants
Run-time optimizations • Dynamic-to-static promotions and polyvariant specialization • At the beginning of each dynamic region, the relevant variables are promoted from dynamic to static • Multiple versions of the code are generated for each combination of possible promoted values
Run-time optimizations • Static loads and calls • Usually memory assumed to be dynamic • Treat loads of invariant parts of structures, or functions, as static • Unchecked dispatching • If only one value of a static variable, don’t check in cache for correct version of dynamically compiled code
Run-time optimizations • Complete loop unrolling • Based on polyvariant specialization • Completely eliminates unrolled loop • Copy propagation, dead-code elimination, strength reduction
Results • Dynamic region performance
Results • Whole program performance
Results • Dynamic region performance - feature comparison
Questions • How fair is it to place the burden of correctness on the programmer? • i.e. unchecked dispatching, static loads and calls • Loop unrolling can get out of hand • NXN matrix could get so big it doesn’t fit in cache • Given the variability in performance based on which optimizations are used, is this worth it?
Selective, value-specific dynamic compilation • Research has shown that the overhead of run-time compilation amortized by increased efficiency of program • But this success is limited to single kernels • Dynamic compilation can’t cope “reasonably” with extra complexity of larger programs • What can we do about larger programs? • Some approaches exist, but haven’t made much progress
Other optimizations • Internal promotions • Promotions at arbitrary program points in the middle of a dynamic region • Polyvariant division • Different combinations of static variables • Strength reduction • Using cheaper operations
DyC Overhead • Cache lookups • Memory allocation • Handling dynamic branches • Checks for copy propagation • Dead-code elimination • Strength reduction • Operations to insure instruction-cache coherence • Instruction construction and emission • Branch patching • Hole patching • Static computations