You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
add_fast(x::T, y::T, zs::T...) where {T<:FloatTypes} =
add_fast(add_fast(x, y), zs...)
It otherwise falls back to non fastmath addition even when add_fast(x, y) is defined, like for ComplexF64 and types in SIMD.jl.
As the 2-arg fastmath add, add_fast(x, y), is defined for all types, should add_fast(x::T, y::T, zs::T...) be defined as above for all T.
The comment at the non fastmath n-arg addition definition seems to suggest that this would be expected and also should add_fast(x::T, y::T, zs::T...) switch to using afoldl?
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.
Currently the n-arg fastmath addition only uses fastmath for
Float16, Float32
andFloat64
,julia/base/fastmath.jl
Lines 171 to 172 in 931f6de
It otherwise falls back to non fastmath addition even when
add_fast(x, y)
is defined, like forComplexF64
and types in SIMD.jl.As the 2-arg fastmath add,
add_fast(x, y)
, is defined for all types, shouldadd_fast(x::T, y::T, zs::T...)
be defined as above for allT
.The comment at the non fastmath n-arg addition definition seems to suggest that this would be expected and also should
add_fast(x::T, y::T, zs::T...)
switch to usingafoldl
?julia/base/operators.jl
Lines 636 to 637 in 931f6de
Presumably, if we change the behaviour for addition, we want to change it for the other operators as well.
The text was updated successfully, but these errors were encountered: