LoopVectorization.jl
LoopVectorization.jl copied to clipboard
For loops with the syntax for i in iter
trafficstars
For loops with the syntax for i in iter dont work even with a simple iterator like a Vector.
MWE
using LoopVectorization
test = rand(10000)
function mymean(func,iter)
len = length(iter)
total = zero(eltype(iter))
@avx for i in iter
total += func(i)
end
total/len
end
mymean(identity,test)
This gives this error:
ERROR: LoadError: MethodError: no method matching canonicalize_range(::Vector{Float64})
I'll probably hold off on this until the triangular loops update, which is probably at least several months away. But if anyone else would like to take a stab at it, I'd be happy to explain how to do it and answer any questions.
The approach would basically be to notice that the type of iter isn't a range, and replace it with eachindex(iter), and then substitute uses of i with iter[i].