Skip to content

Apply ConsecutiveSlice optimizations to CompiledSimulation for ~46% reduction in compile time.#495

Merged
fdxmw merged 4 commits into
UCSBarchlab:developmentfrom
fdxmw:compilesim
Jul 17, 2026
Merged

Apply ConsecutiveSlice optimizations to CompiledSimulation for ~46% reduction in compile time.#495
fdxmw merged 4 commits into
UCSBarchlab:developmentfrom
fdxmw:compilesim

Conversation

@fdxmw

@fdxmw fdxmw commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

For pyrtlnet, this reduces CompiledSimulation's startup time from 2.96 seconds to 1.6 seconds. It does not affect simulation speed, so the compiler was optimizing the inefficient code we were generating before, but we were paying for those optimizations with startup time.

Also: Simplify the interface for make_consecutive_slices and move the shift helper in simulation.py to toplevel so we can call it from compilesim.py. Add some comments and emit bitmasks in hex so they're easier to identify.

…% reduction in compile time.

For pyrtlnet, this reduces `CompiledSimulation`'s startup time from 2.96
seconds to 1.6 seconds. It does not affect simulation speed, so the compiler
was optimizing the inefficient code we were generating before, but we were
paying for those optimizations with startup time.

Also: Simplify the interface for `make_contiguous_slices` and move the `shift`
helper in `simulation.py` to toplevel so we can call it from `compilesim.py`.
Add some comments and emit bitmasks in hex so they're easier to identify.
@codecov

codecov Bot commented Jul 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.2%. Comparing base (1c9ce1f) to head (065d98e).

Additional details and impacted files
@@              Coverage Diff              @@
##           development    #495     +/-   ##
=============================================
+ Coverage         92.2%   92.2%   +0.1%     
=============================================
  Files               30      30             
  Lines             7465    7488     +23     
=============================================
+ Hits              6876    6902     +26     
+ Misses             589     586      -3     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@fdxmw

fdxmw commented Jul 15, 2026

Copy link
Copy Markdown
Contributor Author

Example: the old code would generate:

((1&(w4134_layer1matmulreg10[0]>>0))<<0)|
 ((1&(w4134_layer1matmulreg10[0]>>1))<<1)|
 ((1&(w4134_layer1matmulreg10[0]>>2))<<2)|
 ((1&(w4134_layer1matmulreg10[0]>>3))<<3)|
 ((1&(w4134_layer1matmulreg10[0]>>4))<<4)|
 ((1&(w4134_layer1matmulreg10[0]>>5))<<5)|
 ((1&(w4134_layer1matmulreg10[0]>>6))<<6)|
 ((1&(w4134_layer1matmulreg10[0]>>7))<<7)

while the new code generates:

(w4134_layer1matmulreg10[0] & 0xFF)

"Consecutive" is more correct, because it implies an in-order sequence with
unit spacing, which is what we're modeling.

https://mathworld.wolfram.com/ConsecutiveNumbers.html
@fdxmw fdxmw changed the title Apply ContiguousSlice optimizations to CompiledSimulation for ~46% reduction in compile time. Apply ConsecutiveSlice optimizations to CompiledSimulation for ~46% reduction in compile time. Jul 16, 2026
@fdxmw
fdxmw merged commit 34a4538 into UCSBarchlab:development Jul 17, 2026
4 checks passed
@fdxmw
fdxmw deleted the compilesim branch July 17, 2026 20:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant