-
Notifications
You must be signed in to change notification settings - Fork 100
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
[WIP] Impl AMOS.zairy in pure julia #463
Draft
inkydragon
wants to merge
34
commits into
JuliaMath:master
Choose a base branch
from
inkydragon:native-amos
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some simple benchmark based on c18e324 tldr: with:
full test logNote we have:
Compare airyai: 171.215 ns --> 42.953 ns julia> z = ℯ*1e3 + π*1e2*im
2718.2818284590453 + 314.1592653589793im
julia> @benchmark SpecialFunctions._airy(z, Int32(0), Int32(1))
BenchmarkTools.Trial: 10000 samples with 796 evaluations.
Range (min … max): 158.040 ns … 1.056 μs ┊ GC (min … max): 0.00% … 0.00%
Time (median): 164.070 ns ┊ GC (median): 0.00%
Time (mean ± σ): 171.215 ns ± 39.243 ns ┊ GC (mean ± σ): 0.08% ± 1.11%
██▇▇▅▃▁▁ ▁ ▂
████████▇▇▇▇▇▆▆▆▇▅▆▆▅▅▅▅▄▅▄▃▄▄▄▄▃▄▃▅▁▁▅▅▅▅▅▄▁▄▁▄▃▁▅▄▄▃▃▃▃▆██ █
158 ns Histogram: log(frequency) by time 356 ns <
Memory estimate: 16 bytes, allocs estimate: 1.
julia> @benchmark AMOS.airy(z, 0, 1)
BenchmarkTools.Trial: 10000 samples with 991 evaluations.
Range (min … max): 40.666 ns … 348.133 ns ┊ GC (min … max): 0.00% … 0.00%
Time (median): 41.171 ns ┊ GC (median): 0.00%
Time (mean ± σ): 42.953 ns ± 10.719 ns ┊ GC (mean ± σ): 0.00% ± 0.00%
█▂▂▆▅▂ ▃ ▁
█████████▇▇▆▆▆▆▅▆▅▅▁▃▃▄▅▅▁▁▄▁▄▃▅▃▁▁▁▃▄▁▄▄▃▁▃▁▁▄▁▃▄▁▃▃▃▄▃▃▁▁▄ █
40.7 ns Histogram: log(frequency) by time 78.3 ns <
Memory estimate: 0 bytes, allocs estimate: 0. airyaiprime: 170.120 ns --> 42.807 ns julia> @benchmark SpecialFunctions._airy(z, Int32(1), Int32(1))
BenchmarkTools.Trial: 10000 samples with 792 evaluations.
Range (min … max): 158.081 ns … 1.024 μs ┊ GC (min … max): 0.00% … 81.94%
Time (median): 166.288 ns ┊ GC (median): 0.00%
Time (mean ± σ): 170.120 ns ± 30.089 ns ┊ GC (mean ± σ): 0.10% ± 1.17%
▂▄█▃
████▅▃▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▁▂▂▂▂▂▂▁▂▂▂▂▂▂▂▁▂▂▂▂ ▂
158 ns Histogram: frequency by time 349 ns <
Memory estimate: 16 bytes, allocs estimate: 1.
julia> @benchmark AMOS.airy(z, 1, 1)
BenchmarkTools.Trial: 10000 samples with 992 evaluations.
Range (min … max): 40.524 ns … 309.073 ns ┊ GC (min … max): 0.00% … 0.00%
Time (median): 42.339 ns ┊ GC (median): 0.00%
Time (mean ± σ): 42.807 ns ± 9.549 ns ┊ GC (mean ± σ): 0.00% ± 0.00%
▆█ ▅█▃ ▄▂▁▁▁ ▂▄▁ ▂
██▇▇▆████▇█████▇███▇▆▆▅▆▇▅▆▄▅▄▆▆▅▆▅▆▅▅▄▁▄▃▄▁▅▃▃▄▄▃▁▃▄▃▁▃▃▁▄▃ █
40.5 ns Histogram: log(frequency) by time 56 ns <
Memory estimate: 0 bytes, allocs estimate: 0. airyaix: 359.095 ns --> 204.269 ns julia> @benchmark SpecialFunctions._airy(z, Int32(0), Int32(2))
BenchmarkTools.Trial: 10000 samples with 227 evaluations.
Range (min … max): 328.194 ns … 2.172 μs ┊ GC (min … max): 0.00% … 0.00%
Time (median): 346.256 ns ┊ GC (median): 0.00%
Time (mean ± σ): 359.095 ns ± 77.896 ns ┊ GC (mean ± σ): 0.00% ± 0.00%
▇█▇█▅▅▃▂▂▁▁ ▁ ▁ ▂
█████████████▇▇▇▇▇▆▅▄▆▅▄▅▅▆▆▅▆▄▅▆▅▅▄▆▃▃▃▃▅▄▆▄▄▁▄▃▅▅▄▁▄▄▇██▆█ █
328 ns Histogram: log(frequency) by time 693 ns <
Memory estimate: 16 bytes, allocs estimate: 1.
julia> @benchmark AMOS.airy(z, 0, 2)
BenchmarkTools.Trial: 10000 samples with 763 evaluations.
Range (min … max): 163.827 ns … 3.247 μs ┊ GC (min … max): 0.00% … 87.28%
Time (median): 177.195 ns ┊ GC (median): 0.00%
Time (mean ± σ): 204.269 ns ± 172.904 ns ┊ GC (mean ± σ): 6.69% ± 7.60%
▆█▇▅▄▂▁▁ ▁▁ ▂▁ ▂
█████████████▇▇▆▆▆▆▆▆▅▆▅▆▆▅▅████▆▇▆▅▄▃▅▄▅▄▃▅▃▄▄▁▄▃▁▁▄▃▁▄▁▁▃▃▃ █
164 ns Histogram: log(frequency) by time 604 ns <
Memory estimate: 448 bytes, allocs estimate: 5. airyaiprimex: 385.369 ns --> 228.239 ns julia> @benchmark SpecialFunctions._airy(z, Int32(1), Int32(2))
BenchmarkTools.Trial: 10000 samples with 212 evaluations.
Range (min … max): 355.189 ns … 2.411 μs ┊ GC (min … max): 0.00% … 0.00%
Time (median): 371.226 ns ┊ GC (median): 0.00%
Time (mean ± σ): 385.369 ns ± 93.473 ns ┊ GC (mean ± σ): 0.00% ± 0.00%
█▆█▇▅▅▂▁▂▂▁ ▂ ▁ ▂
█████████████▇▆▆▆▄▆▅▄▅▄▆▃▄▄▅▃▄▃▄▅▄▃▅▅▃▃▃▁▁▄▁▁▄▅▃▄▄▄▄▁▄▄▄█▇▅█ █
355 ns Histogram: log(frequency) by time 729 ns <
Memory estimate: 16 bytes, allocs estimate: 1.
julia> @benchmark AMOS.airy(z, 1, 2)
BenchmarkTools.Trial: 10000 samples with 681 evaluations.
Range (min … max): 183.113 ns … 3.848 μs ┊ GC (min … max): 0.00% … 88.07%
Time (median): 196.256 ns ┊ GC (median): 0.00%
Time (mean ± σ): 228.239 ns ± 180.213 ns ┊ GC (mean ± σ): 5.84% ± 7.25%
▇█▇▄▃▁ ▁▃▃▁ ▂
████████████▇▇▆▆▆▅▅▄▆▅▅▅▆█████▇▆▅▅▄▁▄▄▄▃▅▁▃▁▁▃▃▁▃▄▃▁▃▁▄▁▁▁▃▄▄ █
183 ns Histogram: log(frequency) by time 676 ns <
Memory estimate: 448 bytes, allocs estimate: 5. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The pr has not yet reached a state where it is ready for review.
Since there's a lot of additions to the code that make it difficult to review, and the
airy
function currently passes some tests.I opened up this draft pr, so that you can play around with the early version and give some feedback.
This pr impl those function in pure julia, as a part of #461
NOTE: I chose to rewrite the
airy
function first because it relies on the fewest other functions in the call graph.airy
will replace_airy
SpecialFunctions.jl/src/bessel.jl
Lines 29 to 33 in 9033446
TODO
@show
,@info
, ...)test/amos/helper.jl
, and this test file need rename.AMOS call graph