Repository navigation
Handle fewer than two requests in RotateRoundRobinArbiter - #305
Open
Shubham-Padkonde wants to merge 1 commit into
Open
Shubham-Padkonde wants to merge 1 commit into
Shubham-Padkonde wants to merge 1 commit into
Conversation
RotateRoundRobinArbiter sizes its `preference` register with
log2Ceil(count), which degenerates for small request lists while the
other two arbiters cope:
count=0 UnsupportedError: Infinity or NaN toInt
count=1 PortWidthMismatchException: Expected ports Logic(0): preference
and Logic(1): _binary_add_const_1 to be the same width
MaskRoundRobinArbiter and PriorityArbiter both build for 0 and 1
requests, so make this one consistent rather than failing inside the
rotation math:
- give `preference` a width of at least 1, since a single request needs
no rotation but the increment still has to land somewhere;
- return early for an empty request list, where there is nothing to
arbitrate and no grant to drive.
Fixes intel#272
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
RotateRoundRobinArbitersizes itspreferenceregister withlog2Ceil(count), which degenerates for small request lists. Probing all three arbiters onmainatc67e2f7:RotateRoundRobinArbiterMaskRoundRobinArbiterPriorityArbiterUnsupportedError: Infinity or NaN toIntPortWidthMismatchException: Expected ports Logic(0): preference and Logic(1): _binary_add_const_1 to be the same widthFor one request,
log2Ceil(1)is 0, sopreferenceis 0 bits wide and cannot hold the result of the+ 1in theSequentialblock — exactly the squashing described in #272. For zero requests,log2Ceil(0)goes throughlog(0), so the failure is anInfinity or NaNconversion rather than anything that points at the real problem.The fix follows the suggestion in the issue:
preferencegets a width of at least 1. A single request needs no rotation, but the increment still has to land somewhere.On the question the issue raises — whether an empty list is illegal — I went with accepting it rather than throwing, because
MaskRoundRobinArbiterandPriorityArbiteralready accept it and build a module with no grants. Making the third arbiter behave the same way seemed better than introducing an error that its siblings don't raise. If you'd rather all three rejected an empty list, that's a separate (and breaking) change I'm happy to write instead.I also checked the sibling arbiters for the same class of problem as the issue asks:
MaskRoundRobinArbiterandPriorityArbiterboth handle 0 and 1 requests correctly today, so neither needed changing.Related Issue(s)
Fixes #272
Testing
Two tests added to the existing
round robingroup intest/arbiter_test.dart, so they run against both round-robin arbiters:single request— builds a 1-request arbiter, then simulates: the only requester is granted on every cycle it asks, and the grant drops when the request does.no requests— builds a 0-request arbiter and checkscountandgrantsare empty.Running them with the library change stashed shows the rotate variants failing and the mask variants passing, which is the behaviour difference this PR removes:
test/arbiter_test.dartwith the change:00:00 +15: All tests passed!Full suite,
dart test -j 3, cleanmainversus this branch:No failures either way; the +4 is the two new tests across the two arbiter types.
dart format --output=none --set-exit-if-changedreports no changes anddart analyzefinds no issues on the touched files.Backwards-compatibility
Not a breaking change. Request lists of 2 or more behave exactly as before — the
max(1, ...)only takes effect atcount == 1, wherelog2Ceilreturned 0 and the module could not be built at all. The early return only triggers for an empty list, which previously threw.Documentation
No documentation changes needed — the arbiter's public API is unchanged. I added two short comments at the changed lines explaining why the width has a floor and why an empty list returns early.
Disclosure: this change was written by Claude Code (Claude Opus 5) working as my agent, at my direction. The exception messages and test output quoted above come from real runs in my local environment; I am accountable for the content of this PR and happy to iterate on review feedback.
🤖 Generated with Claude Code