verifying bit manipulations
play

Verifying Bit-Manipulations of Floating-P oint Wonyeol Lee Rahul - PowerPoint PPT Presentation

Verifying Bit-Manipulations of Floating-P oint Wonyeol Lee Rahul Sharma Alex Aiken Stanford University PLDI 2016 This Talk Example: mathematical specification Goal: Bound the difference between spec and implementation


  1. P ossible Alternatives • Exhaustive testing • feasible for 32-bit float: ~ 30 seconds (with 1 core for sinf ) • infeasible for 64-bit double: > 4000 years ( = 30 seconds × 2 32 ) • infeasible even for input range X = −1, 1 1 ∵ (# of doubles between −1 and 1 ) = 2 (# of all doubles) • Machine-checkable proofs • Harrison used transcendental functions are very accurate [ ] • construction of these proofs often requires considerable persistence 24

  2. P ossible Alternatives • Exhaustive testing • feasible for 32-bit float: ~ 30 seconds (with 1 core for sinf ) • infeasible for 64-bit double: > 4000 years ( = 30 seconds × 2 32 ) • infeasible even for input range X = −1, 1 1 ∵ (# of doubles between −1 and 1 ) = 2 (# of all doubles) • Machine-checkable proofs • Harrison used transcendental functions are very accurate [ ] • construction of these proofs often requires considerable persistence 25

  3. P ossible Alternatives • Exhaustive testing • feasible for 32-bit float: ~ 30 seconds (with 1 core for sinf ) • infeasible for 64-bit double: > 4000 years ( = 30 seconds × 2 32 ) • infeasible even for input range X = −1, 1 1 ∵ (# of doubles between −1 and 1 ) = 2 (# of all doubles) • Machine-checkable proofs • Harrison used transcendental functions are very accurate [ ] • construction of these proofs often requires considerable persistence 26

  4. P ossible Alternatives • Exhaustive testing • feasible for 32-bit float: ~ 30 seconds (with 1 core for sinf ) • infeasible for 64-bit double: > 4000 years ( = 30 seconds × 2 32 ) • infeasible even for input range X = −1, 1 1 ∵ (# of doubles between −1 and 1 ) = 2 (# of all doubles) • Machine-checkable proofs • Harrison used transcendental functions are very accurate [ ] • construction of these proofs often requires considerable persistence. 27

  5. P ossible Automatic Alternatives • If only floating-point operations are used, various automatic techniques can be applied • e.g., Astree , Fluctuat , ROSA , FPTaylor • Several commercial tools (e.g., Astree, Fluctuat) can handle certain bit-trick routines • We are unaware of a general technique for verifying mixed floating-point and bit-level code 28

  6. P ossible Automatic Alternatives • If only floating-point operations are used, various automatic techniques can be applied • e.g., Astree , Fluctuat , ROSA , FPTaylor • Several commercial tools (e.g., Astree, Fluctuat) can handle certain bit-trick routines • We are unaware of a general technique for verifying mixed floating-point and bit-level code 29

  7. Our Method 30

  8. 𝑓 𝑦 Explained 1 vmovddup %xmm0, %xmm0 2 vmulpd L2E, %xmm0, %xmm2 3 vroundpd $0, %xmm2, %xmm2 4 vcvtpd2dqx %xmm2, %xmm3 5 vpaddd B, %xmm3, %xmm3 6 vpslld $20, %xmm3, %xmm3 7 vpshufd $114, %xmm3, %xmm3 8 vmulpd C1, %xmm2, %xmm1 9 vmulpd C2, %xmm2, %xmm2 10 vaddpd %xmm1, %xmm0, %xmm1 11 vaddpd %xmm2, %xmm1, %xmm1 12 vmovapd T1, %xmm0 13 vmulpd T12, %xmm1, %xmm2 14 vaddpd T11, %xmm2, %xmm2 ... 36 vaddpd %xmm0, %xmm1, %xmm0 37 vmulpd %xmm3, %xmm0, %xmm0 38 retq 31

  9. 𝑓 𝑦 Explained 𝑦 1 vmovddup %xmm0, %xmm0 2 vmulpd L2E, %xmm0, %xmm2 𝑂 = round 𝑦 ∙ log 2 𝑓 3 vroundpd $0, %xmm2, %xmm2 4 vcvtpd2dqx %xmm2, %xmm3 5 vpaddd B, %xmm3, %xmm3 6 vpslld $20, %xmm3, %xmm3 7 vpshufd $114, %xmm3, %xmm3 8 vmulpd C1, %xmm2, %xmm1 9 vmulpd C2, %xmm2, %xmm2 10 vaddpd %xmm1, %xmm0, %xmm1 11 vaddpd %xmm2, %xmm1, %xmm1 12 vmovapd T1, %xmm0 13 vmulpd T12, %xmm1, %xmm2 14 vaddpd T11, %xmm2, %xmm2 ... 36 vaddpd %xmm0, %xmm1, %xmm0 37 vmulpd %xmm3, %xmm0, %xmm0 38 retq 32

  10. 𝑓 𝑦 Explained 𝑦 1 vmovddup %xmm0, %xmm0 2 vmulpd L2E, %xmm0, %xmm2 𝑂 = round 𝑦 ∙ log 2 𝑓 3 vroundpd $0, %xmm2, %xmm2 4 vcvtpd2dqx %xmm2, %xmm3 5 vpaddd B, %xmm3, %xmm3 2 𝑂 6 vpslld $20, %xmm3, %xmm3 7 vpshufd $114, %xmm3, %xmm3 8 vmulpd C1, %xmm2, %xmm1 9 vmulpd C2, %xmm2, %xmm2 10 vaddpd %xmm1, %xmm0, %xmm1 11 vaddpd %xmm2, %xmm1, %xmm1 12 vmovapd T1, %xmm0 13 vmulpd T12, %xmm1, %xmm2 14 vaddpd T11, %xmm2, %xmm2 ... 36 vaddpd %xmm0, %xmm1, %xmm0 37 vmulpd %xmm3, %xmm0, %xmm0 38 retq 33

  11. 𝑓 𝑦 Explained 𝑦 1 vmovddup %xmm0, %xmm0 2 vmulpd L2E, %xmm0, %xmm2 𝑂 = round 𝑦 ∙ log 2 𝑓 3 vroundpd $0, %xmm2, %xmm2 4 vcvtpd2dqx %xmm2, %xmm3 5 vpaddd B, %xmm3, %xmm3 2 𝑂 6 vpslld $20, %xmm3, %xmm3 7 vpshufd $114, %xmm3, %xmm3 8 vmulpd C1, %xmm2, %xmm1 9 vmulpd C2, %xmm2, %xmm2 𝑠 = 𝑦 − 𝑂 ∙ ln 2 10 vaddpd %xmm1, %xmm0, %xmm1 11 vaddpd %xmm2, %xmm1, %xmm1 12 vmovapd T1, %xmm0 12 𝑠 𝑗 13 vmulpd T12, %xmm1, %xmm2 𝑓 𝑠 ≈ ෍ 14 vaddpd T11, %xmm2, %xmm2 𝑗! ... 𝑗=0 36 vaddpd %xmm0, %xmm1, %xmm0 37 vmulpd %xmm3, %xmm0, %xmm0 𝑓 𝑦 = 𝑓 𝑂∙ln 2 ∙ 𝑓 𝑠 ≈ 2 𝑂 ∙ 𝑓 𝑠 38 retq 34

  12. 𝑓 𝑦 Explained 𝑦 1 vmovddup %xmm0, %xmm0 2 vmulpd L2E, %xmm0, %xmm2 𝑂 = round 𝑦 ∙ log 2 𝑓 3 vroundpd $0, %xmm2, %xmm2 4 vcvtpd2dqx %xmm2, %xmm3 5 vpaddd B, %xmm3, %xmm3 2 𝑂 6 vpslld $20, %xmm3, %xmm3 7 vpshufd $114, %xmm3, %xmm3 8 vmulpd C1, %xmm2, %xmm1 9 vmulpd C2, %xmm2, %xmm2 𝑠 = 𝑦 − 𝑂 ∙ ln 2 10 vaddpd %xmm1, %xmm0, %xmm1 11 vaddpd %xmm2, %xmm1, %xmm1 12 vmovapd T1, %xmm0 12 𝑠 𝑗 13 vmulpd T12, %xmm1, %xmm2 𝑓 𝑠 ≈ ෍ 14 vaddpd T11, %xmm2, %xmm2 𝑗! ... 𝑗=0 36 vaddpd %xmm0, %xmm1, %xmm0 37 vmulpd %xmm3, %xmm0, %xmm0 𝑓 𝑦 = 𝑓 𝑂∙ln 2 ∙ 𝑓 𝑠 ≈ 2 𝑂 ∙ 𝑓 𝑠 38 retq Find a small Θ > 0 such that Goal: 𝑓 𝑦 −2 𝑂 𝑓 𝑠 ≤ Θ for all 𝑦 ∈ 𝑌 𝑓 𝑦 35

  13. 1) Abstract Floating-P oint Operations • Assume only floating-point operations are used • 1 + 𝜗 property • A standard way to model rounding errors • For 64-bit doubles, 𝜗 = 2 −53 • This property has been used in previous automatic techniques (FPTaylor -point programs 36

  14. 1) Abstract Floating-P oint Operations • Assume only floating-point operations are used • 1 + 𝜗 property • A standard way to model rounding errors • For 64-bit doubles, 𝜗 = 2 −53 • This property has been used in previous automatic techniques (FPTaylor -point programs 37

  15. 1) Abstract Floating-P oint Operations • Assume only floating-point operations are used • 1 + 𝜗 property • A standard way to model rounding errors 𝑦 ⨂ f 𝑧 ∈ 𝑦⨂𝑧 1 + 𝜀 ∶ 𝜀 < 𝜗 • For 64-bit doubles, 𝜗 = 2 −53 • This property has been used in previous automatic techniques (FPTaylor -point programs 38

  16. 1) Abstract Floating-P oint Operations • Assume only floating-point operations are used • 1 + 𝜗 property • A standard way to model rounding errors 𝑦 ⨂ f 𝑧 ∈ 𝑦⨂𝑧 1 + 𝜀 ∶ 𝜀 < 𝜗 0 1 𝑦⨂𝑧 • For 64-bit doubles, 𝜗 = 2 −53 • This property has been used in previous automatic techniques (FPTaylor -point programs 39

  17. 1) Abstract Floating-P oint Operations • Assume only floating-point operations are used • 1 + 𝜗 property • A standard way to model rounding errors 𝑦 ⨂ f 𝑧 ∈ 𝑦⨂𝑧 1 + 𝜀 ∶ 𝜀 < 𝜗 0 1 𝑦⨂𝑧 • For 64-bit doubles, 𝜗 = 2 −53 • This property has been used in previous automatic techniques (FPTaylor -point programs 40

  18. 1) Abstract Floating-P oint Operations • Assume only floating-point operations are used • 1 + 𝜗 property • A standard way to model rounding errors 𝑦 ⨂ f 𝑧 ∈ 𝑦⨂𝑧 1 + 𝜀 ∶ 𝜀 < 𝜗 0 1 𝑦⨂𝑧 𝑦 ⨂ f 𝑧 • For 64-bit doubles, 𝜗 = 2 −53 • This property has been used in previous automatic techniques (FPTaylor -point programs 41

  19. 1) Abstract Floating-P oint Operations • Assume only floating-point operations are used • 1 + 𝜗 property • A standard way to model rounding errors 𝑦 ⨂ f 𝑧 ∈ 𝑦⨂𝑧 1 + 𝜀 ∶ 𝜀 < 𝜗 𝜗 0 1 𝑦⨂𝑧 𝑦 ⨂ f 𝑧 • For 64-bit doubles, 𝜗 = 2 −53 • This property has been used in previous automatic techniques (FPTaylor -point programs 42

  20. 1) Abstract Floating-P oint Operations • Assume only floating-point operations are used • 1 + 𝜗 property • A standard way to model rounding errors 𝑦 ⨂ f 𝑧 ∈ 𝑦⨂𝑧 1 + 𝜀 ∶ 𝜀 < 𝜗 𝜗 0 1 𝑦⨂𝑧 𝑦 ⨂ f 𝑧 • For 64-bit doubles, 𝜗 = 2 −53 • This property has been used in previous automatic techniques (FPTaylor -point programs 43

  21. 1) Abstract Floating-P oint Operations • Compute a symbolic abstraction 𝐵 𝜀 𝑦 of a program 𝑄 • Example: • F 𝐵 𝜀 𝑦 satisfies rom 1 + 𝜗 property, 𝑄 𝑦 ∈ 𝐵 𝜀 𝑦 ∶ 𝜀 𝑗 < 𝜗 for all 𝑦 • Example: 44

  22. 1) Abstract Floating-P oint Operations • Compute a symbolic abstraction 𝐵 𝜀 𝑦 of a program 𝑄 • Example: 𝑄 𝑦 = 2 × f 𝑦 1 + 𝜀 1 + f 3 1 + 𝜀 2 • F 𝐵 𝜀 𝑦 satisfies rom 1 + 𝜗 property, 𝑄 𝑦 ∈ 𝐵 𝜀 𝑦 ∶ 𝜀 𝑗 < 𝜗 for all 𝑦 • Example: 45

  23. 1) Abstract Floating-P oint Operations • Compute a symbolic abstraction 𝐵 𝜀 𝑦 of a program 𝑄 • Example: 𝐵 𝜀 𝑦 𝑄 𝑦 = 2 × f 𝑦 1 + 𝜀 1 + f 3 1 + 𝜀 2 • F 𝐵 𝜀 𝑦 satisfies rom 1 + 𝜗 property, 𝑄 𝑦 ∈ 𝐵 𝜀 𝑦 ∶ 𝜀 𝑗 < 𝜗 for all 𝑦 • Example: 46

  24. 1) Abstract Floating-P oint Operations • Compute a symbolic abstraction 𝐵 𝜀 𝑦 of a program 𝑄 • Example: 𝐵 𝜀 𝑦 𝑄 𝑦 = 2 × f 𝑦 × 1 + 𝜀 1 + f 3 + 1 + 𝜀 2 • F 𝐵 𝜀 𝑦 satisfies rom 1 + 𝜗 property, 𝑄 𝑦 ∈ 𝐵 𝜀 𝑦 ∶ 𝜀 𝑗 < 𝜗 for all 𝑦 • Example: 47

  25. 1) Abstract Floating-P oint Operations • Compute a symbolic abstraction 𝐵 𝜀 𝑦 of a program 𝑄 • Example: 𝐵 𝜀 𝑦 𝑄 𝑦 = 2 × f 𝑦 × 1 + 𝜀 1 + f 3 + 1 + 𝜀 2 • F 𝐵 𝜀 𝑦 satisfies rom 1 + 𝜗 property, 𝑄 𝑦 ∈ 𝐵 𝜀 𝑦 ∶ 𝜀 𝑗 < 𝜗 for all 𝑦 • Example: 48

  26. 1) Abstract Floating-P oint Operations • Compute a symbolic abstraction 𝐵 𝜀 𝑦 of a program 𝑄 • Example: 𝐵 𝜀 𝑦 𝑄 𝑦 = 2 × f 𝑦 × 1 + 𝜀 1 + f 3 + 1 + 𝜀 2 • F 𝐵 𝜀 𝑦 satisfies rom 1 + 𝜗 property, 𝑄 𝑦 ∈ 𝐵 𝜀 𝑦 ∶ 𝜀 𝑗 < 𝜗 for all 𝑦 • Example: 49

  27. 1) Abstract Floating-P oint Operations • Compute a symbolic abstraction 𝐵 𝜀 𝑦 of a program 𝑄 • Example: 𝐵 𝜀 𝑦 𝑄 𝑦 = 2 × f 𝑦 × 1 + 𝜀 1 + f 3 + 1 + 𝜀 2 • F 𝐵 𝜀 𝑦 satisfies rom 1 + 𝜗 property, 𝑄 𝑦 ∈ 𝐵 𝜀 𝑦 ∶ 𝜀 𝑗 < 𝜗 for all 𝑦 • Example: 𝑄 𝑦 = 2 × f 𝑦 1 + 𝜀 1 + f 3 1 + 𝜀 2 ∶ 𝜀 1 , 𝜀 2 < 𝜗 50

  28. 1) Abstract Floating-P oint Operations • Compute a symbolic abstraction 𝐵 𝜀 𝑦 of a program 𝑄 • Example: 𝐵 𝜀 𝑦 𝑄 𝑦 = 2 × f 𝑦 × 1 + 𝜀 1 + + f 3 1 + 𝜀 2 • F 𝐵 𝜀 𝑦 satisfies rom 1 + 𝜗 property, 𝑄 𝑦 ∈ 𝐵 𝜀 𝑦 ∶ 𝜀 𝑗 < 𝜗 for all 𝑦 • Example: { } 𝑄 𝑦 = 2 × f 𝑦 × 1 + 𝜀 1 + f 3 + 1 + 𝜀 2 ∶ 𝜀 1 , 𝜀 2 < 𝜗 51

  29. 1) Abstract Floating-P oint Operations • Compute a symbolic abstraction 𝐵 𝜀 𝑦 of a program 𝑄 • Example: 𝐵 𝜀 𝑦 𝑄 𝑦 = 2 × f 𝑦 × 1 + 𝜀 1 + + f 3 1 + 𝜀 2 • F 𝐵 𝜀 𝑦 satisfies rom 1 + 𝜗 property, 𝑄 𝑦 ∈ 𝐵 𝜀 𝑦 ∶ 𝜀 𝑗 < 𝜗 for all 𝑦 • Example: { } 𝑄 𝑦 = ∈ 2 × f 𝑦 × 1 + 𝜀 1 + f 3 + 1 + 𝜀 2 ∶ 𝜀 1 , 𝜀 2 < 𝜗 52

  30. Our Method: Overview 𝑄(𝑦) −1 1 𝑌 ... vpslld $20, ... vpshufd $114, ... vmulpd C1, ... vmulpd C2, ... ... 53

  31. Our Method: Overview 𝑄(𝑦) −1 1 𝑌 ... vpslld $20, ... vpshufd $114, ... vmulpd C1, ... vmulpd C2, ... ... 54

  32. Our Method: Overview 𝑄(𝑦) −1 1 𝑌 ... vpslld $20, ... vpshufd $114, ... vmulpd C1, ... vmulpd C2, ... ... 55

  33. Our Method: Overview 𝑄(𝑦) hard to find −1 1 𝑌 ... vpslld $20, ... vpshufd $114, ... vmulpd C1, ... vmulpd C2, ... ... 56

  34. Our Method: Overview 𝑄(𝑦) hard to find −1 1 𝑌 n ... vpslld $20, ... vpshufd $114, ... vmulpd C1, ... vmulpd C2, ... ... abstract using 57

  35. Our Method: Overview 𝑄(𝑦) hard to find −1 1 𝑌 𝐽 1 𝐽 2 𝐽 𝑜 n ... vpslld $20, ... vpshufd $114, ... vmulpd C1, ... vmulpd C2, ... ... abstract using 58

  36. Our Method: Overview 𝑄(𝑦) hard to find −1 1 𝑌 𝐽 1 𝐽 2 𝐽 𝑜 n ... ... vpslld $20, ... vpslld $20, ... vpshufd $114, ... vpshufd $114, ... vmulpd C1, ... vmulpd C1, ... ... vmulpd C2, ... vmulpd C2, ... ... vpslld $20, ... ... ... vpslld $20, ... vpshufd $114, ... vpshufd $114, ... vmulpd C1, ... vmulpd C1, ... abstract using vmulpd C2, ... vmulpd C2, ... ... ... 59

  37. Our Method: Overview 𝑄(𝑦) hard to find −1 1 𝑌 𝐽 1 𝐽 2 𝐽 𝑜 n ... ... 1 vpslld $20, ... vpslld $20, ... vpshufd $114, ... vpshufd $114, ... 3 vmulpd C1, ... vmulpd C1, ... ... vmulpd C2, ... vmulpd C2, ... ... vpslld $20, ... ... ... 𝒐 vpslld $20, ... vpshufd $114, ... vpshufd $114, ... 𝟑𝒐 + 𝟐 vmulpd C1, ... vmulpd C1, ... abstract using vmulpd C2, ... vmulpd C2, ... ... partial evaluation ... of bit-level operations 60

  38. Our Method: Overview 𝑄(𝑦) hard to find −1 1 𝑌 𝐽 1 𝐽 2 𝐽 𝑜 n ... ... 1 vpslld $20, ... vpslld $20, ... vpshufd $114, ... vpshufd $114, ... 3 vmulpd C1, ... vmulpd C1, ... ... vmulpd C2, ... vmulpd C2, ... ... vpslld $20, ... ... ... 𝒐 vpslld $20, ... vpshufd $114, ... vpshufd $114, ... 𝟑𝒐 + 𝟐 vmulpd C1, ... only floating-point vmulpd C1, ... abstract using vmulpd C2, ... vmulpd C2, ... ... operations partial evaluation ... of bit-level operations 61

  39. Our Method: Overview 𝑄(𝑦) 𝐵 2,𝜀 (𝑦) 𝐵 1,𝜀 (𝑦) hard to find 𝐵 𝑜,𝜀 (𝑦) −1 1 𝑌 𝐽 1 𝐽 2 𝐽 𝑜 n ... ... 1 vpslld $20, ... vpslld $20, ... vpshufd $114, ... vpshufd $114, ... 3 vmulpd C1, ... vmulpd C1, ... ... vmulpd C2, ... vmulpd C2, ... ... vpslld $20, ... ... ... 𝒐 vpslld $20, ... vpshufd $114, ... vpshufd $114, ... 𝟑𝒐 + 𝟐 vmulpd C1, ... only floating-point vmulpd C1, ... abstract using vmulpd C2, ... vmulpd C2, ... ... operations partial evaluation ... of bit-level operations 62

  40. Our Method: Overview 𝐵 2,𝜀 (𝑦) 𝐵 1,𝜀 (𝑦) 𝐵 𝑜,𝜀 (𝑦) 𝐽 1 𝐽 2 𝐽 𝑜 ... 1 vpslld $20, ... vpshufd $114, ... 3 vmulpd C1, ... ... vmulpd C2, ... ... vpslld $20, ... ... 𝒐 vpslld $20, ... vpshufd $114, ... vpshufd $114, ... 𝟑𝒐 + 𝟐 vmulpd C1, ... vmulpd C1, ... vmulpd C2, ... vmulpd C2, ... ... partial evaluation ... of bit-level operations 63

  41. Our Method: Overview 𝐵 2,𝜀 (𝑦) 𝐵 1,𝜀 (𝑦) 𝐵 𝑜,𝜀 (𝑦) 𝑔 𝑦 − 𝐵 𝑜,𝜀 𝑦 𝑔 𝑦 − 𝐵 1,𝜀 𝑦 𝑔(𝑦) 𝑔(𝑦) 𝐽 1 𝐽 2 𝐽 𝑜 𝐽 1 𝐽 2 𝐽 𝑜 ... 1 vpslld $20, ... vpshufd $114, ... 3 vmulpd C1, ... ... vmulpd C2, ... ... vpslld $20, ... ... 𝒐 vpslld $20, ... vpshufd $114, ... vpshufd $114, ... 𝟑𝒐 + 𝟐 vmulpd C1, ... vmulpd C1, ... vmulpd C2, ... vmulpd C2, ... ... partial evaluation ... of bit-level operations 64

  42. Our Method: Overview 𝐵 2,𝜀 (𝑦) 𝐵 1,𝜀 (𝑦) solve optimization problems 𝐵 𝑜,𝜀 (𝑦) 𝑔 𝑦 − 𝐵 𝑜,𝜀 𝑦 𝑔 𝑦 − 𝐵 1,𝜀 𝑦 max 𝑔(𝑦) max 𝑔(𝑦) 𝐽 1 𝐽 2 𝐽 𝑜 𝐽 1 𝐽 2 𝐽 𝑜 ... 1 vpslld $20, ... vpshufd $114, ... 3 vmulpd C1, ... ... vmulpd C2, ... ... vpslld $20, ... ... 𝒐 vpslld $20, ... vpshufd $114, ... vpshufd $114, ... 𝟑𝒐 + 𝟐 vmulpd C1, ... vmulpd C1, ... vmulpd C2, ... vmulpd C2, ... ... partial evaluation ... of bit-level operations 65

  43. Our Method: Overview 𝐵 2,𝜀 (𝑦) 𝐵 1,𝜀 (𝑦) solve optimization problems 𝐵 𝑜,𝜀 (𝑦) 𝑔 𝑦 − 𝐵 𝑜,𝜀 𝑦 𝑔 𝑦 − 𝐵 1,𝜀 𝑦 max 𝑔(𝑦) max 𝑔(𝑦) 𝐽 1 𝐽 2 𝐽 𝑜 𝐽 1 𝐽 2 𝐽 𝑜 ... 1 vpslld $20, ... answer! vpshufd $114, ... 3 vmulpd C1, ... ... vmulpd C2, ... ... vpslld $20, ... ... 𝒐 vpslld $20, ... vpshufd $114, ... vpshufd $114, ... 𝟑𝒐 + 𝟐 vmulpd C1, ... vmulpd C1, ... vmulpd C2, ... vmulpd C2, ... ... partial evaluation ... of bit-level operations 66

  44. 2) Divide the Input Range • Assume bit-level operations are used as well • To handle bit-level operations, divide 𝑌 into intervals 𝐽 𝑙 , on each 𝐽 𝑙 , so that, we can statically know the result of each bit-level operation • Example: 67

  45. 2) Divide the Input Range • Assume bit-level operations are used as well • To handle bit-level operations, divide 𝑌 into intervals 𝐽 𝑙 , on each 𝐽 𝑙 , so that, we can statically know the result of each bit-level operation • Example: 68

  46. 2) Divide the Input Range • Assume bit-level operations are used as well • To handle bit-level operations, divide 𝑌 into intervals 𝐽 𝑙 , on each 𝐽 𝑙 , so that, we can statically know the result of each bit-level operation −1 𝑌 1 • Example: input x y ← x × f C (C = 0x3ff71547652b82fe) N ← round(y) z ← int(N) + i 0x3ff w ← z << 52 ... 69

  47. 2) Divide the Input Range • Assume bit-level operations are used as well • To handle bit-level operations, divide 𝑌 into intervals 𝐽 𝑙 , on each 𝐽 𝑙 , so that, we can statically know the result of each bit-level operation −1 𝑌 1 • Example: 𝐽 −1 𝐽 0 𝐽 1 input x y ← x × f C (C = 0x3ff71547652b82fe) N ← round(y) z ← int(N) + i 0x3ff w ← z << 52 ... 70

  48. 2) Divide the Input Range • Assume bit-level operations are used as well • To handle bit-level operations, divide 𝑌 into intervals 𝐽 𝑙 , on each 𝐽 𝑙 , so that, we can statically know the result of each bit-level operation −1 −1 𝑌 𝑌 1 1 • Example: 𝐽 −1 𝐽 −1 𝐽 0 𝐽 0 𝐽 1 𝐽 1 input x y ← x × f C (C = 0x3ff71547652b82fe) N ← round(y) z ← int(N) + i 0x3ff w ← z << 52 ... 71

  49. 2) Divide the Input Range • Assume bit-level operations are used as well • To handle bit-level operations, divide 𝑌 into intervals 𝐽 𝑙 , on each 𝐽 𝑙 , so that, we can statically know the result of each bit-level operation −1 −1 𝑌 𝑌 1 1 • Example: 𝐽 −1 𝐽 −1 𝐽 0 𝐽 0 𝐽 1 𝐽 1 input x y ← x × f C (C = 0x3ff71547652b82fe) N ← round(y) −1 z ← int(N) + i 0x3ff w ← z << 52 ... 72

  50. 2) Divide the Input Range • Assume bit-level operations are used as well • To handle bit-level operations, divide 𝑌 into intervals 𝐽 𝑙 , on each 𝐽 𝑙 , so that, we can statically know the result of each bit-level operation −1 −1 𝑌 𝑌 1 1 • Example: 𝐽 −1 𝐽 −1 𝐽 0 𝐽 0 𝐽 1 𝐽 1 input x input x y ← x × f C y ← x × f C (C = 0x3ff71547652b82fe) (C = 0x3ff71547652b82fe) N ← round(y) partial evaluation N ← −1 −1 z ← int(N) + i 0x3ff z ← 1022 w ← z << 52 w ← 0.5 ... ... 73

  51. 2) Divide the Input Range • Assume bit-level operations are used as well • To handle bit-level operations, divide 𝑌 into intervals 𝐽 𝑙 , on each 𝐽 𝑙 , so that, we can statically know the result of each bit-level operation −1 −1 𝑌 𝑌 1 1 • Example: 𝐽 −1 𝐽 −1 𝐽 0 𝐽 0 𝐽 1 𝐽 1 input x input x y ← x × f C y ← x × f C (C = 0x3ff71547652b82fe) (C = 0x3ff71547652b82fe) N ← round(y) partial evaluation N ← −1 −1 z ← int(N) + i 0x3ff z ← 1022 Only floating-point operations are left w ← z << 52 w ← 0.5 ... ... → Can compute 𝐵 𝜀 𝑦 on each 𝐽 𝑙 74

  52. 2) Divide the Input Range • How to find such intervals? • Use symbolic abstractions • Example: • 𝑂 = round 𝑦 × f C • (symbolic abstraction of 𝑦 × f C ) = 𝑦 × C 1 + 𝜀 • Let 𝐽 𝑙 = largest interval contained in 𝑦 ∈ 𝑌 ∶ 𝑇 𝑦 ⊂ 𝑙 − 0.5, 𝑙 + 0.5 • Then 𝑂 is evaluated to 𝑙 for every input in 𝐽 𝑙 75

  53. 2) Divide the Input Range • How to find such intervals? −1 𝑌 1 • Use symbolic abstractions 𝐽 −1 𝐽 0 𝐽 1 • Example: • 𝑂 = round 𝑦 × f C • (symbolic abstraction of 𝑦 × f C ) = 𝑦 × C 1 + 𝜀 • Let 𝐽 𝑙 = largest interval contained in 𝑦 ∈ 𝑌 ∶ 𝑇 𝑦 ⊂ 𝑙 − 0.5, 𝑙 + 0.5 • Then 𝑂 is evaluated to 𝑙 for every input in 𝐽 𝑙 76

  54. 2) Divide the Input Range • How to find such intervals? −1 𝑌 1 • Use symbolic abstractions 𝐽 −1 𝐽 0 𝐽 1 𝑂 = −1 𝑂 = 0 𝑂 = 1 • Example: • 𝑂 = round 𝑦 × f C • (symbolic abstraction of 𝑦 × f C ) = 𝑦 × C 1 + 𝜀 • Let 𝐽 𝑙 = largest interval contained in 𝑦 ∈ 𝑌 ∶ 𝑇 𝑦 ⊂ 𝑙 − 0.5, 𝑙 + 0.5 • Then 𝑂 is evaluated to 𝑙 for every input in 𝐽 𝑙 77

  55. 2) Divide the Input Range • How to find such intervals? −1 𝑌 1 • Use symbolic abstractions 𝐽 −1 𝐽 0 𝐽 1 𝑂 = −1 𝑂 = 0 𝑂 = 1 • Example: • 𝑂 = round 𝑦 × f C • (symbolic abstraction of 𝑦 × f C ) = 𝑦 × C 1 + 𝜀 • Let 𝐽 𝑙 = largest interval contained in 𝑦 ∈ 𝑌 ∶ 𝑇 𝑦 ⊂ 𝑙 − 0.5, 𝑙 + 0.5 • Then 𝑂 is evaluated to 𝑙 for every input in 𝐽 𝑙 78

  56. 2) Divide the Input Range • How to find such intervals? −1 𝑌 1 • Use symbolic abstractions 𝐽 −1 𝐽 0 𝐽 1 𝑂 = −1 𝑂 = 0 𝑂 = 1 • Example: • 𝑂 = round 𝑦 × f C • (symbolic abstraction of 𝑦 × f C ) = 𝑦 × C 1 + 𝜀 • Let 𝐽 𝑙 = largest interval contained in 𝑦 ∈ 𝑌 ∶ 𝑇 𝑦 ⊂ 𝑙 − 0.5, 𝑙 + 0.5 • Then 𝑂 is evaluated to 𝑙 for every input in 𝐽 𝑙 79

  57. 2) Divide the Input Range • How to find such intervals? −1 𝑌 1 • Use symbolic abstractions 𝐽 −1 𝐽 0 𝐽 1 𝑂 = −1 𝑂 = 0 𝑂 = 1 • Example: • 𝑂 = round 𝑦 × f C • (symbolic abstraction of 𝑦 × f C ) = 𝑦 × C 1 + 𝜀 • Let 𝐽 𝑙 = largest interval contained in 𝑦 ∈ 𝑌 ∶ 𝑇 𝑦 ⊂ 𝑙 − 0.5, 𝑙 + 0.5 • Then 𝑂 is evaluated to 𝑙 for every input in 𝐽 𝑙 80

  58. 2) Divide the Input Range • How to find such intervals? −1 𝑌 1 • Use symbolic abstractions 𝐽 −1 𝐽 0 𝐽 1 𝑂 = −1 𝑂 = 0 𝑂 = 1 • Example: • 𝑂 = round 𝑦 × f C • (symbolic abstraction of 𝑦 × f C ) = 𝑦 × C 1 + 𝜀 𝑦 × f C 𝑇(𝑦) = 𝑦 × C 1 + 𝜀 : 𝜀 < 𝜗 • Let 𝐽 𝑙 = largest interval contained in 𝑦 ∈ 𝑌 ∶ 𝑇 𝑦 ⊂ 𝑙 − 0.5, 𝑙 + 0.5 • Then 𝑂 is evaluated to 𝑙 for every input in 𝐽 𝑙 81

  59. 2) Divide the Input Range • How to find such intervals? −1 𝑌 1 • Use symbolic abstractions 𝐽 −1 𝐽 0 𝐽 1 𝑂 = −1 𝑂 = 0 𝑂 = 1 • Example: • 𝑂 = round 𝑦 × f C • (symbolic abstraction of 𝑦 × f C ) = 𝑦 × C 1 + 𝜀 𝑦 × f C 𝑇(𝑦) = 𝑦 × C 1 + 𝜀 : 𝜀 < 𝜗 𝑙 − 0.5 𝑙 + 0.5 • Let 𝐽 𝑙 = largest interval contained in 𝑦 ∈ 𝑌 ∶ 𝑇 𝑦 ⊂ 𝑙 − 0.5, 𝑙 + 0.5 • Then 𝑂 is evaluated to 𝑙 for every input in 𝐽 𝑙 82

  60. 2) Divide the Input Range • How to find such intervals? −1 𝑌 1 • Use symbolic abstractions 𝐽 −1 𝐽 0 𝐽 1 𝑂 = −1 𝑂 = 0 𝑂 = 1 • Example: • 𝑂 = round 𝑦 × f C • (symbolic abstraction of 𝑦 × f C ) = 𝑦 × C 1 + 𝜀 𝑦 × f C 𝑇(𝑦) = 𝑦 × C 1 + 𝜀 : 𝜀 < 𝜗 𝑂 = 𝑙 𝑙 − 0.5 𝑙 + 0.5 • Let 𝐽 𝑙 = largest interval contained in 𝑦 ∈ 𝑌 ∶ 𝑇 𝑦 ⊂ 𝑙 − 0.5, 𝑙 + 0.5 • Then 𝑂 is evaluated to 𝑙 for every input in 𝐽 𝑙 83

  61. 2) Divide the Input Range • How to find such intervals? −1 𝑌 1 • Use symbolic abstractions 𝐽 −1 𝐽 0 𝐽 1 𝑂 = −1 𝑂 = 0 𝑂 = 1 • Example: • 𝑂 = round 𝑦 × f C • (symbolic abstraction of 𝑦 × f C ) = 𝑦 × C 1 + 𝜀 𝑦 × f C 𝑇(𝑦) = 𝑦 × C 1 + 𝜀 : 𝜀 < 𝜗 𝑂 = 𝑙 𝑙 − 0.5 𝑙 + 0.5 • Let 𝐽 𝑙 = largest interval contained in 𝑦 ∈ 𝑌 ∶ 𝑇 𝑦 ⊂ 𝑙 − 0.5, 𝑙 + 0.5 • Then 𝑂 is evaluated to 𝑙 for every input in 𝐽 𝑙 84

  62. 2) Divide the Input Range • How to find such intervals? −1 𝑌 1 • Use symbolic abstractions 𝐽 −1 𝐽 0 𝐽 1 𝑂 = −1 𝑂 = 0 𝑂 = 1 • Example: • 𝑂 = round 𝑦 × f C • (symbolic abstraction of 𝑦 × f C ) = 𝑦 × C 1 + 𝜀 𝑦 × f C 𝑇(𝑦) = 𝑦 × C 1 + 𝜀 : 𝜀 < 𝜗 𝑂 = 𝑙 𝑙 − 0.5 𝑙 + 0.5 • Let 𝐽 𝑙 = largest interval contained in 𝑦 ∈ 𝑌 ∶ 𝑇 𝑦 ⊂ 𝑙 − 0.5, 𝑙 + 0.5 • Then 𝑂 is evaluated to 𝑙 for every input in 𝐽 𝑙 85

  63. 3) Compute a Bound on Precision Loss • Precision loss on each interval 𝐽 𝑙 • Let 𝐵 𝜀 𝑦 be a symbolic abstraction on 𝐽 𝑙 • Analytical optimization: 𝑓 𝑦 −𝐵 𝜀 𝑦 max 𝑓 𝑦 𝑦∈𝐽 𝑙 , |𝜀 𝑗 |<𝜗 • Use Mathematica to solve optimization problems analytically 86

  64. 3) Compute a Bound on Precision Loss • Precision loss on each interval 𝐽 𝑙 • Let 𝐵 𝜀 𝑦 be a symbolic abstraction on 𝐽 𝑙 • Analytical optimization: 𝑓 𝑦 −𝐵 𝜀 𝑦 max 𝑓 𝑦 𝑦∈𝐽 𝑙 , |𝜀 𝑗 |<𝜗 • Use Mathematica to solve optimization problems analytically 87

  65. Are We Done? • No. The constructed intervals do not cover 𝑌 in general • Because we made sound approximations −1 input range 𝑌 1 𝐽 −1 𝐽 0 𝐽 1 88

  66. Are We Done? • No. The constructed intervals do not cover 𝑌 in general • Because we made sound approximations −1 input range 𝑌 1 floating-point numbers 𝐽 −1 𝐽 0 𝐽 1 89

  67. Are We Done? • No. The constructed intervals do not cover 𝑌 in general • Because we made sound approximations −1 input range 𝑌 1 floating-point numbers 𝐽 −1 𝐽 0 𝐽 1 between intervals 90

  68. Are We Done? • No. The constructed intervals do not cover 𝑌 in general • Because we made sound approximations −1 input range 𝑌 1 floating-point numbers 𝐽 −1 𝐽 0 𝐽 1 between intervals 91

  69. Are We Done? • Example: 𝑂 = round 𝑦 × f 𝐷 abstraction of 𝑦 × f 𝐷 : 0 1 0.5 1 For 𝑦 = 𝑂 would be 0 or 1 2𝐷 , • Let 𝐼 = {floating- • We observe that |𝐼| is small in experiment 92

  70. Are We Done? • Example: 𝑂 = round 𝑦 × f 𝐷 abstraction of 𝑦 × f 𝐷 : 0 1 𝑦 = 1/(1.5𝐷) 𝑦 = 1/(3𝐷) 0.5 1 For 𝑦 = 𝑂 would be 0 or 1 2𝐷 , • Let 𝐼 = {floating- • We observe that |𝐼| is small in experiment 93

  71. Are We Done? • Example: 𝑂 = round 𝑦 × f 𝐷 abstraction of 𝑦 × f 𝐷 : 0 1 𝑦 = 1/(1.5𝐷) 𝑦 = 1/(3𝐷) 𝑂 = 0 0.5 𝑂 = 1 1 For 𝑦 = 𝑂 would be 0 or 1 2𝐷 , • Let 𝐼 = {floating- • We observe that |𝐼| is small in experiment 94

  72. Are We Done? • Example: 𝑂 = round 𝑦 × f 𝐷 abstraction of 𝑦 × f 𝐷 : 0 1 𝑦 = 1/(1.5𝐷) 𝑦 = 1/(3𝐷) 𝑦 = 1/(2𝐷) 𝑂 = 0 0.5 𝑂 = 1 1 For 𝑦 = 𝑂 would be 0 or 1 2𝐷 , • Let 𝐼 = {floating- • We observe that |𝐼| is small in experiment 95

  73. Are We Done? • Example: 𝑂 = round 𝑦 × f 𝐷 𝑦 × f 𝐷 abstraction of 𝑦 × f 𝐷 : ? ? ? ? ? ? 0 1 𝑦 = 1/(1.5𝐷) 𝑦 = 1/(3𝐷) 𝑦 = 1/(2𝐷) 𝑂 = 0 0.5 𝑂 = 1 1 For 𝑦 = 𝑂 would be 0 or 1 2𝐷 , • Let 𝐼 = {floating- • We observe that |𝐼| is small in experiment 96

  74. Are We Done? • Example: 𝑂 = round 𝑦 × f 𝐷 𝑦 × f 𝐷 abstraction of 𝑦 × f 𝐷 : ? ? ? ? ? ? 0 1 𝑦 = 1/(1.5𝐷) 𝑦 = 1/(3𝐷) 𝑦 = 1/(2𝐷) 𝑂 = 0 0.5 𝑂 = 1 1 For 𝑦 = 𝑂 would be 0 or 1 2𝐷 , • Let 𝐼 = {floating- • We observe that |𝐼| is small in experiment 97

  75. Are We Done? • Example: 𝑂 = round 𝑦 × f 𝐷 𝑦 × f 𝐷 abstraction of 𝑦 × f 𝐷 : ? ? ? ? ? ? 0 1 𝑦 = 1/(1.5𝐷) 𝑦 = 1/(3𝐷) 𝑦 = 1/(2𝐷) 𝑂 = 0 0.5 𝑂 = 1 1 For 𝑦 = 𝑂 would be 0 or 1 2𝐷 , • Let 𝐼 = {floating- • We observe that |𝐼| is small in experiment 98

  76. 3) Compute a Bound on Precision Loss • Precision loss on each interval 𝐽 𝑙 • Let 𝐵 𝜀 𝑦 be a symbolic abstraction on 𝐽 𝑙 • Analytical optimization: 𝑓 𝑦 −𝐵 𝜀 𝑦 max 𝑓 𝑦 𝑦∈𝐽 𝑙 , |𝜀 𝑗 |<𝜗 • Use Mathematica to solve optimization problems analytically • Precision loss on 𝐼 • For each 𝑦 ∈ 𝐼 , obtain 𝑄 𝑦 by executing the binary • Brute force: 𝑓 𝑦 −𝑄 𝑦 max 𝑓 𝑦 𝑦∈𝐼 • Use Mathematica to compute 𝑓 𝑦 and precision loss exactly 99

  77. 3) Compute a Bound on Precision Loss • Precision loss on each interval 𝐽 𝑙 • Let 𝐵 𝜀 𝑦 be a symbolic abstraction on 𝐽 𝑙 • Analytical optimization: take maximum 𝑓 𝑦 −𝐵 𝜀 𝑦 → answer! max 𝑓 𝑦 𝑦∈𝐽 𝑙 , |𝜀 𝑗 |<𝜗 • Use Mathematica to solve optimization problems analytically • Precision loss on 𝐼 • For each 𝑦 ∈ 𝐼 , obtain 𝑄 𝑦 by executing the binary • Brute force: 𝑓 𝑦 −𝑄 𝑦 max 𝑓 𝑦 𝑦∈𝐼 • Use Mathematica to compute 𝑓 𝑦 and precision loss exactly 100

Recommend


More recommend