-
Notifications
You must be signed in to change notification settings - Fork 35
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
@fastmath not applying to additions sometimes #108
Comments
Ok identified what the problem is julia> @macroexpand test(x, y, z) = @fastmath x[0] + y[0] + z[0]
:(test(x, y, z) = begin
#= REPL[45]:1 =#
Base.FastMath.add_fast(x[0], y[0], z[0])
end) The problem is we're calling https://github.com/JuliaLang/julia/blob/e7345b89fd4eb15e8f395395701e19be705d7b06/base/fastmath.jl#L263-L264. # fall-back implementation for non-numeric types
$op_fast(xs...) = $op(xs...) We probably want something like add_fast(x::T, y::T, zs::T...) where {T<:FloatTypes} =
add_fast(add_fast(x, y), zs...) |
n-arg parsing strikes again... |
KristofferC
pushed a commit
to JuliaLang/julia
that referenced
this issue
May 29, 2024
Currently using the fastmath vararg +, *, min, max methods only actually sets fastmath if they are specifically overloaded even when the correct 2 argument methods have been defined. As such, `ComplexF32, ComplexF64` do not currently set fastmath when using the vararg methods. This will also fix any other types, such as those in SIMD.jl, which don't overload the vararg methods. E.g. ```julia x = ComplexF64(1) f(x) = @fastmath x + x + x ``` now works correctly. I see no reason why the vararg methods shouldn't default to using the fastmath 2 argument methods instead of the non fastmath ones, which is the current behaviour. I also switched the implementation to use `afoldl` as that's what the non fastmath vararg methods use. Fixes #54456 and eschnett/SIMD.jl#108.
Fixed by JuliaLang/julia#54513 (on 1.12) at least. |
DilumAluthge
pushed a commit
to JuliaLang/julia
that referenced
this issue
Jun 3, 2024
Currently using the fastmath vararg +, *, min, max methods only actually sets fastmath if they are specifically overloaded even when the correct 2 argument methods have been defined. As such, `ComplexF32, ComplexF64` do not currently set fastmath when using the vararg methods. This will also fix any other types, such as those in SIMD.jl, which don't overload the vararg methods. E.g. ```julia x = ComplexF64(1) f(x) = @fastmath x + x + x ``` now works correctly. I see no reason why the vararg methods shouldn't default to using the fastmath 2 argument methods instead of the non fastmath ones, which is the current behaviour. I also switched the implementation to use `afoldl` as that's what the non fastmath vararg methods use. Fixes #54456 and eschnett/SIMD.jl#108.
lazarusA
pushed a commit
to lazarusA/julia
that referenced
this issue
Jul 12, 2024
Currently using the fastmath vararg +, *, min, max methods only actually sets fastmath if they are specifically overloaded even when the correct 2 argument methods have been defined. As such, `ComplexF32, ComplexF64` do not currently set fastmath when using the vararg methods. This will also fix any other types, such as those in SIMD.jl, which don't overload the vararg methods. E.g. ```julia x = ComplexF64(1) f(x) = @fastmath x + x + x ``` now works correctly. I see no reason why the vararg methods shouldn't default to using the fastmath 2 argument methods instead of the non fastmath ones, which is the current behaviour. I also switched the implementation to use `afoldl` as that's what the non fastmath vararg methods use. Fixes JuliaLang#54456 and eschnett/SIMD.jl#108.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
We see that
For whatever reason doing 2 additions on the same line in a for loop removes the
fast
flag fromfadd
.The text was updated successfully, but these errors were encountered: