Daisy a framework for sound accuracy analysis of numerical programs - - PowerPoint PPT Presentation

daisy
SMART_READER_LITE
LIVE PREVIEW

Daisy a framework for sound accuracy analysis of numerical programs - - PowerPoint PPT Presentation

Daisy a framework for sound accuracy analysis of numerical programs Eva Darulova Anastasiia Izycheva eva@mpi-sws.org izycheva@in.tum.de Daisy a framework for sound accuracy analysis of numerical programs } and optimization Eva Darulova


slide-1
SLIDE 1

Daisy

a framework for sound accuracy analysis of numerical programs

Eva Darulova eva@mpi-sws.org Anastasiia Izycheva izycheva@in.tum.de

slide-2
SLIDE 2

Daisy

a framework for sound accuracy analysis of numerical programs

Eva Darulova eva@mpi-sws.org

}

and optimization

Anastasiia Izycheva izycheva@in.tum.de

slide-3
SLIDE 3

Observation:

slide-4
SLIDE 4

Observation:

many applications use more resources than they really need

slide-5
SLIDE 5

Observation:

many applications use more resources than they really need

➡ particularly important for embedded systems

slide-6
SLIDE 6

Observation:

many applications use more resources than they really need

➡ particularly important for embedded systems ➡ in numerical programs:

slide-7
SLIDE 7

Observation:

many applications use more resources than they really need

➡ particularly important for embedded systems ➡ in numerical programs:

  • too much precision (among other issues)
slide-8
SLIDE 8

Observation:

many applications use more resources than they really need

➡ particularly important for embedded systems ➡ in numerical programs:

  • too much precision (among other issues)

Why?

slide-9
SLIDE 9

Observation:

many applications use more resources than they really need

➡ particularly important for embedded systems ➡ in numerical programs:

  • too much precision (among other issues)

Why?

challenging to optimise manually

slide-10
SLIDE 10

Observation:

many applications use more resources than they really need

➡ particularly important for embedded systems ➡ in numerical programs:

  • too much precision (among other issues)

Why?

challenging to optimise manually

  • verification of finite-precision
slide-11
SLIDE 11

Observation:

many applications use more resources than they really need

➡ particularly important for embedded systems ➡ in numerical programs:

  • too much precision (among other issues)

Why?

challenging to optimise manually

  • verification of finite-precision
  • too many options for optimisation
slide-12
SLIDE 12

Daisy’s Goal

real-valued program with accuracy spec

  • ptimised finite-precision program

Daisy

slide-13
SLIDE 13

Daisy’s Goal

general real-valued program with accuracy spec

  • ptimised finite-precision program

Daisy

slide-14
SLIDE 14

Daisy’s Goal

general real-valued program with accuracy spec

  • ptimised finite-precision program

Daisy

automated

slide-15
SLIDE 15

finite-precision program real-valued program with accuracy spec

slide-16
SLIDE 16

finite-precision program real-valued program with accuracy spec

1: def sine(x: Real): Real = { 2: require(-1.5 <= x && x <= 1.5 && x +/- 1e-11) 3: 4: x - (x^3)/6.0 + (x^5)/120.0 - (x^7)/5040.0 5: 6: } ensuring(res => res +/- 1.001e-11)

slide-17
SLIDE 17

finite-precision program

def sine(x: Double): Double = { require(-1.5 <= x && x <= 1.5) x - (x^3)/6.0 + (x^5)/120.0 - (x^7)/5040.0 }

floating-point arithmetic real-valued program with accuracy spec

1: def sine(x: Real): Real = { 2: require(-1.5 <= x && x <= 1.5 && x +/- 1e-11) 3: 4: x - (x^3)/6.0 + (x^5)/120.0 - (x^7)/5040.0 5: 6: } ensuring(res => res +/- 1.001e-11)

slide-18
SLIDE 18

finite-precision program

def sine(x: Double): Double = { require(-1.5 <= x && x <= 1.5) x - (x^3)/6.0 + (x^5)/120.0 - (x^7)/5040.0 }

floating-point arithmetic

def sine(x: Long): Long = { require(-1.5 <= x && x <= 1.5) val _t1 = ((x * x) >> 31) val _t2 = ((_t1 * x) >> 30) val _t3 = ((_t2 << 30) / 1610612736l) val _t4 = ((x << 1) - _t3) . . .

fixed-point arithmetic real-valued program with accuracy spec

1: def sine(x: Real): Real = { 2: require(-1.5 <= x && x <= 1.5 && x +/- 1e-11) 3: 4: x - (x^3)/6.0 + (x^5)/120.0 - (x^7)/5040.0 5: 6: } ensuring(res => res +/- 1.001e-11)

slide-19
SLIDE 19

finite-precision program

def sine(x: Double): Double = { require(-1.5 <= x && x <= 1.5) x - (x^3)/6.0 + (x^5)/120.0 - (x^7)/5040.0 }

floating-point arithmetic

def sine(x: Long): Long = { require(-1.5 <= x && x <= 1.5) val _t1 = ((x * x) >> 31) val _t2 = ((_t1 * x) >> 30) val _t3 = ((_t2 << 30) / 1610612736l) val _t4 = ((x << 1) - _t3) . . .

fixed-point arithmetic real-valued program with accuracy spec

1: def sine(x: Real): Real = { 2: require(-1.5 <= x && x <= 1.5 && x +/- 1e-11) 3: 4: x - (x^3)/6.0 + (x^5)/120.0 - (x^7)/5040.0 5: 6: } ensuring(res => res +/- 1.001e-11)

  • 1. verification
  • 2. optimisation
slide-20
SLIDE 20

Accuracy Verification

How to measure accuracy?

def sine(x: Real): Real = { require(-1.5 <= x && x <= 1.5 && x +/- 1e-11) x - (x^3)/6.0 + (x^5)/120.0 - (x^7)/5040.0 } ensuring(res => res +/- 1.001e-11)

absolute errors

max

x∈I |f(x) − ˜

f(˜ x)|

slide-21
SLIDE 21

Accuracy Verification

How to measure accuracy? absolute errors

def sine(x: Real): Real = { require(-1.5 <= x && x <= 1.5 && x +/- 1e-11) x - (x^3)/6.0 + (x^5)/120.0 - (x^7)/5040.0 } ensuring(res => res +/- 1.001e-11)

relative errors

max

x∈I |f(x) − ˜

f(˜ x)|

max

x∈I

  • f(x) − ˜

f(˜ x) f(x)

slide-22
SLIDE 22

Accuracy Verification

How to measure accuracy? absolute errors

def sine(x: Real): Real = { require(-1.5 <= x && x <= 1.5 && x +/- 1e-11) x - (x^3)/6.0 + (x^5)/120.0 - (x^7)/5040.0 } ensuring(res => res +/- 1.001e-11)

relative errors

max

x∈I |f(x) − ˜

f(˜ x)|

Challenge: automatically and accurately bound worst-case errors

max

x∈I

  • f(x) − ˜

f(˜ x) f(x)

slide-23
SLIDE 23

Bounding Absolute Errors

max

x∈I |f(x) − ˜

f(˜ x)|

Static dataflow analysis

  • fully automated
  • sound upper bound
slide-24
SLIDE 24

Bounding Absolute Errors

max

x∈I |f(x) − ˜

f(˜ x)|

Static dataflow analysis

  • fully automated
  • sound upper bound

for each arithmetic operation

  • 1. compute real-valued range for intermediate value
  • 2. propagate existing errors
  • 3. compute new roundoff error
slide-25
SLIDE 25

Bounding Absolute Errors [1]

max

x∈I |f(x) − ˜

f(˜ x)|

Challenge: tight bounds for nonlinear arithmetic Static dataflow analysis

  • fully automated
  • sound upper bound
slide-26
SLIDE 26

Bounding Absolute Errors [1]

max

x∈I |f(x) − ˜

f(˜ x)|

Challenge: tight bounds for nonlinear arithmetic Challenge: conditionals (control-flow may diverge) Static dataflow analysis

  • fully automated
  • sound upper bound
slide-27
SLIDE 27

Bounding Absolute Errors [1]

max

x∈I |f(x) − ˜

f(˜ x)|

Challenge: tight bounds for nonlinear arithmetic Challenge: conditionals (control-flow may diverge) Challenge: loops (errors may grow unboundedly) Static dataflow analysis

  • fully automated
  • sound upper bound
slide-28
SLIDE 28

Bounding Absolute Errors

max

x∈I |f(x) − ˜

f(˜ x)|

Challenge: tight bounds for nonlinear arithmetic

abstract domains:

slide-29
SLIDE 29

Bounding Absolute Errors

max

x∈I |f(x) − ˜

f(˜ x)|

Challenge: tight bounds for nonlinear arithmetic

abstract domains:

  • interval arithmetic
slide-30
SLIDE 30

Bounding Absolute Errors

max

x∈I |f(x) − ˜

f(˜ x)|

Challenge: tight bounds for nonlinear arithmetic

abstract domains:

  • interval arithmetic
  • affine arithmetic
slide-31
SLIDE 31

Bounding Absolute Errors

max

x∈I |f(x) − ˜

f(˜ x)|

Challenge: tight bounds for nonlinear arithmetic

abstract domains:

  • interval arithmetic
  • affine arithmetic

additional techniques:

slide-32
SLIDE 32

Bounding Absolute Errors

max

x∈I |f(x) − ˜

f(˜ x)|

Challenge: tight bounds for nonlinear arithmetic

abstract domains:

  • interval arithmetic
  • affine arithmetic

additional techniques:

  • SMT (nonlinear decision procedure)
slide-33
SLIDE 33

Bounding Absolute Errors

max

x∈I |f(x) − ˜

f(˜ x)|

Challenge: tight bounds for nonlinear arithmetic

abstract domains:

  • interval arithmetic
  • affine arithmetic

additional techniques:

  • SMT (nonlinear decision procedure)
  • interval subdivision
slide-34
SLIDE 34

Bounding Absolute Errors

max

x∈I |f(x) − ˜

f(˜ x)|

Challenge: tight bounds for nonlinear arithmetic

abstract domains:

  • interval arithmetic
  • affine arithmetic

additional techniques:

  • SMT (nonlinear decision procedure)
  • interval subdivision

error bounds often within one order of magnitude of true errors

slide-35
SLIDE 35

Bounding Relative Errors

6=

state-of-the-art definition

max

x∈I

  • f(~

x) − ˜ f(~ ˜ x) f(~ x)

  • maxx∈I|f(⃗

x)− ˜ f(⃗ ˜ x)| minx∈I|f(⃗ x)|

Challenge: tight bounds

slide-36
SLIDE 36

Bounding Relative Errors

6=

state-of-the-art definition

max

x∈I

  • f(~

x) − ˜ f(~ ˜ x) f(~ x)

  • maxx∈I|f(⃗

x)− ˜ f(⃗ ˜ x)| minx∈I|f(⃗ x)|

Challenge: tight bounds Challenge: division by zero

slide-37
SLIDE 37

Tight Relative Error Bounds

Our solution:

  • evaluate the relative error expression directly
  • interval subdivision

Assume NO division by zero

errrel = max

x∈I

  • f(~

x) − ˜ f(~ ˜ x) f(~ x)

slide-38
SLIDE 38

Naive approach: Replace ˜

f(~ ˜ x) with its abstraction

according to IEEE754

f(~ x,~ e, ~ d)

f(x) = x + 0.3

Relative Errors Directly

slide-39
SLIDE 39

Naive approach: Replace ˜

f(~ ˜ x) with its abstraction

according to IEEE754

f(~ x,~ e, ~ d)

f(⃗ x,⃗ e, ⃗ d) = (x(1 + ex) + dx + 0.3(1 + e0.3) + d0.3)(1 + e+) + d+

f(x) = x + 0.3

Relative Errors Directly

slide-40
SLIDE 40

Naive approach: Replace ˜

f(~ ˜ x) with its abstraction

according to IEEE754

f(~ x,~ e, ~ d)

f(⃗ x,⃗ e, ⃗ d) = (x(1 + ex) + dx + 0.3(1 + e0.3) + d0.3)(1 + e+) + d+

f(x) = x + 0.3

Relative Errors Directly

slide-41
SLIDE 41

Naive approach: Replace ˜

f(~ ˜ x) with its abstraction

according to IEEE754

f(~ x,~ e, ~ d)

f(⃗ x,⃗ e, ⃗ d) = (x(1 + ex) + dx + 0.3(1 + e0.3) + d0.3)(1 + e+) + d+

f(x) = x + 0.3

Relative Errors Directly

slide-42
SLIDE 42

Naive approach: Replace ˜

f(~ ˜ x) with its abstraction

according to IEEE754

f(~ x,~ e, ~ d)

f(⃗ x,⃗ e, ⃗ d) = (x(1 + ex) + dx + 0.3(1 + e0.3) + d0.3)(1 + e+) + d+

f(x) = x + 0.3

Relative Errors Directly

slide-43
SLIDE 43

Naive approach: Replace ˜

f(~ ˜ x) with its abstraction

according to IEEE754

f(~ x,~ e, ~ d)

f(⃗ x,⃗ e, ⃗ d) = (x(1 + ex) + dx + 0.3(1 + e0.3) + d0.3)(1 + e+) + d+

f(x) = x + 0.3

Relative Errors Directly

slide-44
SLIDE 44

Naive approach: Replace ˜

f(~ ˜ x) with its abstraction

according to IEEE754

f(~ x,~ e, ~ d)

f(x) = x + 0.3

f(⃗ x,⃗ e, ⃗ d) = (x(1 + ex) + dx + 0.3(1 + e0.3))(1 + e+)

Relative Errors Directly

slide-45
SLIDE 45

Naive approach: Replace ˜

f(~ ˜ x) with its abstraction

according to IEEE754

f(~ x,~ e, ~ d)

f(x) = x + 0.3

f(⃗ x,⃗ e, ⃗ d) = (x(1 + ex) + dx + 0.3(1 + e0.3))(1 + e+)

errrel = max

x∈I,|ei|≤M,|di|≤δ

  • (x + 0.3) − (x(1 + ex) + dx + 0.3(1 + e0.3))(1 + e+)

x + 0.3

  • Relative Errors Directly
slide-46
SLIDE 46

Naive approach: Does not scale! Replace ˜

f(~ ˜ x) with its abstraction

according to IEEE754

f(~ x,~ e, ~ d)

f(x) = x + 0.3

f(⃗ x,⃗ e, ⃗ d) = (x(1 + ex) + dx + 0.3(1 + e0.3))(1 + e+)

errrel = max

x∈I,|ei|≤M,|di|≤δ

  • (x + 0.3) − (x(1 + ex) + dx + 0.3(1 + e0.3))(1 + e+)

x + 0.3

  • Relative Errors Directly
slide-47
SLIDE 47
  • simplify expression using Taylor expansion

g(~ x,~ e, ~ d) = f(~ x) − f(~ x,~ e, ~ d) f(~ x)

g(~ x,~ e, ~ d) = g(~ x,~ 0,~ 0) +

k

X

i=1

@g @ei (~ x,~ 0,~ 0)ei + R2(~ x,~ e, ~ d)

Relative Errors Directly

slide-48
SLIDE 48
  • simplify expression using Taylor expansion

=0

g(~ x,~ e, ~ d) = f(~ x) − f(~ x,~ e, ~ d) f(~ x)

g(~ x,~ e, ~ d) = g(~ x,~ 0,~ 0) +

k

X

i=1

@g @ei (~ x,~ 0,~ 0)ei + R2(~ x,~ e, ~ d)

Relative Errors Directly

slide-49
SLIDE 49
  • simplify expression using Taylor expansion

g(~ x,~ e, ~ d) = f(~ x) − f(~ x,~ e, ~ d) f(~ x) g(~ x,~ e, ~ d) =

k

X

i=1

@g @ei (~ x,~ 0,~ 0)ei + R2(~ x,~ e, ~ d)

Relative Errors Directly

slide-50
SLIDE 50

Evaluate the simplified expression using:

  • interval arithmetic
  • interval arithmetic + SMT solver

errrel = max

x∈I,|ei|≤M,|di|≤δ

  • k
  • i=1

∂g ∂ei (⃗ x,⃗ 0,⃗ 0)ei

  • + M2

Relative Errors Directly

slide-51
SLIDE 51

Bounding Relative Errors

Challenge: difficult to obtain tight bounds

slide-52
SLIDE 52

Bounding Relative Errors

Challenge: difficult to obtain tight bounds

  • error bounds at least same and up to six orders of magnitude

tighter than the state-of-the-art tools compute

slide-53
SLIDE 53

Bounding Relative Errors

Challenge: difficult to obtain tight bounds

  • error bounds at least same and up to six orders of magnitude

tighter than the state-of-the-art tools compute

  • interval subdivision + relative errors via absolute is beneficial
slide-54
SLIDE 54

Bounding Relative Errors

Challenge: difficult to obtain tight bounds

  • error bounds at least same and up to six orders of magnitude

tighter than the state-of-the-art tools compute

  • interval subdivision + relative errors via absolute is beneficial
  • interval subdivision + relative errors directly gives no effect
slide-55
SLIDE 55

Bounding Relative Errors

Challenge: difficult to obtain tight bounds Challenge: division by zero

  • error bounds at least same and up to six orders of magnitude

tighter than the state-of-the-art tools compute

  • interval subdivision + relative errors via absolute is beneficial
  • interval subdivision + relative errors directly gives no effect
slide-56
SLIDE 56

Bounding Relative Errors

Challenge: difficult to obtain tight bounds Challenge: division by zero

  • error bounds at least same and up to six orders of magnitude

tighter than the state-of-the-art tools compute

  • interval subdivision + relative errors via absolute is beneficial
  • interval subdivision + relative errors directly gives no effect

Our solution:

  • interval subdivision
  • compute relative errors where possible
slide-57
SLIDE 57

def sine(x: Real): Real = { require(-1.5 <= x && x <= 1.5 && x +/- 1e-11) x - (x^3)/6.0 + (x^5)/120.0 - (x^7)/5040.0 } ensuring(res => res +/- 1.001e-11)

real-valued program with accuracy spec finite-precision program

def sine(x: Double): Double = { require(-1.5 <= x && x <= 1.5) x - (x^3)/6.0 + (x^5)/120.0 - (x^7)/5040.0 }

floating-point arithmetic

def sine(x: Long): Long = { require(-1.5 <= x && x <= 1.5) val _t1 = ((x * x) >> 31) val _t2 = ((_t1 * x) >> 30) val _t3 = ((_t2 << 30) / 1610612736l) val _t4 = ((x << 1) - _t3) . . .

fixed-point arithmetic

verified by static analysis for linear and nonlinear arithmetic a (short) numerical arithmetic expression

slide-58
SLIDE 58

def sine(x: Real): Real = { require(-1.5 <= x && x <= 1.5 && x +/- 1e-11) x - (x^3)/6.0 + (x^5)/120.0 - (x^7)/5040.0 } ensuring(res => res +/- 1.001e-11)

real-valued program with accuracy spec finite-precision program

def sine(x: Double): Double = { require(-1.5 <= x && x <= 1.5) x - (x^3)/6.0 + (x^5)/120.0 - (x^7)/5040.0 }

floating-point arithmetic

def sine(x: Long): Long = { require(-1.5 <= x && x <= 1.5) val _t1 = ((x * x) >> 31) val _t2 = ((_t1 * x) >> 30) val _t3 = ((_t2 << 30) / 1610612736l) val _t4 = ((x << 1) - _t3) . . .

fixed-point arithmetic

verified by static analysis for linear and nonlinear arithmetic a (short) numerical arithmetic expression

  • 1. verification
  • 2. optimisation
slide-59
SLIDE 59

def sine(x: Real): Real = { require(-1.5 <= x && x <= 1.5 && x +/- 1e-11) x - (x^3)/6.0 + (x^5)/120.0 - (x^7)/5040.0 } ensuring(res => res +/- 1.001e-11)

real-valued program with accuracy spec finite-precision program

def sine(x: Double): Double = { require(-1.5 <= x && x <= 1.5) x - (x^3)/6.0 + (x^5)/120.0 - (x^7)/5040.0 }

floating-point arithmetic

def sine(x: Long): Long = { require(-1.5 <= x && x <= 1.5) val _t1 = ((x * x) >> 31) val _t2 = ((_t1 * x) >> 30) val _t3 = ((_t2 << 30) / 1610612736l) val _t4 = ((x << 1) - _t3) . . .

fixed-point arithmetic

  • 1. verification
  • 2. optimisation
slide-60
SLIDE 60

def sine(x: Real): Real = { require(-1.5 <= x && x <= 1.5 && x +/- 1e-11) x - (x^3)/6.0 + (x^5)/120.0 - (x^7)/5040.0 } ensuring(res => res +/- 1.001e-11)

real-valued program with accuracy spec finite-precision program

def sine(x: Double): Double = { require(-1.5 <= x && x <= 1.5) x - (x^3)/6.0 + (x^5)/120.0 - (x^7)/5040.0 }

floating-point arithmetic

def sine(x: Long): Long = { require(-1.5 <= x && x <= 1.5) val _t1 = ((x * x) >> 31) val _t2 = ((_t1 * x) >> 30) val _t3 = ((_t2 << 30) / 1610612736l) val _t4 = ((x << 1) - _t3) . . .

fixed-point arithmetic

  • rder of computation

  • 1. verification
  • 2. optimisation
slide-61
SLIDE 61

def sine(x: Real): Real = { require(-1.5 <= x && x <= 1.5 && x +/- 1e-11) x - (x^3)/6.0 + (x^5)/120.0 - (x^7)/5040.0 } ensuring(res => res +/- 1.001e-11)

real-valued program with accuracy spec finite-precision program

def sine(x: Double): Double = { require(-1.5 <= x && x <= 1.5) x - (x^3)/6.0 + (x^5)/120.0 - (x^7)/5040.0 }

floating-point arithmetic

def sine(x: Long): Long = { require(-1.5 <= x && x <= 1.5) val _t1 = ((x * x) >> 31) val _t2 = ((_t1 * x) >> 30) val _t3 = ((_t2 << 30) / 1610612736l) val _t4 = ((x << 1) - _t3) . . .

fixed-point arithmetic

mixed-precision

  • rder of computation

  • 1. verification
  • 2. optimisation
slide-62
SLIDE 62

def sine(x: Real): Real = { require(-1.5 <= x && x <= 1.5 && x +/- 1e-11) x - (x^3)/6.0 + (x^5)/120.0 - (x^7)/5040.0 } ensuring(res => res +/- 1.001e-11)

real-valued program with accuracy spec finite-precision program

def sine(x: Double): Double = { require(-1.5 <= x && x <= 1.5) x - (x^3)/6.0 + (x^5)/120.0 - (x^7)/5040.0 }

floating-point arithmetic

def sine(x: Long): Long = { require(-1.5 <= x && x <= 1.5) val _t1 = ((x * x) >> 31) val _t2 = ((_t1 * x) >> 30) val _t3 = ((_t2 << 30) / 1610612736l) val _t4 = ((x << 1) - _t3) . . .

fixed-point arithmetic

mixed-precision

  • rder of computation

+ ✔

  • 1. verification
  • 2. optimisation
slide-63
SLIDE 63

Changing the Order of Computation

a + (b + c) 6= (a + b) + c

slide-64
SLIDE 64

Changing the Order of Computation

a + (b + c) 6= (a + b) + c

before: assumed fixed evaluation order for soundness

slide-65
SLIDE 65

Changing the Order of Computation

a + (b + c) 6= (a + b) + c

before: assumed fixed evaluation order for soundness Opportunity:

  • choose order which incurs smallest roundoff error (for free)
  • sound wrt. real-valued specification language
slide-66
SLIDE 66

Changing the Order of Computation

a + (b + c) 6= (a + b) + c

Challenge: efficient search before: assumed fixed evaluation order for soundness Opportunity:

  • choose order which incurs smallest roundoff error (for free)
  • sound wrt. real-valued specification language
slide-67
SLIDE 67

Changing the Order of Computation

a + (b + c) 6= (a + b) + c

Goal: find order which

  • incurs smallest roundoff error (over input range)
  • is equivalent under real-valued semantics
slide-68
SLIDE 68

Changing the Order of Computation

a + (b + c) 6= (a + b) + c

Goal: find order which

  • incurs smallest roundoff error (over input range)
  • is equivalent under real-valued semantics

Our solution: genetic (heuristic) algorithm

  • fitness function: static roundoff error
  • mutation: associativity, distributivity etc. rules
slide-69
SLIDE 69

Changing the Order of Computation

a + (b + c) 6= (a + b) + c

Goal: find order which

  • incurs smallest roundoff error (over input range)
  • is equivalent under real-valued semantics

Our solution: genetic (heuristic) algorithm

  • fitness function: static roundoff error
  • mutation: associativity, distributivity etc. rules

significant (up to 70%) improvements in errors possible

slide-70
SLIDE 70

Mixed Precision

def rigidBody(x1: Double, x2: Double, x3: Double): Double = { require(-15.0 ≤ x1 ≤ 15 && -15.0 ≤ x2 ≤ 15.0 && -15.0 ≤ x3 ≤ 15)

  • x1*x2 - 2*x2*x3 - x1 - x3

}

slide-71
SLIDE 71

Mixed Precision

def rigidBody(x1: Double, x2: Double, x3: Double): Double = { require(-15.0 ≤ x1 ≤ 15 && -15.0 ≤ x2 ≤ 15.0 && -15.0 ≤ x3 ≤ 15)

  • x1*x2 - 2*x2*x3 - x1 - x3

}

satisfies absolute error bound: 3.5e-13 but not 1.75e-13

slide-72
SLIDE 72

Mixed Precision

def rigidBody(x1: Double, x2: Double, x3: Double): Double = { require(-15.0 ≤ x1 ≤ 15 && -15.0 ≤ x2 ≤ 15.0 && -15.0 ≤ x3 ≤ 15)

  • x1*x2 - 2*x2*x3 - x1 - x3

}

What if double floating-point precision is just not enough?

satisfies absolute error bound: 3.5e-13 but not 1.75e-13

slide-73
SLIDE 73

Mixed Precision

def rigidBody(x1: Double, x2: Double, x3: Double): Double = { require(-15.0 ≤ x1 ≤ 15 && -15.0 ≤ x2 ≤ 15.0 && -15.0 ≤ x3 ≤ 15)

  • x1*x2 - 2*x2*x3 - x1 - x3

}

What if double floating-point precision is just not enough?

satisfies absolute error bound: 3.5e-13 but not 1.75e-13

def rigidBody(x1: Quad, x2: Quad, x3: Quad): Quad = { require(-15.0 ≤ x1 ≤ 15 && -15.0 ≤ x2 ≤ 15.0 && -15.0 ≤ x3 ≤ 15)

  • x1*x2 - 2*x2*x3 - x1 - x3

}

satisfies absolute error bound: 1.5e-28 but is significantly slower than double precision

slide-74
SLIDE 74

Mixed Precision

def rigidBody(x1: Quad, x2: Quad, x3: Quad): Quad = { require(-15.0 ≤ x1 ≤ 15 && -15.0 ≤ x2 ≤ 15.0 && -15.0 ≤ x3 ≤ 15)

  • x1*x2 - 2*x2*x3 - x1 - x3

}

satisfies absolute error bound: 1.5e-28 but is significantly slower than double precision

slide-75
SLIDE 75

Mixed Precision

def rigidBody(x1: Quad, x2: Quad, x3: Quad): Quad = { require(-15.0 ≤ x1 ≤ 15 && -15.0 ≤ x2 ≤ 15.0 && -15.0 ≤ x3 ≤ 15)

  • x1*x2 - 2*x2*x3 - x1 - x3

}

satisfies absolute error bound: 1.5e-28 but is significantly slower than double precision

def rigidBody(x1: Double, x2: Double, x3: Double): Quad = {

  • Dx1 *D x2 -Q (2*D x2) *Q x3 -Q x1 -Q x3

}

Use mixed-precision

slide-76
SLIDE 76

Mixed Precision

def rigidBody(x1: Quad, x2: Quad, x3: Quad): Quad = { require(-15.0 ≤ x1 ≤ 15 && -15.0 ≤ x2 ≤ 15.0 && -15.0 ≤ x3 ≤ 15)

  • x1*x2 - 2*x2*x3 - x1 - x3

}

satisfies absolute error bound: 1.5e-28 but is significantly slower than double precision

def rigidBody(x1: Double, x2: Double, x3: Double): Quad = {

  • Dx1 *D x2 -Q (2*D x2) *Q x3 -Q x1 -Q x3

}

Use mixed-precision

slide-77
SLIDE 77

Mixed Precision

def rigidBody(x1: Quad, x2: Quad, x3: Quad): Quad = { require(-15.0 ≤ x1 ≤ 15 && -15.0 ≤ x2 ≤ 15.0 && -15.0 ≤ x3 ≤ 15)

  • x1*x2 - 2*x2*x3 - x1 - x3

}

satisfies absolute error bound: 1.5e-28 but is significantly slower than double precision

def rigidBody(x1: Double, x2: Double, x3: Double): Quad = {

  • Dx1 *D x2 -Q (2*D x2) *Q x3 -Q x1 -Q x3

}

Use mixed-precision

slide-78
SLIDE 78

Mixed Precision

def rigidBody(x1: Quad, x2: Quad, x3: Quad): Quad = { require(-15.0 ≤ x1 ≤ 15 && -15.0 ≤ x2 ≤ 15.0 && -15.0 ≤ x3 ≤ 15)

  • x1*x2 - 2*x2*x3 - x1 - x3

}

satisfies absolute error bound: 1.5e-28 but is significantly slower than double precision

def rigidBody(x1: Double, x2: Double, x3: Double): Quad = {

  • Dx1 *D x2 -Q (2*D x2) *Q x3 -Q x1 -Q x3

}

Use mixed-precision

satisfies absolute error bound: 1.75e13 28% faster than uniform quad precision

slide-79
SLIDE 79

Mixed Precision

def rigidBody(x1: Quad, x2: Quad, x3: Quad): Quad = { require(-15.0 ≤ x1 ≤ 15 && -15.0 ≤ x2 ≤ 15.0 && -15.0 ≤ x3 ≤ 15)

  • x1*x2 - 2*x2*x3 - x1 - x3

}

satisfies absolute error bound: 1.5e-28 but is significantly slower than double precision

def rigidBody(x1: Double, x2: Double, x3: Double): Quad = {

  • Dx1 *D x2 -Q (2*D x2) *Q x3 -Q x1 -Q x3

}

Use mixed-precision

satisfies absolute error bound: 1.75e13 28% faster than uniform quad precision

Challenge: efficient search & performance estimation

slide-80
SLIDE 80

Mixed Precision

Goal: automatically find mixed-precision assignment which

  • satisfies error bound
  • executes faster

def rigidBody(x1: Double, x2: Double, x3: Double): Quad = {

  • Dx1 *D x2 -Q (2*D x2) *Q x3 -Q x1 -Q x3

}

slide-81
SLIDE 81

Mixed Precision

Goal: automatically find mixed-precision assignment which

  • satisfies error bound
  • executes faster

Our solution:

  • incomplete search with static error analysis
  • static cost function obtained with benchmarking

def rigidBody(x1: Double, x2: Double, x3: Double): Quad = {

  • Dx1 *D x2 -Q (2*D x2) *Q x3 -Q x1 -Q x3

}

slide-82
SLIDE 82

rewriting: improves error mixed-precision: improves performance

slide-83
SLIDE 83

rewriting: improves error mixed-precision: improves performance improve performance even more

+ =

slide-84
SLIDE 84

rewriting: improves error mixed-precision: improves performance improve performance even more

+ =

def rigidBody(x1: Quad, x2: Quad, x3: Double): Double = { (-D(x1 *Q x2) -D (x1 +Q x3)) -D ((x2 *Q 2.0f) *D x3) }

satisfies absolute error bound: 1.75e13 43% faster than uniform quad precision

slide-85
SLIDE 85

rewriting: improves error mixed-precision: improves performance improve performance even more

+ =

Challenge: optimizing both at the same time does not scale

def rigidBody(x1: Quad, x2: Quad, x3: Double): Double = { (-D(x1 *Q x2) -D (x1 +Q x3)) -D ((x2 *Q 2.0f) *D x3) }

satisfies absolute error bound: 1.75e13 43% faster than uniform quad precision

slide-86
SLIDE 86

rewriting: improves error mixed-precision: improves performance improve performance even more

+ =

Challenge: optimizing both at the same time does not scale

def rigidBody(x1: Quad, x2: Quad, x3: Double): Double = { (-D(x1 *Q x2) -D (x1 +Q x3)) -D ((x2 *Q 2.0f) *D x3) }

satisfies absolute error bound: 1.75e13 43% faster than uniform quad precision

Our solution:

  • separate rewriting and mixed-precision tuning
  • careful coordination
slide-87
SLIDE 87

Daisy

framework for the analysis and optimisation of numerical programs Supported Features:

  • absolute roundoff error estimation [1]
  • with mixed-precision
  • transcendental functions
  • relative roundoff error estimation [2]
  • rewriting optimisation
  • sound mixed-precision tuning [3]
  • dynamic error evaluation (with arbitrary precision)
  • formal certificates for Coq and HOL4 [4]

for absolute error analysis with intervals, more features to come

D a i s y

slide-88
SLIDE 88

Daisy

framework for the analysis and optimisation of numerical programs

Design Goals:

  • modular ⟶ easy to extend

D a i s y

slide-89
SLIDE 89

Daisy

framework for the analysis and optimisation of numerical programs

Design Goals:

  • modular ⟶ easy to extend
  • limited dependencies ⟶ portable

D a i s y

slide-90
SLIDE 90

Daisy

framework for the analysis and optimisation of numerical programs

Design Goals:

  • modular ⟶ easy to extend
  • limited dependencies ⟶ portable
  • integration of previous techniques:

D a i s y

slide-91
SLIDE 91

Daisy

framework for the analysis and optimisation of numerical programs

Design Goals:

  • modular ⟶ easy to extend
  • limited dependencies ⟶ portable
  • integration of previous techniques:

➡ dataflow analysis (as in Rosa, Fluctuat)

D a i s y

slide-92
SLIDE 92

Daisy

framework for the analysis and optimisation of numerical programs

Design Goals:

  • modular ⟶ easy to extend
  • limited dependencies ⟶ portable
  • integration of previous techniques:

➡ dataflow analysis (as in Rosa, Fluctuat) ➡ optimisation-based analysis (as in FPTaylor, preliminary implementation)

D a i s y

slide-93
SLIDE 93

Daisy

framework for the analysis and optimisation of numerical programs

Design Goals:

  • modular ⟶ easy to extend
  • limited dependencies ⟶ portable
  • integration of previous techniques:

➡ dataflow analysis (as in Rosa, Fluctuat) ➡ optimisation-based analysis (as in FPTaylor, preliminary implementation) ➡ interval subdivision for all techniques

D a i s y

slide-94
SLIDE 94

Daisy

framework for the analysis and optimisation of numerical programs

Design Goals:

  • modular ⟶ easy to extend
  • limited dependencies ⟶ portable
  • integration of previous techniques:

➡ dataflow analysis (as in Rosa, Fluctuat) ➡ optimisation-based analysis (as in FPTaylor, preliminary implementation) ➡ interval subdivision for all techniques

  • clarity of code above performance (written in Scala)

D a i s y

slide-95
SLIDE 95

Bibliography

Daisy source code: https://github.com/malyzajko/daisy [1] Towards a Compiler for Reals E. Darulova, V. Kuncak, ACM Transactions on Programming Languages and Systems, TOPLAS’17 [2] On Sound Relative Error Bounds for Floating-Point Arithmetic A. Izycheva, E. Darulova, FMCAD’17 [3] Sound Mixed-Precision Optimization with Rewriting E. Darulova, E. Horn, S. Sharma, ICCPS’18 [4] A Verified Certificate Checker for Floating-Point Error Bounds H. Becker, E. Darulova, M. O. Myreen, arXiv:1707.02115, 2017

slide-96
SLIDE 96

Accurate Automated Static Analysis of Finite-Precision Roundoff Errors

several tools exist today: Rosa, Fluctuat, Gappa, FPTaylor, Real2Float, PRECiSA

slide-97
SLIDE 97

Accurate Automated Static Analysis of Finite-Precision Roundoff Errors

  • bound worst-case absolute roundoff errors
  • with reasonable accuracy
  • for floating-point precisions
  • (some also for fixed-points)
  • (some support for loops)
  • (some support for discontinuities/branches)

several tools exist today: Rosa, Fluctuat, Gappa, FPTaylor, Real2Float, PRECiSA