This is an archive of the discontinued LLVM Phabricator instance.

[mlir][Transform]Significantly cleanup scf.foreach_thread and GPU transform permutation handling
ClosedPublic

Authored by nicolasvasilache on Nov 13 2022, 5:30 AM.

Details

Summary

Previously, the need for a dense permutation leaked into the thread_dim_mapping specification.
This revision allows to use a sparse specification of the thread_dim_mapping and the proper completion / sorting is applied automatically.

In the process, the sematics of scf.foreach_thread is tightened to require a matching number of thread dimensions and mappings.
The relevant negative test is added.

Diff Detail

Event Timeline

nicolasvasilache requested review of this revision.Nov 13 2022, 5:30 AM
Herald added a project: Restricted Project. · View Herald Transcript
nicolasvasilache edited the summary of this revision. (Show Details)

Drop spurious includes.

Update variable names.

Use BlockAndValueMapping and updateRootInPlace.

guraypp accepted this revision.Nov 14 2022, 12:39 AM

Looks great! Thanks for fixing that.

mlir/lib/Dialect/GPU/TransformOps/GPUTransformOps.cpp
168

I think we should create these attributes in a function and pass that function as another 'function_ref'. This way we can make use of `mapForeachToBlocksImpl' with other attributes that have the same meaning. It can be useful for 3rd party users. I can do this in another PR.

373

similar for them, we can extract these as well.

mlir/test/Dialect/GPU/transform-gpu-failing.mlir
134

typo?

This revision is now accepted and ready to land.Nov 14 2022, 12:39 AM
springerm added inline comments.Nov 14 2022, 12:54 AM
mlir/include/mlir/Dialect/SCF/IR/SCFOps.td
540

if

541

duplicate

mlir/lib/Dialect/GPU/TransformOps/GPUTransformOps.cpp
473

b

nicolasvasilache marked 6 inline comments as done.Nov 14 2022, 4:49 AM
nicolasvasilache added inline comments.
mlir/lib/Dialect/GPU/TransformOps/GPUTransformOps.cpp
168

good point, please do in a followup

373

good point, please do in a followup

mlir/test/Dialect/GPU/transform-gpu-failing.mlir
134

We now need a mapping with 4 elements to exercise the failure case, so I had to reuse a letter.
We will likely need something better ni the future.

nicolasvasilache marked 3 inline comments as done.

Address comments.