1cmreliable and accurate computing. computer arithmetic

74
intel Reliable and accurate computing. Computer arithmetic approach for digital filters. Anastasia Volkova 4 th Workshop on the Design and Analysis of Robust Systems July 13, 2019

Upload: others

Post on 24-Jan-2022

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 1cmReliable and accurate computing. Computer arithmetic

intel

Reliable and accurate computing.Computer arithmetic approachfor digital filters.

Anastasia Volkova

4th Workshop on the Design and Analysis of Robust Systems

July 13, 2019

Page 2: 1cmReliable and accurate computing. Computer arithmetic

intel

Impact of numerical errors

Funny fact:

• Broken YouTube

Not funny:

• Explosion of Ariane 5

• Boeing 787 problems

• Patriot missiles

A. Volkova Reliable and accurate computing 1/27

Page 3: 1cmReliable and accurate computing. Computer arithmetic

intel

Impact of numerical errors

Funny fact:

• Broken YouTube

Not funny:

• Explosion of Ariane 5

• Boeing 787 problems

• Patriot missiles

A. Volkova Reliable and accurate computing 1/27

Page 4: 1cmReliable and accurate computing. Computer arithmetic

intel

Digitization and the choices we make

• Formats and Arithmetic• floating-point• fixed-point

• Hardware and Software• CPU/GPU/FPGA/ASIC• language, compiler

• Generalist and App. Specific• math. libraries†

• digital filters, control, neuralnetworks,. . .

PERFORMANCE

GUARANTEED

ACCURACY

Reliability

Automation

Optimization

†Wed, 17:50 ”Sound Approximation of Programs with Elementary Functions”

A. Volkova Reliable and accurate computing 2/27

Page 5: 1cmReliable and accurate computing. Computer arithmetic

intel

Digitization and the choices we make

• Formats and Arithmetic• floating-point• fixed-point

• Hardware and Software• CPU/GPU/FPGA/ASIC• language, compiler

• Generalist and App. Specific• math. libraries†

• digital filters, control, neuralnetworks,. . .

PERFORMANCE

GUARANTEED

ACCURACY

Reliability

Automation

Optimization

†Wed, 17:50 ”Sound Approximation of Programs with Elementary Functions”

A. Volkova Reliable and accurate computing 2/27

Page 6: 1cmReliable and accurate computing. Computer arithmetic

intel

Digitization and the choices we make

• Formats and Arithmetic• floating-point• fixed-point

• Hardware and Software• CPU/GPU/FPGA/ASIC• language, compiler

• Generalist and App. Specific• math. libraries†

• digital filters, control, neuralnetworks,. . .

PERFORMANCE

GUARANTEED

ACCURACY

Reliability

Automation

Optimization

†Wed, 17:50 ”Sound Approximation of Programs with Elementary Functions”

A. Volkova Reliable and accurate computing 2/27

Page 7: 1cmReliable and accurate computing. Computer arithmetic

intel

Digitization and the choices we make

• Formats and Arithmetic• floating-point• fixed-point

• Hardware and Software• CPU/GPU/FPGA/ASIC• language, compiler

• Generalist and App. Specific• math. libraries†

• digital filters, control, neuralnetworks,. . .

PERFORMANCE

GUARANTEED

ACCURACY

Reliability

Automation

Optimization

†Wed, 17:50 ”Sound Approximation of Programs with Elementary Functions”

A. Volkova Reliable and accurate computing 2/27

Page 8: 1cmReliable and accurate computing. Computer arithmetic

intel

Digitization and the choices we make

• Formats and Arithmetic• floating-point• fixed-point

• Hardware and Software• CPU/GPU/FPGA/ASIC• language, compiler

• Generalist and App. Specific• math. libraries†

• digital filters, control, neuralnetworks,. . .

PERFORMANCE

GUARANTEED

ACCURACY

Reliability

Automation

Optimization

†Wed, 17:50 ”Sound Approximation of Programs with Elementary Functions”

A. Volkova Reliable and accurate computing 2/27

Page 9: 1cmReliable and accurate computing. Computer arithmetic

intel

Digitization and the choices we make

• Formats and Arithmetic• floating-point• fixed-point

• Hardware and Software• CPU/GPU/FPGA/ASIC• language, compiler

• Generalist and App. Specific• math. libraries†

• digital filters, control, neuralnetworks,. . .

PERFORMANCE

GUARANTEED

ACCURACY

Reliability

Automation

Optimization

†Wed, 17:50 ”Sound Approximation of Programs with Elementary Functions”

A. Volkova Reliable and accurate computing 2/27

Page 10: 1cmReliable and accurate computing. Computer arithmetic

intel

Signals are everywhereAnalog signals: continuous-time

Time

Digital signals: discrete-time

Time

A. Volkova Reliable and accurate computing 3/27

Page 11: 1cmReliable and accurate computing. Computer arithmetic

intel

Signals are everywhereAnalog signals: continuous-time

Time

Digital signals: discrete-time

Time

A. Volkova Reliable and accurate computing 3/27

Page 12: 1cmReliable and accurate computing. Computer arithmetic

intel

Linear digital filters

u(k) y(k)

H

Y (z)U(z)

Frequency domain

H (z ) =−z−2 + . . .

1− z−1 + z−2 + . . .

coefficient quantizationin Fixed-Point arithmetic

Finite-precisionarithmetic operations

Time domainu(k)

-1 + +

+ -1 -1

γ1 + γ2 + -1 γ3 +

-1 -1

+ + + -1

+ 0.5y(k)

z−1

z−1

z−1

γ1 =

γ2 =

γ3 =

Constraints w.r.t. surface, speed, accuracy . . .

Circuit / Code

A. Volkova Reliable and accurate computing 4/27

Page 13: 1cmReliable and accurate computing. Computer arithmetic

intel

Linear digital filters

u(k) y(k)

H

Y (z)U(z)

Frequency domain

H (z ) =0.0495329964− 0.148598989z−2 + . . .

1− 2.12060288z−1 + 2.7247492z−2 + . . .

coefficient quantizationin Fixed-Point arithmetic

Finite-precisionarithmetic operations

Time domainu(k)

-1 + +

+ -1 -1

γ1 + γ2 + -1 γ3 +

-1 -1

+ + + -1

+ 0.5y(k)

z−1

z−1

z−1

γ1 =

γ2 =

γ3 =

Constraints w.r.t. surface, speed, accuracy . . .

Circuit / Code

A. Volkova Reliable and accurate computing 4/27

Page 14: 1cmReliable and accurate computing. Computer arithmetic

intel

Linear digital filters

u(k) y(k)

H

Y (z)U(z)

Frequency domain

H (z ) =0.0495329964− 0.148598989z−2 + . . .

1− 2.12060288z−1 + 2.7247492z−2 + . . .

coefficient quantizationin Fixed-Point arithmetic

Finite-precisionarithmetic operations

Time domainu(k)

-1 + +

+ -1 -1

γ1 + γ2 + -1 γ3 +

-1 -1

+ + + -1

+ 0.5y(k)

z−1

z−1

z−1

γ1 = 0.347586468864209

γ2 = 0.334748427563068

γ3 = 0.084938546237853

Constraints w.r.t. surface, speed, accuracy . . .

Circuit / Code

A. Volkova Reliable and accurate computing 4/27

Page 15: 1cmReliable and accurate computing. Computer arithmetic

intel

Linear digital filters

u(k) y(k)

H

Y (z)U(z)

Frequency domain

H (z ) =0.0495329964− 0.148598989z−2 + . . .

1− 2.12060288z−1 + 2.7247492z−2 + . . .

coefficient quantizationin Fixed-Point arithmetic

Finite-precisionarithmetic operations

Time domainu(k)

-1 + +

+ -1 -1

γ1 + γ2 + -1 γ3 +

-1 -1

+ + + -1

+ 0.5y(k)

z−1

z−1

z−1

γ1 = 0.34765625

γ2 = 0.3359375

γ3 = 0.0859375

Constraints w.r.t. surface, speed, accuracy . . .

Circuit / Code

A. Volkova Reliable and accurate computing 4/27

Page 16: 1cmReliable and accurate computing. Computer arithmetic

intel

Linear digital filters

u(k) y(k)

H

Y (z)U(z)

Frequency domain

H (z ) =0.0495329964− 0.148598989z−2 + . . .

1− 2.12060288z−1 + 2.7247492z−2 + . . .

coefficient quantizationin Fixed-Point arithmetic

Finite-precisionarithmetic operations

Time domainu(k)

-1 + +

+ -1 -1

γ1 + γ2 + -1 γ3 +

-1 -1

+ + + -1

+ 0.5y(k)

z−1

z−1

z−1

γ1 = 0.34765625

γ2 = 0.3359375

γ3 = 0.0859375

Constraints w.r.t. surface, speed, accuracy . . .

Circuit / Code

A. Volkova Reliable and accurate computing 4/27

Page 17: 1cmReliable and accurate computing. Computer arithmetic

intel

Reliable and accurate digital filtersMajority of applications

• do not need numerical guarantee

• well-studied subject

• straightforward implementations

• commercial and free tools

Safety-critical applications

• require numerical guarantees

• have high(er) cost

• limited literature

• require expert knowledge fromengineers

• no out-of-box solution

Context: safety-critical applications

Goal: generate Fixed-Point codes reliable by construction

Means: interval, floating-point, multiple precision arithmetics

A. Volkova Reliable and accurate computing 5/27

Page 18: 1cmReliable and accurate computing. Computer arithmetic

intel

Reliable and accurate digital filtersMajority of applications

• do not need numerical guarantee

• well-studied subject

• straightforward implementations

• commercial and free tools

Safety-critical applications

• require numerical guarantees

• have high(er) cost

• limited literature

• require expert knowledge fromengineers

• no out-of-box solution

Context: safety-critical applications

Goal: generate Fixed-Point codes reliable by construction

Means: interval, floating-point, multiple precision arithmetics

A. Volkova Reliable and accurate computing 5/27

Page 19: 1cmReliable and accurate computing. Computer arithmetic

intel

Reliable and accurate digital filtersMajority of applications

• do not need numerical guarantee

• well-studied subject

• straightforward implementations

• commercial and free tools

Safety-critical applications

• require numerical guarantees

• have high(er) cost

• limited literature

• require expert knowledge fromengineers

• no out-of-box solution

Context: safety-critical applications

Goal: generate Fixed-Point codes reliable by construction

Means: interval, floating-point, multiple precision arithmetics

A. Volkova Reliable and accurate computing 5/27

Page 20: 1cmReliable and accurate computing. Computer arithmetic

intel

Outline

• Finite precision, filters and what’s the issue

• FiXiF toolbox: digital filters reliable by construction• Worst-case analysis• Format choice• Frequency spec verification

• Last-bit accurate hardware• Cost of the reliability

A. Volkova Reliable and accurate computing 6/27

Page 21: 1cmReliable and accurate computing. Computer arithmetic

intel

Arithmetics

• Integer arithmetic:y = Y w

2w−1 20

• Fixed-Point arithmetic:y = Y · 2`where ` is an implicit factor

• Floating-Point arithmetic:y = (−1)s ·Y · 2ewhere e is an explicit factor

• Interval arithmetic:[y , y ] =

{y ∈ R | y ≤ y ≤ y

}

• Multiple-Precision arithmetic: the sizeof the mantissa varies dynamically

A. Volkova Reliable and accurate computing 7/27

Page 22: 1cmReliable and accurate computing. Computer arithmetic

intel

Arithmetics

• Integer arithmetic:y = Y w

2w−1 20

• Fixed-Point arithmetic:y = Y · 2`where ` is an implicit factor

m + 1 −`w

−2m 20 2−1 2`

• Floating-Point arithmetic:y = (−1)s ·Y · 2ewhere e is an explicit factor

• Interval arithmetic:[y , y ] =

{y ∈ R | y ≤ y ≤ y

}

• Multiple-Precision arithmetic: the sizeof the mantissa varies dynamically

A. Volkova Reliable and accurate computing 7/27

Page 23: 1cmReliable and accurate computing. Computer arithmetic

intel

Arithmetics

• Integer arithmetic:y = Y w

2w−1 20

• Fixed-Point arithmetic:y = Y · 2`where ` is an implicit factor

m + 1 −`w

−2m 20 2−1 2`

• Floating-Point arithmetic:y = (−1)s ·Y · 2ewhere e is an explicit factor

exponent mantissa

s

• Interval arithmetic:[y , y ] =

{y ∈ R | y ≤ y ≤ y

}

• Multiple-Precision arithmetic: the sizeof the mantissa varies dynamically

A. Volkova Reliable and accurate computing 7/27

Page 24: 1cmReliable and accurate computing. Computer arithmetic

intel

Arithmetics

• Integer arithmetic:y = Y w

2w−1 20

• Fixed-Point arithmetic:y = Y · 2`where ` is an implicit factor

m + 1 −`w

−2m 20 2−1 2`

• Floating-Point arithmetic:y = (−1)s ·Y · 2ewhere e is an explicit factor

exponent mantissa

s

• Interval arithmetic:[y , y ] =

{y ∈ R | y ≤ y ≤ y

}

• Multiple-Precision arithmetic: the sizeof the mantissa varies dynamically

A. Volkova Reliable and accurate computing 7/27

Page 25: 1cmReliable and accurate computing. Computer arithmetic

intel

Arithmetics

• Integer arithmetic:y = Y w

2w−1 20

• Fixed-Point arithmetic:y = Y · 2`where ` is an implicit factor

m + 1 −`w

−2m 20 2−1 2`

• Floating-Point arithmetic:y = (−1)s ·Y · 2ewhere e is an explicit factor

exponent mantissa

s

• Interval arithmetic:[y , y ] =

{y ∈ R | y ≤ y ≤ y

}

• Multiple-Precision arithmetic: the sizeof the mantissa varies dynamically

A. Volkova Reliable and accurate computing 7/27

Page 26: 1cmReliable and accurate computing. Computer arithmetic

intel

Arithmetics

• Integer arithmetic:y = Y

• Fixed-Point arithmetic:y = Y · 2`where ` is an implicit factor

For the implementation

• Floating-Point arithmetic:y = (−1)s ·Y · 2ewhere e is an explicit factor

For the error analysis

• Interval arithmetic:[y , y ] =

{y ∈ R | y ≤ y ≤ y

} For the error analysis

• Multiple-Precision arithmetic: the sizeof the mantissa varies dynamically

For the error analysis

A. Volkova Reliable and accurate computing 7/27

Page 27: 1cmReliable and accurate computing. Computer arithmetic

intel

Fixed-Point Arithmetic

m + 1 −`s

w

−2m 20 2−12m−1 2`

w wordlength hard constraintm Most Significant Bit must choose` Least Significant Bit must choose

A. Volkova Reliable and accurate computing 8/27

Page 28: 1cmReliable and accurate computing. Computer arithmetic

intel

Fixed-Point Arithmetic

m + 1 −`s

w

−2m 20 2−12m−1 2`

w wordlength hard constraintm Most Significant Bit must choose` Least Significant Bit must choose

Example

Algorithm: vector normalization ‖v‖ =√v21 + v22 + v23

I/O format: w = 32,m = 15, ` = −16

Input: v = (125, 125, 125)

Overflow: 1252 + 1252 + 1252 = 46875 /∈ [−215; 215 − 1]

Output: depends on the system

A. Volkova Reliable and accurate computing 8/27

Page 29: 1cmReliable and accurate computing. Computer arithmetic

intel

Fixed-Point Arithmetic

m + 1 −`s

w

−2m 20 2−12m−1 2`

w wordlength hard constraintm Most Significant Bit must choose` Least Significant Bit must choose

Example

Algorithm: vector normalization ‖v‖ =√v21 + v22 + v23

I/O format: w = 32,m = 15, ` = −16

Input: v = (125, 125, 125)

Overflow: 1252 + 1252 + 1252 = 46875 /∈ [−215; 215 − 1]

Output: depends on the system

A. Volkova Reliable and accurate computing 8/27

Page 30: 1cmReliable and accurate computing. Computer arithmetic

intel

Fixed-Point Arithmetic

m + 1 −`s

w

−2m 20 2−12m−1 2`

w wordlength hard constraintm Most Significant Bit must choose` Least Significant Bit must choose

Example

Algorithm: vector normalization ‖v‖ =√v21 + v22 + v23

I/O format: w = 32,m = 15, ` = −16

Input: v = (125, 125, 125)

Overflow: 1252 + 1252 + 1252 = 46875 /∈ [−215; 215 − 1]

Output: depends on the system

A. Volkova Reliable and accurate computing 8/27

Page 31: 1cmReliable and accurate computing. Computer arithmetic

intel

Fixed-Point Arithmetic

m + 1 −`s

w

−2m 20 2−12m−1 2`

w wordlength hard constraintm Most Significant Bit must choose` Least Significant Bit must choose

Format choice problem:

• fix wordlength

• guarantee no overflow

• maximize the precision

• bound the output error

A. Volkova Reliable and accurate computing 8/27

Page 32: 1cmReliable and accurate computing. Computer arithmetic

intel

Filter algorithmsTypical algorithm: input u(k), internal state x (k), output y(k)

u(k)b0

z�1

b1

z�1

bi

z�1

bn

y(k)

z�1

a1

z�1

ai

z�1

an

+

u(k) y(k)

• y(k) =n∑

i=0biu(k − i)−

n∑i=1

aiy(k − i)

•{

x (k + 1) = Ax (k) + bu(k)y(k) = cx (k) + du(k)

• . . .

Math: ”It’s all the same thing”

”Not anymore!”, finite-precision.

A. Volkova Reliable and accurate computing 9/27

Page 33: 1cmReliable and accurate computing. Computer arithmetic

intel

Filter algorithmsTypical algorithm: input u(k), internal state x (k), output y(k)

u(k)b0

z�1

b1

z�1

bi

z�1

bn

y(k)

z�1

a1

z�1

ai

z�1

an

+

u(k)B + z�1 C +

y(k)

D

A

• y(k) =n∑

i=0biu(k − i)−

n∑i=1

aiy(k − i)

•{

x (k + 1) = Ax (k) + bu(k)y(k) = cx (k) + du(k)

• . . .

Math: ”It’s all the same thing”

”Not anymore!”, finite-precision.

A. Volkova Reliable and accurate computing 9/27

Page 34: 1cmReliable and accurate computing. Computer arithmetic

intel

Filter algorithmsTypical algorithm: input u(k), internal state x (k), output y(k)

u(k)b0

z�1

b1

z�1

bi

z�1

bn

y(k)

z�1

a1

z�1

ai

z�1

an

+

u(k)B + z�1 C +

y(k)

D

A

+

z�1

+

z�1

+

z�1

+

b0

b1

bi

bn

�a1

�ai

�an

y(k)u(k)

• y(k) =n∑

i=0biu(k − i)−

n∑i=1

aiy(k − i)

•{

x (k + 1) = Ax (k) + bu(k)y(k) = cx (k) + du(k)

• . . .

Math: ”It’s all the same thing”

”Not anymore!”, finite-precision.

A. Volkova Reliable and accurate computing 9/27

Page 35: 1cmReliable and accurate computing. Computer arithmetic

intel

Filter algorithmsTypical algorithm: input u(k), internal state x (k), output y(k)

u(k)b0

z�1

b1

z�1

bi

z�1

bn

y(k)

z�1

a1

z�1

ai

z�1

an

+

u(k)B + z�1 C +

y(k)

D

A

+

z�1

+

z�1

+

z�1

+

b0

b1

bi

bn

�a1

�ai

�an

y(k)u(k)

u(k)-1 + +

+ -1 -1

�1 + �2 + -1 �3 +

-1

z�1

-1 z�1

+ + z�1 + -1

+ 0.5y(k)

• y(k) =n∑

i=0biu(k − i)−

n∑i=1

aiy(k − i)

•{

x (k + 1) = Ax (k) + bu(k)y(k) = cx (k) + du(k)

• . . .

Math: ”It’s all the same thing”

”Not anymore!”, finite-precision.

A. Volkova Reliable and accurate computing 9/27

Page 36: 1cmReliable and accurate computing. Computer arithmetic

intel

Filter algorithmsTypical algorithm: input u(k), internal state x (k), output y(k)

u(k)b0

z�1

b1

z�1

bi

z�1

bn

y(k)

z�1

a1

z�1

ai

z�1

an

+

u(k)B + z�1 C +

y(k)

D

A

+

z�1

+

z�1

+

z�1

+

b0

b1

bi

bn

�a1

�ai

�an

y(k)u(k)

u(k)-1 + +

+ -1 -1

�1 + �2 + -1 �3 +

-1

z�1

-1 z�1

+ + z�1 + -1

+ 0.5y(k)

• y(k) =n∑

i=0biu(k − i)−

n∑i=1

aiy(k − i)

•{

x (k + 1) = Ax (k) + bu(k)y(k) = cx (k) + du(k)

• . . .

Math: ”It’s all the same thing”

”Not anymore!”, finite-precision.

A. Volkova Reliable and accurate computing 9/27

Page 37: 1cmReliable and accurate computing. Computer arithmetic

intel

Example: a 15th order lowpass filter

Algorithm # coefficientsState-Space (canonical) 31State-Space (balanced) 256

Direct Form II (transposed) 31Li-Gevers-Sun 102

A. Volkova Reliable and accurate computing 10/27

Page 38: 1cmReliable and accurate computing. Computer arithmetic

intel

Example: a 15th order lowpass filter

Algorithm # coefficientsState-Space (canonical) 31State-Space (balanced) 256

Direct Form II (transposed) 31Li-Gevers-Sun 102

Coefficient quantization

A. Volkova Reliable and accurate computing 10/27

Page 39: 1cmReliable and accurate computing. Computer arithmetic

intel

Example: a 15th order lowpass filter

Algorithm # coefficientsState-Space (canonical) 31State-Space (balanced) 256

Direct Form II (transposed) 31Li-Gevers-Sun 102

Coefficient quantization Rounding errors

A. Volkova Reliable and accurate computing 10/27

Page 40: 1cmReliable and accurate computing. Computer arithmetic

intel

Existing approaches on FxPimplementation

• simulations [Matlab], [D. Baez-Lopez,2001]• non-exhaustive

• noise propagation models [Menard, 2008]• does not give intervals for outputs

• interval arithmetic [Carreras, 1999], [Vakili, 2013]• wrapping effect for recursive systems

• affine arithmetic [Puschel, 2003], [Constantinides, 2006]• need to bound `∞ norm of the filter’s output• static unroll of the loops

A. Volkova Reliable and accurate computing 11/27

Page 41: 1cmReliable and accurate computing. Computer arithmetic

intel

TOOLBOX

“Digital filters reliable by construction ”

Available at https://github.com/fixif

Joint work with

Thibault [email protected]

Christoph [email protected]

A. Volkova Reliable and accurate computing 12/27

Page 42: 1cmReliable and accurate computing. Computer arithmetic

intel

Compiler overview

Verification against specifications

Simulinkto

SIF

Simulink

graph

SIF

H(z)H(z)to

SIF

SIF

formats

SIF

Fixed-Pointalgorithm

Code generationC

Software ASIC

FPGAVHDL

• Internal representation: SIF (matrix-based data-flow description)

• Rounding errors: unified, reliable and fast FxP algorithm generation

• Quantization errors: rigorous verification against frequency specs

• Software implementation: floating- and fixed-point C

• Hardware implementation: VHDL generation based on FloPoCo

A. Volkova Reliable and accurate computing 13/27

Page 43: 1cmReliable and accurate computing. Computer arithmetic

intel

Compiler overview

Verification against specifications

Simulinkto

SIF

Simulink

graph

SIF

H(z)H(z)to

SIF

SIF

formats

SIF

Fixed-Pointalgorithm

Code generationC

Software ASIC

FPGAVHDL

• Internal representation: SIF (matrix-based data-flow description)

• Rounding errors: unified, reliable and fast FxP algorithm generation

• Quantization errors: rigorous verification against frequency specs

• Software implementation: floating- and fixed-point C

• Hardware implementation: VHDL generation based on FloPoCo

A. Volkova Reliable and accurate computing 13/27

Page 44: 1cmReliable and accurate computing. Computer arithmetic

intel

Compiler overview

Verification against specifications

Simulinkto

SIF

Simulink

graph

SIF

H(z)H(z)to

SIF

SIF

formats

SIF

Fixed-Pointalgorithm

Code generationC

Software ASIC

FPGAVHDL

• Internal representation: SIF (matrix-based data-flow description)

• Rounding errors: unified, reliable and fast FxP algorithm generation

• Quantization errors: rigorous verification against frequency specs

• Software implementation: floating- and fixed-point C

• Hardware implementation: VHDL generation based on FloPoCo

A. Volkova Reliable and accurate computing 13/27

Page 45: 1cmReliable and accurate computing. Computer arithmetic

intel

Compiler overview

Verification against specifications

Simulinkto

SIF

Simulink

graph

SIF

H(z)H(z)to

SIF

SIF

formats

SIF

Fixed-Pointalgorithm

Code generationC

Software ASIC

FPGAVHDL

• Internal representation: SIF (matrix-based data-flow description)

• Rounding errors: unified, reliable and fast FxP algorithm generation

• Quantization errors: rigorous verification against frequency specs

• Software implementation: floating- and fixed-point C

• Hardware implementation: VHDL generation based on FloPoCo

A. Volkova Reliable and accurate computing 13/27

Page 46: 1cmReliable and accurate computing. Computer arithmetic

intel

Compiler overview

Verification against specifications

Simulinkto

SIF

Simulink

graph

SIF

H(z)H(z)to

SIF

SIF

formats

SIF

Fixed-Pointalgorithm

Code generationC

Software ASIC

FPGAVHDL

• Internal representation: SIF (matrix-based data-flow description)

• Rounding errors: unified, reliable and fast FxP algorithm generation

• Quantization errors: rigorous verification against frequency specs

• Software implementation: floating- and fixed-point C

• Hardware implementation: VHDL generation based on FloPoCo

A. Volkova Reliable and accurate computing 13/27

Page 47: 1cmReliable and accurate computing. Computer arithmetic

intel

Compiler overview

Verification against specifications

Simulinkto

SIF

Simulink

graph

SIF

H(z)H(z)to

SIF

SIF

formats

SIF

Fixed-Pointalgorithm

Code generationC

Software ASIC

FPGAVHDL

• Internal representation: SIF (matrix-based data-flow description)

• Rounding errors: unified, reliable and fast FxP algorithm generation

• Quantization errors: rigorous verification against frequency specs

• Software implementation: floating- and fixed-point C

• Hardware implementation: VHDL generation based on FloPoCoa

ahttp://flopoco.gforge.inria.fr/

A. Volkova Reliable and accurate computing 13/27

Page 48: 1cmReliable and accurate computing. Computer arithmetic

intel

FiXiF tool: under the hood

Front-end

• Python

• Collection of classes

Back-end

• C/C++ libraries

• Sollya procedures

• FloPoCo tool

Requirements:

• MPFR, MPFI,

LAPACK

• mpmath

Python

FxP Arithmetic

WCPGevaluation

C

Python

FxP Formats

CFiXiF

Python

Verification

SollyaFloPoCointerface

C++

A. Volkova Reliable and accurate computing 14/27

Page 49: 1cmReliable and accurate computing. Computer arithmetic

intel

FiXiF – 1◦ Filter specifications and transfer function design

from fixif import *

g = Gabarit(48000, [(0, 9600), (12000, None)], [(0.95, 1.05), -20])

H = g.to_dTF(ftype="butter", method="scipy")

F = Filter(tf=H)

R_SS = State_Space(Filter(tf=H))

R_SS_balanced = State_Space(Filter(tf=H), form="balanced")

R_DFII = DFII(Filter(tf=H), transposed=True)

R_LGS = LGS(Filter(tf=H), transposed=True)

A. Volkova Reliable and accurate computing 15/27

Page 50: 1cmReliable and accurate computing. Computer arithmetic

intel

FiXiF – 1◦ Filter specifications and transfer function design

from fixif import *

g = Gabarit(48000, [(0, 9600), (12000, None)], [(0.95, 1.05), -20])

H = g.to_dTF(ftype="butter", method="scipy")

F = Filter(tf=H)

Type: lowpass (Fs=48000Hz)

Freq. [0Hz,9600Hz]: Passband in [0.95dB, 1.05dB]

Freq. [12000Hz,24000.0Hz]: Stopband at -20dB

4.58056194e-05 + 6.87084291e-04 z-1 + 4.8095900e-03z-2 + ...

H(z) = -----------------------------------------------------

1.0 + -1.6206385z-1 + 3.20872535z-2 + ...

R_SS = State_Space(Filter(tf=H))

R_SS_balanced = State_Space(Filter(tf=H), form="balanced")

R_DFII = DFII(Filter(tf=H), transposed=True)

R_LGS = LGS(Filter(tf=H), transposed=True)

A. Volkova Reliable and accurate computing 15/27

Page 51: 1cmReliable and accurate computing. Computer arithmetic

intel

FiXiF – 1◦ Filter specifications and transfer function design

from fixif import *

g = Gabarit(48000, [(0, 9600), (12000, None)], [(0.95, 1.05), -20])

H = g.to_dTF(ftype="butter", method="scipy")

F = Filter(tf=H)

◦ Filter realization (algorithm)

R_SS = State_Space(Filter(tf=H))

R_SS_balanced = State_Space(Filter(tf=H), form="balanced")

R_DFII = DFII(Filter(tf=H), transposed=True)

R_LGS = LGS(Filter(tf=H), transposed=True)

A. Volkova Reliable and accurate computing 15/27

Page 52: 1cmReliable and accurate computing. Computer arithmetic

intel

State-Space and an error modelTake a State-Space algorithm

H

{x

(k + 1) =

♦mx (

Ax

(k) + Bu(k)

) + εx (k)

y

(k) =

♦my (

Cx

(k) + Du(k)

) + εy(k)

A. Volkova Reliable and accurate computing 16/27

Page 53: 1cmReliable and accurate computing. Computer arithmetic

intel

State-Space and an error modelTake a State-Space algorithm and add rounding

H♦{

x♦(k + 1) = ♦mx (Ax♦(k) + Bu(k))

+ εx (k)

y♦(k) = ♦my (Cx♦(k) + Du(k))

+ εy(k)

where ♦m is some operator ensuring faithful rounding:

|♦m(x )− x | ≤ 2`

A. Volkova Reliable and accurate computing 16/27

Page 54: 1cmReliable and accurate computing. Computer arithmetic

intel

State-Space and an error modelTake a State-Space algorithm and add rounding

H♦{

x♦(k + 1) =

♦mx (

Ax♦(k) + Bu(k)

)

+ εx (k)y♦(k) =

♦my (

Cx♦(k) + Du(k)

)

+ εy(k)

with|εx (k)| ≤ 2`x and |εy(k)| ≤ 2`y

A. Volkova Reliable and accurate computing 16/27

Page 55: 1cmReliable and accurate computing. Computer arithmetic

intel

State-Space and an error modelTake a State-Space algorithm and add rounding

H♦{

x♦(k + 1) =

♦mx (

Ax♦(k) + Bu(k)

)

+ εx (k)y♦(k) =

♦my (

Cx♦(k) + Du(k)

)

+ εy(k)

with|εx (k)| ≤ 2`x and |εy(k)| ≤ 2`y

We express x (k)− x♦ and y(k)− y♦(k) ... using a new filter:

H�

y⌃(k)

u(k)

y(k)

�(k)

H

µ"x (k)"y (k)

rounding errors

H⌃|y⌃(k)| |�(k)| + |y(k)||y⌃(k)| |�q(k)| + |y(k)|

A. Volkova Reliable and accurate computing 16/27

Page 56: 1cmReliable and accurate computing. Computer arithmetic

intel

Reliable implementation

H�

y⌃(k)

u(k)

y(k)

�(k)

H

µ"x (k)"y (k)

rounding errors

H⌃|∆(k)| ≤ 〈〈H∆〉〉

(2`x

2`y

)

Basic bricks:• Reliable bound on a linear filter’s output

• Worst-Case Peak Gain measure [V-Lauter-Hilaire’15]

• Take into account error propagation• Iterative refinement of MSB [V-Lauter-Hilaire’16]

• Never overestimate MSB by more than one

A. Volkova Reliable and accurate computing 17/27

Page 57: 1cmReliable and accurate computing. Computer arithmetic

intel

Worst-Case Peak Gain• Matrix 〈〈S〉〉 =

∑∞k=0

∣∣CAkB∣∣ [Balakrishnyan-Boyd’91]

Problem: approximation and evaluation of the WCPG with an apriori absolute error bound ε∣∣∣〈〈S〉〉 − 〈〈S〉〉

∣∣∣ ≤ |〈〈S〉〉 − 〈〈SN 〉〉|+∣∣∣〈〈SN 〉〉 − 〈〈S〉〉

∣∣∣ < ε

Solution [V-Hilaire-Lauter’15]:1X

k=0

|CAkB| bSN"1 "2 "3 "4 "5 "6

truncation

direct formula

sum evaluation

adaptation of internal precisions.t. error bound is satisfied a priori"i

Techniques: a priori floating-point error analysis, verifiedinclusions for eigendecomposition, Gershgorin circles computation

A. Volkova Reliable and accurate computing 18/27

Page 58: 1cmReliable and accurate computing. Computer arithmetic

intel

FiXiF – 2◦ Determine the Fixed-Point Formats

w = 16

while True:

msb, lsb, error, additionalSteps = FXPF_ABCD(R_SS.A,

R_SS.B, R_SS.C, R_SS.D, 1.0, w)

w = w - 1

Wordlength=[16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16]

Additional steps: 1

LSB: [-13 -13 -14 -14 -15 -15 -15 -15 -15 -15 -15 -15 -15 -15 -15 -15]

Errors: [[ 0.00086691 0.00121799 0.00152309 0.00172836 0.00158205

0.00121137 0.00079471 0.00048683 0.00029988 0.0001935 0.00013235

0.00009573 0.00007329 0.00005811 0.00004509 0.00152433]]...

Wordlength=[5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5]

Error: LSB reached point when it is larger than initial MSB estimation

Error determining Fixed-Point Formats.

A. Volkova Reliable and accurate computing 19/27

Page 59: 1cmReliable and accurate computing. Computer arithmetic

intel

FiXiF – 2◦ Determine the Fixed-Point Formats

w = 16

while True:

msb, lsb, error, additionalSteps = FXPF_ABCD(R_SS.A,

R_SS.B, R_SS.C, R_SS.D, 1.0, w)

w = w - 1

Wordlength=[16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16]

Additional steps: 1

LSB: [-13 -13 -14 -14 -15 -15 -15 -15 -15 -15 -15 -15 -15 -15 -15 -15]

Errors: [[ 0.00086691 0.00121799 0.00152309 0.00172836 0.00158205

0.00121137 0.00079471 0.00048683 0.00029988 0.0001935 0.00013235

0.00009573 0.00007329 0.00005811 0.00004509 0.00152433]]...

Wordlength=[5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5]

Error: LSB reached point when it is larger than initial MSB estimation

Error determining Fixed-Point Formats.

A. Volkova Reliable and accurate computing 19/27

Page 60: 1cmReliable and accurate computing. Computer arithmetic

intel

Verification of specifications

Implementation :u(k)

-1 + +

+ -1 -1

γ1 + γ2 + -1 γ3 +

-1

z−1

-1 z−1

+ + z−1 + -1

+ 0.5y(k)

Verify the specifications:

!

��H(ei!)��

no false positives

Solution [V-Lauter-Hilaire’17]

• MP approximation of H (z )→ error Θ bounded usingWCPG [Balakrishnyan’92]

• Verification of H (z )→ proof of non-negativity of apolynomial

� + ⇥

� �⇥

| bH(ei!)|

!

A. Volkova Reliable and accurate computing 20/27

Page 61: 1cmReliable and accurate computing. Computer arithmetic

intel

Verification of specifications

Implementation :u(k)

-1 + +

+ -1 -1

γ1 + γ2 + -1 γ3 +

-1

z−1

-1 z−1

+ + z−1 + -1

+ 0.5y(k)

Verify the specifications:

!

��H(ei!)��

no false positives

Solution [V-Lauter-Hilaire’17]

• MP approximation of H (z )→ error Θ bounded usingWCPG [Balakrishnyan’92]

• Verification of H (z )→ proof of non-negativity of apolynomial

� + ⇥

� �⇥

| bH(ei!)|

!

A. Volkova Reliable and accurate computing 20/27

Page 62: 1cmReliable and accurate computing. Computer arithmetic

intel

Verification of specifications

Implementation :u(k)

-1 + +

+ -1 -1

γ1 + γ2 + -1 γ3 +

-1

z−1

-1 z−1

+ + z−1 + -1

+ 0.5y(k)

Verify the specifications:

!

��H(ei!)��

no false positives

Solution [V-Lauter-Hilaire’17]

• MP approximation of H (z )→ error Θ bounded usingWCPG [Balakrishnyan’92]

• Verification of H (z )→ proof of non-negativity of apolynomial

� + ⇥

� �⇥

| bH(ei!)|

!A. Volkova Reliable and accurate computing 20/27

Page 63: 1cmReliable and accurate computing. Computer arithmetic

intel

FiXiF – 3◦ Verification

g = Gabarit(48000, [(0, 9600), (12000, None)], [(0.95, 1.05), -20])

CheckIfRealizationInGabarit(g, R_SS.quantize(16))

Overall check okay: false

Computing this result took 2258ms

The following issues have been found:

Issue in subdomain Omega = pi * [0;0.4] at omega = pi *

[0;5.3172964416593691658936355013934529087741417880979e-53]:

|H(exp(j*omega))| should be between 10^ 4.75e-2 and 10^ (1.05 / 20) but

evaluates to [1.0000497795523700519233990284759435759640164376565;

1.0000497795523700519233990284759435759640164376566] =

10^ ([4.323689366417695635232485092238116632596970479257e-4;

4.3236893664176956352324850922381166325969704866858e-4]/20)...

A. Volkova Reliable and accurate computing 21/27

Page 64: 1cmReliable and accurate computing. Computer arithmetic

intel

FiXiF – 3◦ Verification

g = Gabarit(48000, [(0, 9600), (12000, None)], [(0.95, 1.05), -20])

CheckIfRealizationInGabarit(g, R_SS.quantize(16))

Overall check okay: false

Computing this result took 2258ms

The following issues have been found:

Issue in subdomain Omega = pi * [0;0.4] at omega = pi *

[0;5.3172964416593691658936355013934529087741417880979e-53]:

|H(exp(j*omega))| should be between 10^ 4.75e-2 and 10^ (1.05 / 20) but

evaluates to [1.0000497795523700519233990284759435759640164376565;

1.0000497795523700519233990284759435759640164376566] =

10^ ([4.323689366417695635232485092238116632596970479257e-4;

4.3236893664176956352324850922381166325969704866858e-4]/20)...

A. Volkova Reliable and accurate computing 21/27

Page 65: 1cmReliable and accurate computing. Computer arithmetic

intel

Behind the scenesDuring these 2.26 seconds...• Rational arithmetic

• proof of non-negativity of a real polynomial

• Interval arithmetic• Verified Inclusions for the eigenvalues

• Dynamic Multiple-Precision arithmetic• Computation of Gershgorin circles• Evaluation of WCPG

• Floating-Point arithmetic• Computation of eigenvalues with LAPACK• Matrix arithmetic with a priori error bounds

. . . to verify an implementation in Fixed-Point arithmetic!

A. Volkova Reliable and accurate computing 22/27

Page 66: 1cmReliable and accurate computing. Computer arithmetic

intel

Back to the generator

Verification against specifications

Simulinkto

SIF

Simulink

graph

SIF

H(z)H(z)to

SIF

SIF

formats

SIF

Fixed-Pointalgorithm

Code generationC

Software ASIC

FPGAVHDL

• Rigorous use of a combination of different arithmetics

• Numerical guarantees in time and frequency domains

• Unifying internal representation

• Easily extendable modular implementation

NEW Non-linear optimization to minimize circuit area [Hilaire, 2019]

A. Volkova Reliable and accurate computing 23/27

Page 67: 1cmReliable and accurate computing. Computer arithmetic

intel

Last-bit accurate hardware

FloPoCo

http://flopoco.gforge.inria.fr/

Joint work with

Florent de DinechinFlorent.de-Dinechin@

insa-lyon.fr

Matei IstoanFlorent.de-Dinechin@insa-

lyon.fr

A. Volkova Reliable and accurate computing 24/27

Page 68: 1cmReliable and accurate computing. Computer arithmetic

intel

Last-bit accurate hardware

FloPoCo

http://flopoco.gforge.inria.fr/

A push-button tool that generates filters accurate just-enough

LTI Filterarchitecturegenerator

{ai}1≤i<na, {bi}0≤i<nb

input format (1, `in)

output accuracy `outFPGA frequency

.vhdl

Functional spec. Performance spec.

A. Volkova Reliable and accurate computing 25/27

Page 69: 1cmReliable and accurate computing. Computer arithmetic

intel

The cost of reliabilityArea and Delay vs. Accuracy

0

2

4

6

8

10

12

8 12 16 20 24 28 32 0

2000

4000

6000

8000

10000

12000

crit

ical p

ath

dela

y (

ns)

are

a (

LUT)

input/output precision (fraction bits)

IIR8b areaIIR8b delayIIR8a area

IIR8a delayIIR4 area

IIR4 delay

A. Volkova Reliable and accurate computing 26/27

Page 70: 1cmReliable and accurate computing. Computer arithmetic

intel

The cost of reliabilityPessimism of the method:• (almost) worst-case input signal• removing ≥ 2 bits yields failure

⇒ bounds are tight

SQNR vs. Guaranteed accuracy

[Constantinides, 2004] Our approach

16 bit output 8 (13) bit outputSQNR 49.3dB to 78.5dB error bound ≤ 2−8 (≤ 2−13)8 to 13 meaningful bits last-bit accurate

16 bit multipliers16/32 bit accumulators

18 (23) bits datapaths

⇒ we are competitive

A. Volkova Reliable and accurate computing 27/27

Page 71: 1cmReliable and accurate computing. Computer arithmetic

intel

The cost of reliabilityPessimism of the method:• (almost) worst-case input signal• removing ≥ 2 bits yields failure

⇒ bounds are tight

SQNR vs. Guaranteed accuracy

[Constantinides, 2004] Our approach

16 bit output 8 (13) bit outputSQNR 49.3dB to 78.5dB error bound ≤ 2−8 (≤ 2−13)8 to 13 meaningful bits last-bit accurate

16 bit multipliers16/32 bit accumulators

18 (23) bits datapaths

⇒ we are competitive

A. Volkova Reliable and accurate computing 27/27

Page 72: 1cmReliable and accurate computing. Computer arithmetic

intel

The cost of reliabilityPessimism of the method:• (almost) worst-case input signal• removing ≥ 2 bits yields failure

⇒ bounds are tight

SQNR vs. Guaranteed accuracy

[Constantinides, 2004] Our approach

16 bit output 8 (13) bit outputSQNR 49.3dB to 78.5dB error bound ≤ 2−8 (≤ 2−13)8 to 13 meaningful bits last-bit accurate

16 bit multipliers16/32 bit accumulators

18 (23) bits datapaths

⇒ we are competitive

A. Volkova Reliable and accurate computing 27/27

Page 73: 1cmReliable and accurate computing. Computer arithmetic

intel

The cost of reliabilityPessimism of the method:• (almost) worst-case input signal• removing ≥ 2 bits yields failure

⇒ bounds are tight

SQNR vs. Guaranteed accuracy

[Constantinides, 2004] Our approach

16 bit output 8 (13) bit outputSQNR 49.3dB to 78.5dB error bound ≤ 2−8 (≤ 2−13)8 to 13 meaningful bits last-bit accurate

16 bit multipliers16/32 bit accumulators

18 (23) bits datapaths

⇒ we are competitive

A. Volkova Reliable and accurate computing 27/27

Page 74: 1cmReliable and accurate computing. Computer arithmetic

TOOLBOX

“Digital filters reliable by construction ”

https://github.com/fixif

Anastasia [email protected]

avolkova.org

Thibault [email protected]

docmatic.fr

Christoph [email protected]

christoph-lauter.org