JuliaSIMD / JuliaSIMD/LoopVectorization.jl

AssertionError: M == 1

Open
#506 9 comments 0 reactions 0 assignees View on GitHub
Dominant language
Julia
Stars
789
Forks
73
PR merge metrics
No merged PRs in 30d

Description

Firstly, many thanks for this amazing package!

I managed to cook it down to the following MWE

```julia
using LoopVectorization

function testy(N, MDM, rhs, fx)

NN = N^2
rng = 1:NN
v_rhs = reshape(view(rhs, rng), (N,N))
v_fx = reshape(view(fx, rng), (N,N))

x = 1.0
@turbo for j = 1:N
for i = 1:N
rhsij = 0.0
for k = 1:N
# rhsij += MDM[i,k] * v_fx[k+(N-1)*j]
rhsij += MDM[i,k] * v_fx[k,j]
end
rhsij *= x
v_rhs[i,j] = rhsij
end
end

end

N = 8
MDM = randn(N,N)
rhs = randn(N*N)
fx = randn(N*N)

testy(N, MDM, rhs, fx)
```
gives
```julia
julia> include("mwe_lv3.jl")
ERROR: LoadError: AssertionError: M == 1
Stacktrace:
[1] #s221#49
@ ~/.julia/packages/LoopVectorization/xHfLl/src/codegen/lower_compute.jl:338 [inlined]
[2] var"#s221#49"(F::Any, M::Any, K::Any, D::Any, S::Any, ::Any, f::Any, default::Any, #unused#::Type, #unused#::Any, vargs::Any)
@ LoopVectorization ./none:0
[3] (::Core.GeneratedFunctionStub)(::Any, ::Vararg{Any})
@ Core ./boot.jl:602
[4] macro expansion
@ ~/.julia/packages/LoopVectorization/xHfLl/src/reconstruct_loopset.jl:1107 [inlined]
[5] _turbo_!(::Val{(false, 0, 0, 0, false, 4, 32, 15, 64, 0x0000000000000001, 1, true)}, ::Val{(:numericconstant, Symbol("###0.0###5###"), LoopVectorization.OperationStruct(0x00000000000000000000000000000012, 0x00000000000000000000000000000000, 0x00000000000000000000000000000003, 0x00000000000000000000000000000000, 0x00000000000000000000000000000000, 0x00000000000000000000000000000000, 0x00000000000000000000000000000000, LoopVectorization.constant, 0x0001, 0x0000), :LoopVectorization, :getindex, LoopVectorization.OperationStruct(0x00000000000000000000000000000023, 0x00000000000000000000000000000000, 0x00000000000000000000000000000000, 0x00000000000000000000000000000000, 0x00000000000000000000000000000000, 0x00000000000000000000000000000000, 0x00000000000000000000000000000000, LoopVectorization.memload, 0x0002, 0x0001), :LoopVectorization, :getindex, LoopVectorization.OperationStruct(0x00000000000000000000000000000031, 0x00000000000000000000000000000000, 0x00000000000000000000000000000000, 0x00000000000000000000000000000000, 0x00000000000000000000000000000000, 0x00000000000000000000000000000000, 0x00000000000000000000000000000000, LoopVectorization.memload, 0x0003, 0x0002), :LoopVectorization, :vfmadd_fast, LoopVectorization.OperationStruct(0x00000000000000000000000000000231, 0x00000000000000000000000000000003, 0x00000000000000000000000000000000, 0x00000000000000000000000200030001, 0x00000000000000000000000000000000, 0x00000000000000000000000000000000, 0x00000000000000000000000000000000, LoopVectorization.compute, 0x0001, 0x0000), :LoopVectorization, :identity, LoopVectorization.OperationStruct(0x00000000000000000000000000000012, 0x00000000000000000000000000000003, 0x00000000000000000000000000000000, 0x00000000000000000000000000000004, 0x00000000000000000000000000000000, 0x00000000000000000000000000000000, 0x00000000000000000000000000000000, LoopVectorization.compute, 0x0001, 0x0000), :LoopVectorization, :LOOPCONSTANTINSTRUCTION, LoopVectorization.OperationStruct(0x00000000000000000000000000000000, 0x00000000000000000000000000000000, 0x00000000000000000000000000000000, 0x00000000000000000000000000000000, 0x00000000000000000000000000000000, 0x00000000000000000000000000000000, 0x00000000000000000000000000000000, LoopVectorization.constant, 0x0004, 0x0000), :numericconstant, Symbol("###reduction##zero###11###"), LoopVectorization.OperationStruct(0x00000000000000000000000000000012, 0x00000000000000000000000000000000, 0x00000000000000000000000000000012, 0x00000000000000000000000000000000, 0x00000000000000000000000000000000, 0x00000000000000000000000000000000, 0x00000000000000000000000000000000, LoopVectorization.constant, 0x0005, 0x0000), :LoopVectorization, :mul_fast, LoopVectorization.OperationStruct(0x00000000000000000000000000000012, 0x00000000000000000000000000000012, 0x00000000000000000000000000000000, 0x00000000000000000000000000060007, 0x00000000000000000000000000000000, 0x00000000000000000000000000000000, 0x00000000000000000000000000000000, LoopVectorization.compute, 0x0005, 0x0000), :LoopVectorization, :reduced_prod, LoopVectorization.OperationStruct(0x00000000000000000000000000000012, 0x00000000000000000000000000000000, 0x00000000000000000000000000000000, 0x00000000000000000000000000080005, 0x00000000000000000000000000000000, 0x00000000000000000000000000000000, 0x00000000000000000000000000000000, LoopVectorization.compute, 0x0001, 0x0000), :LoopVectorization, :setindex!, LoopVectorization.OperationStruct(0x00000000000000000000000000000021, 0x00000000000000000000000000000000, 0x00000000000000000000000000000000, 0x00000000000000000000000000000009, 0x00000000000000000000000000000000, 0x00000000000000000000000000000000, 0x00000000000000000000000000000000, LoopVectorization.memstore, 0x0006, 0x0003))}, ::Val{(LoopVectorization.ArrayRefStruct{:MDM, Symbol("##vptr##_MDM")}(0x00000000000000000000000000000101, 0x00000000000000000000000000000203, 0x00000000000000000000000000000000, 0x00000000000000000000000000000101), LoopVectorization.ArrayRefStruct{:v_fx, Symbol("##vptr##_v_fx")}(0x00000000000000000000000000000101, 0x00000000000000000000000000000301, 0x00000000000000000000000000000000, 0x00000000000000000000000000000101), LoopVectorization.ArrayRefStruct{:v_rhs, Symbol("##vptr##_v_rhs")}(0x00000000000000000000000000000101, 0x00000000000000000000000000000201, 0x00000000000000000000000000000000, 0x00000000000000000000000000000101))}, ::Val{(0, (), (6,), (), (), ((1, LoopVectorization.HardFloat),), ((7, 2.0),))}, ::Val{(:j, :i, :k)}, ::Val{Tuple{Tuple{CloseOpenIntervals.CloseOpen{Static.StaticInt{0}, Int64}, CloseOpenIntervals.CloseOpen{Static.StaticInt{0}, Int64}, CloseOpenIntervals.CloseOpen{Static.StaticInt{0}, Int64}}, Tuple{LayoutPointers.GroupedStridedPointers{Tuple{Ptr{Float64}, Ptr{Float64}, Ptr{Float64}}, (1, 1, 1), (0, 0, 0), ((1, 2), (1, 2), (1, 2)), ((1, 2), (3, 4), (5, 6)), Tuple{Static.StaticInt{8}, Int64, Static.StaticInt{8}, Int64, Static.StaticInt{8}, Int64}, NTuple{6, Static.StaticInt{0}}}, Float64}}}, ::Int64, ::Int64, ::Int64, ::Ptr{Float64}, ::Ptr{Float64}, ::Ptr{Float64}, ::Int64, ::Int64, ::Int64, ::Float64)
@ LoopVectorization ~/.julia/packages/LoopVectorization/xHfLl/src/reconstruct_loopset.jl:1107
[6] testy(N::Int64, MDM::Matrix{Float64}, rhs::Vector{Float64}, fx::Vector{Float64})
@ Main .../mwe_lv3.jl:12
[7] top-level scope
@ .../mwe_lv3.jl:32
[8] include(fname::String)
@ Base.MainInclude ./client.jl:478
[9] top-level scope
@ REPL[44]:1
in expression starting at .../mwe_lv3.jl:32
```

Changing one of the following makes it work though
- remove `@turbo` (obviously)
- move `@turbo` onto the `i` loop
- lower `N` to 7 or smaller
- replace the line in the inner most loop with `rhsij += MDM[i,k] * v_fx[k+(N-1)*j]`
- remove the line `rhsij *= x` from within the `i` loop

My setup is
```julia
julia> versioninfo()
Julia Version 1.9.3
Commit bed2cd540a1 (2023-08-24 14:43 UTC)
Build Info:
Official https://julialang.org/ release
Platform Info:
OS: Linux (x86_64-linux-gnu)
CPU: 12 × Intel(R) Core(TM) i7-5820K CPU @ 3.30GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-14.0.6 (ORCJIT, haswell)
Threads: 1 on 12 virtual cores
```
and using `LoopVectorization v0.12.165`.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.