1 / 15

Code Specialization

Code Specialization. Michael E. Locasto September 19, 2002. What is Code Specialization?. General algorithm --> domain-specific implementation eliminate (hold invariant) some inputs a compiler optimization. Compiler Optimizations Invariants partial evaluation promotion and accumulation

olathe
Download Presentation

Code Specialization

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. 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

More Related