Pegasus: A Program Intermediate Representation - PowerPoint PPT Presentation

1 / 51
About This Presentation
Title:

Pegasus: A Program Intermediate Representation

Description:

Side-effect sequencing. Optimizations. Conclusions /40. 13. Block- and Edge-Predicates ... side-effect. Delete predicates of instructions w/o side-effects /40. 20 ... – PowerPoint PPT presentation

Number of Views:540
Avg rating:3.0/5.0
Slides: 52
Provided by: MIh73
Category:

less

Transcript and Presenter's Notes

Title: Pegasus: A Program Intermediate Representation


1
Pegasus A Program Intermediate Representation
  • Mihai Budiu
  • April 9, 2002

2
Original MotivationCompiling C to Hardware
HLL program
Compiler
Circuit
Reconfigurable hardware
3
Context
Phoenix project http//www.cs.cmu.edu/phoenix Re
configurable nanotechology
ASHApplication-Specific Hardware
CASHCompiler for ASH
Pegasus Predicated Explicit GAted Simple Uniform
SSAIntermediate Representation
4
Pegasus
  • Intermediate program representation
  • Unifies
  • Static-Single Assignment (SSA)
  • Predication
  • Speculative execution
  • Dataflow machines
  • Precise semantics
  • Sparse
  • Very efficient for scalar optimizations

5
ModelData is Produced and Consumed


7
3

5

6
ModelAsynchronous Computation

ack
data
rdy
one for each consumer
7
Outline
  • Pegasus features
  • Building Pegasus
  • Hyperblock formation
  • Path predicates
  • Predication Speculation SSA
  • Inter-hyperblock control-flow
  • Side-effect sequencing
  • Optimizations
  • Conclusions

8
Building Pegasus Overview
  • divide CFG in regions(atomic execution units)
  • implement each region
  • link regions
  • optimize
  • generate code

CFG
9
Hyperblocks
  • CFG fragment
  • One entry, multiple exits
  • No back-edges
  • DAGs
  • Introduced for EPIC

basic block
10
Speculation
  • Hyperblock unit of speculation(execute
    everything inside)
  • Can partition CFG in many ways

Maximum speculation
No speculation
11
Covering CFG with Hyperblocks
  • We chose maximal hyperblocks
  • Interval analysis
  • hyperblocks minimum intervals
  • Entry points
  • loop entry
  • loop exit successors
  • predecessors in different hypers
  • CFG Edges
  • internal (thick)
  • cross (thin)incl. backedges (blue)

12
Outline
  • Pegasus features
  • Building Pegasus
  • Hyperblock formation
  • Path predicates
  • Predication Speculation SSA
  • Inter-hyperblock control-flow
  • Side-effect sequencing
  • Optimizations
  • Conclusions

13
Block- and Edge-Predicates
e
s
t
b
P(b) true iff b is executed
14
Predicated Execution
if (x gt 0) y -x else y 2x z / y
15
Predication in Pegasus
p(a)
p(b)
p(c)
p(d)
16
Outline
  • Pegasus features
  • Building Pegasus
  • Hyperblock formation
  • Path predicates
  • Predication Speculation SSA
  • Inter-hyperblock control-flow
  • Side-effect sequencing
  • Optimizations
  • Conclusions

17
Speculative Execution
f()0
f()
h()
g()
if (f()) g() else h()
h()
g()
Code
Sequential
Speculative
18
Predicate Promotion Speculation
19
Speculation in Pegasus
side-effect
predicatecomputation
predicatecomputation
instructions
instructions
Delete predicates of instructions w/o side-effects
20
Predicates Speculation G-SSA
p
a e if (x) goto L
q
a f if (y) goto L
r
L ... a ...
21
Example
22
Outline
  • Pegasus features
  • Building Pegasus
  • Hyperblock formation
  • Path predicates
  • Predication Speculation SSA
  • Inter-hyperblock control-flow
  • Side-effect sequencing
  • Optimizations
  • Conclusions

23
Merge and eta
i1
i2
o
o some i
24
Cross-edges
25
Example
26
Outline
  • Pegasus features
  • Building Pegasus
  • Hyperblock formation
  • Path predicates
  • Predication Speculation SSA
  • Inter-hyperblock control-flow
  • Side-effect sequencing
  • Optimizations
  • Conclusions

27
Handling Pointers
p 2 a q
p
2
  • Must preserveprogram order fornon-commutative
    side-effects

q

a
28
Example
29
Outline
  • Pegasus features
  • Building Pegasus
  • Optimizations
  • Conclusions

30
Free Optimizations
  • Global constant propagation
  • Copy propagation
  • Unreachable code elimination
  • Straightening
  • Branch chaining
  • (Almost) minimal SSA representation

31
Control-Flow Optimizations on Pegasus
CFG
Pegasus
optimize
optimize
Pegasus
CFG
32
Constant Folding
5
3
8

33
Dead-Code Elimination
34
Global Common Subexpression Elimination



35
GCSE
  • Same as
  • partial redundancy elimination
  • value numbering
  • redundant load elimination
  • code hoisting
  • tail merging

36
Store Forwarding
a
e

p
tk

tk
37
Loop-invariant Code Motion
8

38
New Algebraic Simplifications
constant ifs
gt minimal SSA
39
Optimizations
  • Those presented take linear time
  • Do not require dataflow analysis
  • Do not require incremental recomputations
  • Complete implementation 1000 C lines(incl.
    constant folding strength reduction, but
    except loop-invariant code motion)
  • All required information is encoded in graph.

40
Conclusions
  • Pegasus is a practical IR
  • Sparse SSA space complexity
  • Easy to build (linear time)
  • Encodes data-flow and control-flow
  • Complete description of program
  • Precise semantics
  • Efficient for optimizations (linear time for
    most scalar optimizations)

41
Extra Slides
  • Generating hardware
  • Lenient evaluation
  • Loop pipelining
  • Semantics
  • Reconfigurable hardware

42
Generating Hardware from Pegasus
  • Almost one-to-one correspondence
  • naturally asynchronous implementation
  • extensible to globally-async, locally sync
  • Special care for efficient speculation
  • lenient operations

back
43
Critical Paths
x
b
0
if (x gt 0) y -x else y bx

!
y
44
Executing Lenient Operators
x
b
0
if (x gt 0) y -x else y bx

!
y
45
Lenient Operations
  • Multiplexors
  • Boolean (and, or)
  • Predicated operations, when predicate is false

back
46
Pipelining
47
Loop Pipelining
48
Loop Pipelining
back
49
Semantics
  • Precise formulation for all operations
  • Only 3 main types of operations
  • strict
  • lenient
  • non-strict
  • Enables formal correctness proofs

back
50
Reconfigurable Hardware
back to presentation
51
Main RH Ingredient RAM Cell
data in
0
control
Switch controlled by a 1-bit RAM cell
back
Write a Comment
User Comments (0)
About PowerShow.com