Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failure with reduction to scalar over three arrays with triple-repeated index #252

Closed
oschulz opened this issue Apr 27, 2021 · 4 comments
Closed

Comments

@oschulz
Copy link

oschulz commented Apr 27, 2021

Transferred from mcabbott/Tullio.jl#104:

This loop over three arrays

using LoopVectorization

function lv_test(A, B ,C)
    D = zero(promote_type(eltype(A),eltype(B),eltype(C)))
    @avx for i in axes(C,1), j in axes(C,2), k in axes(C,3)
        D += A[i,j] * B[i,k] * C[i,j,k]
    end
    D
end

A = rand(2, 3); B = rand(2, 3); C = rand(2, 3, 3)

lv_test(A, B, C)

fails with (only seems to happen with 3-dim C and index i repeated three times)

ERROR: UndefVarError: ####op#270_0 not defined
Stacktrace:
 [1] macro expansion
   @ /user/.julia/packages/LoopVectorization/THOni/src/reconstruct_loopset.jl:630 [inlined]
 [2] _avx_!(#unused#::Val{(false, 0, 0, false, 4, 32, 15, 64, 32768, 262144, 16777216, 0x0000000000000001)}, #unused#::Val{(:LoopVectorization, :getindex, LoopVectorization.OperationStruct(0x0000000000000123, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, LoopVectorization.memload, 0x01, 0x01), :LoopVectorization, :getindex, LoopVectorization.OperationStruct(0x0000000000000012, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, LoopVectorization.memload, 0x02, 0x02), :LoopVectorization, :getindex, LoopVectorization.OperationStruct(0x0000000000000013, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, LoopVectorization.memload, 0x03, 0x03), :LoopVectorization, :mul_fast, LoopVectorization.OperationStruct(0x0000000000000123, 0x0000000000000000, 0x0000000000000000, 0x0000000000000203, LoopVectorization.compute, 0x00, 0x04), :LoopVectorization, :LOOPCONSTANTINSTRUCTION, LoopVectorization.OperationStruct(0x0000000000000000, 0x0000000000000000, 0x0000000000000123, 0x0000000000000000, LoopVectorization.constant, 0x00, 0x05), :LoopVectorization, :vfmadd_fast, LoopVectorization.OperationStruct(0x0000000000000123, 0x0000000000000123, 0x0000000000000000, 0x0000000000010405, LoopVectorization.compute, 0x00, 0x05))}, #unused#::Val{(LoopVectorization.ArrayRefStruct{:C, Symbol("##vptr##_C")}(0x0000000000010101, 0x0000000000010203, 0x0000000000000000, 0x0000000000010101), LoopVectorization.ArrayRefStruct{:A, Symbol("##vptr##_A")}(0x0000000000000101, 0x0000000000000102, 0x0000000000000000, 0x0000000000000101), LoopVectorization.ArrayRefStruct{:B, Symbol("##vptr##_B")}(0x0000000000000101, 0x0000000000000103, 0x0000000000000000, 0x0000000000000101))}, #unused#::Val{(0, (6,), (5,), (), (), (), ())}, #unused#::Val{(:i, :j, :k)}, tuple#args#::Tuple{Tuple{ArrayInterface.OptionallyStaticUnitRange{Static.StaticInt{1}, Int64}, ArrayInterface.OptionallyStaticUnitRange{Static.StaticInt{1}, Int64}, ArrayInterface.OptionallyStaticUnitRange{Static.StaticInt{1}, Int64}}, Tuple{VectorizationBase.GroupedStridedPointers{Tuple{Ptr{Float64}, Ptr{Float64}, Ptr{Float64}}, (1, 1, 1), (0, 0, 0), ((1, 2, 3), (1, 2), (1, 2)), ((1, 2, 3), (4, 5), (6, 7)), Tuple{Static.StaticInt{8}, Int64, Int64, Static.StaticInt{8}, Int64, Static.StaticInt{8}, Int64}, NTuple{7, Static.StaticInt{1}}}, Float64}})
   @ LoopVectorization /user/.julia/packages/LoopVectorization/THOni/src/reconstruct_loopset.jl:630

System info:

julia> versioninfo()
Julia Version 1.6.0
Commit f9720dc2eb (2021-03-24 12:55 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-11.0.1 (ORCJIT, skylake)
@oschulz oschulz changed the title Weird failure with reduction to scalar over three arrays with triple-repeated index Failure with reduction to scalar over three arrays with triple-repeated index Apr 27, 2021
@chriselrod
Copy link
Member

chriselrod commented Apr 27, 2021

Very similar to: #251
I'll try and fix these within the next week & before LoopVectorization's next release.

@oschulz
Copy link
Author

oschulz commented Apr 27, 2021

Awesome - thanks a lot in advance! (I ran into this in a current real-live use case.)

@chriselrod
Copy link
Member

Same as in #251, this is fixed and should be fast now.

@oschulz
Copy link
Author

oschulz commented Apr 30, 2021

Thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants