I’m trying to use the @turbo
macro from LoopVectorization iterating over values from a sparse array. The way I’m doing it is the following:
I have a variable state::Vector{Float32}
and a square sparse matrix holding Float32
values, with both dimensions equal to the length state
. Then I pick a random index in a loop and evaluate the following function:
function getEFactor(state, sparse::SparseMatrixCSC, idx)
efac = 0f0
@turbo for idx in nzrange(sparse, idx)
efac += -state[sparse.rowval[idx]] * sparse.nzval[idx]
end
return efac
end
It seems to SIMD correctly, but I get segfaults when idx corresponds to an empty row of the matrix.