On Wed, Nov 18, 2015 at 5:44 PM, 'Greg Plowman' via julia-users
<julia-users@googlegroups.com> wrote:
> 1. Does simd work for Integer types?
>
> code_llvm shows vector.body section for Int16,Int32,Float32,Float64 but not
> for Int64. (on my Windows 64 machine, Julia v0.4.1)
>
> Speedup is seen for Float32 and to lesser extent Float64, as expected.
> Integers show no speed up. Is this because simd is applied implicitly?
> Why is Int64 apparently not using simd?

Integers can be implicitly vectorized since their addition is
associative (floating point addsitions are not). Whether it will
actually be vectorized depending on the cost model. Your timing shows
that Int64 is ~2x slower than Int32 dispide not being vectorized so
LLVM is making the right decision here.

>
> buf = IOBuffer()
> n = 10000
> reps = 1000
> for T in (Int16,Int32,Int64,Float32,Float64)
>     code_llvm(buf, innersimd, Tuple{Vector{T},Vector{T}})
>     println(T, " ", contains(takebuf_string(buf), "vector.body"))
>     timeit(T, n, reps)
> end
>
> Int16 true
> GFlop Int16        = 14.329049425190183
> GFlop Int16 (SIMD) = 14.64120268695352
>
> Int32 true
> GFlop Int32        = 4.339303129613899
> GFlop Int32 (SIMD) = 4.436321047681579
>
> Int64 false
> GFlop Int64        = 2.1942537759816103
> GFlop Int64 (SIMD) = 2.195101499298226
>
> Float32 true
> GFlop Float32        = 2.1954870446504984
> GFlop Float32 (SIMD) = 7.82465266366826
>
> Float64 true
> GFlop Float64        = 2.171535919755667
> GFlop Float64 (SIMD) = 4.0068798126383
>
>
> 2. Can simd be applied to unrolled statements? Perhaps using some form of
> meta expression?
>
> begin
>     Expr(:meta, :simd)
>     s = 0
>     s += x[1]*y[1]
>     s += x[2]*y[2]
>     s += x[3]*y[3]
>     s += x[4]*y[4]
>     s += x[5]*y[5]
>     s += x[6]*y[6]
>     s += x[7]*y[7]
>     s += x[8]*y[8]
> end

Not right now but maybe[1]. I'm not sure how metadata can help here
though. Maybe `@fastmath` could relax some LLVM constraint and help
vectorize this case if the LLVM patch linked is merged?

[1] https://github.com/JuliaLang/julia/issues/11899#issuecomment-152604312

>
>
>

Reply via email to