-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Closed
Labels
mathsMathematical functionsMathematical functions
Description
@simd results in @fastmath being applied. This is undocumented behavior (except for re-association of reduction variables). The behavior needs to be documented or the @fastmath needs to not occur.
Reduced example derived from an effort to write a faster norm(x, 2):
# Julia v1.8.0
function test(x)
scale = exp2(768)
s1 = 0.0
s2 = 0.0
@simd for z in x
s1 += abs2(z)
s2 += abs2(z*scale)
end
s = s2==Inf ? s1 : s2
return s,s1,s2
end
test(1:3)
# (Inf, 14.0, Inf)Inspecting the @code_llvm shows many @fastmath operations and the @code_native shows unauthorized fma instructions. The result should be s == s1 == 14.0, but instead we get s == s2 == Inf because the s2==Inf check is replaced by false by the "noinf" property inherited from @fastmath.
Metadata
Metadata
Assignees
Labels
mathsMathematical functionsMathematical functions