Skip to content

perf(testbench)!: roll up compiled Veryl testbench execution - #2484

Merged
mergify[bot] merged 1 commit into
masterfrom
stack/tignear/perf/rollup-veryl-testbench-execution/roll-compiled-veryl-testbench-execution--f61ef7bf
Oct 29, 2026
Merged

mergify[bot] merged 1 commit into
masterfrom
stack/tignear/perf/rollup-veryl-testbench-execution/roll-compiled-veryl-testbench-execution--f61ef7bf

Conversation

@tignear

@tignear tignear commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

Land the Veryl testbench execution stack as one queue entry; its members are
not merged into master individually.

Lower Veryl testbench expressions and resumable processes into shared SIR
before optimization and state layout, and run them through the native,
interpreter, Cranelift and Wasm backends, so tiered execution promotes DUT
and TB kernels together. The separate TB VM, Cranelift compiler, scalar
assembler and runtime loop evaluator are removed. Concurrent TB continuation
dispatch, clock waits and multi-clock time progression are generated as
ordinary SIR composed with the shared compiled clock-domain scheduler, so
process arithmetic, settlement and eligible clock slots execute together
between host services and tiering safe points. The shared scheduler no longer
invalidates clean combinational state for unchanged clocks and internal
clock-alias notifications.

Native SIR/MIR traces now include process entries, including compiled
testbench and scheduler code. Tiered circuit and Heliodor comparisons publish
only total workload time; startup and execution intervals stay in diagnostic
reports.

The tree is identical to #2483 at the SHA below. The source PRs are held with
release:hold while this rollup is active. Their changes are squashed here;
they close automatically when this PR lands on master. If a source head
changes, rebuild the rollup before queueing it. Removing this rollup requires
releasing those holds before resuming individual stack merges.

Source PRs and pinned heads:

Validation (from the source PRs, same tree as #2483):

  • 281 Celox library tests; 98 native TB tests (1 existing ignored); 9 native MIR tests including a native testbench process trace; 8 native image tests; 5 completion tests; 8 slot-observer tests; 6 tiered tests.
  • 81 runtime and 28 testbench library tests; affected-crate all-target Clippy with systemverilog, cranelift, veryl-reference and wasm-runtime; compiler-only, WASI and ARM64 code-generation checks; formatting and the default-dependency guard.
  • SHA-256, FFT and LZ77 pass both positive and deliberately broken oracle qualification. Rica completes all 16 replays with identical cycle and retirement counts.
  • Benchmark publication and runner tests, Heliodor conversion fixtures, and the VitePress production build.

Performance status: no end-to-end speedup over Veryl simulator has been
established; this rollup makes no performance claim. No large Heliodor
workload was run.

BREAKING CHANGE: CompiledExpr no longer evaluates expressions against a raw
memory pointer; compile testbenches with the simulator pipeline and invoke
their bound backend kernels. Serialized testbench metadata gains scheduler
state, and appended native images use container version 55 and must be
regenerated.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-29T00:23:14.806185Z 8ade1aa New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: dee6b6046e

ℹ️ 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".

@tignear tignear added the merge-ready Request merging through Mergify after required checks label Oct 28, 2026
@tignear

tignear commented Oct 28, 2026

Copy link
Copy Markdown
Contributor Author

@celox-agent fix conflict

@github-actions

Copy link
Copy Markdown
Contributor

develop 向け PR のみ対応しています(この PR の base: master)。

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5a88caef60

ℹ️ 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".

}
self.kernel.builder().switch_to_block(advance);
let current = self.load(current_slot, width, signed);
let step = self.imm(width, step as u64);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve the full shift count when advancing loop counters

For a dynamically bounded loop whose shift step exceeds the induction variable's width, constructing step at width bits truncates the shift count before applying it. For example, a default i32 loop with dynamic bounds start = 1, end = 3, and step <<= 4294967297 now shifts by one and successfully visits 1 and 2, rather than shifting out every bit and reporting non-progress as the previous evaluator did. Keep shift counts at their full host width and truncate only the resulting counter value.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reproduced from Veryl: for i in start..end_bound step <<= 4294967297 with dynamic start = 1, end_bound = 3 (default i32 induction) visited 1 and 2 instead of reporting non-progressing stepped for loop. Fixed: a left-shift step is now clamped to the induction width (step.min(width)) instead of being truncated to it, so a count at or above the width shifts every bit out and is reported as non-progress. Regression test: test_for_loop_dynamic_shift_step_wider_than_counter_reports_non_progress in crates/celox/tests/native_testbench.rs. Folded into the commit locally; it will be in the next push.

Comment on lines +252 to +254
if matches!(result, ExecResult::Finished) {
if m.processes.len() == 1 && clocks.len() <= 1 {
return Some(result);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Collect temporary strings before returning from a finished kernel

For a single-process bench that evaluates temporary string arguments and then calls $finish, the compiled kernel can reach this first host request without any heap collection. Returning here also bypasses maybe_collect_heap at the bottom of the runner, leaving every temporary interned string in the simulator heap. This affects the newly added compiled_conditions_collect_temporary_string_arguments regression: its checkpoint retains all 1,500 strings rather than reclaiming the overwritten arguments. Collect at terminal kernel boundaries too, and preserve that behavior in the fallback process runner, which likewise returns before its collection call.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reproduced, though not with the cited test: nonempty("...") arguments are never interned at run time (the heap holds only the empty string at the end of that test), so compiled_conditions_collect_temporary_string_arguments passes as it is. Assigning 1,500 distinct literals to a string var and then calling $finish does intern them inside the kernel. The run then returned with all 1,500 still live (about 19.9 KB of checkpoint growth) on both the interpreter and native backends. Fixed: exec_testbench now runs a heap safepoint after compiled::run returns and after the single-process fallback runner returns, since no process is suspended at either point. Regression test: finished_compiled_kernel_collects_temporary_strings in crates/celox/tests/testbench_string.rs. Folded into the commit locally; it will be in the next push.

Comment thread crates/celox/src/scheduler/testbench.rs Outdated
Comment on lines +306 to +308
g.b.switch_to_block(completed);
put(&mut g, p[0], 2);
jump(&mut g, save[i]);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Stop completed testbenches before dispatching another clock edge

When a single initial process falls through after clk.next(n) without calling $finish, this completion path still reaches edge; the all-processes-complete check runs only after those edges execute. For example, initial { clk.next(1); } now drives a counter through two rising edges and returns with the clock high, whereas the previous single-process runner returns after exactly one complete period. Falling through is explicitly supported by run_compiled_testbench, so this changes the returned DUT state and tick count for valid callers. Check completion before dispatching another rising edge.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reproduced: initial { clk.next(1); } with no $finish, driving an always_ff tick counter, ended with ticks == 2 under run_compiled_testbench (the synchronous runner gives 1). Fixed: when the generated scheduler has one process and at most one clock, a completed process now goes straight to the end-of-run check instead of the edge dispatch. Multi-process schedules keep their current ordering, which matches the fallback concurrent runner. Regression test: test_fall_through_after_clock_wait_stops_after_one_period in crates/celox/tests/native_testbench.rs. Folded into the commit locally; it will be in the next push.

@tignear

tignear commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor Author

Revision history

# Type Changes Reason Date
1 initial 5a88cae 2026-10-28 21:40 UTC
2 content 5a88cae → 8346254 Rebase onto master: the GitHub branch update merged #2480, which kept the native backend's clock_aliases module this rollup moves to crate::clock_aliases 2026-10-28 21:40 UTC
3 content 8346254 → 0e76169 2026-10-28 23:38 UTC
4 content 0e76169 → 102f3d5 2026-10-28 23:58 UTC
5 content 102f3d5 → 8ade1aa 2026-10-29 00:18 UTC

@tignear
tignear force-pushed the stack/tignear/perf/rollup-veryl-testbench-execution/roll-compiled-veryl-testbench-execution--f61ef7bf branch 2 times, most recently from 8346254 to 0e76169 Compare October 28, 2026 23:39
@tignear

tignear commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor Author

This pull request is part of a Mergify stack:

# Pull Request Link
1 perf(testbench)!: roll up compiled Veryl testbench execution #2484 👈
2 perf(runtime)!: defer settles that are a function of their inputs #2497

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0e76169382

ℹ️ 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".

Comment on lines +385 to +388
let first_fits = self.bound_fits(first, width, signed, false);
let last_fits = self.bound_fits(last, width, signed, !inclusive);
let fits = self.binary(BinaryOp::And, first_fits, last_fits, 1);
let fits = self.binary(BinaryOp::Or, fits, singleton, 1);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Check for empty wide ranges before validating endpoint fit

For dynamically bounded empty ranges whose endpoints exceed the induction variable's width, this check now reports non-progressing stepped for loop even though no iteration is required. For example, with var bound: logic<128> assigned 128'd1 << 100, for _i in bound..bound { count += 1; } previously skipped the body and continued, but now fails because both bounds fail bound_fits and the exclusive range cannot use the singleton exception. The previous evaluator explicitly handled empty wide ranges before rejecting unrepresentable endpoints. Preserve that empty-range check before enforcing endpoint representability.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reproduced from Veryl: with var bound: logic<128> set to 128'd1 << 100, for _i in bound..bound { count += 1; } failed with non-progressing stepped for loop. Fixed: the loop now checks for an empty range on the full-width endpoints (first >= last, or first > last for inclusive ranges) before checking that the endpoints fit, using the same signedness as the loop condition. An empty range runs in the existing single-iteration mode with no iteration left, so it skips the body without the fit check failing. Regression test: test_for_loop_empty_wide_dynamic_range_skips_body (forward and rev) in crates/celox/tests/native_testbench.rs. Folded into the rollup commit locally; it will be in the next push.

Comment on lines +254 to +258
self.kernel.builder().emit(Inst::Store(
stable(dst.signal.address),
offset,
dst.width,
value,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Bound selected assignments before emitting memory stores

When a testbench assignment uses an out-of-range dynamic destination index, this emits a store at the unchecked offset rather than ignoring the write. The previous sim_set_target path clamped the selection to target.signal.width and returned when no bits remained; the native backend instead lowers this SIR operation directly to indexed memory accesses without checking the object's extent. Consequently, an assignment such as bits[index] = 1 can overwrite unrelated simulator state, or access outside the state buffer for a sufficiently large index. Guard the destination offset and clamp partially overlapping selections before emitting the store.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reproduced from Veryl. With var index: logic<32>, the writes bits[index] = 1 and values[index] = 8'hff with index = 32'h7fff_fff0 crashed the test process with SIGSEGV on the native backend. Fixed: selected TB assignments now go through a guarded store. An offset that keeps the whole selection inside the object stores as before. An offset past the end writes nothing. A multi-bit selection that runs past the end merges only its in-range bits into the object's last width bits. This matches the clamp the old sim_set_target path applied. Regression test: test_out_of_range_testbench_destinations_write_nothing in crates/celox/tests/native_testbench.rs. It covers an out-of-range bit select, an out-of-range array element (both a near index and a huge one), guard variables on both sides, and a partly out-of-range part[index +: 4], on the native and Cranelift backends. Folded into the rollup commit locally; it will be in the next push.

@tignear
tignear force-pushed the stack/tignear/perf/rollup-veryl-testbench-execution/roll-compiled-veryl-testbench-execution--f61ef7bf branch from 0e76169 to 102f3d5 Compare October 28, 2026 23:59

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 102f3d5472

ℹ️ 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".

None
};
if let Some(selection) = &dst.selection {
let offset = self.expression(&selection.offset)?.register;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Settle hardware before evaluating destination selections

When a destination index depends on combinational RTL, evaluating it through expression bypasses the settling check. For example, after changing a DUT input drive, values[dut.index] = 8'hff can write the wrong element when the DUT computes index = drive + 1: the constant RHS does not observe hardware, so settled_expression(expr) does not settle the pending input change, and the destination reads the old index. This affects ordinary combinational designs without external observers; the previous selected-assignment path explicitly settled before evaluating the assignment. Apply the settling check to the selection offset as well.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reproduced from Veryl: with assign index = drive + 1; in the DUT, drive = 2; values[index] = 8'hff; wrote values[1] (the index before the input change). The destination selection's offset now goes through settled_expression, like the assigned value, so it sees the settled DUT. Regression: test_destination_index_reads_settled_hardware in crates/celox/tests/native_testbench.rs.

Land the Veryl testbench execution stack as one queue entry; its members are
not merged into master individually.

Lower Veryl testbench expressions and resumable processes into shared SIR
before optimization and state layout, and run them through the native,
interpreter, Cranelift and Wasm backends, so tiered execution promotes DUT
and TB kernels together. The separate TB VM, Cranelift compiler, scalar
assembler and runtime loop evaluator are removed. Concurrent TB continuation
dispatch, clock waits and multi-clock time progression are generated as
ordinary SIR composed with the shared compiled clock-domain scheduler, so
process arithmetic, settlement and eligible clock slots execute together
between host services and tiering safe points. The shared scheduler no longer
invalidates clean combinational state for unchanged clocks and internal
clock-alias notifications.

Native SIR/MIR traces now include process entries, including compiled
testbench and scheduler code. Tiered circuit and Heliodor comparisons publish
only total workload time; startup and execution intervals stay in diagnostic
reports.

The tree is identical to #2483 at the SHA below. The source PRs are held with
release:hold while this rollup is active. Their changes are squashed here;
they close automatically when this PR lands on master. If a source head
changes, rebuild the rollup before queueing it. Removing this rollup requires
releasing those holds before resuming individual stack merges.

Source PRs and pinned heads:
- #2445: a26c0a4 — perf(testbench)!: compile Veryl testbenches through the HDL backends
- #2462: 544ca13 — fix(bench): compare tiered simulators by total completion time
- #2482: 7a0ee19 — fix(trace): include native process kernels in codegen traces
- #2483: 387fb86 — perf(testbench)!: compile concurrent Veryl scheduling through SIR

Validation (from the source PRs, same tree as #2483):
- 281 Celox library tests; 98 native TB tests (1 existing ignored); 9 native MIR tests including a native testbench process trace; 8 native image tests; 5 completion tests; 8 slot-observer tests; 6 tiered tests.
- 81 runtime and 28 testbench library tests; affected-crate all-target Clippy with systemverilog, cranelift, veryl-reference and wasm-runtime; compiler-only, WASI and ARM64 code-generation checks; formatting and the default-dependency guard.
- SHA-256, FFT and LZ77 pass both positive and deliberately broken oracle qualification. Rica completes all 16 replays with identical cycle and retirement counts.
- Benchmark publication and runner tests, Heliodor conversion fixtures, and the VitePress production build.

Performance status: no end-to-end speedup over Veryl simulator has been
established; this rollup makes no performance claim. No large Heliodor
workload was run.

BREAKING CHANGE: CompiledExpr no longer evaluates expressions against a raw
memory pointer; compile testbenches with the simulator pipeline and invoke
their bound backend kernels. Serialized testbench metadata gains scheduler
state, and appended native images use container version 55 and must be
regenerated.

Change-Id: If61ef7bfc9c47ddc0c3bf3e81cf6bdbce4d62a28
@tignear
tignear force-pushed the stack/tignear/perf/rollup-veryl-testbench-execution/roll-compiled-veryl-testbench-execution--f61ef7bf branch from 102f3d5 to 8ade1aa Compare October 29, 2026 00:19
@mergify mergify Bot added the queued Mergify queue entry label Oct 29, 2026
@mergify

mergify Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

✅ Merged into master as 0546e24 at 01:02 UTC

Merged together with #2497. 9 min in the queue, 7 min of it CI.

So far

Merge conditions: 8 of 8 met

This pull request

Condition
✅ depends-on=celox-sim/celox#2484

The batch, tested on draft #2504

Condition Required by
✅ check-success = Conventional Commit title —
✅ check-success = Queue validation —
✅ any of: check-success = @github-actions/Lint & Format, check-neutral = @github-actions/Lint & Format, check-skipped = @github-actions/Lint & Format GitHub repository ruleset rule master
✅ any of: check-success = @github-actions/Rust Test & NAPI Build, check-neutral = @github-actions/Rust Test & NAPI Build, check-skipped = @github-actions/Rust Test & NAPI Build GitHub repository ruleset rule master
✅ any of: check-success = @github-actions/JS Test (Ubuntu), check-neutral = @github-actions/JS Test (Ubuntu), check-skipped = @github-actions/JS Test (Ubuntu) GitHub repository ruleset rule master
✅ any of: check-success = @github-actions/Conventional Commit title, check-neutral = @github-actions/Conventional Commit title, check-skipped = @github-actions/Conventional Commit title GitHub repository ruleset rule master
✅ any of: check-success = @github-actions/Queue validation, check-neutral = @github-actions/Queue validation, check-skipped = @github-actions/Queue validation GitHub repository ruleset rule master

Times in UTC · dashboard · how the merge queue works

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-ready Request merging through Mergify after required checks

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant