Skip to content

LoadError: BoundsError: attempt to access 2-element Vector{LoopVectorization.ArrayReferenceMeta} at index [0] #527

@chengxo

Description

@chengxo

Hi,

I am working with Julia v1.6.2 with LoopVectorization v0.12.166. I am new to LoopVectorization, and I cannot figure out the problem after searching online for quite a while.

Here is a MWE of the error that I encounter.

using LoopVectorization
function test(a, b)
    @turbo for i in axes(a,1)
        a[i, 1] = 0.0
        for j in axes(a,2)
            a[i, 1] += b[i,j]
        end
    end
    return nothing
end

a = rand(256, 256)
b = rand(256, 256)
test(a, b)

will give me ($HOMEFOLDER is used below for privacy)
ERROR: LoadError: BoundsError: attempt to access 2-element Vector{LoopVectorization.ArrayReferenceMeta} at index [0]
Stacktrace:
[1] getindex
@ .\array.jl:801 [inlined]
[2] getindex
@ .\abstractarray.jl:1173 [inlined]
[3] mref_elbytes
@ $HOMEFOLDER.julia\packages\LoopVectorization\7gWfp\src\reconstruct_loopset.jl:675 [inlined]
[4] add_op!(ls::LoopVectorization.LoopSet, instr::LoopVectorization.Instruction, ops::Vector{LoopVectorization.OperationStruct}, nopsv::Vector{Int64}, expandedv::Vector{Bool}, i::Int64, mrefs::Vector{LoopVectorization.ArrayReferenceMeta}, opsymbol::Symbol, elementbytes::Vector{Int64})
@ LoopVectorization $HOMEFOLDER.julia\packages\LoopVectorization\7gWfp\src\reconstruct_loopset.jl:69

However, if I remove the line a[i, 1] = 0.0, it works well. The original also works if I don't use @turbo.

Could you help me understand this error message? And how should I implement such a task using @turbo? Thanks very much!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions