Repository navigation
Conversation
…lves
Resolve performance bottlenecks on heavy constrained randomization benchmarks:
1. Scope foreach affine bounds narrowing (inline_constraints):
- Added inline_foreach_affine_ref to resolve affine element expressions
such as (chunk[i] + start) and arr[idx] +/- C.
- Narrow bounds for inside ranges in narrow_inline_foreach_bounds.
- Avoid clobbering weighted dist values with unweighted inside checks in
apply_inline_foreach_pins when the value already satisfies the range.
- Enforce relational interval repair in solve_inline_foreach_elem regardless
of prior pins so elements do not violate relational bounds.
- Prevents spurious failures in chunked array randomization (tb_rand_grind_01)
that triggered a fallback to a monolithic joint CSP solve over 8k variables;
runtime dropped from 921s to 3.7s (~250x speedup).
2. Factorized class solve with top-level pins (rand_csp):
- Run solve_forced across all constraint items during post-size factorized
solving rather than only items with item_has_foreach. Top-level array
element equality pins in inline with{} blocks now bind immediately,
allowing Phase A/A2 to stay on the factorized fast path.
3. Foreach frame reuse and fallback gating (constraint_domains, constraint_targets):
- Added body_needs_generate_and_test to skip expensive item_holds sweeps
when constraints are purely structural.
- Added body_has_bare_inside to skip body_inside_ranges computations.
- Reused single-variable foreach local frames in-place rather than allocating
a HashMap per element across hundreds of iterations.
- Avoided cloning rand_set per element in solve_forced.
- Cuts tb_rand_grind_00 simulation time from 184s to 62s (~3x speedup).
Added regression test tests/classes/randomize_scope_chunked_dist_bounds.rs.
Verified byte-for-byte against reference simulators.
…rent in uvm_config_db tests
1. Expression packed struct member memo (aggregate_expressions, simulator):
- Memoize (su_span_start, member_name) -> (offset, width, is_signed, element, dimensions)
in declared_packed_access to avoid re-resolving struct layouts, dimensions,
and typedef widths on every member access in expressions and constraints.
- Avoid allocating kept Vec in dist_weighted_ranges when all weights are
positive integer literals (all_dist_weights_positive).
2. Fix formal parent in uvm_config_db_tests:
- Provide null parent argument to uvm_component::new in test_config_db_inst_name,
test_config_db_wildcard, and test_config_db_hit_wildcard_and_miss per
IEEE 1800-2017 §13.5 formal argument requirements, fixing the failure in
uvm_groups::uvm_foundation_config_factory.
Verified byte-for-byte against reference simulators.
…rays Match ExprKind::Inside in body_has_bare_inside so multidimensional array foreach constraints with inside expressions populate elem_inside_hint, fixing constraint_foreach_conditional::a_globally_coupled_monotone_mesh_is_solved_not_given_up_on. Verified byte-for-byte against reference simulators.
…ists
1. Compiled Foreach Checker (constraint_targets):
- In check_coll_foreach: compile element-independent foreach constraint
bodies into a CompiledForeachCheck plan once before the loop, pre-evaluating
loop-invariant expressions, resolving struct member offsets, and checking
elements using direct bit-shift and range comparisons.
- Gated on scalar element collections (!c.row_tail.is_some() && !c.nested),
and cleanly falls back to the standard per-iteration frame push/pop for
dynamic rows and multidimensional collections (preserving
constraint_foreach_signed_indices::dynamic_row_sizes_and_elements_use_signed_index_arithmetic).
- In try_compile_foreach_item: check !expr_reads_var on dist weights and ranges,
preventing spurious drops of index-dependent dist items (preserving
review_940_constraint_memos::foreach_dist_reads_index_rand_and_property_per_element).
- Reduces tb_rand_grind_00 simulation time to 44s (from 62.9s; original baseline was 184.2s,
4.2x speedup overall).
Verified byte-for-byte against reference simulators.
…_stack in solve_coll_foreach 1. Support ExprKind::Conditional and ExprKind::Concatenation in expr_reads_var so expressions like ((i > -1) ? i + 30 : -1) are correctly identified as reading the loop index variable, preventing erroneous loop-invariant folding and fixing dynamic_row_sizes_and_elements_use_signed_index_arithmetic. 2. Push this_stack with handle in solve_coll_foreach so class collection element expressions resolve their instance handle. Verified byte-for-byte against reference simulators.
…onflict Resolve the single content conflict in tests/classes.rs by keeping both the PR's randomize_scope_chunked_dist_bounds module and upstream's static_shadow_write_944 and vif_collection_formals_925 module declarations. Verified: cargo build clean; tests/classes (1348 passed); collections/misc/ perf/scheduling/types (1339 passed, 1 pre-existing upstream failure in relax_library_packages_compiles_v_file_packages where the --relax-library- packages flag implementation is absent from both origin/main and HEAD src/).
Owner
|
Integrated by cherry-pick with @Thomasb81's authorship preserved: b19450cd, the tests 939be3dd, and the
The rewritten foreach shapes can pick different solutions than before for the same seed; seeded runs remain reproducible. Published in xezim 603c9bf3 with xezim-core 212dde0. |
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.
Summary
This PR resolves the constrained randomization performance bottlenecks discussed in #876:
Affine and
insidebounds narrowing in scope foreach solves (inline_constraints):inline_foreach_affine_refto recognize affine element offsets like(chunk[i] + start)andarr[idx] +/- C.(chunk[i] + start) inside [0:255]restrictsdistdraws when checking unweightedinsideconstraints if the current value already satisfies the range.solve_inline_foreach_elemregardless of prior pins to prevent drawing values that violate<or<=bounds.tb_rand_grind_01) that triggered 10-attempt rejection cycles and fell back to a monolithic joint CSP solve over 8,192 variables.Compiled foreach check plans (
constraint_targets):check_coll_foreach: compiles element-independent foreach constraint bodies into aCompiledForeachCheckplan once before the loop, pre-evaluating loop-invariant expressions, resolving struct member offsets, and checking elements using direct bit-shift and range comparisons.Complete factorized array solve with top-level pins (
rand_csp):solve_forcedacross all constraint items during post-size factorized solving rather than only items withitem_has_foreach, binding top-level element equality pins (arr[0].member == val) in inlinewithblocks directly on the fast path.Foreach frame reuse and fallback gating (
constraint_domains,constraint_targets):body_needs_generate_and_testto skip expensiveitem_holdssweeps when constraints are purely structural.body_has_bare_insideto skip re-evaluatingbody_inside_rangeswhen no bare array inside constraints exist.splice_elem_memberfor scalar element widthspacked_struct_member_memoindeclared_packed_accessto memoize struct member bit offsets.Formal argument fix in tests (
uvm_config_db_tests):nullas the parent argument touvm_component::newin testbench snippets to comply with IEEE 1800-2017 §13.5.Benchmarks (Release Build)
Test Case 2 (
tb_rand_grind_01.sv, 100,000 elements across 13 chunks of 8,192):Test Case 1 (
tb_rand_grind_00.sv, 2,900randomize()calls):Verification
classes,hierarchy,collections,misc,types,scheduling,strings,gates,lrm,perf,upf).tests/classes/randomize_scope_chunked_dist_bounds.rs.