This is an archive of the discontinued LLVM Phabricator instance.

[mlir][affine] Option to unroll cleanup loop if smaller trip count.
ClosedPublic

Authored by Lewuathe on Jul 5 2022, 10:01 PM.

Details

Summary

Add an option (cleanUpUnroll) to unroll cleanup loop even if the trip count is smaller the unroll factor.

Diff Detail

Event Timeline

Lewuathe created this revision.Jul 5 2022, 10:01 PM
Herald added a project: Restricted Project. · View Herald Transcript
Lewuathe requested review of this revision.Jul 5 2022, 10:01 PM
Lewuathe updated this revision to Diff 442447.Jul 5 2022, 11:35 PM

Add test case.

@Groverkss Sorry if I'm pinging the wrong person. But could you review this PR when you get a chance or tell me who I should ask to take a look at this type of change?

@Groverkss Sorry if I'm pinging the wrong person. But could you review this PR when you get a chance or tell me who I should ask to take a look at this type of change?

Hi! the right person to review this would be @ftynse @bondhugula or @dcaballe

bondhugula requested changes to this revision.Aug 16 2022, 6:21 PM
bondhugula added inline comments.
mlir/include/mlir/Dialect/Affine/LoopUtils.h
53

The option should be documented in the comment above.

mlir/include/mlir/Dialect/Affine/Passes.td
216

The "even if" wording would be inaccurate/confusing here -- since the question of a cleanup loop equal to and larger than the trip count doesn't arise in the first place. Instead: "Fully unroll the cleanup loop when possible."?

mlir/lib/Dialect/Affine/Transforms/LoopUnroll.cpp
125–126

Use /*argName = ... style for any constant values passed as arguments.

133–134

Likewise.

mlir/lib/Dialect/Affine/Utils/LoopUtils.cpp
1054–1080

I don't think this would be the simpler approach. Instead, just simply use the unrollFull utility on any cleanup loop generated?

mlir/test/Dialect/Affine/unroll.mlir
696

It'll be good also to have a test case where the trip count is larger than the unroll factor.

This revision now requires changes to proceed.Aug 16 2022, 6:21 PM
Lewuathe updated this revision to Diff 453531.Aug 17 2022, 11:29 PM

Updated the patch to reflect the review feedback.

Lewuathe updated this revision to Diff 453533.Aug 17 2022, 11:31 PM

Remove unused helper method.

bondhugula accepted this revision.Aug 18 2022, 2:14 AM

LGTM - thanks.

mlir/include/mlir/Dialect/Affine/LoopUtils.h
48

we can ensure ... -> unroll the cleanup loop fully
?

mlir/lib/Dialect/Affine/Utils/LoopUtils.cpp
1112

Nit: Force unroll -> Unroll

1155

Nit: Drop blank line change.

This revision is now accepted and ready to land.Aug 18 2022, 2:14 AM
Lewuathe updated this revision to Diff 453849.Aug 18 2022, 5:52 PM

Thank you!. I updated accordingly.

This revision was landed with ongoing or failed builds.Aug 18 2022, 5:53 PM
This revision was automatically updated to reflect the committed changes.