function simd_sum{T}(x::Vector{T})
s = zero(T)
@simd for i in eachindex(x)
@inbounds s = s + x[i]
end
return s
end
which vectorizes with Vector{Float64} fails to vectorize with ForwardDiff numbers. For example:
@code_llvm simd_sum(rand(Float64, 10))
G = ForwardDiff.GradientNumber{4, Float64, NTuple{4, Float64}}
G_vec = G[rand(G) for i = 1:10]
@code_llvm simd_sum(G_vec)
It is possible that there is nothing that can be done on the ForwardDiff side to solve this but I thought it could be interesting to track nonetheless.
A standrad reduction function like:
which vectorizes with
Vector{Float64}
fails to vectorize with ForwardDiff numbers. For example:It is possible that there is nothing that can be done on the ForwardDiff side to solve this but I thought it could be interesting to track nonetheless.