Repository navigation
perf(sv): skip the always_comb alternative nothing can watch - #1859
Conversation
In a design with a wait, every always_comb that may store a variable twice was also lowered as an imperative unit, which assembly drops unless a wait or flip-flop domain counts one of its targets. A module now collects what may name its variables: wait terms, triggers, event copies, package variables, instance connections, ports of an instantiated module, and whatever a same-width write and read of a combinational process connects to them. The second lowering runs only for a process whose targets meet that set. Designs with a nonblocking switch or with foreign modules lower every alternative as before. Closes #1754 Change-Id: I6ca8cdf3e1561a784cd9ac5536b8d42b3618b9a3
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Queued — the merge queue status continues in this comment ↓. |
Merge Queue Status
This pull request spent 20 minutes 48 seconds in the queue, with no time running CI. ReasonThe pull request #1859 has been manually updated Waiting for
All conditions
Requeued — the merge queue status continues in this comment ↓. |
A process that writes a watchable variable or reads one makes all the variables it writes and reads watchable, at any width and through any expression, not only same-width pairs. Unit tests keep the alternative for waits through a part-select, a concatenation and an arithmetic expression, and check that a hierarchical reference is rejected. Change-Id: Ib61347656ea07409622b103f02eeb213d3405364
Change-Id: I9f2a272e29a62dcb551993e8ca60979cb137fb92
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e76981dd4b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
written_variables now maps every output and inout formal of a user call, and every argument a system function writes, to the names of its actual argument, for calls in statements and expressions and through the bodies of callees. A process that writes only through such an argument, like `always @* if ($random(w) && y[0]) ...` or a function that writes its output only through a nested system call, keeps its group, so a wait on the argument keeps the alternative of what it reads. Change-Id: I6bd823800910fabb75486fb969f84cbe6647f941
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: dbeeb17fde
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Change-Id: Ibfaeb92d38d799b99267b34c2bb5e72e9f55565b
Merge Queue Status
This pull request spent 31 minutes 10 seconds in the queue, including 28 minutes 52 seconds running CI. Required conditions to merge
|
Closes #1754.
In a design with at least one wait site, every
always_combthat may store a variable twice was lowered twice: symbolically, and as an imperative gated unit (lower_comb_alternative). Assembly keeps the unit only if a wait or a flip-flop domain counts one of its candidates (choose_comb_alternatives). Otherwise the second lowering was wasted.Change
Before comb lowering,
attach_instance_gluecollects the variables of the module that a counted signal can be:watchable_variablescloses this set over the comb processes and port assignments, in both directions. When a process writes or reads a watchable variable, every variable it writes or reads becomes watchable. This holds at any width and through any expression: part-selects, concatenations, arithmetic. It is wider than what assembly can count: clock-domain unification aliases only whole-variable copies, and wait terms aren't aliased at all.lower_comb_alternativenow runs only for a process whose symbolic targets or syntactic writes (ProcModule::written_variables, including callee bodies) meet that set.Two cases still lower every alternative as before:
observedset of staged NBAs), so dropping a slot could change the SIR.foreign), where the module doesn't see its foreign parents or children.Perf
SIR: base is eb30f0e. A dump of the post-optimized SIR of all 669 SV suite designs (after the closure was widened), timed ones included, is byte-identical between base and branch. No suite design takes the skip. Every one of the 12 alternatives the suite lowers has a target that a wait or trigger names directly (the #1726 watched-comb cases), so the suite covers the keep path. The unit test
comb_alternatives_only_for_watchable_targetscovers the skip and these keep cases:assign c = y[0];It also checks that a hierarchical reference (
@(child.y)) is rejected ("structure member"), so only ports reach another module's variables.The new timing case
intermediate_combinational_writes_reach_part_select_waiters_settledwaits onassign w = y[3:0]while analways_combrewritesythrough 0. It passes against Icarus and Verilator: all three printy=26 w=6 n=2, one event per settled change. Its Icarus and Verilator results are not added to the retained reports: CONTRIBUTING.md takes new passing cases without a baseline refresh.Compile time, callgrind Ir of building the scheduler gate (64
always_fflanes, an XOR-reductionalways_comb sumloop over 64 lanes,initial forever @(posedge clk) stim = stim + 3), median of 5:sumunwatchedalways_comb w(@(w))sumunrolled (64 statements), before the closure was widenedIn c,
wis still lowered twice and keeps its unit; onlysumis skipped.SV suite build (the digest test binary, building all 668 designs;
perf statinstructions:u, 3 runs each): base 261,190,795,729 / 261,194,965,554 / 261,198,491,989, branch 261,194,940,307 / 261,196,035,760 / 261,199,459,779. Equal (+0.0004% median). The watch set costs nothing measurable.Validation
All runs use the
systemverilogfeature:celox --test systemverilog: 4356 passed.celox-sv-analyzer,celox-frontend-svandcelox-test-suitetests: 0 failed.retained_reports: passed.celox --libtraces: 4 passed.-D warnings: clean.expected.tsv.