JuliaSIMD / JuliaSIMD/LoopVectorization.jl
Difficulty with 8 nested loops?
- Lingua principale
- Julia
- Stelle
- 789
- Fork
- 73
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
From https://stackoverflow.com/questions/62245905/optimisation-of-4d-tensor-rotation, a strange error:
```julia
Q = rand(3,3);
C = rand(3,3,3,3);
Crot = zeros(3,3,3,3);
function rotation_avx!(Crot::Array{Float64,4},Q::Array{Float64,2},C::Array{Float64,4})
# aux = 0.0
@avx for i = 1:3
for j = 1:3
for k = 1:3
for l = 1:3
aux = 0.0 # surely!
for m = 1:3
for n = 1:3
for o = 1:3
for p = 1:3
aux += Q[m,i] * Q[n,j] * Q[o,k] * Q[p,l] * C[m,n,o,p];
end
end
end
end
Crot[i,j,k,l] += aux
end
end
end
end
end
rotation_avx!(Crot, Q, C)
# ERROR: InexactError: trunc(Int64, Inf)
# Stacktrace:
# [1] trunc at ./float.jl:703 [inlined]
# [2] floor at ./float.jl:363 [inlined]
# [3] solve_unroll_constU(::SubArray{Float64,1,Array{Float64,2},Tuple{Base.Slice{Base.OneTo{Int64}},Int64},true}, ::Int64) at /Users/me/.julia/packages/LoopVectorization/lmGAZ/src/determinestrategy.jl:301
# [4] solve_unroll(::Symbol, ::Symbol, ::SubArray{Float64,1,Array{Float64,2},Tuple{Base.Slice{Base.OneTo{Int64}},Int64},true}, ::SubArray{Float64,1,Array{Float64,2},Tuple{Base.Slice{Base.OneTo{Int64}},Int64},true}, ::Int64, ::Symbol, ::LoopVectorization.Loop, ::LoopVectorization.Loop) at /Users/me/.julia/packages/LoopVectorization/lmGAZ/src/determinestrategy.jl:389
```
It works if I use `@avx for m = 1:3`, i.e. only on the inner loops.
It also works when generated by `@tullio Crot[i,j,k,l] += Q[m,i] * Q[n,j] * Q[o,k] * Q[p,l] * C[m,n,o,p]`, which has each group of loops in the opposite order but seems otherwise similar. But it takes almost a whole minute to compile.
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Direzione di ricerca
Run the provided 8-nested-loop @avx reproducer and compare it with the working inner-loop version and the @tullio form. Start in LoopVectorization/src/determinestrategy.jl around solve_unroll_constU at line 301, where the stack trace reports the InexactError. Done means the nested-loop example no longer fails while the existing working variants remain functional.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- julia
- Ambito
- performance, tooling
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 25/100