LoopVectorization.jl icon indicating copy to clipboard operation
LoopVectorization.jl copied to clipboard

Handing of `end` in indexing

Open mcabbott opened this issue 4 years ago • 2 comments

From https://github.com/mcabbott/Tullio.jl/issues/97, this gives an error:

function col!(out, A)
  @avx for i in 1:3
    out[i, end] = 10 * A[i]
    out[i, begin] = 100 * A[i]
  end
  out
end
col!(rand(3,3), collect(1:3))  # UndefVarError: end not defined

mcabbott avatar Apr 20 '21 18:04 mcabbott

begin would throw that error too. The expression parser should replace those with firstindex/lastindex.

chriselrod avatar Apr 20 '21 18:04 chriselrod

Trying to decide the best way to handle this. LoopVectorization's parsing currently doesn't keep track of the index with respect to the parent array, but with respect to the stridedpointer while it parses. The problem with that is that it'll drop dimensions from the pointer by taking views, so that to be correct with multiple constant indices, e.g. A[i,begin,end], it'll have to start tracking both. That's probably the best option.

chriselrod avatar Apr 25 '21 02:04 chriselrod