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

Round Robin oracle and eDSL #2177

Merged
merged 45 commits into from
Jul 2, 2024
Merged

Round Robin oracle and eDSL #2177

merged 45 commits into from
Jul 2, 2024

Conversation

csziklai
Copy link
Contributor

@csziklai csziklai commented Jun 25, 2024

This PR makes progress towards #1810. It implements the python oracle for PIFOs generalized to n flows, now known as Round Robin queues. Just as with the PIFO, if a flow falls silent, the remaining flows will take their turns. That flow effectively skips its turn. To re-generate the test files with 20000 commands and a max length of 16, type in the command line after navigating to the directory calyx/calyx-py/calyx

./gen_queue_data_expect.sh

Additionally, this PR also implements the Calyx version of Round Robin queues in rr_queue.py. This was originally supposed to be its own PR, but I thought it might be more complicated if I branched off a branch. To run these tests, type in the command line

runt -i "rr_queue"

Copy link
Contributor

@anshumanmohan anshumanmohan left a comment

Choose a reason for hiding this comment

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

Nice stuff, Cassandra!! Congratulations on really really moving the needle on our PIFOs! I have a bunch of comments for you here, but I think you will find they are all easy to understand and implement. Largely I am just trying to get your code to be future-proof and readable.

I have only reviewed one of your eDSL .py files. I don't think three of those should be merged; it's quite bad for code maintainability. Let's talk more IRL about the fix for this! But in the meantime please make fixes to that one file only; don't bother trying to massage all three files into shape. We won't need that, as I'll show you

calyx-py/calyx/builder.py Outdated Show resolved Hide resolved
calyx-py/calyx/queues.py Outdated Show resolved Hide resolved
calyx-py/calyx/queues.py Outdated Show resolved Hide resolved
calyx-py/calyx/queues.py Outdated Show resolved Hide resolved
calyx-py/calyx/queues.py Outdated Show resolved Hide resolved
calyx-py/test/correctness/queues/rr_queues/rr_queue.py Outdated Show resolved Hide resolved
calyx-py/test/correctness/queues/rr_queues/rr_queue.py Outdated Show resolved Hide resolved
calyx-py/test/correctness/queues/rr_queues/rr_queue.py Outdated Show resolved Hide resolved
calyx-py/test/correctness/queues/rr_queues/rr_queue.py Outdated Show resolved Hide resolved
calyx-py/test/correctness/queues/rr_queues/rr_queue.py Outdated Show resolved Hide resolved
@anshumanmohan
Copy link
Contributor

anshumanmohan commented Jun 27, 2024

At this point does this PR totally subsume #2147? If so, please say so in the conversation of that PR, be sure to link to this PR, and close that PR. Also rename this PR so it more accurately reflects all that you've done in it. Not just the oracles but also the eDSL code to match! Hooray!

@anshumanmohan
Copy link
Contributor

In your topmatter of this PR, you give us the commands to generate .data and .expect files. Would you mind trying to put those commands into gen_queue_data_expect.sh? My bad, I should have done this with you much earlier and that would have saved you some copy-pasting. Better late than never!

@anshumanmohan
Copy link
Contributor

Also I jumped in and changed your topmatter a little: we're calling them round robin queues, not red robin! 😛

@csziklai csziklai mentioned this pull request Jun 27, 2024
@csziklai csziklai changed the title Generalize pifo oracle Round Robin oracle and eDSL Jun 27, 2024
@anshumanmohan
Copy link
Contributor

I jumped in and made a few changes, and I think you'd enjoy working through them a little, @csziklai! I have one very concrete request in the comments for you, since I think it will greatly improve our scalability. Please catch me IRL if you'd like to work through it together! After you have taken a stab at that, I'll jump back in and do the last few things I wanted. For now, you have control :)

@anshumanmohan anshumanmohan self-requested a review July 2, 2024 15:02
Copy link
Contributor

@anshumanmohan anshumanmohan left a comment

Choose a reason for hiding this comment

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

Awesome job, Cassandra!! 🎉

I jumped in and made a few more changes. I recommend you look through my commits and see what you think of them. I tried to make each commit discrete and easy to understand; they more or less contain one logical change each.

I was able to massage away the value = 0 edge case. I was also able to lift a little more code into roundrobin.py. Take a look, I think you'll like it!

One last thing before we merge: could you please remove the directory strict_queues from this branch? Something like git rm should work. You may need a -r flag since it's a directory.

calyx-py/test/correctness/queues/rr_queues/rr_queue.py Outdated Show resolved Hide resolved
calyx-py/calyx/queues.py Outdated Show resolved Hide resolved
calyx-py/calyx/queues.py Outdated Show resolved Hide resolved
calyx-py/calyx/queues.py Show resolved Hide resolved
calyx-py/calyx/queues.py Show resolved Hide resolved
calyx-py/test/correctness/queues/rr_queues/rr_queue.py Outdated Show resolved Hide resolved
calyx-py/test/correctness/queues/rr_queues/rr_queue.py Outdated Show resolved Hide resolved
Comment on lines 124 to 129
incr_hot_wraparound = cb.if_with(
# If hot = numflows - 1, we need to wrap around to 0. Otherwise, we increment.
pifo.eq_use(hot.out, numflows - 1),
pifo.reg_store(hot, 0, "reset_hot"),
pifo.incr(hot),
)
Copy link
Contributor

Choose a reason for hiding this comment

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

I pulled out this common pattern into its own little thing! Feels like a helper function now, no? :)

calyx-py/test/correctness/queues/rr_queues/rr_queue.py Outdated Show resolved Hide resolved
calyx-py/test/correctness/queues/rr_queues/rr_queue.py Outdated Show resolved Hide resolved
@anshumanmohan
Copy link
Contributor

Also just a heads up, I found it helpful to always run:

cd calyx-py/calyx/; ./gen_queue_data_expect.sh; cd -; runt -i rr_queues

so that I knew for sure that I was working with fresh .data and .expect files.

In case I did see errors from runt, I changed the command into

cd calyx-py/calyx/; ./gen_queue_data_expect.sh; cd -; runt -i rr_queues -d > huh.txt

and then examined the file huh.txt.

@anshumanmohan
Copy link
Contributor

Hooray! Now feel free to hit the big green "squash and merge" button, @csziklai!

@csziklai csziklai merged commit ba0d5f0 into main Jul 2, 2024
18 checks passed
@csziklai csziklai deleted the generalize_pifo_oracle branch July 2, 2024 20:15
polybeandip added a commit that referenced this pull request Jul 3, 2024
It looks like `calyx-py/test/correctness/queues/*.py` was removed from
the path of its runt test by #2177: i.e. the old `fifo`, `pifo`, and
`pifo_tree` tests aren't running at CI. Was this intentional? In case it
wasn't, I've made a minor fix to `runt.toml`.
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