Repository navigation
feat(sim): fail runs on reports and drain runtime events in TypeScript - #1876
Conversation
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. |
|
This pull request is part of a Mergify stack:
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 693f32a7e1
ℹ️ 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".
|
Queued — the merge queue status continues in this comment ↓. |
2da588a to
1a9cabc
Compare
693f32a to
3df1b35
Compare
Revision history
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3df1b35b52
ℹ️ 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".
1a9cabc to
e96ed5a
Compare
3df1b35 to
7b255b9
Compare
e96ed5a to
960a5f3
Compare
0eb27bd to
bac33ca
Compare
960a5f3 to
a8d379a
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: bac33ca55d
ℹ️ 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".
A TypeScript `Simulation` could not see what the design reported. `$display` output, `$error` and failed assertions stayed in the event buffer, and only `$fatal` reached TypeScript, as an error of the run. This adds both halves of #89's fail-fast on top of the structured reports of the previous change. **`Simulation::set_fail_on`.** - `run_until`, `run_until_bounded` and `step` stop after the time step of the first report of at least the given severity. - `Simulation::failure` returns that report, as `is_stopped` does for `$stop`. The next run clears it and continues. - While it is set, the events of each step are taken from the event buffer after the step, with the time of that step. Reports then carry an exact `time`, and the buffer cannot overwrite them before the host drains. `drain_runtime_events` returns them first. - A step watches one time slot. A slot that only settles host writes is watched on its own, so a report it causes stops the run before later slots run. - Combinational logic left dirty by host writes that wake no process settles at the current time and is watched before the run moves to a later time or ends (`watch_settle`). Otherwise the later slot, or the settle at the run's end, issued its reports unwatched and with a later time. - Events lost to a full event buffer (`Missed`) may have held a failure, so they are one: `failure()` is a report of the `fail_on` severity, `missed N runtime events`. - Runs with it set take a separate loop. Runs without it keep the loop they had, with one check per run. **NAPI.** `NativeSimulationHandle` has: - `drainRuntimeEvents()`: objects with `kind` (`display`, `write`, `report`, `finish`, `stop`, `missed`) and, for a report, `severity`, `message`, `time`, `scope`, `file`, `line` and `assertion`; - `setFailOn(severity | null)`. `runUntil`, `runUntilBounded` and `step` throw `failOn: <rendered report>` when they stop at a failure. The bare `Simulator` handle wraps only a backend, and the WASM addon has no timed simulation, so neither has these. **TypeScript.** - `Simulation.drainRuntimeEvents()` returns a `RuntimeEvent` union. A `Report` has absent fields omitted. - `Simulation.setFailOn()` sets the severity. - `Severity`, `Report`, `AssertionSite` and `RuntimeEvent` are exported. callgrind, whole native program at 200,000 cycles minus at 20,000 cycles, 64 `always_ff` counters on a clock, without `failOn`. Both binaries are built in the same worktree: | | previous change (base) | this change | |---|---|---| | instructions | 1,015,380,290 | 1,015,380,043 | Equal. The first version checked the setting in every step and drained through the lazy comb path. That cost +0.96%, all from codegen around the drain: - an extra caller of the comb evaluation made LLVM outline `eval_comb_capturing_events` from `eval_comb_checked` (+10.8M); - the step loop got longer. The watched loop is now separate, and it drains through `drain_settled_runtime_events_with_context`, which does not evaluate comb: a step leaves comb settled. - New Rust test `sv_reports::*::fail_on_stops_runs_at_the_time_of_a_report` on the interpreter, cranelift, native and wasm backends: - with `Error`, `$warning` at 1 and `$error` at 2 stop the run at 2; - `failure()` is the `$error`; - the drained reports have times 1 and 2; - the next run reaches the target and shows the later `$display`. - New `fail_on_stops_at_reports_of_host_writes`: a host write at 2 that wakes `always @(posedge a) $error`, with a `$display` at 5, stops `run_until(10)` and `step()` at 2 with the report at 2. Without the change both reach 5. - New `fail_on_stops_at_reports_of_settles_without_steps`: an `always_comb` `$error` that a host write at 2 enables, with nothing scheduled and with an `initial #5 $display`, stops `run_until(10)` and `step()` at 2 with the report at 2, and the next run reaches 10. Without the change the run went on to 5 or 10. - New `fail_on_stops_at_missed_events`: 2,000 `$display`s at 1 stop the run at 1 with a `missed` failure. Without the change it runs on. - New `packages/celox/src/runtime-events-addon.test.ts` (Veryl through the addon): - `drainRuntimeEvents` returns `$display` output and an `$assert_continue` report in order, then nothing; - `setFailOn("error")` makes `runUntil` throw at the time of the report, which the drained report carries, and the next `runUntil` continues; - an unknown severity is rejected. - `vitest run --testTimeout 60000` in `packages/celox` with a debug addon: 435 passed. With the default 5 s timeout, `e2e.test.ts > several threads simulate exactly like one` times out on the debug addon; CI builds it in release. - `tsc -p tsconfig.test.json` and `biome check`. - `cargo nextest run -p celox -p celox-napi -p celox-vpi --features celox/systemverilog`: 13,586 passed. - `cargo clippy` with CI's features and `-D warnings`, `cargo fmt --check`. Change-Id: I4b6716e776cfafba8386e0b35191299213b4897b
bac33ca to
305f5a5
Compare
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
@Mergifyio queue |
Merge Queue Status
This pull request spent 52 minutes 59 seconds in the queue, including 25 minutes 45 seconds running CI. Required conditions to merge
|
A TypeScript
Simulationcould not see what the design reported.$displayoutput,$errorand failed assertions stayed in the event buffer, and only$fatalreached TypeScript, as an error of the run. This adds both halves of #89's fail-fast on top of the structured reports of the previous change.Simulation::set_fail_on.run_until,run_until_boundedandstepstop after the time step of the first report of at least the given severity.Simulation::failurereturns that report, asis_stoppeddoes for$stop. The next run clears it and continues.time, and the buffer cannot overwrite them before the host drains.drain_runtime_eventsreturns them first.watch_settle). Otherwise the later slot, or the settle at the run's end, issued its reports unwatched and with a later time.Missed) may have held a failure, so they are one:failure()is a report of thefail_onseverity,missed N runtime events.NAPI.
NativeSimulationHandlehas:drainRuntimeEvents(): objects withkind(display,write,report,finish,stop,missed) and, for a report,severity,message,time,scope,file,lineandassertion;setFailOn(severity | null).runUntil,runUntilBoundedandstepthrowfailOn: <rendered report>when they stop at a failure. The bareSimulatorhandle wraps only a backend, and the WASM addon has no timed simulation, so neither has these.TypeScript.
Simulation.drainRuntimeEvents()returns aRuntimeEventunion. AReporthas absent fields omitted.Simulation.setFailOn()sets the severity.Severity,Report,AssertionSiteandRuntimeEventare exported.callgrind, whole native program at 200,000 cycles minus at 20,000 cycles, 64
always_ffcounters on a clock, withoutfailOn. Both binaries are built in the same worktree:Equal. The first version checked the setting in every step and drained through the lazy comb path. That cost +0.96%, all from codegen around the drain:
eval_comb_capturing_eventsfromeval_comb_checked(+10.8M);The watched loop is now separate, and it drains through
drain_settled_runtime_events_with_context, which does not evaluate comb: a step leaves comb settled.sv_reports::*::fail_on_stops_runs_at_the_time_of_a_reporton the interpreter, cranelift, native and wasm backends:Error,$warningat 1 and$errorat 2 stop the run at 2;failure()is the$error;$display.fail_on_stops_at_reports_of_host_writes: a host write at 2 that wakesalways @(posedge a) $error, with a$displayat 5, stopsrun_until(10)andstep()at 2 with the report at 2. Without the change both reach 5.fail_on_stops_at_reports_of_settles_without_steps: analways_comb$errorthat a host write at 2 enables, with nothing scheduled and with aninitial #5 $display, stopsrun_until(10)andstep()at 2 with the report at 2, and the next run reaches 10. Without the change the run went on to 5 or 10.fail_on_stops_at_missed_events: 2,000$displays at 1 stop the run at 1 with amissedfailure. Without the change it runs on.packages/celox/src/runtime-events-addon.test.ts(Veryl through the addon):drainRuntimeEventsreturns$displayoutput and an$assert_continuereport in order, then nothing;setFailOn("error")makesrunUntilthrow at the time of the report, which the drained report carries, and the nextrunUntilcontinues;vitest run --testTimeout 60000inpackages/celoxwith a debug addon: 435 passed. With the default 5 s timeout,e2e.test.ts > several threads simulate exactly like onetimes out on the debug addon; CI builds it in release.tsc -p tsconfig.test.jsonandbiome check.cargo nextest run -p celox -p celox-napi -p celox-vpi --features celox/systemverilog: 13,586 passed.cargo clippywith CI's features and-D warnings,cargo fmt --check.