verifying bit manipulations

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