Skip to content

[CPU] Add option to LLVMCPUTileRootAndFuseProducerConsumer to tiling with scf.forall - #21009

Merged
hanhanW merged 10 commits into
iree-org:mainfrom
AaronStGeorge:stgeorge-aaron/cpu-tile-using-forall_3/4
Jun 24, 2025
Merged

hanhanW merged 10 commits into
iree-org:mainfrom
AaronStGeorge:stgeorge-aaron/cpu-tile-using-forall_3/4

Conversation

@AaronStGeorge

Copy link
Copy Markdown
Contributor

This PR is part of a larger change moving LLVMCPUTileRootAndFuseProducerConsumer's tiling of parallel dimensions to use scf.forall rather than scf.for; allowing us to take advantage of some canonicalization patterns available on scf.forall. The patterns available prevent redundant stack allocations seen in #20792. Tiling parallel dimensions with scf.forall rather than scf.for could also be said to be semantically cleaner.

As part of that change, this PR intrudes an option to TileRootAndFuseProducerConsumer for tiling with scf.forall.

PR 3/4 addressing #20792

@AaronStGeorge

Copy link
Copy Markdown
Contributor Author

This will need to merge before PR 4/4 can be opened, but it can be viewed here: AaronStGeorge#2

@egebeysel egebeysel left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was interested in the issue from the beginning, so self appointing myself to review if you don't mind :) a few nits but cool to see this almost being fully merged!

@MaheshRavishankar MaheshRavishankar left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @AaronStGeorge . If you are interested, you can try to add a generic tileProducersAndFuseConsumers method in MLIR that could become the basis of this pass. We do this a couple of places, and a utility method upstream would be useful common place for this.

@hanhanW hanhanW left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think Mahesh/Prashant/Quinn is the best person to review the change, so I'd wait an approval from them.

RE war: I feel that we start building things on top of workaround, and it is not a good sign. We need to fix it, and I think Mahesh has a plan in his mind. (We had a small chat offline before, IIRC.)

EDIT: I'll help the review, but I'll be traveling next week.

@AaronStGeorge
AaronStGeorge force-pushed the stgeorge-aaron/cpu-tile-using-forall_3/4 branch from 478ca9e to a2c794e Compare June 11, 2025 19:21
@AaronStGeorge

Copy link
Copy Markdown
Contributor Author

Thanks @AaronStGeorge . If you are interested, you can try to add a generic tileProducersAndFuseConsumers method in MLIR that could become the basis of this pass. We do this a couple of places, and a utility method upstream would be useful common place for this.

I'd definitely be interested @MaheshRavishankar! First step would probably be getting the underlying issue necessitating the useWARForConsumerFusionSSAViolation workaround, after that it should be pretty straightforward to move upstream it seems.

pashu123 and others added 6 commits June 18, 2025 21:18
Currently, it selects the last operation which has workgroup level tile
sizes due to legacy reasons.
…tiling with `scf.forall`

This PR is part of a larger change moving `LLVMCPUTileRootAndFuseProducerConsumer`'s tiling of parallel dimensions to use `scf.forall` rather than `scf.for`; allowing us to take advantage of some canonicalization patterns available on scf.forall. The patterns available prevent redundant stack allocations seen in iree-org#20792. Tiling parallel dimensions with `scf.forall` rather than `scf.for` could also be said to be semantically cleaner.

As part of that change, this PR intrudes an option to TileRootAndFuseProducerConsumer for tiling with `scf.forall`.

PR 3/4 addressing iree-org#20792
@AaronStGeorge
AaronStGeorge force-pushed the stgeorge-aaron/cpu-tile-using-forall_3/4 branch from a2c794e to 292e806 Compare June 18, 2025 22:03
@AaronStGeorge
AaronStGeorge force-pushed the stgeorge-aaron/cpu-tile-using-forall_3/4 branch from 292e806 to 2ddf7a9 Compare June 18, 2025 22:09

@hanhanW hanhanW left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, just two nits!

AWoloszyn pushed a commit that referenced this pull request Dec 1, 2025
…g with `scf.forall` (#21009)

This PR is part of a larger change moving
`LLVMCPUTileRootAndFuseProducerConsumer`'s tiling of parallel dimensions
to use `scf.forall` rather than `scf.for`; allowing us to take advantage
of some canonicalization patterns available on scf.forall. The patterns
available prevent redundant stack allocations seen in
#20792. Tiling parallel
dimensions with `scf.forall` rather than `scf.for` could also be said to
be semantically cleaner.

As part of that change, this PR intrudes an option to
`TileRootAndFuseProducerConsumer` for tiling with `scf.forall`.

PR 3/4 addressing #20792

---------

Co-authored-by: Prashant Kumar <[email protected]>
Co-authored-by: Han-Chung Wang <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants