Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Initial versions of Enzyme had an option for globally nuking the caching mechanism (for extra performance, I suppose). Since this is clearly not very useful, I propose adding an option to allow the user to control this on a per-argument basis.
What does "nocache" mean?
The definition is not precise, and any user would have to try their code with it and see if it still works. The basic idea is that it is a promise between the __enzyme_augmentfwd and __enzyme_reverse that the given argument will not be modified, hence much of the caching can be skipped.
What does it mean "argument will not be modified"?
This is also not precisely defined, but in general it means that all loads emanating from the given argument can skip caching. The implementation in
compute_nocache
is quite flexible and allows for easy tweaking of the handling of specific instruction. For example, I currently said that all of the argument of a phi must be 'nocache' in order for the phi itself to be 'nocache'. This allows the linked list examples to work (they still get some caching because this is the only way they can work).@wsmoses Please let me know if you think this kind of performance-minded option is viable in enzyme.