This is an archive of the discontinued LLVM Phabricator instance.

[mlir][transform] Add multi-buffering to the transform dialect
ClosedPublic

Authored by kile on Sep 15 2022, 4:10 PM.

Details

Summary

Add the plumbing necessary to call the memref dialect's multiBuffer
function. This will allow separation between choosing which buffers
to multi-buffer and the actual transform.

Alter the multibuffer function to return the newly created
allocation if multi-buffering succeeds. This is necessary to
communicate with the transform dialect hooks what allocation
multi-buffering created.

Diff Detail

Event Timeline

kile created this revision.Sep 15 2022, 4:10 PM
kile requested review of this revision.Sep 15 2022, 4:10 PM
ftynse accepted this revision.Sep 16 2022, 4:30 AM

LGTM with comments addressed.

llvm-project/mlir/include/mlir/Dialect/MemRef/Transforms/Passes.h
60 ↗(On Diff #460531)

typo

llvm-project/mlir/lib/Dialect/MemRef/TransformOps/MemRefTransformOps.cpp
49 ↗(On Diff #460531)

This also needs to declare that it generates the affine dialect so it is loaded appropriately by passes. I checked the implementation of multibuffering and it seems to only generate memref and affine, but in case I missed something, this needs to declare as generated any dialect that the transform application may produce except for the dialect that contains the target payload IR op. This is similar to how passes must declare "dependent" dialects, and is practically used for that purpose.

llvm-project/mlir/test/Dialect/MemRef/transform-ops.mlir
4 ↗(On Diff #460531)

Nit: I landed the diff that changes the default subview behavior to use the strided form instead of this, make sure to rebase before landing.

31 ↗(On Diff #460531)

There is no need to wrap the transform snippet in with_pdl_patterns if it does not contain pdl patterns.

This revision is now accepted and ready to land.Sep 16 2022, 4:30 AM
kile updated this revision to Diff 460826.Sep 16 2022, 11:09 AM

Update dialects generated by memref transform dialect to include affine/arith.
Updated a test and fixed a typo.

Herald added a project: Restricted Project. · View Herald TranscriptSep 16 2022, 11:09 AM
kile marked 4 inline comments as done.Sep 16 2022, 11:17 AM

Apologies that the paths all changed, the original patch I made was with llvm-project as a subdirectory of a larger project.

nicolasvasilache accepted this revision.Sep 19 2022, 3:44 AM
nicolasvasilache added inline comments.
mlir/test/Dialect/MemRef/transform-ops.mlir
19

should this capture the fact that the step should has doubled from 4 to 8 ?

kile added inline comments.Sep 19 2022, 9:41 AM
mlir/test/Dialect/MemRef/transform-ops.mlir
19

Hi, no the loop and its stepping remains the same. All that changes is that %tmp is now 2x its original size and all references to %tmp now go through a subview of %tmp.

kile marked an inline comment as done.Sep 19 2022, 9:45 AM

Would it be possible for someone to merge this commit in? I don't have commit access.

Many thanks for the review!

kile added a comment.Sep 26 2022, 9:18 AM

Ping :) would it be possible to have this commit merged into mainline by someone? Unfortunately I don't have the permissions to commit it myself @nicolasvasilache @ftynse

I am not able to arc patch this, could you please rebase?

kile updated this revision to Diff 462986.Sep 26 2022, 11:55 AM

rebased

kile added a comment.Sep 27 2022, 4:13 PM

@nicolasvasilache I rebased the change - would you mind trying again? Thank you in advance!