Closed sortraev closed 7 months ago
Regarding point (1), since you only ever create Safe
UpdateAcc
s, propagation should maintain the current behaviour, which is therefore correct.
Using Unsafe
where appropriate in AD can be done later.
Is this still WIP or can it be merged?
As far as I'm concerned, it is ready to merge, yes!
Adds support for unsafe
UpdateAcc
ops, to omit boundary checks on the accumulator in cases where the indices are known (or assumed) to always be within bounds. The initial motivation was to useWithAcc
to read block/register tiles from global to shared memory in the (WIP) tensor contraction tiling, wherein I would like to handle boundaries manually (if at all).In most places, I simply took inspiration from the existing
Update
cases.TODOs: 1) In those places in the compiler where
UpdateAcc
ops are passed along, I simply pass on the existingSafety
information. I cannot discern whether there may be cases where an optimization or transformation enables or necessitates changing theSafety
, so I hope someone will look into this before merging. 2) In those places in e.g. AD where newUpdateAcc
s are created, I usedSafe
safety to preserve behavior, but it may or may not be beneficial to substituteUnsafe
in certain places. 3) I am not familiar with Megaparsec, so I simply copy+pasted the current rule forUpdateAcc
inIR.Parse
(andIR.Pretty
).