Skip to content

Commit

Permalink
Queues: edge case in data-gen when num_cmds is odd (#2190)
Browse files Browse the repository at this point in the history
  • Loading branch information
anshumanmohan authored Jul 2, 2024
1 parent b5aafd5 commit ecf05cc
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion calyx-py/calyx/queue_data_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,14 @@ def no_err_cmds_list(queue_size, num_cmds):
commands += (push_goal - total_pop_count) * [0]
break

assert len(commands) == num_cmds
# If the total number of commands is not `num_cmds`, pad it with `peek`s.
# This is because the `commands` list must have `num_cmds` items.
commands += (num_cmds - len(commands)) * [1]
# The above command will add either zero or one `peek` command to the end.

assert (
len(commands) == num_cmds
), f"Length of commands list was {len(commands)}, expected {num_cmds}"
return commands


Expand Down Expand Up @@ -110,6 +117,7 @@ def dump_json(num_cmds, use_rank: bool, no_err: bool, queue_size: Optional[int]
else:
print(json.dumps(commands | values | ans_mem, indent=2))


if __name__ == "__main__":
# Accept a flag that we pass to dump_json.
# This says whether we should use the special no_err helper.
Expand Down

0 comments on commit ecf05cc

Please sign in to comment.