a probabilistic pointer analysis for speculative optimizations n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
A Probabilistic Pointer Analysis for Speculative Optimizations PowerPoint Presentation
Download Presentation
A Probabilistic Pointer Analysis for Speculative Optimizations

Loading in 2 Seconds...

play fullscreen
1 / 40

A Probabilistic Pointer Analysis for Speculative Optimizations - PowerPoint PPT Presentation


  • 131 Views
  • Uploaded on

Electrical and Computer Engineering University of Toronto. A Probabilistic Pointer Analysis for Speculative Optimizations. Jeff DaSilva Greg Steffan. ASPLOS XII. foo(int *a) { … while(…) { x = *a; … } } . Pointers Impede Optimization. Loop Invariant Code Motion.

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 'A Probabilistic Pointer Analysis for Speculative Optimizations' - keaton


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
a probabilistic pointer analysis for speculative optimizations

Electrical and Computer Engineering

University of Toronto

A Probabilistic Pointer Analysis for Speculative Optimizations

Jeff DaSilva

Greg Steffan

ASPLOS XII

pointers impede optimization

foo(int *a) {

while(…)

{

x = *a;

}

}

Pointers Impede Optimization

Loop Invariant

Code Motion

Parallelize

Can pointer analysis help?

ASPLOS XII

slide3

optimize

Definitely

Pointer

Analysis

Definitely Not

Maybe

*a = ~

~ = *b

How can we optimize cases?

Maybe

Pointer Analysis

  • Do pointers a and b point to the same location?
    • Repeat for every pair of pointers at every program point

*a = ~

~ = *b

ASPLOS XII

lets speculate

int *a, x;

while(…)

{

x = *a;

}

int *a, x, tmp;

tmp = *a;

while(…)

{

x = tmp;

}

<verify, recover?>

a is probably

loop invariant

Lets Speculate
  • Implement a potentially unsafe optimization
    • Verify and Recover if necessary

ASPLOS XII

data speculative optimizations
Data Speculative Optimizations
  • EPIC Instruction sets
    • Support for speculative load/store instructions (eg. Itanium)
  • Speculative compiler optimizations
    • Dead store elimination, redundancy elimination, copy propagation, strength reduction, register promotion
  • Thread-level speculation (TLS)
    • Hardware and compiler support for speculative parallel threads
  • Transactional programming
    • Hardware and software support for speculative parallel transactions

Heavy reliance on detailed profile feedback

ASPLOS XII

can we quantify

Maybe

Recovery

penalty

(if unsuccessful)

Overhead

for verify

Probability

of success

Expected

speedup

(if successful)

Speculate?

Ideally would be a probability

Maybe

Can We Quantify ?

Maybe

  • Estimate the potential benefit for speculating:

ASPLOS XII

slide7

optimize

optimize

p = 1.0

Definitely

Pointer

Analysis

PPA

p = 0.0

Definitely Not

0.0 < p < 1.0

Maybe

*a = ~

~ = *b

Probabilistic Pointer Analysis (PPA)

Conventional Pointer Analysis

  • Do pointers a and b point to the same location?
    • Do this for every pair of pointers at every program point

*a = ~

~ = *b

  • With what probability p, do pointers a and b point to the same location?
    • Repeat for every pair of pointers at every program point

Potential bonus: PPA doesn’t have to be safe

ASPLOS XII

ppa research objectives
PPA Research Objectives
  • Accurate points-to probability information
    • at every static pointer dereference
  • Scalable analysis
    • Goal: entire SPEC integer benchmark suite
  • Understand scalability/accuracytradeoff
    • through flexible static memory model

Improve our understanding of programs

ASPLOS XII

related work
Related Work

ASPLOS XII

algorithm design choices
Algorithm Design Choices
  • Fixed
    • Bottom Up / Top Down Approach
    • Linear transfer functions (for scalability)
    • One-level context and flow sensitive
  • Flexible
    • Edge profiling (or static prediction)
    • Safe (or unsafe)
    • Field sensitive (or field insensitive)

ASPLOS XII

traditional points to graph

int x, y, z, *b = &x;

void foo(int *a) {

if(…)

b = &y;

if(…)

a = &z;

else(…)

a = b;

while(…) {

x = *a;

}

}

=

Definitely

= pointer

=

= pointed at

Maybe

Traditional Points-To Graph

b

a

x

y

z

UND

Results are inconclusive

ASPLOS XII

probabilistic points to graph

int x, y, z, *b = &x;

void foo(int *a) {

if(…)

b = &y;

if(…)

a = &z;

else

a = b;

while(…) {

x = *a;

}

}

=

p = 1.0

= pointer

p

=

= pointed at

0.0<p< 1.0

Probabilistic Points-To Graph

0.1 taken(edge profile)

b

a

0.2 taken(edge profile)

0.72

0.9

0.1

0.2

0.08

x

y

z

UND

Results provide more information

ASPLOS XII

slide13

Linear

One -

Level

Interprocedural

Probabilistic

Pointer Analysis

LOLLIPOPOur PPA Algorithm

ASPLOS XII

fundamentals
Fundamentals
  • Location sets (Wilson & Lam)
    • One or more mem locations
    • Classified as pointer, pointer target, or both
  • Matrix-based approach
    • Nice properties, optimized implementations
  • Two key matrices:
    • Points-to matrix
    • Linear transformation matrix

ASPLOS XII

points to matrix
Points-To Matrix

Location Sets

M-1 M

Area

Of

Interest

1

2

Pointer Sets

N-1

N

I

Location Sets

All matrix rows sum to 1.0

ASPLOS XII

points to matrix example

x

y

z

UND

a

b

a

b

0.72

0.9

0.1

0.2

x

0.08

y

x

y

z

UND

z

UND

Points-To Matrix Example

0.72 0.08 0.20

0.90 0.10

1.0

1.0

1.0

1.0

I

ASPLOS XII

computing new points to matrices

I

I

Computing New Points-To Matrices

Points-To

Matrix In

Any Instruction

Points-To

Matrix Out

ASPLOS XII

the fundamental ppa equation
The Fundamental PPA Equation

Transformation

Matrix

Points-To

Matrix In

Points-To

Matrix Out

=

This can be applied to any instruction(incl. function calls)

ASPLOS XII

transformation matrix
Transformation Matrix

Location Sets

Pointer Sets

1 2 3 …

N-1 N

1

2

Area of Interest

Pointer Sets

ø

I

Location Sets

N-1

N

All matrix rows sum to 1.0

ASPLOS XII

transformation matrix example

a

b

x

y

z

UND

Transformation Matrix Example

a

b

x

y

z

UND

S1:a = &z;

1.0

1.0

TS1

1.0

1.0

1.0

1.0

=

ASPLOS XII

example the ppa equation

PTout

TS1

PTin

=

x

y

z

UND

a

1.0

1.0

0.72 0.08 0.20

0.90 0.10

b

a

b

0.72

0.9

0.1

0.2

x

1.0

1.0

1.0

1.0

1.0

1.0

1.0

1.0

0.08

y

x

y

z

UND

z

UND

Example - The PPA Equation

S1:a = &z;

PTout

=

ASPLOS XII

example the ppa equation1

PTout

TS1

PTin

=

x

y

z

UND

a

b

b

a

0.9

0.1

x

y

x

y

z

UND

z

UND

Example - The PPA Equation

S1:a = &z;

1.0

0.90 0.10

PTout

=

1.0

1.0

1.0

1.0

I

ASPLOS XII

combining transformation matrices

Basic Block

S1: Instr

S2: Instr

S3: Instr

I

I

Combining Transformation Matrices

PTout

TS2

TS3

TS1

PTin

PTin

TS1

PTin

=

PTout

TBB

PTin

=

ASPLOS XII

control flow if else
Control flow - if/else

p + q = 1.0

X

Y

p

p

q

q

TX

TY

+

=

ASPLOS XII

control flow loops

N

<L,U>

X

Y

i

1

TY

=

U-L+1

Control flow - loops

N

TX

=

Both operations can be implemented efficiently

<L,U>  <min,max>

ASPLOS XII

safe vs unsafe pointer assignment instructions





Safe vs. Unsafe Pointer Assignment Instructions

Safe?

Shadow/invisible vars: non-linear to handle

ASPLOS XII

safety for shadow variables

Steensgaard

FICI PA for

shadow vars

p

p

Safe

q

p_1

p_1

q

+

=

p_1

q

p_1 and q are considered aliased

Safety for Shadow Variables

Unsafe

q

q

= pointer

= shadow ptr

= pointed at

ASPLOS XII

lol l ip o p implementation
LOLLIPOP Implementation

.spd

SUIF Infrastructure

Static

Memory

Model

TF-Matrix

Collector

Points-To

Matrix

Propagator

ICFG

SMM

BU

TD

Edge

Profile

.spx

  • Implementation details:
  • Sparse matrices
  • Efficient matrix algorithms
  • Result memoization

Results

Stats

MATLAB

C Library

ASPLOS XII

slide29

Measuring

LOLLIPOP’s

Efficiency and Accuracy

ASPLOS XII

spec2000 benchmark data
SPEC2000 Benchmark Data

Experimental Framework: 3GHz P4 with 1GB of RAM

Scales to all of SPECint

ASPLOS XII

spec2000 benchmark data1

Reduced

Input Set

SPEC2000 Benchmark Data

Experimental Framework: 3GHz P4 with 1GB of RAM

More efficient than points-to profiling

ASPLOS XII

easy spec2000 benchmarks

Average Dereference Size

more accurate

Easy SPEC2000 Benchmarks

A one-level Analysis is often adequate (i.e. safe~=unsafe)

ASPLOS XII

challenging spec 95 2000 benchmarks

Average Dereference Size

more accurate

Challenging SPEC 95/2000 Benchmarks

Many improbable points-to relations can be pruned away

ASPLOS XII

metric average max certainty

while(…)

{

x = *a;

}

{ (0.72, ), (0.08, ), (0.2, ) }

x

y

z

Σ

(max probability value)

=

Avg Certainty

(num of loads & stores)

Metric: Average Max Certainty

Max probability value = 0.72

ASPLOS XII

spec2000 average certainty

Probabilistic Certainty

more accurate

SPEC2000 Average Certainty

On average, LOLLIPOP can predict a single likely points-to relation

ASPLOS XII

metric naed

while(…)

{

x = *a;

}

{ (0.72, ), (0.08, ), (0.2, ) }

{ (0.88, ), (0.02, ), (0.1, ) }

x

x

y

y

z

z

Pd

Ps

Σ

║Ps – Pd ║

1

=

NAED

√2

(num of loads & stores)

Metric: NAED
  • Normalized Average Euclidean Distance

LOLIPoP’s Static prediction

Pts-to Profiler’s Dynamic freq vector

ASPLOS XII

summary
Summary
  • A novel matrix-based PPA algorithm
  • Scales to the SPECint 95/2000 benchmarks
    • One level context and flow sensitive
  • Future Work
    • Applying LOLLIPOP to TLS/TM
    • Further optimize LOLLIPOP’s implementation

ASPLOS XII

references
References
  • Manuvir Das, Ben Liblit, Manuel Fahndrich, and Jakob Rehof. Estimating the Impact of Scalable Pointer Analysis on Optimization. SAS 2001, 260-278.
  • Peng-Sheng Chen, Ming-Yu Hung, Yuan-Shin Hwang, Roy Dz-Ching Ju, and Jenq Kuen Lee. Compiler support for speculative multithreading architecture with probabilistic points-to analysis. PPOPP 2003, 25-36.
  • Jin Lin, Tong Chen, Wei-Chung Hsu, Peng-Chung Yew, Roy Dz-Ching Ju, Tin-Fook Ngai and Sun Chan, A Compiler Framework for Speculative Analysis and Optimizations. PLDI 2003, 289-299.
  • R.D. Ju, J. Collard, and K. Oukbir. Probabilistic Memory Disambiguation and its Application to Data Speculation. SIGARCH Comput. Archit. News 27 1999, 27-30.
  • Manel Fernandez and Roger Espasa. Speculative Alias Analysis for Executable Code. PACT 2002, 221-231.

ASPLOS XII