Repository navigation
feat(runtime)!: host periodic clocks in the compiled loop - #1805
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. |
|
Queued — the merge queue status continues in this comment ↓. |
17cd2f0 to
594c565
Compare
594c565 to
4aff484
Compare
Merge Queue Status
This pull request spent 9 minutes 29 seconds in the queue, including 3 minutes 14 seconds running CI. ReasonThe merge conditions cannot be satisfied due to failing checks
Failing checks:
HintYou may have to fix your CI before adding the pull request to the queue again. Waiting for
All conditions
Requeued — the merge queue status continues in this comment ↓. |
4aff484 to
6f2a0a1
Compare
The compiled scheduler now also runs kernels whose every wait is the same single edge of a one-bit signal that one compiled delay-only kernel alone drives, whose statuses are Wait, Nba, Done or Finish, and whose nonblocking sites stage their values into targets nothing else writes. Such a kernel wakes at most once a slot, so a site is never staged again before the NBA region. A slot runs the ready kernels lowest first, tests the waits after each run while kernels remain ready or the kernel resumes at once, and again after each pass's settle, as the reference's process phase does; a wait compares against a baseline that follows every tested change. The ready set is a mask over the compiled kernels in kernel order. Staged values publish after the domains, or with a settle of their own without one. Waiting kernels move between Waiters and the scheduler's slots at each run, and a run that ends in the middle of a slot hands back the ready set and the baselines as the reference leaves them. Kernels that drive or wait for a clock whose domain commits blocking results in the active region keep the reference loop. A staged site's target must also lie outside every occurrence probe: the reference publishes nonblocking updates through the runtime, which bumps the probes' counters, and the scheduler's publication does not. BREAKING CHANGE: SchedulerSlots has new fields, `ready` and `baseline`. Native images use container format 30; images written by earlier versions must be rebuilt. Change-Id: Ib033a13b9ad213155c0ffca86c4e891fe61876b2
6f2a0a1 to
344d7de
Compare
A delay-only kernel that pulses the signal another kernel waits on within one activation, by two stores or in a loop, makes the frontend count the signal's occurrences, and the compiled scheduler leaves a design that counts occurrences to the reference loop. The test checks that every mode wakes on each pulse as the reference does, the guard for when counted designs become compilable. Change-Id: I479dec1591e33514389937797b7283eb3baefba2
Periodic clocks from add_clock now run inside the compiled scheduler's loop when their event is a one-bit clock edge (not an asynchronous reset) that no design code writes, whose domain does not commit blocking results in the active region, and the queue holds exactly one periodic edge of the event's own signal. Every other scheduled event stays in the Rust queue and ends a compiled run before its time. A slot applies the clocks due at its time, in event order, before any kernel runs and tests the waits once after them; their edges start the slot's edges and chain with the kernels' writes into the domains. At the end of the slot each clock whose edge applied waits for its opposite level half a period later, with the extra unit of an odd period in the high phase; a next edge past the end of time fails the run as the reference does, after the clocks before it re-armed. Clock edges move between the event queue and the scheduler's clock slots at every run; a run that ends in the middle of a slot leaves the clocks that fired in it out of the queue, as the reference leaves them. A run that takes no clock skips the clock code of its slots behind one test of the armed mask. A kernel that waits for one edge also compiles when no design code writes its one-bit signal: a host clock, or an input the host writes between runs, changes in a compiled slot only at its start. State files list the queued events in the order they fire instead of the queue's internal order, which depends on the order of the pushes. BREAKING CHANGE: SchedulerSlots has new fields, `clock_next`, `clock_period`, `clock_value` and `clock_armed`; SchedulerSchema has `clocks` and SchedulerExit has `ClockOverflow`. Native images use container format 31; images written by earlier versions must be rebuilt. Change-Id: I3b7e4561ecbf897a5bf1f4e6d83dc5f3e2697311
344d7de to
3912589
Compare
Merge Queue Status
This pull request spent 1 hour 14 minutes 13 seconds in the queue, including 1 hour 13 minutes 29 seconds running CI. Required conditions to merge
|
Part of #1123, step 3b-1 (compiled scheduler), PR 5 of 7. Builds on #1801.
Periodic clocks from
add_clocknow run inside the compiled scheduler's loop, and kernels may wait for them: a testbench whose clock comes from the host, such asinitial forever @(posedge clk) stim = stim + 3;withadd_clock("clk", 10, 5), the new bench case (bh), drops from about 8,200 to about 1,090 Ir per cycle.A slot that touches anything the scheduler does not run still runs entirely in the Rust reference loop, as before: one-shot
schedule()events and clocks the scheduler does not take only bound its runs.BREAKING CHANGE
celox_design::SchedulerSlots(public) has new fields:clock_next,clock_period,clock_value,clock_armed.SchedulerSchemahasclocks, andSchedulerExithasClockOverflow.Stacked on #1801: review the last commit (
feat(runtime)!: host periodic clocks in the compiled loop).Which clocks and kernels
add_clockregistered. A run that takes no clock skips all clock code of its slots behind one test of the armed mask (the next-edge scan, the batch, the re-arm). Asynchronous resets get no clock slots: each reserved event costs the unit its domains' code even when no clock runs, and the host drives resets by writes; kernels waiting for a host-written reset still compile (below).What a slot does with host clocks
The reference's round (
run_time,step_round,rearm_clocks), unchanged:observeafter the batch); their edges are the first edges of the slot, judged against the levels the slot started from, and chain with the kernels' writes into the domains, asmark_scheduled_edgeschains the batch's transitions with the first pass's;ceil(P/2)high,floor(P/2)low,P < 2taken as 2), in event order; a next edge past the end of time fails the run with the reference'sevent N overflows simulation time, after the clocks before it re-armed. The reference re-arms at the end of the slot's first round; a compiled slot has a single round, since no kernel it runs resumes in the same slot.Clock edges move between the Rust event queue and the scheduler's clock slots at every run. A run that ends in the middle of a slot (a
$finish) leaves the clocks whose edge applied out of the queue, as the reference leaves them beforerearm_clocks.State files now list the queued events in the order they fire rather than in the queue's internal order, which depends on the order they were pushed: a run that hands its clocks back must leave the same state file as the reference's.
Coverage
compiled_scheduler_coverage(test output): 132 of 296 kernels of the timed SV suite cases compile, against 129 with #1801. The suite's timed cases drive their own clocks (none usesadd_clock); the gain is kernels that wait for a one-bit signal no design code writes. Kernels that wait for a signal not driven this way fall from 44 to 39:@*: 3b-2)Perf
Callgrind, whole program, Ir per cycle = (Ir at 200,000 cycles − Ir at 20,000) / 180,000, median of 5. Base: #1801's head (97108e9). (bh) has no base binary; its base is the branch binary in reference mode, whose loop this PR does not change.
Simulator::tickSimulation+add_clockalways #5 clk = ~clk+forever @(posedge clk) stim = stim + 3+ RTLstim <= stim + 3always #5 clk = ~clk+ RTLadd_clock(10, 5)instead of the clock kernel (reference mode → default)compiled slots 4000, kernels [Compiled]at 2,000 cycles) and stays below (b1).Validation
cargo test -p celox --features systemverilog --test systemverilog(all groups, native/cranelift/parallel/wasm): 4,222 passed, 20 ignored in each ofCELOX_SCHEDULER=differential,differential-runsand the default (compiled).--lib: 201 passed, with new tests, each in the compiled, differential and differential-runs modes, comparing the state file with the reference's after every run (on the native and Cranelift backends, except the restore and overflow cases, native only):$finishin a slot with host clock edges, and a state file and a checkpoint taken in the middle, restored and run on;$finishin the middle of a slot, in runs that take no clock.state_file,checkpoint,clock_alias_edges,edge_api,vcd,shared_jit_cachewith image format 31, ...),celox-runtime,celox-design,celox-frontend-core,celox-sir,celox-heap: all passed.napi build --platform --target wasm32-wasip1-threads(WASI SDK 25): builds.-D warnings(tests, examples) andcargo fmt --check: clean.