Repository navigation
perf(runtime): handle element-strided unpacked arrays per element - #2048
Merged
Merged
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. |
Whole element-strided arrays were materialized as one BigUint by shifting every element into or out of an array-sized value, which is quadratic in the array size. rtlmeter C906's 2^19-element SRAM banks made the tiered start run out of memory in apply_initial_values, and the native backend spent minutes in read_signal_plane/write_signal_plane. Packed initial values of an element-strided array become write runs (`InitialStateData::packed_write_runs`) applied element by element. Whole-array commits in the interpreter copy element bytes directly. The host-boundary gather/scatter of the interpreter and the native backend share linear `SignalArrayLayout::gather`/`scatter`, so a whole-array BigUint exists only when a caller asks for the whole value. Closes #2029 Change-Id: I5e80207ab292701da28aa9de019ebe3c87ddfcbc
tignear
force-pushed
the
feature/perf/2029-unpacked-per-element
branch
from
October 25, 2026 17:41
1149564 to
a686342
Compare
Contributor
Merge Queue Status
This pull request spent 33 minutes 59 seconds in the queue, including 31 minutes 42 seconds running CI. Required conditions to merge
|
40 of 71 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #2029
What
Whole element-strided unpacked arrays were materialized as one
BigUintby shifting every element into or out of an array-sized value. That is quadratic in the array size. rtlmeter C906's 2^19-element SRAM banks made the tiered start run out of memory (apply_initial_values→get_four_state/set_four_state→gather_strided/scatter_strided). The native backend spent minutes inread_signal_plane/write_signal_planeafter compiling.InitialStateData::Packedfor an element-strided array becomes write runs (InitialStateData::packed_write_runs, linear). They go through the existing per-elementapply_initial_memory_writes, so the array is never read and written back whole. This covers all three sites:Simulator::apply_initial_values, declaration records, and the native backend's initial state. Two-state targets still get unknown bits as 0.SignalArrayLayout::copy) instead of gather + scatter.get_four_state/set_four_state/get_wide/set_wideof a whole array): interpretergather_strided/scatter_stridedand nativeread_signal_plane/write_signal_planenow share linearSignalArrayLayout::gather/scatter. They build the packed byte image in one pass, so a whole-arrayBigUintexists only when a caller asks for the whole value.Cranelift and WASM never use element-strided storage (
array_layout: None), so they had no such path.Validation
backend::tiered::tests::strided_sv_arrays_initialize_commit_and_read_like_packed_ones. An SV four-state 13-bit × 8 array starts as X through packed initial values, then takes element writes and whole-array NBA commits. The element-strided interpreter (gated tiered, never promotes), the packed interpreter and native (both asserted strided where expected) agree on every element and on the whole-array read.celox-runtimestrided_planes_round_trip_like_element_shiftschecks gather/scatter/copy against per-element BigUint shifts for element widths 1–70, including padding and bits past the array.celox-designpacked_write_runs_match_the_packed_mergechecks that applying the runs equals the packed merge, in two- and four-state, for empty, full, sparse and over-wide written masks.cargo nextest run -p celox -p celox-runtime -p celox-design -p celox-test-suite -p celox-vpi --features celox/systemverilog,celox/cranelift,celox/wasm-runtime,celox/wasm-component,celox-vpi/cranelift,celox-vpi/wasm-runtime,celox-test-suite/runtime-cases: 14255 passed, 207 skipped. (The first CI run caught a VPI regression: handles on part of an array keep the whole plane size, and nativewrite_signal_planecleared it whole; plane accesses now cover only the handle's elements,SignalArrayLayout::element_extent.)cargo clippy(touched crates, all targets, same features) andcargo fmt --check: clean.This is a complexity fix (quadratic → linear), so no benchmark per the issue.