Skip to content

Commit

Permalink
Remove peek functionality (#2243)
Browse files Browse the repository at this point in the history
This PR closes #2241. It removes peek from all the queues, making `cmd`
now a 1-bit signal. Please note that the corresponding update in the
documentation `queues.md` is part of #2237.

One minor issue is that now that peek is removed, round robin no longer
uses the group `restore_hot`, leading to unused group error. Strict
still uses `restore_hot` so I can’t delete it, and if you remember
gen_strict_or_rr.py is used to make both strict and round robin queues.
I’ve gone ahead and turned off wellformedness in the runt file as a
temporary solution because I’m not sure what would be best.

What remains to be figured out is how many LUTs and cycles the old
designs took versus the new.

---------

Co-authored-by: Anshuman Mohan <[email protected]>
Co-authored-by: Akash Dhiraj <[email protected]>
  • Loading branch information
3 people authored Aug 8, 2024
1 parent c1b2037 commit 369e684
Show file tree
Hide file tree
Showing 53 changed files with 1,756,358 additions and 1,756,608 deletions.
20 changes: 9 additions & 11 deletions calyx-py/calyx/queue_call.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@ def insert_runner(prog, queue, name, num_cmds, use_ranks, stats_component=None):
of items that are passed to this component by reference.
#
- 1: `commands`, a list of commands.
Where each command is a 2-bit unsigned integer with the following format:
Where each command is a 1-bit unsigned integer with the following format:
`0`: pop
`1`: peek
`2`: push
`1`: push
- 2: `values`, a list of values.
Where each value is a 32-bit unsigned integer.
The value at `i` is pushed if the command at `i` is `2`.
Expand Down Expand Up @@ -47,15 +46,14 @@ def insert_runner(prog, queue, name, num_cmds, use_ranks, stats_component=None):
# - input `cmd`
# where each command is a 2-bit unsigned integer, with the following format:
# `0`: pop
# `1`: peek
# `2`: push
# `1`: push
# - input `value`
# which is a 32-bit unsigned integer. If `cmd` is `2`, push this value.
# which is a 32-bit unsigned integer. If `cmd` is `1`, push this value.
# - ref register `ans`, into which the result of a pop or peek is written.
# - ref register `err`, which is raised if an error occurs.

# Our memories and registers, all of which are passed to us by reference.
commands = runner.seq_mem_d1("commands", 2, num_cmds, 32, is_ref=True)
commands = runner.seq_mem_d1("commands", 1, num_cmds, 32, is_ref=True)
values = runner.seq_mem_d1("values", 32, num_cmds, 32, is_ref=True)
ranks = (
runner.seq_mem_d1("ranks", 32, num_cmds, 32, is_ref=True) if use_ranks else None
Expand All @@ -65,7 +63,7 @@ def insert_runner(prog, queue, name, num_cmds, use_ranks, stats_component=None):
err = runner.reg(1, "component_err", is_ref=True)

i = runner.reg(32) # The index of the command we're currently processing
cmd = runner.reg(2) # The command we're currently processing
cmd = runner.reg(1) # The command we're currently processing
value = runner.reg(32) # The value we're currently processing
rank = runner.reg(32) # The rank we're currently processing

Expand Down Expand Up @@ -117,9 +115,9 @@ def insert_runner(prog, queue, name, num_cmds, use_ranks, stats_component=None):
cb.if_with(
runner.not_use(err.out), # If there was no error
[
# If cmd <= 1, meaning cmd is pop or peek, raise the `has_ans` flag.
# If cmd = 1, meaning cmd is pop, raise the `has_ans` flag.
# Otherwise, lower the `has_ans` flag.
runner.le_store_in_reg(cmd.out, 1, has_ans)[0]
runner.eq_store_in_reg(cmd.out, 0, has_ans)[0]
],
),
runner.incr(i), # i++
Expand Down Expand Up @@ -156,7 +154,7 @@ def insert_main(
dataplane_ans = main.reg(32)
dataplane_err = main.reg(1)

commands = main.seq_mem_d1("commands", 2, num_cmds, 32, is_external=True)
commands = main.seq_mem_d1("commands", 1, num_cmds, 32, is_external=True)
values = main.seq_mem_d1("values", 32, num_cmds, 32, is_external=True)
ans_mem = main.seq_mem_d1("ans_mem", 32, num_cmds, 32, is_external=True)
ranks = (
Expand Down
23 changes: 8 additions & 15 deletions calyx-py/calyx/queue_data_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def no_err_cmds_list(queue_size, num_cmds):
running_count -= 1
total_pop_count += 1
# Put the command into `commands`.
commands.append(0 if command == "pop" else 2)
commands.append(0 if command == "pop" else 1)

if total_push_count == push_goal:
# Pad the `commands` list with (push_goal - total_pop_count) `pop`s,
Expand All @@ -70,20 +70,16 @@ def dump_json(num_cmds, no_err: bool, queue_size: Optional[int]=None, nwc=False,
The data itself is populated randomly, following certain rules:
- It has three "memories": `commands`, `values`, and `ans_mem`.
- Optional memories `ranks` and `times` are included for queues primed for non-work-conserving algorithms.
- The `commands` memory has `num_cmds` items, which range from 0-2 for work-conserving policies,
and from 0-4 for non-work-conserving. They are as follows:
- The `commands` memory has `num_cmds` items, which are 0 or 1 for both work-conserving and
non-work-conserving policies. They are as follows:
FOR WORK-CONSERVING POLICIES
0 : pop
1 : peek
2 : push
1 : push
FOR NON-WORK-CONSERVING POLICIES
0 : pop by predicate
1 : peek by predicate
2 : push
3 : pop by value
4 : peek by value
1 : push
If the `no_err` flag is set and the policy is work-conserving,
then items are chosen from 0 and 2 using a helper.
Expand All @@ -104,19 +100,16 @@ def dump_json(num_cmds, no_err: bool, queue_size: Optional[int]=None, nwc=False,
commands = {
"commands": {
"data": (
# The `commands` memory has `num_cmds` items, which are all 0, 1, or 2 (or 3 and 4, for nwc policies)
# The `commands` memory has `num_cmds` items, which are all 0 or 1
no_err_cmds_list(queue_size, num_cmds)
if no_err
# If the `no_err` flag is set, then we use the special helper
# that ensures no overflow or overflow will occur.
else (
[random.randint(0, 4) for _ in range(num_cmds)]
if nwc
else
[random.randint(0, 2) for _ in range(num_cmds)]
[random.randint(0, 1) for _ in range(num_cmds)]
)
),
"format": format_gen(3 if nwc else 2),
"format": format_gen(1),
}
}
values = {
Expand Down
Loading

0 comments on commit 369e684

Please sign in to comment.