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

Use propagate_inbounds to restore functionality on 0.7 #11

Closed
wants to merge 1 commit into from

Conversation

vchuravy
Copy link
Collaborator

  • uses @propagate_inbounds
  • drops support for Julia 0.4, and 0.5
  • removes deprecation warnings

fixes #10

@vchuravy vchuravy force-pushed the vc/propagate_inbounds branch from cb9ca74 to dfe521e Compare January 27, 2018 21:29
@KristofferC
Copy link

FWIW, it seems like LLVM now uses SIMD even for the regular array.

@vchuravy
Copy link
Collaborator Author

Might be the SLPVectoriser? But in general SoA is still valuable since it saves a bunch of scatter/gather operations

@KristofferC
Copy link

Yeah, I didn't notice a big difference now though (using https://github.com/piever/StructArrays.jl/)

using StructArrays
regular = randn(1000000) + im*randn(1000000);
soa = convert(StructArray, regular);

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

julia> @btime f(regular, 0.5+0.5im)
  929.258 μs (2 allocations: 64 bytes)

julia> @btime f(soa, 0.5+0.5im);
  960.669 μs (2 allocations: 64 bytes)

When using @fastmath the soa version goes over to use 256 bit SIMD registries though (while something terrible happens for the regular version):

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

julia> @btime f_fast(regular, 0.5+0.5im)
  2.957 ms (2 allocations: 64 bytes)

julia> @btime f_fast(soa, 0.5+0.5im)
  701.956 μs (2 allocations: 64 bytes)

@KristofferC
Copy link

I can repeat the timings above with this package as well so it doesn't seem to be an implementation detail of the specific SoA package.

@vchuravy vchuravy closed this Dec 3, 2019
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 this pull request may close these issues.

StructsOfArrays on Julia 0.7 doesn't elide boundschecks
2 participants