a probabilistic pointer analysis a probabilistic pointer
play

A Probabilistic Pointer Analysis A Probabilistic Pointer Analysis - PowerPoint PPT Presentation

A Probabilistic Pointer Analysis A Probabilistic Pointer Analysis for Speculative Optimization for Speculative Optimization Jeff DaSilva Jeff DaSilva Greg Steffan Greg Steffan Electrical and Computer Engineering Electrical and Computer


  1. A Probabilistic Pointer Analysis A Probabilistic Pointer Analysis for Speculative Optimization for Speculative Optimization Jeff DaSilva Jeff DaSilva Greg Steffan Greg Steffan Electrical and Computer Engineering Electrical and Computer Engineering University of Toronto University of Toronto Toronto, ON, Canada Toronto, ON, Canada Oct 17 th , 2005 Oct 17 th , 2005

  2. Pointers Impede Optimization Pointers Impede Optimization � Many optimizations come to a halt when they encounter an ambiguous pointer foo(int *a) { Loop Invariant … Code Motion while(…) { x = *a; Parallelize … } } � Pointer Analysis is Important 2 University Of Toronto

  3. Pointer Analysis Pointer Analysis optimize *a = ~ ~ = *b Pointer Definitely Analysis Definitely Not Maybe *a = ~ ~ = *b � Do pointers a and b point to the same location? � Do this for every pair of pointers at every program point 3 University Of Toronto

  4. Pointer Analysis is Difficult Pointer Analysis is Difficult � Pointer analysis Pointer analysis is a difficult problem � � scalable scalable and overly conservative overly conservative � or or � fails fails- -to to- -scale scale and accurate accurate � � Ambiguous pointers will persist � even when using the most accurate accurate of algorithms � output is often unavoidable Maybe � What can be done with ? Maybe 4 University Of Toronto

  5. Lets Speculate Lets Speculate � Compilers make conservative conservative assumptions � They must always always preserve program correctness “It's easier to apologize than ask for permission.” Author: Anonymous Implement a potentially unsafe unsafe optimization Verify and Recover Recover if necessary Verify 5 University Of Toronto

  6. Speculation applied to Pointers Speculation applied to Pointers int *a, x; int *a, x, tmp; … … while(…) tmp = *a; { while(…) x = *a; { a is probably … x = tmp; loop invariant } … } <verify, recover?> <verify, recover?> 6 University Of Toronto

  7. Data Speculative Optimizations Data Speculative Optimizations � The EPIC Instruction set � Explicit support for speculative load/store instructions (eg. Itanium) � Speculative compiler transformations � Dead store elimination, redundancy elimination, copy propagation, strength reduction, register promotion � Thread-level speculation (TLS) � Hardware support for tracking speculative parallel threads � Transactional programming � Rollback support for aborted transactions � When to speculate? Techniques rely on profiling 7 University Of Toronto

  8. Quantitative Output Required Quantitative Output Required Maybe � Estimate the potential benefit for speculating: Recovery Recovery Maybe Overhead Overhead penalty penalty Probability Probability for verify for verify (if unsuccessful) (if unsuccessful) of success of success Expected Expected speedup speedup SPECULATE? (if successful) (if successful) � Probabilistic output needed Maybe 8 University Of Toronto

  9. Conventional Pointer Analysis Conventional Pointer Analysis optimize optimize *a = ~ ~ = *b Pointer Definitely Analysis Definitely Not Maybe *a = ~ ~ = *b � Do pointers a and b point to the same location? � Do this for every pair of pointers at every program point 9 University Of Toronto

  10. Probabilistic Pointer Analysis (PPA) Probabilistic Pointer Analysis (PPA) optimize optimize *a = ~ ~ = *b p = 1.0 p PPA p = 0.0 p 0.0 < p p < 1.0 *a = ~ ~ = *b p , do pointers a and b point � With what probability p to the same location? � Do this for every pair of pointers at every program point 10 University Of Toronto

  11. PPA Research Objectives PPA Research Objectives � Accurate points-to probability information � at every static pointer dereference � Scalable analysis � Goal: The entire SPEC integer benchmark suite scalability/accuracy accuracy tradeoff � Understand scalability � through flexible static memory model � Improve our understanding of programs 11 University Of Toronto

  12. Algorithm Design Choices Algorithm Design Choices � Fixed Fixed � � Bottom Up / Top Down Approach � Linear Linear transfer functions (for scalability) context and flow flow sensitive � One-level context � Flexible Flexible � � Edge profiling (or static prediction) � Safe (or unsafe) � Field sensitive (or field insensitive) 12 University Of Toronto

  13. Traditional Points- -To Graph To Graph Traditional Points int x, y, z, *b = &x; = Definitely = pointer void foo(int *a) { if(…) = pointed at = Maybe b = &y; if(…) b a a = &z; else(…) a = b; x y z UND while(…) { x = *a; … � Results are inconclusive } } 13 University Of Toronto

  14. Probabilistic Points- -To Graph To Graph Probabilistic Points int x, y, z, *b = &x; = p = 1.0 = pointer void foo(int *a) { � 0.1 � p if(…) 0.1 taken taken ( (edge edge profile profile) ) = pointed at = 0.0<p< 1.0 b = &y; � 0.2 if(…) � 0.2 taken b a taken ( (edge edge profile profile) ) 0.72 a = &z; 0.9 0.1 0.2 else(…) a = b; 0.08 x y z UND while(…) { x = *a; … � Results provide more information } } 14 University Of Toronto

  15. L inear L inear O ne O ne - - L evel L evel I nterprocedural I nterprocedural P robabilistic P robabilistic P ointer Analysis P ointer Analysis LOL L IP O P LOL L IP O P Our PPA Algorithm Our PPA Algorithm 15 University Of Toronto

  16. Points- -To Matrix To Matrix Points Location Sets M-1 M 1 2 Area … Pointer Sets Of Interest I … Location Sets N-1 N � All matrix rows sum to 1.0 16 University Of Toronto

  17. Points- -To Matrix Example To Matrix Example Points x y z UND a 0.72 0.08 0.20 0.90 0.10 b a b 0.72 0.9 0.1 0.2 1.0 x I 0.08 1.0 y x y z UND 1.0 z UND 1.0 17 University Of Toronto

  18. Solving for a Points- -To Matrix To Matrix Solving for a Points Points-To I Matrix In Any I nstruction Any I nstruction Points-To I Matrix Out 18 University Of Toronto

  19. The Fundamental PPA Equation The Fundamental PPA Equation Transformation Points-To = Points-To Matrix Matrix In Matrix Out � This can be applied to any instruction (incl. function calls) 19 University Of Toronto

  20. Transformation Matrix Transformation Matrix Pointer Sets Location Sets N-1 N 1 2 3 … 1 2 … Pointer Sets Area of Interest ø I Location Sets … N-1 N � All matrix rows sum to 1.0 20 University Of Toronto

  21. Transformation Matrix Example Transformation Matrix Example x y z S1: a = &z; a = &z; UND a b S1: a 1.0 1.0 b 1.0 x = T S1 1.0 y 1.0 z UND 1.0 21 University Of Toronto

  22. Example - - The PPA Equation The PPA Equation Example PT out = T S1 S1: a = &z; a = &z; PT in S1: 0.72 0.08 0.20 1.0 0.90 0.10 1.0 = 1.0 1.0 PT out 1.0 1.0 1.0 1.0 1.0 1.0 22 University Of Toronto

  23. Example - - The PPA Equation The PPA Equation Example PT out = T S1 S1: a = &z; a = &z; PT in S1: x y z UND a 1.0 b a 0.90 0.10 b 0.9 0.1 = 1.0 x PT out y 1.0 x y z UND z 1.0 UND 1.0 23 University Of Toronto

  24. Combining Transformation Matrices Combining Transformation Matrices I = T S3 T S1 T S1 PT in PT out Basic Block I nstr S1: I nstr S1: I nstr S2: I nstr S2: I nstr S3: I nstr S3: PT out = T BB PT in I 24 University Of Toronto

  25. p + q = 1.0 25 T Y q + T X - if/else if/else p = Control flow - Y Y Control flow q University Of Toronto p X X

  26. Control flow - - loops loops Control flow N N = T X X X < L , U > � <min,max> i U ∑ 1 < L , U > = T Y Y Y U-L+1 = i L � Both operations can be implemented efficiently 26 University Of Toronto

  27. Safe vs. Unsafe Safe vs. Unsafe Pointer Assignment Instructions Pointer Assignment Instructions Safe? � x = &y Address-of Assignment � x = y Copy Assignment x = *y Load Assignment � � *x = y Store Assignment � � 27 University Of Toronto

  28. LOL L IP O P Implementation LOL L IP O P Implementation SUIF Infrastructure . spd ICFG SMM BU TD ICFG SMM BU TD Edge . spx Profile Points-To Static TF-Matrix Results Memory Matrix Collector Model Stats Propagator MATLAB C Library 28 University Of Toronto

  29. Measuring Measuring LOL L IP O P ’ LOL L IP O P ’s s Efficiency and and Accuracy Accuracy Efficiency 29 University Of Toronto

  30. SPEC2000 Benchmark Data SPEC2000 Benchmark Data Benchmark PPA Analysis Time PPA Analysis Time LOC Matrix Size N [Unsafe] [Safe] Bzip2 Bzip2 0.3 seconds 0.3 seconds 4686 251 Mcf Mcf 2429 354 0.39 seconds 0.61 seconds Gzip Gzip 8616 563 0.71 seconds 0.77 seconds Cr Craf afty ty 21297 1917 5.49 seconds 5.51 seconds Vpr Vpr 17750 1976 9.33 seconds 10.34 seconds Twolf Twolf 20469 2611 16.59 seconds 20.64 seconds Parser Parser 11402 2732 30.72 seconds 50.04 seconds Vortex Vortex 3min 59seconds 4min 56seconds 67225 11018 Gap Gap 71766 25882 54min 56seconds 83min 38seconds Perlb Perlbmk 85221 20922 44min 15seconds 89min 43seconds Gcc Gcc Still Running… 5hour 10 min 22225 42109 Experimental Framework: 3GHz P4 with 2GB of RAM � Scales to all of SPECint 30 University Of Toronto

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend