Open
Description
From https://stackoverflow.com/questions/62245905/optimisation-of-4d-tensor-rotation, a strange error:
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.
Metadata
Metadata
Assignees
Labels
No labels