JuliaLang / julia

The Julia Programming Language
https://julialang.org/
MIT License
45.44k stars 5.46k forks source link

Cannot combine @simd and @threads on a loop #32684

Open mihirparadkar opened 5 years ago

mihirparadkar commented 5 years ago
julia> import Base: Threads

julia> @simd Threads.@threads for i in 1:10 end
ERROR: LoadError: Base.SimdLoop.SimdError("for loop expected")
Stacktrace:
 [1] compile(::Expr, ::Bool) at ./simdloop.jl:54
 [2] @simd(::LineNumberNode, ::Module, ::Any) at ./simdloop.jl:124
in expression starting at REPL[2]:1

julia> Threads.@threads @simd for i in 1:10 end
ERROR: LoadError: ArgumentError: unrecognized argument to @threads
Stacktrace:
 [1] @threads(::LineNumberNode, ::Module, ::Vararg{Any,N} where N) at ./threadingconstructs.jl:101
in expression starting at REPL[4]:1
vchuravy commented 5 years ago

We probably just want the expr loopinfo to be inserted in this case.

xwuupb commented 1 year ago

Any progress for this issue? (Because both multi-threading and vectorization are important topics for code performance, especially for HPC applications)

oscardssmith commented 1 year ago

this case is currently best handled by the loopvectoization library since it also generates better vectorized code than llvm.