salsa
play

Salsa An Automatic Tool to Improve the Numerical Accuracy of - PowerPoint PPT Presentation

Salsa An Automatic Tool to Improve the Numerical Accuracy of Programs Nasrine Damouche & Matthieu Martel University of Perpignan, LAMPS Laboratory Metalibm Workshop 2018 March 12, 2018 N. DAMOUCHE MetaLibm Workshop 1 / 61 SALSA Context


  1. Salsa An Automatic Tool to Improve the Numerical Accuracy of Programs Nasrine Damouche & Matthieu Martel University of Perpignan, LAMPS Laboratory Metalibm Workshop 2018 March 12, 2018 N. DAMOUCHE MetaLibm Workshop 1 / 61

  2. SALSA Context Critical systems perform computations N. DAMOUCHE MetaLibm Workshop 2 / 61

  3. SALSA Context Critical systems perform computations ( ÷ ) 1998: USS Yorktown ship (drive system stopped) 1996: Ariane 5 (flight crash) (overflow) 1991: Patriot (failed interception) (accuracy) N. DAMOUCHE MetaLibm Workshop 3 / 61

  4. SALSA Context Critical systems perform computations ( ÷ ) 1998: USS Yorktown ship (drive system stopped) 1996: Ariane 5 (flight crash) (overflow) 1991: Patriot (failed interception) (accuracy) Important to guarantee the accuracy of computations N. DAMOUCHE MetaLibm Workshop 4 / 61

  5. SALSA Context Computer arithmetic is error-prone Exact arithmetic ( a + b ) − b a + ( b − b ) = 1 . 0 + ( 100 . 0 20 − 100 . 0 20 ) ( 1 . 0 + 100 . 0 20 ) − 100 . 0 20 = 1 . 0 1 . 0 = Computer arithmetic ( a + b ) − b � = a + ( b − b ) 1 . 0 + ( 100 . 0 20 − 100 . 0 20 ) ( 1 . 0 + 100 . 0 20 ) − 100 . 0 20 � = 0 . 0 � = 1 . 0 N. DAMOUCHE MetaLibm Workshop 5 / 61

  6. SALSA Context Automatic Optimization of Accuracy Original program a = 1 . 0 ; b = 10 . 0 − 21 ; c = ( a + b ) + b ; What we can do with SARDANA [SAS’12] /HERBIE [PLDI’15] ? b = 10 . 0 − 21 ; b = 10 . 0 − 21 ; a = 1 . 0 ; a = 1 . 0 ; c = ( a + b ) + b ; c = a + ( b + b ); What we cannot do with SARDANA [SAS’12] /HERBIE [PLDI’15] ? b = 10 . 0 − 21 ; b = 10 . 0 − 21 ; a = 1 . 0 ; a = 1 . 0 ; c = a + b ; c = a + b ; d = c + b ; d = a + ( b + b ); N. DAMOUCHE MetaLibm Workshop 6 / 61

  7. SALSA Context Motivating Example θ ( t + 1 ) = θ ( t ) + ∆ θ ( t ) ∆ d ( t ) = ∆ d r ( t ) + ∆ d l ( t ) 2 ∆ θ ( t ) = ∆ d r ( t ) − ∆ d l ( t ) L ∆ d l ( t ) = s l ( t ) × C ∆ d r ( t ) = s r ( t ) × C Trajectory Sl Sr � θ ( t ) + ∆ θ ( t + 1 ) � ϴ x ( t + 1 ) = x ( t ) + ∆ d ( t + 1 ) × cos y 2 � θ ( t ) + ∆ θ ( t + 1 ) � y ( t + 1 ) = y ( t ) + ∆ d ( t + 1 ) × sin L 2 x N. DAMOUCHE MetaLibm Workshop 7 / 61

  8. SALSA Context Motivating Example Straightforward implementation of equations Initial program sl = [ 0 . 52 , 0 . 53 ] double main () { x = 0 . 0 ; y = 0 . 0 ; arg = 0 . 0 ; delta d = 0 . 0 ; delta dl = 0 . 0 ; delta dr = 0 . 0 ; delta theta = 0 . 0 ; sr = 0 . 62831853071 ; t = 0 . 0 ; x = 0 . 0 ; y = 0 . 0 ; inv l = 0 . 1 ; c = 12 . 34 ; theta = − 0 . 985 ; while ( t < 1 . 0 ) { delta dl = c ∗ sl ; delta dr = c ∗ sr ; delta d = ( delta dl + delta dr ) ∗ 0 . 5 ; delta theta = ( delta dr − delta dl ) ∗ inv l ; arg = theta + ( delta theta ∗ 0 . 5 ); z = cosi ( arg ); x = x + ( delta d ∗ z ); q = sini ( arg ); y = y + ( delta d ∗ q ); theta = theta + delta theta ; t = t + 0 . 1 ; Trajectory } return y ; Sl Sr } double sini ( double u ) { ϴ w = u − (( u ∗ u ∗ u ) ∗ 0 . 1666 ) + (( u ∗ u ∗ u ∗ u ∗ u ) ∗ 0 . 0083 ); y return w ; } double cosi ( double a ) { b = 1 . 0 − ( a ∗ a ∗ 0 . 5 ) + (( a ∗ a ∗ a ∗ a ) ∗ 0 . 0416 ); return b ; L } x N. DAMOUCHE MetaLibm Workshop 8 / 61

  9. SALSA Context Motivating Example Non intuitive accurate implementation Transformed program sl = [ 0 . 52 , 0 . 53 , − 0 ., 0 . ] double main () { t = 0 . 0 ; theta = − 0 . 985 ; y = 0 . 0 ; x = 0 . 0 ; arg = 0 . 0 ; delta theta = 0 . 0 ; delta d = 0 . 0 ; delta dr = 0 . 0 ; delta dl = 0 . 0 ; while ( t < 1 . 0 ) { delta dl = ( 12 . 34 ∗ sl ); delta dr = 7 . 753450668961402 ; delta d = ( 0 . 5 ∗ ( delta dl + delta d r )); delta theta = ( 0 . 1 ∗ ( delta dr − delta d l )); arg = ( theta + ( delta theta ∗ 0 . 5 )); z = cosiTMP 2 ( theta , delta theta ); x = ( x + ( delta d ∗ z )); q = siniTMP 6 ( theta , delta theta ); y = ( y + ( delta d ∗ q )); theta = ( theta + delta theta ); t = ( t + 0 . 1 ); } ; return y ; } double siniTMP 6 ( doubletheta , doubledelta theta ) { TMP 3 = ( theta + ( delta theta ∗ 0 . 5 )); w = (( TMP 3 − ((( TMP 3 ∗ TMP 3 ) ∗ TMP 3 ) ∗ 0 . 1666 )) + ((((( TMP 3 ∗ TMP 3 ) ∗ TMP 3 ) ∗ TMP 3 ) ∗ TMP 3 ) ∗ 0 . 0083 )); return w ; } double cosiTMP 2 ( doubletheta , doubledelta theta ) { TMP 1 = ( theta + ( delta theta ∗ 0 . 5 )); b = (( 1 . 0 − (( TMP 1 ∗ TMP 1 ) ∗ 0 . 5 )) + (((( TMP 1 ∗ TMP 1 ) ∗ TMP 1 ) ∗ TMP 1 ) ∗ 0 . 0416 )); return b ; } N. DAMOUCHE MetaLibm Workshop 9 / 61

  10. SALSA Context Motivating Example Original and transformed value of x It Original Transformed Original Odometry 8 . 681698 8 . 444116 1 Transformed Odometry 17 . 038230 16 . 589474 2 24 . 756744 24 . 147995 3 31 . 549016 30 . 852965 4 37 . 163761 36 . 469708 5 41 . 398951 40 . 806275 6 44 . 114126 43 . 724118 7 45 . 242707 45 . 148775 8 N. DAMOUCHE MetaLibm Workshop 10 / 61

  11. SALSA Floating-point arithmetics Background Floating-point numbers Computation of errors N. DAMOUCHE MetaLibm Workshop 11 / 61

  12. SALSA Floating-point arithmetics Floating-point numbers F = finite representation of Reals R 1 3 = 0 . 33333333333333333333333333333333333 ..... Computed F result � = expected R result ⇒ Round-off errors These errors may have catastrophic consequences N. DAMOUCHE MetaLibm Workshop 12 / 61

  13. SALSA Floating-point arithmetics IEEE754 Standard Binary representation of floating-point numbers sign exponent mantissa 1 1 0 0 0 0 1 1 1 0 1 1 0 1 0 0 1 0 1 s : sign {+, -} e : exponent (8 or 11 bits) m : mantissa (23 or 52 bits) Basic IEEE754 Standard floating-point format Type Mantissa (bits) e max e min Exponent (bits) Single 23+1 +127 -126 8 Double 52+1 +1023 -1022 11 N. DAMOUCHE MetaLibm Workshop 13 / 61

  14. SALSA Floating-point arithmetics IEEE754 Standard Rounding mode -1/3 +1/3 To nearest Toward zero To nearest Toward zero Toward -in fi nity Toward -in fi nity Toward +in fi nity Toward +in fi nity 0 -in fi nity +in fi nity N. DAMOUCHE MetaLibm Workshop 14 / 61

  15. SALSA Floating-point arithmetics Floating-point numbers Representation of 1 3 with p = 10 in b = 2 1 . 0101010101 Rounding Error 1 . 0101010101 . . . 0101 Rounding function : ↑ ∼ ( 1 / 3 ) = 0 . 0101010101 - 1 . 0101010101 = 0 . 0000000000 . . . 0101 Round-off error : ↓ ∼ ( 1 / 3 ) = 0 . 0000000000 . . . 0101 N. DAMOUCHE MetaLibm Workshop 15 / 61

  16. SALSA Floating-point arithmetics Addition of two numbers [ 3 . 141 , 3 . 142 ] [ 0 . 00059 , 0 . 000592 ] µ 1 + [ 99 . 88 , 99 . 99 ] [ 0 . 09 , 0 . 1 ] µ 2 [ 103 . 021 , 103 . 132 ] [ 0 . 00059 , 0 . 000592 ] µ 1 = [ 0 . 09 , 0 . 1 ] µ 2 + [ 103 . 0 , 103 . 1 ] [ 0 . 00059 , 0 . 000592 ] µ 1 = [ 0 . 09 , 0 . 1 ] µ 2 + [ 0 . 0 , 0 . 032 ] ↓ ∼ ( x 1 + x 2 ) + [ 103 . 0 , 103 . 1 ] [ 0 . 09059 , 0 . 132592 ] = Global error N. DAMOUCHE MetaLibm Workshop 16 / 61

  17. SALSA Floating-point arithmetics Multiplication of two numbers [ 3 . 141 , 3 . 142 ] [ 0 . 00059 , 0 . 000592 ] µ 1 × [ 99 . 98 , 99 . 99 ] [ 0 . 09 , 0 . 1 ] µ 2 [ 314 . 03718 [ 0 . 28269 , 0 . 3142 ] x 1 × µ 2 = , 314 . 16858 ] + [ 0 . 0589882 , 0 . 05919408 ] x 2 × µ 1 [ 0 . 0000531 , 0 . 0000592 ] µ 1 × µ 2 + [ 314 . 0 , 314 . 2 ] [ 0 . 28269 , 0 . 3142 ] x 1 × µ 2 = + [ 0 . 0589882 , 0 . 05919408 ] x 2 × µ 1 [ 0 . 0000531 , 0 . 0000592 ] µ 1 × µ 2 + [ 0 . 0 , 0 . 03718 ] ↓ ∼ ( x 1 × x 2 ) + [ 314 . 0 , 314 . 2 ] [ 0 . 3417313 , 0 . 4123328 ] = Global error N. DAMOUCHE MetaLibm Workshop 17 / 61

  18. SALSA Related work Related Work Transformation for Numerical Accuracy Transformation of Expressions 1 Intraprocedural Transformation 2 Interprocedural Transformation 3 N. DAMOUCHE MetaLibm Workshop 18 / 61

  19. SALSA Related work Transformation of Expressions APEG introduced to limit combinatory [A. Ioualalen] APEG (Abstract Program Expression Graph) (a + a + b) × c (a + b + a) × c (b + a + a) × c × × + + c × (a + a + b) c × (a + b + a) □ + c × × c × (b + a + a) ((a + a) × c) + ( b × c) (((2 × a) + b ) × c) × b +(a,a,b) × + c b c ((2 × a) × c) + (b × c) (c × b) + (c × (a + a)) 2 a a a (a × c) + (a × c) + (b × c) ((a + b) × c ) + (a × c) APEG for e = ((a + a) + b) × c. . . . N. DAMOUCHE MetaLibm Workshop 19 / 61

  20. SALSA Related work Transformation of Expressions APEG introduced to limit combinatory [A. Ioualalen] APEG (Abstract Program Expression Graph) (a + a + b) × c (a + b + a) × c (b + a + a) × c × × + + c × (a + a + b) c × (a + b + a) □ + c × × c × (b + a + a) ((a + a) × c) + ( b × c) (((2 × a) + b ) × c) × b +(a,a,b) × + c b c ((2 × a) × c) + (b × c) (c × b) + (c × (a + a)) 2 a a a (a × c) + (a × c) + (b × c) ((a + b) × c ) + (a × c) APEG for e = ((a + a) + b) × c. . . . Build the APEG of expression and search an accurate formula among it ([ 3 . 141 , 3 . 142 ] , [ 0 . 00059 , 0 . 000592 ]) � ([ 99 . 98 , 99 . 99 ] , [ 0 . 09 , 0 . 1 ]) because 0 . 000592 ≤ 0 . 1 N. DAMOUCHE MetaLibm Workshop 20 / 61

  21. SALSA Related work Related Work Transformation for Numerical Accuracy Transformation of Expressions 1 Intraprocedural Transformation 2 Interprocedural Transformation 3 N. DAMOUCHE MetaLibm Workshop 21 / 61

Recommend


More recommend