Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prefer simpler vals in replace sizes #3344

Merged
merged 5 commits into from
Nov 6, 2024
Merged

Conversation

naoyam
Copy link
Collaborator

@naoyam naoyam commented Nov 5, 2024

Noticed while working on #3309 that i0 is replaced with ceilDiv(i0, 1). While it isn't incorrect, it would make generated code look simpler if ceilDiv(i0, 1) is replaced with i0.

This PR just changes representative iter domains used for replacing extents. In addition to the existing priority rules, the iter domain with the simplest extent is preferred as the representative ID of a given ID group. The simplicity of extents is just defined based on the number of expressions defining the extent val. So, for example, an iter domain with extent of i0 should be used as the representative ID instead of iter domains with extent ceilDiv(i0, 1).

There should be no logic change.

@naoyam
Copy link
Collaborator Author

naoyam commented Nov 5, 2024

!test --diff-bench

@naoyam naoyam marked this pull request as ready for review November 5, 2024 06:40
@naoyam
Copy link
Collaborator Author

naoyam commented Nov 5, 2024

!build

Copy link
Collaborator

@jacobhinkle jacobhinkle left a comment

Choose a reason for hiding this comment

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

LGTM

csrc/device_lower/pass/replace_size.cpp Outdated Show resolved Hide resolved
// Within these three classes, we find the IterDomain with the smallest
// name().
// Within these three classes, we find the IterDomain with the
// smallest name(). For case 3, we also prefer the IterDomain with
Copy link
Collaborator

Choose a reason for hiding this comment

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

I guess we could also do this for Case 1 just for readability, but it shouldn't affect the compiled kernel so not important..

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, I didn't do that just because get_number_of_defs may not be cheap.

@naoyam
Copy link
Collaborator Author

naoyam commented Nov 6, 2024

!test

@naoyam naoyam merged commit 967c282 into main Nov 6, 2024
47 checks passed
@naoyam naoyam deleted the replace_size_prefer_simpler_val branch November 6, 2024 16:01
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.

2 participants