AD Cleanup: Use a temporary accumulation inst such as IRAccumulate
instead of explicitly loading, adding and storing differential values in reverse mode
#4211
Labels
goal:forward looking
Feature needed at a later date, not connected to a specific use case.
kind:cleanup
tech debt and rough edges
kind:enhancement
a desirable new feature, option, or behavior
Milestone
We currently accumulate derivatives in a somewhat explicit manner by loading the current differential value, adding the new derivative contribution and then storing this back.
This makes our code fairly messy, and impedes potential optimizations, since accumulation instructions (i.e. +=) can be reordered, but standard loads and stores can't.
We can simply lower these instructions into standard load/add/store instructions after optimizations are performed.
Further, this allows Slang to explicitly emit accumulate instructions on targets that support it (for further downstream optimizations).
Note:
IRAccumulate
can also have a correspondingIRConsume
which would read the derivative and write back a 0. This wouldn't be too helpful other than code clarity, since they can't be reordered. However subsequent consume instructions to the same variable/address can be removed as an optimization (though this is likely to occur anyway with standard loads/stores)The text was updated successfully, but these errors were encountered: