Skip to content

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 force-pushed the LoopVecRange branch 2 times, most recently from 67ce672 to ca17a51 Compare April 9, 2023 15:29
@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