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

SIMD not enabled when iterating over two Arrays with equal sizes #29571

Open
nalimilan opened this issue Oct 9, 2018 · 2 comments
Open

SIMD not enabled when iterating over two Arrays with equal sizes #29571

nalimilan opened this issue Oct 9, 2018 · 2 comments
Labels
compiler:optimizer Optimization passes (mostly in base/compiler/ssair/) compiler:simd instruction-level vectorization performance Must go faster

Comments

@nalimilan
Copy link
Member

nalimilan commented Oct 9, 2018

At #29458 I noticed that SIMD is not enabled when iterating over two Array objects (e.g. Vector{Int}) with the same size. Here are two examples similar to copyto!:

function f(x, y)
    @assert size(x) == size(y)
    for (i, v) in zip(eachindex(x), y)
        x[i] = v
    end
    x
end

function g(x, y)
    @assert size(x) == size(y)
    for (i, j) in zip(eachindex(x), eachindex(y))
        x[i] = y[j]
    end
    x
end

In the case of g, SIMD is used if adding @inbounds to both indexing operations. In the case of f it doesn't make any difference.

It seems to me that it should be possible to enable SIMD at least when both arguments use 1-based indices.

@nalimilan nalimilan added performance Must go faster compiler:optimizer Optimization passes (mostly in base/compiler/ssair/) labels Oct 9, 2018
@KristofferC
Copy link
Sponsor Member

Could you be explicit about the input to the functions to reproduce it? Any Array?

@nalimilan
Copy link
Member Author

Ah, right. I tested this with Vector{Int} (added to the description).

@brenhinkeller brenhinkeller added the compiler:simd instruction-level vectorization label Nov 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler:optimizer Optimization passes (mostly in base/compiler/ssair/) compiler:simd instruction-level vectorization performance Must go faster
Projects
None yet
Development

No branches or pull requests

3 participants