A Global Progressive Register Allocator - PowerPoint PPT Presentation

About This Presentation
Title:

A Global Progressive Register Allocator

Description:

School of Computer Science. A Global Progressive Register Allocator. David Ryan Koes ... School of Computer Science. Control Flow. MCNF can only represent ... – PowerPoint PPT presentation

Number of Views:61
Avg rating:3.0/5.0
Slides: 27
Provided by: david661
Learn more at: http://www.cs.cmu.edu
Category:

less

Transcript and Presenter's Notes

Title: A Global Progressive Register Allocator


1
A Global Progressive Register Allocator
  • David Ryan Koes
  • Seth Copen Goldstein
  • Carnegie Mellon University
  • dkoes,seth_at_cs.cmu.edu

2
Register Allocation Problem
unbounded number of program variables
limited number of processor registers slow
memory
spill code optimization
v 1 w v 3 x w v u v t u
x print(x) print(w) print(t) print(u)
register preferences
rematerialization
register allocator
live range splitting
memory operands
3
A More Principled Register Allocator
  • fully utilize machine description
  • explicit and expressive model of costs of
    allocation for given architecture
  • optimal solutions

reg alloc
machine description
4
Multi-commodity Network Flow An Expressive Model
  • Given network (directed graph) with
  • cost and capacity on each edge
  • sources sinks for multiple commodities
  • Find lowest cost flow of commodities
  • NP-complete for integer flows

b
a
Example edges have unit capacity
0
1
b
a
5
Register Allocation as a MCNF
Variables ? Commodities Variable Definition ?
Source Variable Last Use ? Sink Nodes ?
Allocation Classes (Reg/Mem/Const) Registers
Limits ? Node Capacities Spill Costs ? Edge
Costs Allocation ? Flow
r1
mem
1
3
Also need anti-variables to model persistent
memory
6
Example
load cost
Source Code int example(int a, int b) int d
1 int c a - b return cd
insn pref cost
Pre-alloc Assembly MOVE 1 -gt d SUB a,b -gt c ADD
c,d -gt c MOVE c -gt r0
mem access cost
7
Control Flow
  • MCNF can only represent straight-line code
  • need to link together networks from basic blocks

New nodes to handle block entry/exit constraints
a eax
a mem
8
A More Principled Register Allocator
  • fully utilize machine description
  • explicit and expressive model of costs of
    allocation for given architecture Global MCNF
  • optimal solutions
  • NP-hard, so use progressive solution technique

9
Solution Procedure
  • Compute Lagrangian prices using iterative
    subgradient optimization
  • guaranteed converge to optimal prices
  • for linear relaxation of the problem
  • Prices used by allocator to find solution
  • solution improves as prices converge
  • two allocators
  • iterative heuristic allocator
  • simultaneous heuristic allocator

10
Solution Procedure
  • Advantages
  • iterative nature ? progressive
  • Lagrangian relaxation theory provides means for
    computing a good lower bound
  • Can compute optimality bound
  • Disadvantages
  • No guarantee of finding optimal solution
  • Optimality bound poor if integrality gap large

99 of the time integrality gap 0
11
Iterative Heuristic Allocator
Edges to/from memory cost 3
Allocation order a, b, c, d
Cost
Total 2
12
Simultaneous Heuristic Allocator
Edges to/from memory cost 3
Current cost
-1
-3
-2
13
Evaluation
  • Implemented in gcc 3.4.3 targeting x86
  • Optimize for code size
  • perfect static evaluation
  • important metric in its own right
  • MediaBench, MiBench, Spec95, Spec2000
  • over 10,000 functions

14
Progressiveness
15
Progressiveness
16
Code Size
17
Optimality
Proven maximum distance from optimal
Proven optimality
18
Compile Time Slowdown -(
19
A More Principled Register Allocator
  • fully utilize machine description
  • explicit and expressive model of costs of
    allocation for given architecture Global MCNF
  • optimal solutions
  • approach optimality using progressive solution
    technique Lagrangian directed allocators

20
Questions?
21
(No Transcript)
22
Accuracy of the Model
Global MCNF model correctly predicts costs of
register allocation within 2 for 71 of
functions compiled
23
Code Size
24
Compile Time Asymptotic Complexity
one iteration O(nv)
25
Code Performance
26
Compile Time Slowdown -(
10x slower
Write a Comment
User Comments (0)
About PowerShow.com