the.bay.news

Why is dot so slow for small vectors?

Julia Programming Language
Why is dot so slow for small vectors?
I used LinearAlgebra.dot for small to medium sized vectors but discovered recently that it is much slower for short vectors than an simple for loop. The following code using Printf using LinearAlgebra using BenchmarkTools function mydot(x, y) s = zero(eltype(x)) axes(x) === axes(y) || error("axes must match") @inbounds @simd for i in eachindex(x, y) s += x[i]*y[i] end return s end lens = [3, 11, 21, 51, 501, 2501] mtdot = similar(lens, Float64) mtmydot = similar(le...

0 comments

Sign in to join the discussion — your thebay.events account works here.

No comments yet.