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

An attempt to share scratch slot assignments among subroutines #533

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

jasonpaulos
Copy link
Contributor

@jasonpaulos jasonpaulos commented Sep 13, 2022

This PR sets up a pipeline for sharing scratch slot assignments among subroutines when possible, and provides a placeholder greedy algorithm to determine which subroutines should share scratch slots.

Very little testing and analysis has been done, so use this at your own risk.

Notably, this code no longer honors user-defined scratch slot locations. That can probably be fixed, it was just too much to think about what I was prototyping this.

subroutine3: {subroutine4, subroutine5},
subroutine4: {subroutine2, subroutine3, subroutine5},
subroutine5: {subroutine3, subroutine4},
}
Copy link
Contributor

@tzaffi tzaffi Sep 13, 2022

Choose a reason for hiding this comment

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

This approach looks promising though I haven't dug into the details.

Summarizing this test example as a graph (represented by a file-system-like tree hierarchy):

s1 -> s2 -> s3
         -> s5
   -> s4

and suppose that each subroutine requires exacty 10 slots. Then if my understanding is correct, you end up with the final assignments:

s1: 20-29
s2: 10-19
s3: 0-9
s4: 0-9
s5: 0-9

This is the same slot assignment as I get from the theoretical pseudocode that I've written elsewhere.
Is my understanding correct?
And if so, what assignment would the following graph produce?

s1 -> s2 -> s3 -> s4
         -> s5 -> s6

The SCC algo ought to produce:

s1: 30-39
s2: 20-29
s3: 10-19
s4: 0-9
s5: 10-19
s6: 0-9

Copy link
Contributor Author

Choose a reason for hiding this comment

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

And if so, what assignment would the following graph produce?

s1 -> s2 -> s3 -> s4
         -> s5 -> s6

I expect the code here would produce the same result that you indicated above, or this:

s1: 30-39
s2: 20-29
s3: 10-19
s4: 0-9
s5: 0-9
s6: 10-19

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