-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Fix fastmath methods of sin, cos, tan, atan2 #24031
Conversation
Bump |
@simonbyrne, it would be great if you could review this when you get a chance. |
Patch rebased on current master |
Bump |
Can you show some benchmarks of before and after this PR for the relevant functions when using fastmath? |
You can simply compare julia> using BenchmarkTools
julia> function f()
a = 0.0
for x in -100:0.01:100
a = @fastmath sin(x)
end
return a
end
f (generic function with 1 method)
julia> function g()
a = 0.0
for x in -100:0.01:100
a = sin(x)
end
return a
end
g (generic function with 1 method)
julia> @benchmark f()
BenchmarkTools.Trial:
memory estimate: 0 bytes
allocs estimate: 0
--------------
minimum time: 382.706 μs (0.00% GC)
median time: 383.062 μs (0.00% GC)
mean time: 389.019 μs (0.00% GC)
maximum time: 655.759 μs (0.00% GC)
--------------
samples: 10000
evals/sample: 1
julia> @benchmark g()
BenchmarkTools.Trial:
memory estimate: 0 bytes
allocs estimate: 0
--------------
minimum time: 356.151 μs (0.00% GC)
median time: 356.489 μs (0.00% GC)
mean time: 356.659 μs (0.00% GC)
maximum time: 486.692 μs (0.00% GC)
--------------
samples: 10000
evals/sample: 1 With this PR the performance of |
Bump. I think it might be good to have this reviewd and merged before 0.7 |
LGTM. Just needs a rebase. |
These functions now have a fast pure Julia implementation, let the fastmath versions fall back on the default methods.
Rebased on master |
Circleci is: |
Base decided in JuliaLang/julia#24031 that FastMath.sincos should fall back to the native implementation in Julia, because it is faster than the intrinsics (for the CPU at least). That does not hold for CUDA GPUs, so have it again call sin_fast/cos_fast.
Base decided in JuliaLang/julia#24031 that FastMath.sincos should fall back to the native implementation in Julia, because it is faster than the intrinsics (for the CPU at least). That does not hold for CUDA GPUs, so have it again call sin_fast/cos_fast.
Base decided in JuliaLang/julia#24031 that FastMath.sincos should fall back to the native implementation in Julia, because it is faster than the intrinsics (for the CPU at least). That does not hold for CUDA GPUs, so have it again call sin_fast/cos_fast.
Base decided in JuliaLang/julia#24031 that FastMath.sincos should fall back to the native implementation in Julia, because it is faster than the intrinsics (for the CPU at least). That does not hold for CUDA GPUs, so have it again call sin_fast/cos_fast.
Base decided in JuliaLang/julia#24031 that FastMath.sincos should fall back to the native implementation in Julia, because it is faster than the intrinsics (for the CPU at least). That does not hold for CUDA GPUs, so have it again call sin_fast/cos_fast.
These functions now have a fast pure Julia implementation, let the fastmath
versions fall back on the default methods.
I'm not very familiar with
@fastmath
stuff, so please double (or even triple) check I'm not missing something :-) At least, fastmath tests are passing locally.