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

Float64sr via Double64 #61

Merged
merged 11 commits into from
Jul 11, 2023
Merged

Float64sr via Double64 #61

merged 11 commits into from
Jul 11, 2023

Conversation

milankl
Copy link
Owner

@milankl milankl commented Dec 7, 2022

fixes #59

julia> using StochasticRounding

julia> A = Float64sr.(rand(4,4))
4×4 Matrix{Float64sr}:
 Float64sr(0.38418416963682733)    Float64sr(0.5286745680704084)
 Float64sr(0.6002555882832199)      Float64sr(0.5193716738812405)
 Float64sr(0.7037500894099693)      Float64sr(0.4781770819341078)
 Float64sr(0.8019156074397128)      Float64sr(0.522393411487242)

julia> b = Float64sr.(rand(4))
4-element Vector{Float64sr}:
 Float64sr(0.7554796403393423)
 Float64sr(0.4199864825038644)
 Float64sr(0.30487539136735975)
 Float64sr(0.7228777754787546)

julia> A\b
4-element Vector{Float64sr}:
 Float64sr(-0.5018580578417031)
 Float64sr(-1.1517596349045047)
 Float64sr(0.21765870439733434)
 Float64sr(2.8794910547991557)

julia> A\b   # do it again, slightly different answer
4-element Vector{Float64sr}:
 Float64sr(-0.5018580578417027)
 Float64sr(-1.1517596349045056)
 Float64sr(0.21765870439733445)
 Float64sr(2.879491054799156)

@avleenk2312 could you try out this branch (and maybe even write some tests for it? 😄) before I merge it?

@milankl milankl added the enhancement New feature or request label Dec 7, 2022
@milankl milankl added this to the v0.7 milestone Dec 7, 2022
@avleenk2312
Copy link
Contributor

Sure, I will try it out. ◡̎

@milankl
Copy link
Owner Author

milankl commented Dec 7, 2022

A single error is occurring, unrelated to this pull request

Test Summary:   |  Pass  Fail  Total   Time
Test for U(0,1) | 29999     1  30000  15.4s

which seems to be because a Float16sr isn't rounded to either of two but of three (for whatever buggy reason) numbers

 Test for U(0,1): Test Failed at /home/runner/work/StochasticRounding.jl/StochasticRounding.jl/test/float16sr.jl:114
  Expression: Ndown + Nup == N
   Evaluated: 99999 == 100000

@milankl
Copy link
Owner Author

milankl commented Jan 18, 2023

This ☝🏼 error is now issued in #62, so @avleenk2312 please ignore it here. Have you had a chance to test Float64sr?

@avleenk2312
Copy link
Contributor

avleenk2312 commented Jan 19, 2023

Thanks for pointing out this error. We just completed our code that uses Float32sr tonight. I have started looking into Float64sr now. I will get back to you.

@milankl
Copy link
Owner Author

milankl commented Jul 11, 2023

@avleenk2312 As #62 was resolved with #67 these tests here now pass. However, we're not actually testing Float64sr in /test yet.

@milankl
Copy link
Owner Author

milankl commented Jul 11, 2023

Have added a small test set similar to other formats, locally tests pass. So the implementation looks good!

@milankl
Copy link
Owner Author

milankl commented Jul 11, 2023

Screw this, there's another one of those from #62

 [ Info: Test failed for 5.5849552e-5, 0000001110101001
Test for subnormals: Test Failed at /home/runner/work/StochasticRounding.jl/StochasticRounding.jl/test/float16sr.jl:179
  Expression: Ndown + Nup == N
   Evaluated: 99990 == 100000

[ Info: Test failed for -5.5849552e-5, 1000001110101001
Test Summary:       |  Pass  Fail  Total   Time
Test for subnormals | 59998     2  60000  25.1s
ERROR: LoadError: Some tests did not pass: 59998 passed, 2 failed, 0 errored, 0 broken.
in expression starting at /home/runner/work/StochasticRounding.jl/StochasticRounding.jl/test/float16sr.jl:162

@milankl milankl merged commit cd05692 into main Jul 11, 2023
1 check passed
@milankl milankl deleted the mk/float64sr branch July 11, 2023 13:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Float64sr via Double64?
2 participants