Data-Flow Analyi or Hot-Spot Program Optimization Jn Knoop Tchnich Univrität Win 1 Motivation 2 A Poibly Hug Program Rgion x Hot Spot 1 Hot Spot 2 A Poibly Hug Program Rgion 3 4 A Poibly Hug Program Rgion x x A Poibly Hug Program Rgion 5 6 Availability at a Singl Program Point Why Standard Data-Flow Analyi Fail a) b) Availability o trm al i n = AVAIL(n) = [[ (m,n) ]](AVAIL(n)) othrwi m prd(n) a := b := a := b := whr [[ (m,n) ]](b) = (COMP (m,n) + b) TRANSP (m,n) b := a+b b := a+b 7 8
Outlin o th Talk Standard v. Rvr Data-Flow Analyi Background Ential Th Conncting Link Th Clou: Why do it work? Application Concluion 9 Background Dmand-Drivn Data-Flow Analyi Agrawal (2000) Horwitz, Rp, Sagiv (1994+) Dutrwald, Gupta, Soa (1995+) Knoop (Euro-Par 1999, KPS 2007) 10 Rvr Data-Flow Analyi: Th Baic (Standard) Data-Flow Analyi Data-Flow Lattic Ĉ =(C,,,,, ) Data-Flow Functional [[ ]] : E (C C) Rvr Data-Flow Analyi Rvr Data-Flow Functional (Hugh, Launchbury 1992+) [[ ]] R : E (C C) dind by E c C. [[ ]] R (c)= d {c [[ ]](c ) c } Availability o Trm Abtract mantic or availability o trm 1. Data-Flow Lattic: (C,,,,, )= d (B,,,,al,tru) 2. Data-Flow Functional: [[ ]] av : E ( B B ) dind by Ct tru i Comp Tranp E. [[ ]] av = d Id B i Comp Tranp othrwi Ct al 11 12 On th Rlationhip o [ ] and [ ] R Lmma 1. [[ ]] R i wll-dind and monotonic. 2. [[ ]] R i additiv, i [[ ]] i ditributiv. Monotonicity, Ditributivity, and Additivity o data-low unction. Dinition [Monotonicity, Ditributivity, Additivity] Lt Ĉ =(C,,,,, ) b a complt lattic and : C C a unction on C. Thn: i 1. monotonic i c,c C. c c (c) (c ) (Prrving th ordr o lmnt) 2. ditributiv i C C. ( C ) = {(c) c C } (Prrving gratt lowr bound) 3. additiv i C C. ( C ) = {(c) c C } (Prrving lat uppr bound) 13 14 Otn uul th ollowing quivalnt charactrization o monotonicity: Lmma On th Rlationhip o [ ] and [ ] R (Cont d) Lmma 1. [[ ]] R [[ ]] Id C, i [[ ]] i monotonic. Lt Ĉ =(C,,,,, ) b a complt lattic and : C C a unction on C. Thn: i monotonic C C. ( C ) {(c) c C } ( C C. ( C ) {(c) c C } ) 2. [[ ]] [[ ]] R Id C, i [[ ]] i ditributiv. In trm o th thory o abtract intrprtation : [[ ]] and [[ ]] R orm a Galoi-connction. 15 16
Rvr : Th R-MinFP -Approach Th R-MinFP -Equation Sytm: c q i n=q rqin (n)= {[[ (n,m) ]] R (rqin (m)) m ucc(n) } othrwi Th R-MinFP -Solution: c q C n N. R-MinFP cq (n)= d rqin c q (n) whr rqin c q dnot th lat olution o th R-MinFP -quation ytm wrt c q C. 17 Standard : Th MaxFP -Approach Th MaxFP -Equation Sytm: c i n= in (n) = {[[ (m,n) ]](in (m)) m prd(n) } othrwi Th MaxFP -Solution: c C n N. MaxFP ([[ ]],c)(n)= d in c (n) whr in c dnot th gratt olution o th MaxFP -quation ytm wrt c C. 18 Th Conncting Link Link Thorm For ditributiv data-low unctional [[ ]], q N, and c,c q C, w hav: R-MinFP cq () c MaxFP c (q) c q Continuing th Analogy o Standard and Rvr Data-Flow Analyi rgarding Soundn & Compltn (in trm o program vriication) / Saty & Coincidnc (Prciion) (in trm o data-low analyi) 19 20 Ential th xtnibility o data-low unctional to path Id C i q <1 [[ p ]]= d [[ 2,, q ]] [[ 1 ]] othrwi Th MOP -Approach c C n N. MOP c (n)= {[[ p ]](c ) p P[,n] } 21 22 Standard : Main Rult Thorm [Soundn / Saty] c C n N. MaxFP c (n) MOP c (n) i th data-low unctional [[ ]] i monotonic. Standard : Th Tool Kit Viw at a glanc: Intraprocdural C Spciication c 0 Thorm [Compltn / Coincidnc (Prciion)] Intraprocdural Framwork Thory Practic Tool Kit Gnric Fixd Point Alg. A.1 c C n N. MaxFP c (n)=mop c (n) i th data-low unctional [[ ]] i ditributiv. Program Proprty φ Equivalnc Intraprocdural Trmination Lmma Intraprocdural Intraprocdural Coincidnc Thorm Corrctn Lmma MOP-Solution MFP-Solution Computd Solution 1 2 3a) 3b) 23 24
O cour Rvr data-low unctional can b xtndd to path, too: Id C i q <1 [[ p ]] R = d [[ 1,, q 1 ]] R [[ q ]] R othrwi 25 Th R-JOP -Solution: Th R-JOP -Approach c q C n N. R-JOP cq (n)= d {[[ p ]] R (c q ) p P[n,q]} 26 Rvr : Main Rult Putting it togthr Thorm [Soundn / Rvr Saty] c q C n N. R-MinFP cq (n) R-JOP cq (n) Data-low Analyi PV {p}π {q} Program Vriication Thorm [Compltn / Rvr Coincidnc (Prciion)] MaxFP Coincidnc Thorm MOP (q) c c q C ditributiv induc C Strongt Potcondition Viw {p} π {?} c q C n N. R-MinFP cq (n)=r-jop cq (n) Link Thorm i [[ ]] i ditributiv. Rvr Coincidnc Thorm R-JOP R-MinFP c ( q ) c R (c) = d {c (c ) c} {?} π {q} Wakt Prcondition Viw 27 28 Ar W Don? Rcall th motivating xampl A Poibly Hug Program Rgion Matring th Road to Succ rquir mor. It rquir u to conclud rom wakt pr-condition on trongt pot-condition. x ntially, thi man to rplac th analyi problm by a vriication problm. A Poibly Hug Program Rgion 29 30 Changing th Prpctiv Implmntation Problm Spciication Problm Vriication Problm Changing th Prpctiv: Th Standard Taxonomy!cti?wci!cti Convntional Claiication o Tchniqu? ci! cpi! cpi! Givn: Contxt Inormation cti! Givn: Componnt Inormation cpi! Givn: Contxt Inormation cti Componnt Inormation cpi Exhautiv Dmand-Drivn? Sought: Strongt Componnt Inormation ci? Sought: Wakt Contxt Inormation wci? Sought: Validity o cpi with rpct o cti 31 32
Changing th Prpctiv: Concluion Drivd Th pciication problm: {?} π {q} Th vriication problm: {p} π {q}? th domain o dmand-drivn Th implmntation problm: {p} π {?} th domain o xhautiv 33 (R)-Framwork / (R)-Tool Kit Th Standard Viw Strongt Pot-condition Problm Partial (By-nd + Early Trmination) BN-MaxFP Exhautiv Program Analyi Formally anwr Formally anwr ( ) ( ) MaxFP MOP R-JOP R-MinFP 34 Wakt Pr-condition Problm Exhautiv Th Dual Viw Partial (Dmand-drivn + Early Trmination) DD-R-MinFP Gn/Kill-Problm allow u to matr th road to ucc: Th SPC-analyi problm boil down to a WPC-vriication problm. Thi i important bcau Rdundant Exprion/Aignmnt Elimination Dad-Cod Elimination Strngth Rduction Concluding th Exampl: Availability Abtract mantic or availability 1. Data-low lattic: (C,,,,, )= d (B X,,,,al,ailur) with =al tru ailur = 2. Data-low unctional: [[ ]] av : E ( B X B X ) dind by Ct X tru i Comp Tranp E. [[ ]] av = d Id BX i Comp Tranp othrwi Ct X al ar bad on Gn-Kill-problm. 35 36 Rvr Availability Rvr abtract mantic or availability 1. Data-low lattic: (C,,,,, )= d (B X,,,,al,ailur) 2. Rvr data-low unctional: [[ ]] avr : E ( B X B X ) dind by R-Ct X tru E. [[ ]] avr = d R-Id BX R-Ct X al i [[ ]] av =Ct X tru i [[ ]] av =Id BX i [[ ]] av =Ct X al Supporting Function al b B X. R-Ct X tru(b) = d ailur b B X. R-Ct X al al(b) = d ailur R-Id BX = d Id BX i b B othrwi (i.., i b=ailur) i b=al othrwi 37 38 Summing Up / Extnion (R)-Framwork / (R)-Tool Kit (Cont d) In thi talk th gnral pattrn: Th intraprocdural baic tting o (R) (Knoop, KPS 2007) Spciication Extnion ar poibl Framwork Thory Practic Intrac Tool Kit Intrprocdural tting (Knoop, CC 1992, LNCS 1428 (1998)) Gnric Fixd Point Alg. Paralll tting (Knoop, Euro-Par 1999) Program Proprty φ Equivalnc MOP-Solution Coincidnc Thorm MFP-Solution Corrctn Lmma Trmination Computd Solution 1 2 3a) 3b) Lmma 39 40
(R)-Framwork / (R)-Tool Kit th gnral pattrn mor abtract: Program Proprty φ Proo Obligation: Intraprocdural Intrprocdural Conditional Spciication Ectivity Coincidnc Thorm Thorm 3a) 3b) 1 2 3a) 3b) Equivalnc Paralll Coincidnc Framwork 41 Corrctn Trmination Ectivity From Application toward Concluion a) c := a+b rad(a,b) x a := "Hot Spot" Optimizr Program point atii availability, whil do not! Application b := writ(c) b) 42 c := a+b rad(a,b) a := Dbuggr b := writ(c) Variabl c i not initializd along om path raching program point g Rvr Data-Flow Analyi pcially wll-uitd or Hot-Spot Optimization Dbugging Jut-in-tim Compilation Concluion (Cont d) bad on anwring data-low quri. Hnc A an appaling add-on R i tailord or paralllization! Data-Flow Analyi or Dbugging Data-Flow Analyi or Jut-in-tim Compilation wr titl conidrd optionally. 43 44 Rcall again A Poibly Hug Program Rgion Concluion and Prpctiv x Data-Flow Analyi or Multi-Cor Architctur A Poibly Hug Program Rgion 45 46