-
Notifications
You must be signed in to change notification settings - Fork 51
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
Queues: generalize PIFOs #1810
Comments
This all seems quite sensible! Except that I don't quite understand one thing: what does "strict prioritization" mean? Is it an alternative to fairness? |
Ah, sorry! I'll edit the text above to explain, but yes, this is a different scheduling policy that I think is easily within our grasp using just our simple approach. The idea is to strictly prefer flow A over flow B over flow C, and so on. |
Just documenting a wrinkle that has come up now that @csziklai has started working on this! Let's just focus on round-robin scheduling with 3 flows. Review:
|
Here's a sketch proposal. Warning that it's a quick and dirty sketch mostly focussed on If we have three flows
Whatever our policy, it needs to behave correctly in all eight cases. Cases 1 and 8 are sorta easy, and cases 5, 6, and 7 are not so bad because there is only one correct flow to send from. Cases 2, 3, and 4 are harder because, see above, we need to alternate between the two flows that are chatty. I have sketched up the following, and I can walk through the thinking IRL. I have abstracted away "transmit ans", which is how we'd tell the world that we found an answer. hot = 0 # the point is just that hot has been set for us arbitrarily.
# the value 0 does not matter.
ans = pop(hot)
if ans: # the target queue had something, great!
hot++ # move the target. incr is assumed to overflow at n, which is 3.
explore = 0 # set/reset exploration probe.
transmit ans
else:
repeat(3): # we limit our explorations to n steps.
ans = pop(hot + explore) # this addition is assumed to overflow at n, here 3.
# So if hot = 2 and explore = 1, this will try to pop queue 0.
explore++
if ans:
transmit ans
break # break out of this repeat loop
# the n-step exploration has ended, because of success or failure.
if not ans:
underflow error |
Here is the updated pop() code, as discussed in the meeting. def pop(self) -> Optional[int]:
"""Pops the PIFO."""
print("pop " + str(self.hot))
if self.pifo_len == 0:
if self.error_mode:
raise QueueError("Cannot pop from empty PIFO.")
return None
self.pifo_len -= 1
original_hot = self.hot
while True:
val = self.data[self.hot].pop()
if val is not None:
self.increment_hot()
return val
else:
self.increment_hot()
if self.hot == original_hot:
return None``` |
Thanks Cassandra! So yes, to sum: the problem I chalked out was reasonable, but my proposed code was actually still a little off. The code above takes a slightly different tack to achieving round-robin. It is simpler and will translate to Calyx more easily. In English, the policy is simply:
Two notes:
|
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" ``` --------- Co-authored-by: Cassandra Nicole Sziklai <cns58@havarti.cs.cornell.edu> Co-authored-by: Anshuman Mohan <anshumanmohan@live.com> Co-authored-by: Anshuman Mohan <10830208+anshumanmohan@users.noreply.github.com>
This PR ties off the last half of #1810. It implements the python oracle and Calyx eDSL for strict PIFOs, which are generalized to n flows. Flows have a strict order of priority, which determines popping and peeking order. If the highest priority flow is silent when it is its turn, that flow simply skips its turn and the next flow is offered service. If that higher priority flow get pushed to in the interim, the next call to pop/peek will return from that flow. 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 ``` To run the runt tests on the eDSL implementation, type ``` runt -i "strict" ``` --------- Co-authored-by: Cassandra Nicole Sziklai <cns58@havarti.cs.cornell.edu> Co-authored-by: Anshuman Mohan <anshumanmohan@live.com> Co-authored-by: Anshuman Mohan <10830208+anshumanmohan@users.noreply.github.com>
At present our PIFOs can only handle:
These limitations of PIFOs also limit PIFO trees.
There is room for generalization on a few axes. I see these as orthogonal, though of course they'd be more powerful if combined. I think these are doable even just using our approach where a PIFO merely orchestrates some
n
FIFOs, wheren
can be determined in advance.n
flows and affects the policy du jour on them.n
flows.The text was updated successfully, but these errors were encountered: