Code Specialization - PowerPoint PPT Presentation

1 / 15
About This Presentation
Title:

Code Specialization

Description:

Don't need to 'save the world' (just your continent) Respond to change in ... performance guarantees in algorithm design: randomize, amortize, or optimize. ... – PowerPoint PPT presentation

Number of Views:9
Avg rating:3.0/5.0
Slides: 16
Provided by: michaele5
Category:

less

Transcript and Presenter's Notes

Title: Code Specialization


1
Code Specialization
  • Michael E. LocastoSeptember 19, 2002

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

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

4
Why Is It Useful?
  • Performance boost 13-25, and sometimes more
    (60)
  • Dont 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
The Idea of Invariants
  • int foo( int a, int b) if( agtb ) //many
    instructions else if( ab ) //many
    instructions else return a
  • int foo( int a, int b ) return a//or
    evenint foo( int a ) return a//or evena

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/code
    spec/codespecialization.summary.html )

10
Specific Applications
  • 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

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/activitie
    s/PartialEvaluation.html
  • http//www.cs.columbia.edu/locasto/projects/codes
    pec/codespecialization.survey.html
  • http//www.dina.dk/sestoft/pebook/pebook.html

15
Questions /Comments/
  • Specific problems?
  • Applications
  • how to apply to crypto
  • optimizations
Write a Comment
User Comments (0)
About PowerShow.com