Skip to content

Bounds checking and instructions with predicates

@inducer: I am fighting the bounds check code because I have a number of instructions that are masked by predicates which are meant to prevent them from writing an array out of bounds. Example:

>>> import loopy as lp
>>> knl = lp.make_kernel("{[i]: 0 <= i < 10}",
... "out[i+1] = i {if=i+1<10}",
... [lp.GlobalArg("out", shape=(10,))])
>>> lp.generate_code_v2(knl)

But the bounds checker ignores the predicates:

loopy.diagnostic.LoopyError: 'out[i + 1]' in instruction 'insn' accesses out-of-bounds array element

I feel like the bounds checker should leave such instructions alone. What is the best way to do this?

  • Bounds check always ignores instructions with predicates
  • Bounds check tries to be smart about predicates if it can
  • New "noboundscheck" instruction tag