Stream: helpdesk (published)

Topic: @turbo macro trouble


view this post on Zulip Jack C (Apr 25 2022 at 22:17):

Why might this application of the turbo macro fail and fall back to inbounds and simd? We're trying to do mul!(y, A, x[:, col]), but without copying the column of x.

function matmul_column!(y, A, x, col)
    @turbo for i in axes(A, 1)
        yi = 0.
        for j in axes(A, 2)
            yi += A[i, j] * x[j, col]
        end
        y[i] = yi
    end
end

view this post on Zulip chriselrod (Apr 26 2022 at 13:13):

What are the element types?
Note that @view(x[:,col]) should also let you avoid copying the column of x.

view this post on Zulip Jack C (Apr 27 2022 at 16:59):

Turns out the element types were SVectors, no wonder it wasn't working. Reshaping things to be a 3d SArray rather than a SMatrix{SVector} fixed it.

The matrix x is tiny enough that I don't want the overhead of the @view, but that's something I should measure too.


Last updated: Dec 28 2024 at 04:38 UTC