Skip to content

Add support for dynamic unit trip scf.for to scf.if - #20880

Merged
nirvedhmeshram merged 2 commits into
iree-org:mainfrom
nirvedhmeshram:remove_dynamic_unit_trip_pr
May 27, 2025
Merged

nirvedhmeshram merged 2 commits into
iree-org:mainfrom
nirvedhmeshram:remove_dynamic_unit_trip_pr

Conversation

@nirvedhmeshram

@nirvedhmeshram nirvedhmeshram commented May 21, 2025 •

Copy link
Copy Markdown
Contributor

This PR adds support for dynamic unit trip (0 or 1 trip) scf.for using scf.if. Additionally, the existing implementation was conservative in testing the neverRunsSecondIteration logic, by only looking at upper bound and step value, but we can find a better check by taking the lower bound into consideration.

@nirvedhmeshram nirvedhmeshram changed the title Add support for dynamic unit trip sc.for to scf.if Add support for dynamic unit trip scf.for to scf.if May 22, 2025
@nirvedhmeshram
nirvedhmeshram force-pushed the remove_dynamic_unit_trip_pr branch 2 times, most recently from 2177485 to c6013f1 Compare May 22, 2025 17:21
@nirvedhmeshram
nirvedhmeshram marked this pull request as ready for review May 22, 2025 17:21
@nirvedhmeshram
nirvedhmeshram requested review from Max191 and jerryyin May 22, 2025 17:22
@nirvedhmeshram
nirvedhmeshram force-pushed the remove_dynamic_unit_trip_pr branch 2 times, most recently from 08898b8 to 7d50263 Compare May 22, 2025 17:27

@Max191 Max191 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.

LGTM, just a few nits!

@jerryyin jerryyin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM with one nit


// Tile and distribute to GPU subgroups.
funcPassManager.addPass(createSPIRVTileToCooperativeOpsPass());
funcPassManager.addPass(createPropagateDispatchSizeBoundsPass());

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is needed because createSPIRVTileToCooperativeOpsPass will make new bounds on thread.ids and we need those for createRemoveSingleIterationLoopPass to do the right thing.

@nirvedhmeshram
nirvedhmeshram merged commit 26e6e97 into iree-org:main May 27, 2025
AWoloszyn pushed a commit that referenced this pull request Dec 1, 2025
This PR adds support for dynamic unit trip (0 or 1 trip) scf.for using scf.if.

---------

Signed-off-by: Nirvedh Meshram <[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.

3 participants