Repository navigation
perf(runtime)!: compiled slots for designs without process kernels - #1815
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. |
1525a3f to
47c3210
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
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 47c3210098
ℹ️ 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".
47c3210 to
a97bc6e
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
A compiled slot settles combinational logic after every pass of the process phase and after the domains. It now skips a settle when nothing combinational logic reads changed since the last one. What it reads is structural: the storage its units load or commit from. Every write path inside a run marks a change when it may touch that storage: an inlined kernel or domain unit whose stores do, a published nonblocking value, a host clock's level, the time slots, and the start of each run for what the host wrote before it. Combinational logic with records, captures, external calls or trigger marks settles every time. BREAKING CHANGE: SchedulerSlots has a new field, `dirty`. Native images use container format 32; images written by earlier versions must be rebuilt. Change-Id: I31ed70b330f7f42680f4cb0c3b5494c6d3012bcd
A timed simulation of a design without process kernels, whose clocks come from add_clock, now gets a compiled scheduler for its host clocks: the unit runs their slots as the batch step does (the clocks' levels, a settle, the triggered domains, a settle, the re-arm). Every design declares the scheduler's slots, kernels or not. Such a design has no units for several triggered domains when it has a single domain; the scheduler needs them only when more than one event can have an edge in a slot. Exits a unit never takes, such as the $finish exit of a unit without kernels, are left out of it. BREAKING CHANGE: every design, Simulator builds included, gains about 1.1 KB of hidden state for the scheduler's slots: checkpoints, the NAPI total_size and the shared buffer grow, and later signals move to other offsets. State files are unaffected. Designs without kernels get a scheduler unit. Native images use container format 33; images written by earlier versions must be rebuilt. Change-Id: I817dbd29966ea24f118978b64ca24fc17fe61cce
a97bc6e to
ef64c92
Compare
|
Queued — the merge queue status continues in this comment ↓. |
Merge Queue Status
This pull request spent 1 hour 14 minutes 15 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 7 of 7. Builds on #1811.
A timed simulation of a design without process kernels, whose clocks come from
add_clock(the TS/NAPI testbench path), now runs its slots in the compiled scheduler too: (ac), the bench's RTL throughSimulation+add_clock(10, 5), drops from 6,093 to 690 Ir per cycle, belowSimulator::tick(a, 969, unchanged).Today's
add_clocksemantics are kept exactly, as in #1805.BREAKING CHANGE
Simulatorbuilds included, gains about 1.1 KB of hidden state for the scheduler's slots ($scheduler.*): checkpoints, the NAPItotal_sizeand the shared buffer grow, and the offsets of later signals move. State files are unaffected (they leave the slots out).Stacked on #1811: review the last commit (
perf(runtime)!: compiled slots for designs without process kernels).What changes
Simulator(noemit_triggers) still generate nothing, so (a) is unchanged.batch_round: the clocks' levels, a settle, the triggered domains (eval_applyalone oreval_onlythenapplyin event order), a settle, the re-arm. The unit's slot with no kernel ready is exactly that, with perf(runtime)!: skip compiled settles whose inputs did not change #1811's settle elision.eval_only/applyunits; the scheduler needs them only when more than one event can have an edge in a slot, and otherwise keeps the reference loop.$finishexit; the generator now drops blocks unreachable from the entry (the x86 backend's verifier rejects them).Everything else stays in the reference loop, per slot: one-shot
schedule()events, clocks on events the scheduler does not take, host writes, and designsPlan::newrejects (four-state, counted events, derived clocks, comb observers, fatal comb assertions).Perf
Callgrind, whole program, Ir per cycle = (Ir at 200,000 cycles − Ir at 20,000) / 180,000, median of 5. Base: #1811's head, the same bench file.
Simulator::tickSimulation+add_clock(10, 5), no kernelsalways #5 clk = ~clk+forever @(posedge clk) stim = stim + 3+ RTLstim <= stim + 3add_clock(10, 5)instead of the clock kernelalways #5 clk = ~clk+ RTLcompiled slots 4000at 2,000 cycles); in reference mode on the branch binary it is 6,093.0.Build cost
Every kernel-less
Simulationwith a host-clockable event now generates the unit at build. Measured on a synthetic design of N 32-bit registersrK <= rK + (seed ^ K)with an XOR of all of them as combinational output, on one clock or split over two (two clocks also inlineeval_only/apply), building the same release binary in reference mode (no generator) and in the default mode. User-space instructions of the whole process (perf stat -e instructions:u, build plus a 1,000-unit run; two runs each, equal to 0.001%):Wall time (median of 3, pinned to one core, a loaded machine): 2,000/one 5.93 s → 5.39 s, 2,000/two 4.52 s → 4.88 s, 4,000/one 20.12 s → 20.63 s, 4,000/two 17.69 s → 20.14 s (spread within a mode up to 8%). Peak RSS changes by less than 0.2% in every case. The unit is generated at build; generating it lazily at the first run with an armed host clock is not needed under the 10% bound.
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: 204 passed. A new test ends a kernel-less run with analways_ff$finishin every mode against the reference's state file. The other new test runs two kernel-less designs, one domain (no units for several domains) and two coinciding domains with a domain-less edge, with host writes between runs and a one-shot event, in the compiled, differential and differential-runs modes on the native and Cranelift backends, comparing state files with the reference's after every run.add_clock(state_file,checkpoint,clock_alias_edges,flip_flop,vcd,edge_api,shared_jit_cachewith image format 33, ...), andcelox-runtime,celox-design,celox-frontend-core,celox-sir,celox-heap: all passed.pnpm run build, and the CI's package tests (pnpm --filter=!celox-napi --filter=!playground -r test): 432 + 132 + the template packages, all passed.napi build --platform --target wasm32-wasip1-threads(WASI SDK 25): builds.-D warnings(tests, examples) andcargo fmt --check: clean.