This is an archive of the discontinued LLVM Phabricator instance.

[mlir][vector] Add patterns for vector distribution
ClosedPublic

Authored by ThomasRaoux on Jun 6 2022, 2:04 PM.

Details

Summary

Add pattern to hoist scalar code outside of warp distribute region as
those cannot be distributed and we would want to execute them on all
the lanes.
Add patterns to distribute transfer_write ops. Those operations can be
distributed in different ways and it is control by user.

co-authored with @springerm.

Diff Detail

Event Timeline

ThomasRaoux created this revision.Jun 6 2022, 2:04 PM
Herald added a project: Restricted Project. · View Herald Transcript
ThomasRaoux requested review of this revision.Jun 6 2022, 2:04 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 6 2022, 2:04 PM
springerm accepted this revision.Jun 9 2022, 1:28 AM

I think we have to go through the rewriter for all IR modifications. Otherwise, the pattern driver may miss them and fail to apply other patterns.

mlir/include/mlir/Dialect/Vector/Transforms/VectorDistribution.h
64

nit: "on op" or "on the warp op"

mlir/lib/Dialect/Vector/Transforms/VectorDistribute.cpp
136

remove

139

RewriterBase &rewriter

153

wrap in

rewriter.updateRootInplace(yield, [&]() { ... });
159

RewriterBase &rewriter

175

Use rewriter, we can probably drop the old op, right? rewriter.replaceOp...

204

We may want to have a comment with some example IR here.

This revision is now accepted and ready to land.Jun 9 2022, 1:28 AM
springerm added inline comments.Jun 9 2022, 2:35 AM
mlir/lib/Dialect/Vector/Transforms/VectorDistribute.cpp
150

Not sure if this can mess with the rewriter op tracking. The safest way is to use rewriter.mergeBlocks or rewriter.inlineRegionBefore.

150

The old op will be in an invalid state (no body), so we could just remove it explicitly here. Otherwise, we may crash if people dump the IR in the middle of a rewrite (e.g, during debugging).

Address review comments

ThomasRaoux marked 8 inline comments as done.Jun 10 2022, 10:33 AM
ThomasRaoux added inline comments.
mlir/lib/Dialect/Vector/Transforms/VectorDistribute.cpp
150

right I combined that with the replaceAllUses to do a replaceOp

This revision was landed with ongoing or failed builds.Jun 10 2022, 10:47 AM
This revision was automatically updated to reflect the committed changes.