This is an archive of the discontinued LLVM Phabricator instance.

[mlir][bufferization] Remove allow-return-allocs and create-deallocs pass options, remove bufferization.escape attribute
ClosedPublic

Authored by maerhart on Jul 31 2023, 3:21 AM.

Details

Summary

This is the first commit in a series with the goal to rework the
BufferDeallocation pass. Currently, this pass heavily relies on copies
to perform correct deallocations, which leads to very slow code and
potentially high memory usage. Additionally, there are unsupported cases
such as returning memrefs which this series of commits aims to add
support for as well.

This first commit removes the deallocation capabilities of
one-shot-bufferization.One-shot-bufferization should never deallocate any
memrefs as this should be entirely handled by the buffer-deallocation pass
going forward. This means the allow-return-allocs pass option will
default to true now, create-deallocs defaults to false and they, as well
as the escape attribute indicating whether a memref escapes the current region,
will be removed.

The documentation should w.r.t. these pass option changes should also be
updated in this commit.

Depends on D159430

Diff Detail

Event Timeline

maerhart created this revision.Jul 31 2023, 3:21 AM
Herald added a reviewer: ftynse. · View Herald Transcript
Herald added a reviewer: kuhar. · View Herald Transcript
Herald added a project: Restricted Project. · View Herald Transcript
maerhart requested review of this revision.Jul 31 2023, 3:21 AM
aartbik added inline comments.Aug 1 2023, 12:52 PM
mlir/lib/Dialect/SparseTensor/Pipelines/SparseTensorPipelines.cpp
37 ↗(On Diff #545573)

shouldn't we remove this comment too now?

nice cleanup!

mlir/docs/Bufferization.md
224–225

This can be removed here. Deallocation is now a property of the deallocation pass not One-Shot Bufferize. But we should mention the ABI (e.g., returned memrefs from a function call always come with ownership) somewhere, maybe a separate subsection.

224–225

This is no longer correct.

The entire Buffer Deallocation section should probably be rewritten. This revision does not add the new buffer deallocation pass yet. I'd delete the entire section in this revision and add a new one in the revision that adds the new buffer deallocation pass.

225

You can remove this reference to the dialect conversion passes, most of which have been removed. But let's keep the reference to the buffer deallocation pass.

mlir/include/mlir/Dialect/Bufferization/Transforms/Passes.td
246–248

does not deallocate any buffers

248–250

can be deleted

mlir/lib/Dialect/SCF/Transforms/BufferizableOpInterfaceImpl.cpp
653–684

We should still keep these verifyAnalysis methods for now. Their purpose is to alert the user in case copies would be inserted during loop bufferization. These copies are not due to the old buffer deallocation pass, but because of current limitations in the analysis of One-Shot Bufferize. Let's add a new flag allowReturnAllocsFromLoops. We're going to remove it later when we improve the implementations of getAliasing*.

945–946

same here

mlir/lib/Dialect/SparseTensor/Pipelines/SparseTensorPipelines.cpp
37 ↗(On Diff #545573)

yes this is no longer an issue

mlir/test/Dialect/Bufferization/Transforms/one-shot-module-bufferize-invalid.mlir
76–81

These loop test cases can stay for now.

maerhart updated this revision to Diff 548519.Aug 9 2023, 2:04 AM
maerhart marked 10 inline comments as done.

Address comments. Thanks for the reviews!

springerm accepted this revision.Aug 9 2023, 6:25 AM

Looks good, but let's wait until the buffer deallocation pass is ready, so that we don't have any gaps in test coverage.

This revision is now accepted and ready to land.Aug 9 2023, 6:25 AM
maerhart updated this revision to Diff 552003.Aug 21 2023, 6:28 AM

Rebase on current main

maerhart updated this revision to Diff 555727.Sep 4 2023, 6:25 AM

Depends on D159430 now

This revision was landed with ongoing or failed builds.Sep 13 2023, 2:31 AM
This revision was automatically updated to reflect the committed changes.