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.
[XLA:MSA] Sync copy replacement
This CL implements the sync copy replacement feature in MSA.
The feature is implemented by creating a closure of intervals for each buffer in sorted_buffer_intervals. Each closure has an entrance interval and all intervals of a closure are connected to the entrance interval through at least one sync copy instruction that we are trying to replace. The closure is then processed in a loop, and the allocation values for the closure are created. If all allocation values of the closure can be allocated successfully, and the sync copy instruction replacement correctness conditions are met, the sync copy will be replaced with an async copy instruction. If not, the sync copy instruction is kept as is, and will be ignored in replacement efforts of future closures. For a sync copy to be consider replaceable, beside not being in the ignored list because of the past failures, it must not change the layout between its input and output, it must not have a preassigned memory space for its operand or output, and its operand value must only show up in one position.
In order to replace a copy, we create segments from the AllocationValue to the uses of its copy uses that are considered for replacement.