JuliaSIMD / JuliaSIMD/LoopVectorization.jl
@turbo can't find index when looping over sparse arrays
- Vorherrschende Sprache
- Julia
- Sterne
- 789
- Forks
- 73
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
I am trying to use turbo in this function to multiply `A'x` when A is sparse
```Julia
function my_mul_lv!(y::Vector{Float64}, A::SparseMatrixCSC{Float64,Int64}, x::Vector{Float64})
@turbo for i in eachindex(y)
tmp = 0.0
for j in nzrange(A, i)
tmp += A.nzval[j] * x[A.rowval[j]]
end
y[i] = tmp
end
return
end
```
The function works without the `@turbo` macro but when I add it, it throws this an error that `i` isn't defined: `UndefVarError: i not defined`
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Rechercherichtung
Reproduce the reported Julia function with `@turbo`, `SparseMatrixCSC`, `nzrange`, and the nested loop, then inspect how the macro handles `eachindex(y)` and the loop variable `i`. Compare the behavior with the same function without `@turbo`; done means the sparse-array loop no longer raises `UndefVarError: i not defined`.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- julia
- Bereich
- performance
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100