Hi,
I try to learn how to use SIMD.jl and the following snippet produces a segmentation fault when I use @btime.
using BenchmarkTools
using SIMD
const SBS=8
function microaxpy_simd!(ys::Vector{T}, a::T, xs::Vector{T}) where {T}
@assert length(ys) == length(xs)
lane = VecRange{SBS}(0)
ys[lane+1] += a*xs[lane+1]
end
function test()
x=ones(SBS)
y=ones(SBS)
a=2.0
microaxpy_simd!(y,a,x) #Seems OK
@show y
# @btime microaxpy_simd!($y,$a,$x) #produce s segfault
end
lane = VecRange{SBS}(1)
ys[lane+0] += a*xs[lane+0]
I have the same segfault crash as with
lane = VecRange{SBS}(0)
ys[lane+1] += a*xs[lane+1]
which I copied from the SIMD.jl markdown README (I could not find a more detailed doc).
What is strange is that if you try the top MWE, the result y looks fine ([3.0,...3.0]).
Ah OK, yeah. I think it might have to do with returning the Vec{8, Float64} from microaxpy_simd!. If you return ys or nothing, it’s fine. Not sure why.