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

Small dispatch fix for gamma #63

Merged
merged 2 commits into from
Nov 2, 2022
Merged

Small dispatch fix for gamma #63

merged 2 commits into from
Nov 2, 2022

Conversation

heltonmc
Copy link
Member

@heltonmc heltonmc commented Oct 25, 2022

Unfortunately we are promoting the argument to Float64 before hitting the gamma calls....

# This PR
julia> @benchmark Bessels.besselj(10, x) setup=(x=rand()*0.0000000001)
BenchmarkTools.Trial: 10000 samples with 996 evaluations.
 Range (min  max):  26.144 ns  52.565 ns  ┊ GC (min  max): 0.00%  0.00%
 Time  (median):     27.193 ns              ┊ GC (median):    0.00%
 Time  (mean ± σ):   27.259 ns ±  0.996 ns  ┊ GC (mean ± σ):  0.00% ± 0.00%

                      ▂█▅                                      
  ▂▂▂▂▂▂▂▂▂▁▁▁▁▁▁▁▁▂▂▅███▆▃▄▃▂▁▁▁▁▁▁▁▁▁▁▁▁▁▂▁▁▁▁▁▁▁▁▁▁▁▁▁▁▂▁▂ ▂
  26.1 ns         Histogram: frequency by time          29 ns <

 Memory estimate: 0 bytes, allocs estimate: 0.

# Master
julia> @benchmark Bessels.besselj(10, x) setup=(x=rand()*0.0000000001)
BenchmarkTools.Trial: 10000 samples with 988 evaluations.
 Range (min  max):  45.090 ns  98.066 ns  ┊ GC (min  max): 0.00%  0.00%
 Time  (median):     46.202 ns              ┊ GC (median):    0.00%
 Time  (mean ± σ):   46.266 ns ±  1.262 ns  ┊ GC (mean ± σ):  0.00% ± 0.00%

                    █▂  █▂                                     
  ▂▂▂▂▂▂▂▂▁▁▂▂▂▂▂▂▄███▄███▄▃▃▂▂▂▂▂▂▂▂▂▂▂▂▁▂▁▁▁▁▁▁▁▁▁▁▂▂▂▂▂▂▂▂ ▃
  45.1 ns         Histogram: frequency by time        48.2 ns <

 Memory estimate: 0 bytes, allocs estimate: 0.

So this does improve computational time now..... but I'm not for sure we should do much more than this for #58.... hoping our Float32 tests are robust enough to catch if this promotion is even needed.

Edit: Just fixed the dispatch calls to actually hit the gamma integer branch and fixed the proper return value at x = 0. This does nothing to improve #58 as that promotion was needed for accuracy.

@heltonmc
Copy link
Member Author

heltonmc commented Oct 25, 2022

Ya that is not going to work we need that promotion for single precision. The result for gamma at zero returns NaN instead of Inf for 0 and -Inf for -0.0. Just need a function to return the sign of zero.

@heltonmc heltonmc changed the title Dispatch besselj for int gamma Small dispatch fix for gamma Nov 2, 2022
@codecov
Copy link

codecov bot commented Nov 2, 2022

Codecov Report

Base: 94.53% // Head: 94.80% // Increases project coverage by +0.27% 🎉

Coverage data is based on head (5ae131e) compared to base (325cb5b).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##           master      #63      +/-   ##
==========================================
+ Coverage   94.53%   94.80%   +0.27%     
==========================================
  Files          18       18              
  Lines        1957     1964       +7     
==========================================
+ Hits         1850     1862      +12     
+ Misses        107      102       -5     
Impacted Files Coverage Δ
src/gamma.jl 86.11% <100.00%> (+13.88%) ⬆️
src/besseli.jl 98.10% <0.00%> (+0.01%) ⬆️
src/besselk.jl 97.28% <0.00%> (+0.02%) ⬆️
src/besselj.jl 93.08% <0.00%> (+0.07%) ⬆️
src/bessely.jl 91.66% <0.00%> (+0.07%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@heltonmc heltonmc merged commit a1dc369 into master Nov 2, 2022
@heltonmc heltonmc deleted the test branch November 2, 2022 16:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant