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
The idea is not to check whether a function has a SIMD implementation, but to scalarize in case we do not have one.
@inlinefunctionmaybescalarize(f::F, x::Vararg{Any,K}) where {K}
T = Base.promote_op(f, x...)
T === Union{} &&scalarize(f, x...)
returnf(x...)
endusing VectorizationBase: AbstractSIMDVector
@inlinefunctionscalarize(f::F, x::AbstractSIMDVector{W}) where {W}
Vec(ntuple(f ∘ x, Val(8))...)
end
Two things are missing:
Add all the missing scalarize methods I didn't include above. This means VecUnroll and things that are neither VecUnroll or AbstractSIMDVector. We also need to consider functions with all sorts of different numbers of arguments. Thankfully, we don't need to consider memory operations like vload or vstore, because these should always vectorize (our checks on the arrays should handle that).
Updating LV's code generation to call maybescalarize(f, args...) instead of f(args...). This might only mean editing here:
With respect to JuliaSIMD/StrideArrays.jl#62 this will vectorize the call (exactly what we want), because our type check will be using the actually correct argument types to the function, and not just Vec{2,Int}.
Seems like this should be fairly straightforward, and may be a nice improvement.
I'd be happy to provide instructions/guidance/answer questions if anyone wants to take this on!
The text was updated successfully, but these errors were encountered:
See here for some background: JuliaSIMD/StrideArrays.jl#62 (comment)
The idea is not to check whether a function has a
SIMD
implementation, but to scalarize in case we do not have one.Two things are missing:
scalarize
methods I didn't include above. This meansVecUnroll
and things that are neitherVecUnroll
orAbstractSIMDVector
. We also need to consider functions with all sorts of different numbers of arguments. Thankfully, we don't need to consider memory operations likevload
orvstore
, because these should always vectorize (our checks on the arrays should handle that).maybescalarize(f, args...)
instead off(args...)
. This might only mean editing here:LoopVectorization.jl/src/modeling/costs.jl
Lines 17 to 23 in 35f8310
and this file
https://github.com/JuliaSIMD/LoopVectorization.jl/blob/main/src/codegen/lower_compute.jl
because all of the other places are probably related to load/store or address calculation.
With respect to JuliaSIMD/StrideArrays.jl#62 this will vectorize the call (exactly what we want), because our type check will be using the actually correct argument types to the function, and not just
Vec{2,Int}
.Seems like this should be fairly straightforward, and may be a nice improvement.
I'd be happy to provide instructions/guidance/answer questions if anyone wants to take this on!
The text was updated successfully, but these errors were encountered: