an optimistic and conservative register assignment heuristic for chordal graphs
Download
Skip this Video
Download Presentation
An Optimistic and Conservative Register Assignment Heuristic for Chordal Graphs

Loading in 2 Seconds...

play fullscreen
1 / 32

An Optimistic and Conservative Register Assignment Heuristic for Chordal Graphs - PowerPoint PPT Presentation


  • 80 Views
  • Uploaded on

An Optimistic and Conservative Register Assignment Heuristic for Chordal Graphs. Philip Brisk. Ajay K. Verma. Paolo Ienne. International Conference on Compilers, Architecture, and Synthesis for Embedded Systems October 3, 2007. Salzburg, Austria. Outline. Coalescing Problem Biased Coloring

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about ' An Optimistic and Conservative Register Assignment Heuristic for Chordal Graphs' - pancho


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.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
an optimistic and conservative register assignment heuristic for chordal graphs

An Optimistic and Conservative Register Assignment Heuristic for Chordal Graphs

Philip Brisk

Ajay K. Verma

Paolo Ienne

International Conference on Compilers, Architecture, and Synthesis for Embedded Systems

October 3, 2007. Salzburg, Austria

outline
Outline
  • Coalescing Problem
  • Biased Coloring
  • Chordal Graphs
  • Optimistic Chordal Coloring Heuristic
  • Experimental Results
  • Conclusion
coalescing problem
Coalescing Problem
  • Given:
    • k-colorable interference graph G = (V, E)
      • Spilling already performed
    • Set of copy operations y  x
      • x and y do not interfere
      • Runtime profiling gives execution count
  • Objective:
    • Find legal k-coloring of G
    • Minimize the number of dynamic copies executed
example

5 copies

7 copies

K

J

K

J

B

F

A

C

D

K

G

H

I

J

E

L

M

L

M

L

M

I

H

I

H

G

G

F

F

E

D

E

D

C

B

C

B

A

A

Example

K = 4 Registers

Interference Edge

Copy Instruction

coalescing problem complexity
Coalescing Problem: Complexity
  • SSA Form
    • Theorem: SSA interference graphs are chordal
      • [Bouchez et al., MS Thesis, ENS-Lyon, 2005]
      • [Brisk et al., IWLS 2005, TCAD 2006]
      • [Hack et al., Tech. Report, U. Karlsruhe, 2005; IPL, 2006]
  • Coalescing is NP-Complete, even for chordal graphs
    • [Bouchez et al., CGO 2007, Best Paper Award]
contribution
Contribution
  • Coloring heuristic for chordal graphs
    • Conservative
      • Stronger guarantees than “Conservative Coalescing”
    • Optimistic
      • Retains the benefits of “Optimistic Coalescing”
    • Bottom Line
      • Near-optimal solutions for set of benchmarks studied
        • +1 extra copy, across all benchmarks
coalescing via node merging

Y

X

XY

Coalescing via Node Merging

[Chaitin et al., Comp. Languages 1981; SCC 1982]

negative side effects of coalescing

XY

Deg(X) = 3

Y

X

Deg(XY) = 6

Deg(Y) = 4

Negative Side Effects of Coalescing

Vertex degree increases

  • [Briggs et al., TOPLAS 1994]
  • [George and Appel, TOPLAS 1996]
  • [Hailperin, TOPLAS 2005]
negative side effects of coalescing1

X

Y

XY

Negative Side Effects of Coalescing

Chromatic number increases

[Briggs et al., TOPLAS 1994]

[George and Appel, TOPLAS 1996]

Triangles form

[Kaluskar, MS Thesis, GA Tech., 2003]

positive effects of coalescing

Y

X

Z

Z

Positive Effects of Coalescing

Reduce the degree of neighboring vertices

  • [Park and Moon, PACT 1998, TOPLAS 2004]
  • [Vegdahl, PLDI 1999]

Deg(Z) = 2

Deg(Z) = 1

XY

coalescing strategies
Coalescing Strategies
  • Conservative
    • Coalesce if you can prove that the resulting graph is still k-colorable
  • Optimistic
    • Aggressively coalesce as many moves as possible
    • De-coalesce, when necessary, to avoid spilling
    • Coalesce non-move-related nodes to exploit positive benefit
  • Complexity
    • Conservative, aggressive, optimistic coalescing are all NP-Complete

[Bouchez et al., CGO 2007]

biased coloring

Y

X

X

Y

Biased Coloring
  • Introduced by [Briggs et al., TOPLAS 1994]
    • For whatever reason, we couldn’t coalesce X and Y
    • Assume X gets a color before Y
    • If Color(X) is available when we assign a color to Y…
      • Then assign Color(X) to Y
chordal graphs

Non-chordal

Chordal

Non-chordal

Still Non-chordal

Chordal

Chordal

Non-Chordal

Chordal Graphs
  • No chordless cycles of length 4 or more
coalescing and chordal graphs

Chordal

(Before coalescing)

Non-chordal

(After coalescing)

Coalescing and Chordal Graphs
  • Coalescing does not preserve chordality
pseudo coalescing
Pseudo-coalescing
  • Find independent sets of move-related vertices, but don’t merge them
    • Try to assign the same color to the vertices

Chordal

(Before pseudo-coalescing)

Chordal

(After pseudo-coalescing)

simpicial vertices
Simpicial Vertices
  • v is a Simplicial Vertex if the neighbors of v form a clique.
  • Theorems:
    • Every chordal graph has at least one simplicial vertex [Lekkerkerker and Boland, Fund. Math 1964]
    • Every induced subgraph of a chordal graph is chordal
perfect elimination order
Perfect Elimination Order
  • Undirected graph: G = (V, E)
  • Elimination Order
    • One-to-one and onto function: σ: V  {0, …, |V| - 1}
    • Rename vertices: vi satisfies σ(vi) = i
    • Vi = {v1, …, vi}
    • Gi = (Vi, Ei) is the subgraph of G induced by Vi
  • Perfect Elimination Order (PEO)
    • vi is a simplicial vertex in Gi, for i = 1 to n
    • G is chordal iff G has a PEO
coloring chordal graphs
Coloring Chordal Graphs
  • Optimal, O(|V| + |E|)-time Algorithm
    • [Gavril, Siam J. Comp, 1972]
    • Process vertices in PEO order
    • Give vi the smallest color not assigned to its neighbors
      • Works because vi is simplicial in Gi
  • Extensions for copy elimination (this paper)
    • Pseudo-coalescing
    • Bias color assignment
correctness argument
Correctness Argument
  • Invariant:
    • When we assign a color to vi, Gi is legally colored
  • Optimistic extensions for copy elimination
    • Examples given in the next 3 slides
    • Invariant above is always maintained
      • Color assignment is conservative
        • The chromatic number is known, and never changes
simple color assignment rules

Try to respect the fact that node 3 has been optimistically colored

Only choose RED if no other color is available

If RED is the only option… then we’ll re-color node 3 later

Propagate color RED to node 3

Simple Color Assignment Rules

1

3

PEO order:

2

That’s a really bad idea

No harm done

But that isn’t how it really happens…

Let’s assume nodes 1 and 3 are pseudo-coalesced

undo pseudo coalescing
Undo Pseudo-coalescing

1

PEO order:

2

3

5

4

Pre-assigned color is legal

Pre-assigned color is illegal

Assign color

Propagate color

Undo pseudo-coalescing

Cannot stay pseudo-coalesced with node 2

Pseudo-coalesce with nodes 3 and 4 instead

Legal coloring invariant still holds

I can’t pseudo-coalesce all the nodes…

negative biasing same example
Negative Biasing (Same Example)

1

PEO order:

2

3

5

4

Select a Color for Node 2

Node 2 is pseuo-coalesced with Node 5

Node 5 interferes with Node 1, which has Color RED

So bias Node 1, AWAY FROM Color RED

Assign Color BLUE to Node 1 instead

maximum cardinality search
Maximum Cardinality Search
  • Compute PEO order in O(|V| + |E|) time

[Tarjan and Yannakakis, Siam J. Comput, 1984]

  • Color move-related nodes early
    • A legal color is always found for each node…
    • So coloring non-move-related node …
      • Constrains the move-related-nodes
  • Biased MCS
    • Push move-related vertices toward the front of the PEO
simplification
Simplification
  • If Deg(v) < k, remove v from G
    • [Kempe, American J. Math. 1876]
    • A color can always be found for v later
    • Don’t do this for move-related nodes
      • Removing them doesn’t help to eliminate moves
  • Repeat until all remaining nodes v…
    • Have Deg(v) > k, or
    • Are move-related
  • Justification
    • Fewer coloring constraints on move-related vertices
    • [Hack and Grund, CC 2007]
      • In the context of chordal coloring
refinement
Refinement

Sometimes heuristics just don’t do the right thing…

Can’t hurt, right?

optimistic chordal coloring heuristic
Optimistic Chordal Coloring Heuristic
  • Simplification
  • (Biased) Maximum Cardinality Search
  • Aggressive Pseudo-Coalescing
  • Optimistic Chordal Color Assignment
  • Refinement
  • Unsimplify
register allocation for asips
Register Allocation for ASIPs

Profile, Convert to Pruned SSA, Build Interference Graph

Input

Data

Proc1

Proc2

Procm

G1

G2

Gm

Chordal Color [Gavril, Siam J. Comp. 1972]

χ(G1)

χ(G2)

χ(Gm)

MAX

χmax – Number of registers to allocate (only spill at procedure calls)

experiments
Experiments
  • Benchmarks
    • MediaBench, MiBench in SSA Form
  • Color Assignment
    • Optimal Coalescing via ILP (OPT)
      • [Hack and Grund CC, 2007]
    • Iterated Register Coalescing (IRC)
      • [George and Appel, TOPLAS 1996]
    • Optimistic Chordal Coloring (OCC)
    • OCC++ (Not in the paper)
      • “Illegal” pseudo-coalescing
      • More aggressive color propagation
      • Enhanced refinement stage
results
Results

4 graphs were solved sub-optimally by OCC -> motivated OCC++

conclusion
Conclusion
  • OCC Heuristic for chordal graphs
    • Optimistic
      • Pseudo-coalescing instead of node merging
      • Preserves the chordal graph property
    • Conservative
      • Stronger guarantees than conservative coalescing
        • Chromatic number is easy to compute for chordal graphs
        • Same correctness invariant as chordal graph coloring
    • Choice of color assignment/color propagation
      • Shares principal similarities to biased coloring
sym decrypt
sym_decrypt

Weakness in aggressive pseudo-coalescing phase

6

3

5

Color is illegal

2

4

13

12

10

1

7

Propagate

8

9

11

rules for color assignment
Rules for Color Assignment
  • If vi is move-related…
    • and vi is uncolored
      • Be judicious when selecting a color
      • Propagate the color to vertices pseudo-coalesced with vi
    • or, vi has “optimistically” been assigned a color already
      • Is this color still legal with respect to Gi?
        • If not, re-color vi
          • Undo/redo pseudo-coalescing
  • Non-move-related nodes
    • Color assignment affects move-related nodes
ad