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

Reorder Compaction #1884

Merged
merged 30 commits into from
Feb 1, 2024
Merged

Reorder Compaction #1884

merged 30 commits into from
Feb 1, 2024

Conversation

calebmkim
Copy link
Contributor

@calebmkim calebmkim commented Jan 29, 2024

Inserts compaction pass in between inference and promotion. This means that compaction takes @promote_static blocks of code and converts them to static<n> blocks.

Right now the "heuristic" is quite basic: it converts to static<n> for any seq block that it can compact at all (i.e., the new schedule is at least one cycle shorter than the original schedule).

@calebmkim calebmkim marked this pull request as ready for review January 29, 2024 15:16
@rachitnigam
Copy link
Contributor

Right now the "heuristic" is quite basic: it converts to static for any seq block that it can compact at all (i.e., the new schedule is at least one cycle shorter than the original schedule).

How does this impact the heuristic defined for promotion? Should we eventually define a threshold for compaction also? Seems like this threshold business might get out of hand soon 😅

@calebmkim
Copy link
Contributor Author

calebmkim commented Jan 30, 2024

How does this impact the heuristic defined for promotion? Should we eventually define a threshold for compaction also? Seems like this threshold business might get out of hand soon 😅

Yeah, I think there are a few points here.

  1. This change could increase promotion opportunities by affecting the control program that the promotion pass sees (see example here).

  2. One thought I had, which goes hand in hand with Decouple aliases from pass names #1874: it may be useful to define "universal promotion heuristics" that we can apply to both compaction and promotion passes.

1

Footnotes

  1. One nitty-gritty detail, that I'm mostly have here for my own reference: for the "size threshold" parameter of static promotion, we count any static control block basically as a leaf (i..e, it has the same "size'' as a group enable or an invoke would). The reason for this is, when we measure "size threshold" as a heuristic, we really want to know "if we promote this block, how many times are we switching from the static calling convention to the dynamic calling convention?" If it is greater than threshold, then this will make up for the overhead of instantiating the fsm and wrapper logic. Because static control statements are already committed to using the static calling convention, it didn't really make sense to count their size as anything more than a group enable or an invoke. But for control programs were originally dynamic, then maybe it does make sense to count their children in the sizes, i.e., a compacted par with 12 groups in it as children should count as size 12, not 1.

@rachitnigam
Copy link
Contributor

universal promotion heuristics

I really like this idea! This can either be a compilation pipeline-level configuration that can be queried by various compiler passes or an analysis of some form. The former idea (compilation-level configuration) seems like a generally useful thing to have; many compiler passes may want to query the same oracle about how to make decisions. Centralizing this configuration somewhere would make maintaining and debugging it much easier!

@calebmkim calebmkim merged commit 74104af into main Feb 1, 2024
7 checks passed
@calebmkim calebmkim deleted the reorder-compaction branch February 1, 2024 15:01
rachitnigam pushed a commit that referenced this pull request Feb 16, 2024
* progress

* first try at separating passes

* use helper function

* better tests, cleaner code

* existing tests passing

* inference

* updated code

* clippy

* clippy is annoying

* fixup works now

* fixup is fixed up

* another fixup test

* rewrite tests

* cleaner code

* commented code

* first try working in certain cases

* test rewrite

* refactored code

* small bug fix

* add better compaction

* tests reflect this

* rewrite tests

* add more fixups

* clippy

* documentation

* small change

* small change + another test case

* changed failing tests
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