Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement specialized posit<16,2> addition #403

Merged
merged 1 commit into from
Dec 19, 2023

Conversation

davidmallasen
Copy link
Contributor

@davidmallasen davidmallasen commented Dec 19, 2023

Following issue #343 I implemented the specialized posit<16,2> addition following the guidelines from softposit. I think it is working correctly, but the tests are not computing the golden solution correctly. When I run the exhaustive tests with the reportTestCases=true, I get the following fails:

.
.
.
8.8817841970012523234e-16 +                -8.0703125 !=                -8.0703125 golden reference is             -3.0087890625
    0b0.00000000000001.1. +     0b1.10.11.00000010010 !=     0b1.10.11.00000010010 golden reference is     0b1.10.01.10000001001
FAIL
8.8817841970012523234e-16 +               -8.06640625 !=               -8.06640625 golden reference is                -3.0078125
    0b0.00000000000001.1. +     0b1.10.11.00000010001 !=     0b1.10.11.00000010001 golden reference is     0b1.10.01.10000001000
FAIL
8.8817841970012523234e-16 +                   -8.0625 !=                   -8.0625 golden reference is                -3.0078125
    0b0.00000000000001.1. +     0b1.10.11.00000010000 !=     0b1.10.11.00000010000 golden reference is     0b1.10.01.10000001000
FAIL
8.8817841970012523234e-16 +               -8.05859375 !=               -8.05859375 golden reference is             -3.0068359375
    0b0.00000000000001.1. +     0b1.10.11.00000001111 !=     0b1.10.11.00000001111 golden reference is     0b1.10.01.10000000111
FAIL
8.8817841970012523234e-16 +                -8.0546875 !=                -8.0546875 golden reference is             -3.0068359375
    0b0.00000000000001.1. +     0b1.10.11.00000001110 !=     0b1.10.11.00000001110 golden reference is     0b1.10.01.10000000111
FAIL
8.8817841970012523234e-16 +               -8.05078125 !=               -8.05078125 golden reference is              -3.005859375
    0b0.00000000000001.1. +     0b1.10.11.00000001101 !=     0b1.10.11.00000001101 golden reference is     0b1.10.01.10000000110
FAIL
8.8817841970012523234e-16 +                 -8.046875 !=                 -8.046875 golden reference is              -3.005859375
    0b0.00000000000001.1. +     0b1.10.11.00000001100 !=     0b1.10.11.00000001100 golden reference is     0b1.10.01.10000000110
FAIL
8.8817841970012523234e-16 +               -8.04296875 !=               -8.04296875 golden reference is             -3.0048828125
    0b0.00000000000001.1. +     0b1.10.11.00000001011 !=     0b1.10.11.00000001011 golden reference is     0b1.10.01.10000000101
FAIL
8.8817841970012523234e-16 +                -8.0390625 !=                -8.0390625 golden reference is             -3.0048828125
    0b0.00000000000001.1. +     0b1.10.11.00000001010 !=     0b1.10.11.00000001010 golden reference is     0b1.10.01.10000000101
FAIL
8.8817841970012523234e-16 +               -8.03515625 !=               -8.03515625 golden reference is               -3.00390625
    0b0.00000000000001.1. +     0b1.10.11.00000001001 !=     0b1.10.11.00000001001 golden reference is     0b1.10.01.10000000100
FAIL
8.8817841970012523234e-16 +                  -8.03125 !=                  -8.03125 golden reference is               -3.00390625
    0b0.00000000000001.1. +     0b1.10.11.00000001000 !=     0b1.10.11.00000001000 golden reference is     0b1.10.01.10000000100
.
.
.

Where I believe the computed value is correct and the golden one isn't.

I checked the to_double() function and it seems to be correct, but calls some other functions in posit_impl.hpp that I don't know. Could you have a look at this @Ravenwater @theo-lemurian ?

@Ravenwater Ravenwater self-assigned this Dec 19, 2023
@Ravenwater Ravenwater merged commit 451af3e into stillwater-sc:v3.74 Dec 19, 2023
1 check passed
@Ravenwater
Copy link
Contributor

I'll take a look at the golden reference path

@davidmallasen davidmallasen deleted the davidmallasen-v3.74 branch December 19, 2023 16:04
@Ravenwater
Copy link
Contributor

gnarly situation of crossing bad edits: turns out that the golden reference is ok, the failure is in the proper carry propagation in the exponent and regime, as shown here:

Fast specialization posit<16,2>: report test cases
 posit< 16,2> useed scale     4     minpos scale        -56     maxpos scale         56  :  0

FAIL
1.3877787807814456755e-17 + 4.5474735088646411896e-13 != 1.3642420526593923569e-12 golden reference is 4.5474735088646411896e-13
    0b0.000000000000001.. +     0b0.000000000001.11.0 !=     0b0.00000000001.00.10 golden reference is     0b0.000000000001.11.0
FAIL
1.3877787807814456755e-17 + 6.8212102632969617844e-13 != 1.5916157281026244164e-12 golden reference is 6.8212102632969617844e-13
    0b0.000000000000001.. +     0b0.000000000001.11.1 !=     0b0.00000000001.00.11 golden reference is     0b0.000000000001.11.1
FAIL
1.3877787807814456755e-17 +             -3.9990234375 !=            -1.99951171875 golden reference is             -3.9990234375
    0b0.000000000000001.. +     0b1.10.01.11111111111 !=     0b1.10.00.11111111111 golden reference is     0b1.10.01.11111111111
FAIL
1.3877787807814456755e-17 +              -3.998046875 !=            -1.99951171875 golden reference is              -3.998046875
    0b0.000000000000001.. +     0b1.10.01.11111111110 !=     0b1.10.00.11111111111 golden reference is     0b1.10.01.11111111110
FAIL
1.3877787807814456755e-17 +             -3.9970703125 !=             -1.9990234375 golden reference is             -3.9970703125
    0b0.000000000000001.. +     0b1.10.01.11111111101 !=     0b1.10.00.11111111110 golden reference is     0b1.10.01.11111111101
FAIL
1.3877787807814456755e-17 +               -3.99609375 !=             -1.9990234375 golden reference is               -3.99609375
    0b0.000000000000001.. +     0b1.10.01.11111111100 !=     0b1.10.00.11111111110 golden reference is     0b1.10.01.11111111100
FAIL
1.3877787807814456755e-17 +             -3.9951171875 !=            -1.99853515625 golden reference is             -3.9951171875
    0b0.000000000000001.. +     0b1.10.01.11111111011 !=     0b1.10.00.11111111101 golden reference is     0b1.10.01.11111111011
FAIL
1.3877787807814456755e-17 +              -3.994140625 !=            -1.99853515625 golden reference is              -3.994140625
    0b0.000000000000001.. +     0b1.10.01.11111111010 !=     0b1.10.00.11111111101 golden reference is     0b1.10.01.11111111010
FAIL
1.3877787807814456755e-17 +             -3.9931640625 !=              -1.998046875 golden reference is             -3.9931640625
    0b0.000000000000001.. +     0b1.10.01.11111111001 !=     0b1.10.00.11111111100 golden reference is     0b1.10.01.11111111001
FAIL
1.3877787807814456755e-17 +                -3.9921875 !=              -1.998046875 golden reference is                -3.9921875
    0b0.000000000000001.. +     0b1.10.01.11111111000 !=     0b1.10.00.11111111100 golden reference is     0b1.10.01.11111111000```

Now need to figure out what is going wrong. 

Ravenwater added a commit that referenced this pull request Jan 3, 2024
* Bumping SEMVER to v3.74.1

* removing extraneous function

* adding QSNR to the benchmarking

* adding range reporting for the Scalar type

* adding elastic integer traits to try to disambiguate type_tag (not entirely successful yet)

* compilation fix for gcc and clang

* streamlining elastic binary integer API test

* renaming Adaptive to Elastic

* expanding QSNR experiment to sample across multiple sets

* generalizing qsnr as a service

* adding is_subnormal() attribute method

* specialized posit<16,2> engineering

* redefining nibble markers to be 0-based

* WIP: fast posit<16,2> addition

* restructuring specialized posits test infrastructure

* adding a posit oracle as a separate data type to be used to validate specialized posits

* adding a arithmetic debug test

* Implement specialized posit<16,2> addition (#403)

* rearchitecting the regression test suite to have a universal number system check

* cleaning up include file dependencies

* bug fix in the argument order of ReportBinaryArithmeticError as called in the posit test suite

* WIP: bug fixes for add/sub, not quite there yet

* compilation fix for gcc and clang

* WIP: fast posit<16,2> subtraction checks

* Implement specialized posit<16,2> sub, mul, div (#404)

Div is not working 100% yet

* enabling the regression level 1 again in specialized posit<16,2> while we are RCAing the div on extreme regime values

* bug fix and reporting improvement of posit randoms

* WIP: cleaning up posit<16,1> and posit<16,2>

* adding a math library to the posito oracle so we can use it to compare native implementations

* WIP: building test infrastructure to RCA specialized posit implementations

* WIP: RCAing specialized posit<16,2> divide operator

* adding multiplication tests for specialized posits

* WIP: code hygiene for old posit code

* WIP: redoing the fast posit<16,2> arithmetic operators

* restoring the multiplication operator algorithm

* configuring a regression test for fast posit multiplication

* configuring a regression test for fast posit addition

* test name edit

* configuring a regression test for fast posit division: not enabled yet

* adding a regression suite for fast posit subtraction

* code hygiene for old posit code

* bug fix in fast posit<32,2> that code hygiene activities had introduced

* WIP: fixed bugs in regime and exponent fields for fast posit<16,2>, rounding still buggy

* bug fix of bitnplusone calculation in divround of posit<16,2>

* code hygiene posit<32,2>

* bug fix div operator for fast posit<16,2>

* adding new posit attribute functions: maxprecision_max/min, this is the largest value of Regime 0, and the smallest value of Regime -1

* adding full regression results for reference

---------

Co-authored-by: David Mallasén Quintana <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants