Download
code specialization n.
Skip this Video
Loading SlideShow in 5 Seconds..
Code Specialization PowerPoint Presentation
Download Presentation
Code Specialization

Code Specialization

80 Views Download Presentation
Download Presentation

Code Specialization

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

  1. Code Specialization Michael E. LocastoSeptember 19, 2002

  2. What is Code Specialization? • General algorithm --> domain-specific implementation • eliminate (hold invariant) some inputs • a compiler optimization

  3. Compiler Optimizations Invariants partial evaluation promotion and accumulation memoization JIT code obfuscation transformational programming finite differencing loop unrolling Related Terms & Concepts

  4. Why Is It Useful? • Performance boost ~13-25%, and sometimes more (60%) • Don’t need to “save the world” (just your continent) • Respond to change in environment (JIT) • useful in embedded env (highly specialized hardware)

  5. Why Is It Useful ? (con) • MAC operation in DSP Harvard 56000 • “three approaches to providing performance guarantees in algorithm design: randomize, amortize, or optimize.” • manual optimizations (better programmers) • automatic optimizations (save your fingers)

  6. Some Manual Optimizations • Algebraic and logical expression manipulation • eliminate recursive method calls (& method call overhead in general) • reduce excessive object creation • write in ASM

  7. int foo( int a, int b){ if( a>b ){ //many instructions }else if( a==b ){ //many instructions }else{ return a; }} int foo( int a, int b ){ return a;}//or even:int foo( int a ){ return a;}//or evena The Idea of Invariants

  8. Partial Evaluation • Non-deterministic, may fail to terminate • lazy evaluation • Program p + Data d = new source (p_d) • Basic idea: your data has mostly been evaluated so the program does not waste time getting, scanning, and verifying large set of input

  9. Another Example • See sheet • (http://www.cs.columbia.edu/~locasto/projects/codespec/codespecialization.summary.html )

  10. Database querying hardware simulation spreadsheet computations Configuration files (seldom-changing parameters) Support both modularity and performance crypto (many repeated operations with predictable data) R: replacing complex function with multiplication by 2,3 Specific Applications

  11. Security and Code Specialization • Partial Evaluation is used to create the intermediate permissions for java.security.Policy • in some way make code simpler (proof of security may be easier) • 2.29 Gb/s Rijndael processor (for AES) - designers used code specialization to turn the C ref imp to hardware

  12. Rijndael Code Specialization • Look up table (Galois field) • large mem required, embedded device limits • analysis revealed simple 2 or 3 mul

  13. Embedded Devices • Much work being done here (as well as for the JVM/JIT) • save power, space, heat, cpu cycles • these devices have highly specialized architecture, making it natural to want to automatically specialize an algorithm. Also, their data is of a predictable and uniform type.

  14. Resources • http://www.diku.dk/research-groups/topps/activities/PartialEvaluation.html • http://www.cs.columbia.edu/~locasto/projects/codespec/codespecialization.survey.html • http://www.dina.dk/~sestoft/pebook/pebook.html

  15. Questions && /*Comments*/ • Specific problems? • Applications • how to apply to crypto • optimizations