ECE1724F Presentation - PowerPoint PPT Presentation

1 / 23
About This Presentation
Title:

ECE1724F Presentation

Description:

ECE1724F Presentation. C: A Language for High-Level, Efficient, and ... Peephole Optimizations. Templates and vcode? Improvement of one order magnitude expected ... – PowerPoint PPT presentation

Number of Views:38
Avg rating:3.0/5.0
Slides: 24
Provided by: MAD5160
Category:

less

Transcript and Presenter's Notes

Title: ECE1724F Presentation


1
ECE1724F Presentation
  • C A Language for High-Level, Efficient, and
    Machine-Independent Dynamic Code Generation

Dawson R. Engler, Wilson C. Hsieh and M. Frans
Kaashoek
Madhusudan Raman
October 23, 2002
2
Outline
  • Motivation - Why?
  • Objectives - What?
  • Methodology - How?
  • Performance - How much?
  • Future Work - Now what?
  • Conclusions - So what?

3
Motivation Why?
  • Tradeoffs
  • Portability
  • Ease of Programming
  • Efficiency
  • Tackle all three - How?
  • Build on ANSI C
  • Add-on to highly evolved language

4
Objectives What?
  • Portable, Easy
  • Extend on ANSI C
  • Strict superset
  • Flexible specification of dynamic code
  • Unknown parameters of functions
  • Efficiency
  • Shift most costs to compile time
  • Static typing

5
Methodology How?
  • 'C Language
  • Constructs
  • Similar to Function Pointers
  • Unary operators
  • Standard library
  • Type Specifications
  • Runtime Constructed Function Calls

6
The Operator
  • Specify dynamically generated code
  • No nesting
  • Lexical Scoping
  • "Capture" static variables
  • Type-checking at compile time
  • Cannot transfer control outside backquote

7
Cspec Types
  • Type of a dynamic code specification
  • Evaluation type - dynamic value of code
  • Compile returns a void function pointer
  • Cast into appropriate type

8
vspec Types
  • Variable Specification
  • Dynamically generated lvalue
  • Evaluation type - type of lvalue
  • Statically type lvalue
  • Instruction selection at compile time

9
vspec Types
  • Initialization
  • Param - used to create parameter for function
  • Local - Reserve space, allocate register
  • Void - generic vspec type
  • Incorporated vspec
  • Used as a variable
  • both lvalue, rvalue
  • Functions taking runtime-determined arguments

10
Other Operators
  • The _at_ Operator
  • Combination of dynamic code specifications
  • "dereferences" cspecs and vspecs
  • returns evaluation type of operand
  • The Operator
  • Incorporate Runtime Constants
  • Evaluates operand at specification time

11
Example 1Runtime Constants
  • Hardcode relatively constant values
  • Generic hash function
  • Table size, scatter, normalize - computed at
    runtime
  • Function specialized for hte, scatter, norm

12
hptr mk_hash(struct ht ht) int vspec val
param(0, TC_I) void cspec hc hc struct
hte hte hte (ht-gthte)(_at_valht-gtscatter)/ht
-gtnorm while(hte hte-gtval ! _at_val) hte
hte-gtnext return hte return (hptr)
compile(hc, TC_P)
13
Example 2Matrix Dot Product
  • Runtime Characteristics
  • Large numbers of zeroes
  • Small integers
  • Code for each row used n times
  • Easy to recoup dynamic code generation costs
  • Encode row values as immediates
  • Function eliminating multiplication by zero

14
void cspec mkdot(int row, int n) int k, cspec
sum, vspec col col (int vspec) param(0,
TC_P) sum '0 for(k0kltnk) if(rowk
sum '(_at_sum (_at_col)k rowk) re
turn 'return _at_sum
15
Performance How Much?
  • 'C Compiler
  • Prototype, so non-optimal
  • Sparc 10
  • Integer divide and multiply in software

16
Matrix Scaling
  • Multiplication, Division Reduce to Adds and
    Shifts
  • Constant Loop Bounds Encode at runtime

17
Matrix Scaling Performance
  • 1024 X 1024 Matrix
  • Scaled Up by integers 1, 2.. 1024

18
Compiling Interpreter
  • Compile, then execute freq. code
  • TinyC - recursive-descent compiling interpreter
  • Test Candidates
  • C
  • gcc-O2
  • Tree-Interpreter
  • Translate TinyC into abstract syntax trees
  • Recursively Evaluate

19
Compiling Interpreter Performance
  • 30th Fibonacci number computed
  • C slower than gcc
  • Within 10 of hand-optimized
  • Much faster than Tree-Interpreter

20
Future Work Now What?
  • Scope for improvement
  • Language Extensions
  • C Compiler Improvements

21
Language Extensions
  • Partial signatures
  • Prevent code explosions
  • Specify permutations of args
  • Generate multiple functions simultaneously
  • Full generality???
  • Parameterize Code Fragments
  • Nameless functions
  • Increased modularity

22
Compiler extensions
  • Excuse for low performance now?
  • Optimizations
  • Instruction scheduling
  • Peephole Optimizations
  • Templates and vcode?????
  • Improvement of one order magnitude expected

23
Conclusions So What?
  • Achieved
  • Somewhat increased efficiency
  • Portability
  • Need better compiler
  • Not easy to use
  • Successful overall
Write a Comment
User Comments (0)
About PowerShow.com