JuliaSIMD / JuliaSIMD/LoopVectorization.jl

Incorrect result in accumulator expression

Abierto
#147 2 comentarios 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
Julia
Estrellas
789
Forks
73
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

Something is causing this third case to be unhappy:
```julia
julia> using LoopVectorization

julia> let a = 1.0, b = 1.0, h = 1.0, v = rand(10)
@avx for i in eachindex(v)
h = a * v[i] + h
end
end
5.877242734755752

julia> let a = 1.0, b = 1.0, h = 1.0, v = rand(10)
@avx for i in eachindex(v)
h = v[i] + b * h
end
end
5.35890841491465

julia> let a = 1.0, b = 1.0, h = 1.0, v = rand(10)
@avx for i in eachindex(v)
h = a * v[i] + b * h
end
end
ERROR: UndefVarError: ##op#602_0 not defined
Stacktrace:
[1] macro expansion at /home/mason/.julia/packages/LoopVectorization/OZUlx/src/reconstruct_loopset.jl:503 [inlined]
[2] _avx_! at /home/mason/.julia/packages/LoopVectorization/OZUlx/src/reconstruct_loopset.jl:503 [inlined]
[3] top-level scope at ./REPL[16]:2
```
Furthermore, if I try to fix it by changing around the syntax, it actually runs and gets an incorrect result:
```julia
julia> let a = 1.5, b = 2.0, h = 3.0, v = rand(10)
@avx for i in eachindex(v)
h_old = h
h = a * v[i] + b * h_old
end
h
end
3.0

julia> let a = 1.5, b = 2.0, h = 3.0, v = rand(10)
for i in eachindex(v)
h_old = h
h = a * v[i] + b * h_old
end
h
end
3979.1681593580383

(@v1.5) pkg> st LoopVectorization
Status `~/.julia/environments/v1.5/Project.toml`
[bdcacae8] LoopVectorization v0.8.24

julia> versioninfo()
Julia Version 1.5.0
Commit 96786e22cc* (2020-08-01 23:44 UTC)
Platform Info:
OS: Linux (x86_64-pc-linux-gnu)
CPU: AMD Ryzen 5 2600 Six-Core Processor
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-9.0.1 (ORCJIT, znver1)
Environment:
JULIA_NUM_THREADS = 6

```

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Línea de trabajo

Reproduce the three accumulator examples with Julia 1.5 and LoopVectorization v0.8.24. Start at src/reconstruct_loopset.jl:503, identified in the stack trace, and trace how the @avx loop handles the combined a * v[i] + b * h expression. Done means the expression no longer raises UndefVarError and the transformed loop matches the ordinary loop's result.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
julia
Área
performance
Tipo de issue
Error
Dificultad
4/5
Tiempo estimado
3-5 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
35/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.