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

Add Iterator to loop over vector using VecRange #112

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

Zentrik
Copy link
Contributor

@Zentrik Zentrik commented Apr 9, 2023

using SIMD
function vadd!(xs::Vector{T}, ys::Vector{T}, ::Type{Vec{N,T}}) where {N, T}
    @assert length(ys) == length(xs)
    @assert length(xs) % N == 0

    @inbounds for lane in LoopVecRange{N}(xs)
        xs[lane] += ys[lane]
    end
end

This avoids the current performance issue with using StepRange (fixed now from Julia v1.10) and is a simpler way to loop.

Not sure if I should have has_offset_axes, I just copied it from StepRange.
Also not sure if this is the right use for @boundscheck. I added unsafe as @inbounds wasn't working with the masked tests.

@Zentrik Zentrik marked this pull request as ready for review June 18, 2023 17:49
@Zentrik
Copy link
Contributor Author

Zentrik commented Jun 18, 2023

The performance issue with the existing approach (i.e. using a StepRange) should be solved on Julia master.
This still strikes me as a nice to have though.

@MasonProtter
Copy link

Bump @KristofferC @eschnett

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.

2 participants