provably correct posit arithmetic

0 downloads 0 Views 5MB Size Report
Mar 28, 2018 - 28/3/18. 4. Intersection point rounded to front or back of the triangle? Page 5. Posit Implementations. • Posit rounding is omitted in many implementations. 28/3/18. 5. Issues were fixed ... Rounded up: 0 1 1 1 1 0 0 1 1 0 0 0 0 0 ...
PROVABLY CORRECT POSIT ARITHMETIC Conference for Next Generation Arithmetic 28 March 2018

Chung ShinYee SpeedGo Computing

28/3/18

About Myself • Love algorithms. • Like parallel programming. • Enjoy mathematics. • Not necessary good at any above.

2

28/3/18

3

Inspiration • Unum type I

è variable bit size è difficult to index. • Posit è fixed bit size è easy to index. è higher accuracy than floats. • Reduce memory footprint? • Resolve accuracy issues in rendering?

4

28/3/18

Research Plan • Ray tracing: self intersecting problem Intersection point rounded to front or back of the triangle?

5

28/3/18

Posit Implementations Issues were fixed after paper submission.

Issues still persist.

• Posit rounding is omitted in many implementations.

PROVABLY CORRECT POSIT ARITHMETIC Conference for Next Generation Arithmetic 28 March 2018

Chung ShinYee SpeedGo Computing

28/3/18

7

Motivations • Implement a correct posit implementation. • Provably correct posit arithmetic.

“Beware of bugs in the above code; I have only proved it correct, not tried it.” − Donald E. Knuth • Software tests and verifications.

28/3/18

Approach • Simple mathematical proofs. • Big integer model è No overflow. • Fixed-point number. • Focus on: • Decoded posit. • Basic posit arithmetic. • Correctness.

8

28/3/18

9

Special Posit Arithmetic Special posits: • Zero • NaR (Not-a-Real) or

28/3/18

Conversions Posit, P Fixed-Point, B

10

28/3/18

Conversions Posit, P Fixed-Point, B

11

28/3/18

Conversions Posit, P Fixed-Point, B

12

28/3/18

Conversions

13

28/3/18

Conversions

14

28/3/18

Arithmetic − Addition

15

28/3/18

Arithmetic − Addition

16

28/3/18

Arithmetic − Addition

17

18

28/3/18

Arithmetic − Multiplication Q.E.D.

28/3/18

Arithmetic − Division • Long division. • Residual r/y. • Cannot be represented by a posit. • Accuracy controlled by h fraction bits. • Posit rounding.

19

28/3/18

20

Posit Rounding • Round to nearest. • Absolute difference for rounding fraction bits. • Ratio for rounding exponent bits.

• Break to even on a tie. • Never round to zero or NaR.

21

28/3/18

Posit Bits posit 0 sign bit

1

1

1

regime bits

1

0

0

1

1

exponent bits

0

1

1

1

1

fraction bits

0

0

22

28/3/18

Posit Bits posit 0 sign bit

1

1

1

regime bits

1

0

0

1

1

exponent bits

0

1

1

1

1

fraction bits

0

0

23

28/3/18

Rounding Exponent Bits • Residual r/y. • Rounding from posit

to posit 0

1

1

1

1

8 bits

0

0

1

1

0

1

1

1

1

t = 1 exponent bit to round

0

0

24

28/3/18

Rounding Exponent Bits Rounded down:

0 1 1 1 1 0 0 1 0 0 0 0 0 0 0 0

Tie: r = 0

0 1 1 1 1 0 0 1 1 0 0 0 0 0 0 0

Rounded up:

0 1 1 1 1 0 1 0 0 0 0 0 0 0 0 0 8 bits

t = 1 exponent bit to round

25

28/3/18

Rounding Exponent Bits Rounded down:

0 1 1 1 1 0 0 1 0 0 0 0 0 0 0 0

Tie: r = 0

0 1 1 1 1 0 0 1 1 0 0 0 0 0 0 0

Rounded up:

0 1 1 1 1 0 1 0 0 0 0 0 0 0 0 0

26

28/3/18

Rounding Exponent Bits Rounded down:

0 1 1 1 1 0 0 1 0 0 0 0 0 0 0 0

Tie: r = 0

0 1 1 1 1 0 0 1 1 0 0 0 0 0 0 0

Rounded up:

0 1 1 1 1 0 1 0 0 0 0 0 0 0 0 0

28/3/18

Rounding Exponent Bits • Value of t bits: • Round down: • Round to even: • Round up:

27

28/3/18

28

Rounding Exponent Bits • Value of t bits: • Round down: • Round to even: • Round up:

Need not knowing exact r value.

28/3/18

29

Rounding Fraction Bits • Value of t bits: • Round down: • Round to even: • Round up:

Need not knowing exact r value.

30

28/3/18

Rounding Residual Rounded down: Tie: r/y = 0.5 (2r = y) Rounded up:

0 1 1 1 1 0 0 1 1 0 1 1 1 1 0 0

0 1 1 1 1 0 0 1 1 0 1 1 1 1 0 0

0 1 1 1 1 0 0 1 1 0 1 1 1 1 0 1 16 bits

28/3/18

31

Rounding Residual • Value of residual: • Round down: • Round to even: • Round up:

Need not knowing exact r and y values.

28/3/18

Reduced Residual

32

28/3/18

Software Tests and Verifications • Special posit arithmetic tests. • Normal posit arithmetic tests. • Posit encoding and decoding tests. • Checksum comparisons.

33

34

28/3/18

Special Posit Arithmetic Tests Special posits: • Zero • NaR (Not-a-Real) or

35

28/3/18

Normal Posit Arithmetic Tests • Use rational numbers as reference. P+ = Smallest number greater than P NaR Computed posit P (bogus implementation) -1

1

0

P− = Greatest number smaller than P Exact rational V

36

28/3/18

Normal Posit Arithmetic Tests • Use rational numbers as reference. P+ = Smallest number greater than P Exact rational V

NaR

Computed posit P (Truncated) -1

1

0

P− = Greatest number smaller than P

37

28/3/18

Normal Posit Arithmetic Tests • Use rational numbers as reference. P+ = Smallest number greater than P NaR

Exact rational V (equally near to P and P+) Computed posit P

-1

1

0

P− = Greatest number smaller than P

28/3/18

38

Posit Encoding and Decoding Tests • Symmetry tests. • Posit bits + 1 has strictly increasing value,

except ±maxpos and NaR. • Intervals of s, k, e, f, and h are well defined.

28/3/18

39

Checksum Comparisons • Generate arithmetic inputs deterministically. • Use the computed results to compute

checksum. • Subsequent implementation updates just match the expected checksum.

28/3/18

40

Conclusion • Posit arithmetic based on fixed-point. • Division result consists of a residual. • Conditions for posit rounding. • Reduced residual with 2-bit information. • Systematic software tests.

41

28/3/18

Q&A Chung ShinYee SpeedGo Computing

Suggest Documents