Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StructsOfArrays on Julia 0.7 doesn't elide boundschecks #10

Open
vchuravy opened this issue Nov 12, 2017 · 0 comments
Open

StructsOfArrays on Julia 0.7 doesn't elide boundschecks #10

vchuravy opened this issue Nov 12, 2017 · 0 comments

Comments

@vchuravy
Copy link
Collaborator

Running the example from the readme on 0.7.0-DEV.2484

using BenchmarkTools
using StructsofArrays

regular = complex(randn(1000000), randn(1000000))
soa = convert(StructOfArrays, regular)

function f(x, a)
    s = zero(eltype(x))
    @simd for i in 1:length(x)
        @inbounds s += x[i] * a
    end
    s
end

@benchmark f(regular, 0.5+0.5im)
@benchmark f(soa, 0.5+0.5im)

Leads to the disappointing result of:

julia> @benchmark f(regular, 0.5+0.5im)
BenchmarkTools.Trial: 
  memory estimate:  64 bytes
  allocs estimate:  2
  --------------
  minimum time:     786.494 μs (0.00% GC)
  median time:      817.898 μs (0.00% GC)
  mean time:        864.446 μs (0.00% GC)
  maximum time:     4.601 ms (0.00% GC)
  --------------
  samples:          5757
  evals/sample:     1

julia> @benchmark f(soa, 0.5+0.5im)
BenchmarkTools.Trial: 
  memory estimate:  64 bytes
  allocs estimate:  2
  --------------
  minimum time:     1.091 ms (0.00% GC)
  median time:      1.261 ms (0.00% GC)
  mean time:        1.359 ms (0.00% GC)
  maximum time:     7.935 ms (0.00% GC)
  --------------
  samples:          3661
  evals/sample:     1

and inspection of the @code_llvm shows that there are still oob blocks visible and no vectorization is happening.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant