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

nd LinearIndices prevents auto vectorization? #41444

Open
N5N3 opened this issue Jul 2, 2021 · 0 comments
Open

nd LinearIndices prevents auto vectorization? #41444

N5N3 opened this issue Jul 2, 2021 · 0 comments

Comments

@N5N3
Copy link
Member

N5N3 commented Jul 2, 2021

Found this when tuning copyto_unalias!

Some benchmark

f1!(a,b) = @inbounds for i in LinearIndices(a)
        a[i+1] = b[i]
    end
f2!(a,b) = @inbounds @simd for i in LinearIndices(a)
        a[i] = b[i]
end

a = randn(8,8,8,8); b = similar(a);
@btime  f1!(b,a);   #  1.930 μs (0 allocations: 0 bytes)
@btime  f2!(b,a);   #  535.263 ns (0 allocations: 0 bytes)
a = randn(16,16,16); b = similar(a);
@btime  f1!(b,a);   #  1.300 μs (0 allocations: 0 bytes)
@btime  f2!(b,a);   #  552.105 ns (0 allocations: 0 bytes)
a = randn(64,64); b = similar(a);
@btime  f1!(b,a);   #  1.940 μs (0 allocations: 0 bytes)
@btime  f2!(b,a);   #  541.579 ns (0 allocations: 0 bytes)
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

No branches or pull requests

1 participant