mirror of
https://github.com/powdr-labs/powdr.git
synced 2026-01-10 20:18:20 -05:00
Should work for both use cases. Sample usage in Powdr: ``` cargo run --bin powdr_openvm -r compile guest --input 10 --autoprecompiles 10 --apc-candidates-dir 10apc python3 autoprecompiles/scripts/rank_apc_candidates.py 10apc/apc_candidates.json rank_apc_candidates_output.txt ``` Updated output. Note that Total Cost here is the total columns (main + bus interaction + preprocessed). In the other use case, total cost will be the same as total main columns. ``` ======================================================================================================================== SUMMARY STATISTICS OVER ALL APC CANDIDATES ======================================================================================================================== # of APC Candidates: 21 Total Instructions: 82 Average Instructions per APC Candidate: 3.9 Total Cost: 4671.0 → 1442.0 (3.24x reduction) Total Main Columns: 2683 → 794 (3.38x reduction) Total Constraints: 1537 → 338 (4.55x reduction) Total Bus Interactions: 1385 → 530 (2.61x reduction) Instructions Count Distribution: +----------------+-------------------+--------------+ | Instructions | # of Candidates | Percentage | +================+===================+==============+ | 2 | 6 | 28.6% | +----------------+-------------------+--------------+ | 3 | 4 | 19.0% | +----------------+-------------------+--------------+ | 4 | 4 | 19.0% | +----------------+-------------------+--------------+ | 5 | 4 | 19.0% | +----------------+-------------------+--------------+ | 6 | 1 | 4.8% | +----------------+-------------------+--------------+ | 7 | 1 | 4.8% | +----------------+-------------------+--------------+ | 9 | 1 | 4.8% | +----------------+-------------------+--------------+ Execution Frequency Distribution: +-------------+-------------------+--------------+ | Frequency | # of Candidates | Percentage | +=============+===================+==============+ | 1x | 20 | 95.2% | +-------------+-------------------+--------------+ | 9x | 1 | 4.8% | +-------------+-------------------+--------------+ ======================================================================================================================== APC CANDIDATES RANKED BY DENSITY (VALUE / COST_AFTER) ======================================================================================================================== +--------+------------+--------------+--------+---------+--------------------------------+-----------+-------------------------------------+---------------------------------------+-----------------------------------+ | Rank | Start PC | # of Instr | Freq | Value | Cost Before -> After (Redux) | Density | Main Cols Before -> After (Redux) | Constraints Before -> After (Redux) | Bus Int Before -> After (Redux) | +========+============+==============+========+=========+================================+===========+=====================================+=======================================+===================================+ | 1 | 2099588 | 5 | 9x | 1926000 | 298 -> 84 (3.5x) | 22928.6 | 170 -> 48 (3.5x) | 99 -> 22 (4.5x) | 91 -> 30 (3.0x) | +--------+------------+--------------+--------+---------+--------------------------------+-----------+-------------------------------------+---------------------------------------+-----------------------------------+ | 2 | 2101656 | 9 | 1x | 440000 | 561 -> 121 (4.6x) | 3636.36 | 321 -> 77 (4.2x) | 207 -> 56 (3.7x) | 171 -> 40 (4.3x) | +--------+------------+--------------+--------+---------+--------------------------------+-----------+-------------------------------------+---------------------------------------+-----------------------------------+ | 3 | 2101636 | 2 | 1x | 76000 | 98 -> 22 (4.5x) | 3454.55 | 54 -> 10 (5.4x) | 31 -> 1 (31.0x) | 30 -> 8 (3.8x) | +--------+------------+--------------+--------+---------+--------------------------------+-----------+-------------------------------------+---------------------------------------+-----------------------------------+ | 4 | 2107116 | 5 | 1x | 198000 | 271 -> 73 (3.7x) | 2712.33 | 155 -> 41 (3.8x) | 90 -> 26 (3.5x) | 84 -> 25 (3.4x) | +--------+------------+--------------+--------+---------+--------------------------------+-----------+-------------------------------------+---------------------------------------+-----------------------------------+ | 5 | 2101352 | 6 | 1x | 227000 | 315 -> 88 (3.6x) | 2579.55 | 179 -> 48 (3.7x) | 92 -> 20 (4.6x) | 95 -> 32 (3.0x) | +--------+------------+--------------+--------+---------+--------------------------------+-----------+-------------------------------------+---------------------------------------+-----------------------------------+ | 6 | 2101692 | 3 | 1x | 107000 | 150 -> 43 (3.5x) | 2488.37 | 86 -> 23 (3.7x) | 56 -> 18 (3.1x) | 43 -> 14 (3.1x) | +--------+------------+--------------+--------+---------+--------------------------------+-----------+-------------------------------------+---------------------------------------+-----------------------------------+ | 7 | 2100992 | 7 | 1x | 250000 | 353 -> 103 (3.4x) | 2427.18 | 201 -> 59 (3.4x) | 93 -> 23 (4.0x) | 109 -> 39 (2.8x) | +--------+------------+--------------+--------+---------+--------------------------------+-----------+-------------------------------------+---------------------------------------+-----------------------------------+ | 8 | 2099612 | 5 | 1x | 219000 | 314 -> 95 (3.3x) | 2305.26 | 182 -> 51 (3.6x) | 103 -> 10 (10.3x) | 90 -> 38 (2.4x) | +--------+------------+--------------+--------+---------+--------------------------------+-----------+-------------------------------------+---------------------------------------+-----------------------------------+ | 9 | 2101332 | 4 | 1x | 147000 | 212 -> 65 (3.3x) | 2261.54 | 120 -> 33 (3.6x) | 58 -> 7 (8.3x) | 68 -> 26 (2.6x) | +--------+------------+--------------+--------+---------+--------------------------------+-----------+-------------------------------------+---------------------------------------+-----------------------------------+ | 10 | 2101380 | 5 | 1x | 215000 | 314 -> 99 (3.2x) | 2171.72 | 182 -> 55 (3.3x) | 103 -> 16 (6.4x) | 90 -> 38 (2.4x) | +--------+------------+--------------+--------+---------+--------------------------------+-----------+-------------------------------------+---------------------------------------+-----------------------------------+ | 11 | 2099532 | 4 | 1x | 148000 | 217 -> 69 (3.1x) | 2144.93 | 125 -> 37 (3.4x) | 61 -> 13 (4.7x) | 65 -> 26 (2.5x) | +--------+------------+--------------+--------+---------+--------------------------------+-----------+-------------------------------------+---------------------------------------+-----------------------------------+ | 12 | 2101452 | 4 | 1x | 148000 | 217 -> 69 (3.1x) | 2144.93 | 125 -> 37 (3.4x) | 61 -> 13 (4.7x) | 65 -> 26 (2.5x) | +--------+------------+--------------+--------+---------+--------------------------------+-----------+-------------------------------------+---------------------------------------+-----------------------------------+ | 13 | 2101620 | 4 | 1x | 141000 | 209 -> 68 (3.1x) | 2073.53 | 121 -> 36 (3.4x) | 67 -> 10 (6.7x) | 58 -> 24 (2.4x) | +--------+------------+--------------+--------+---------+--------------------------------+-----------+-------------------------------------+---------------------------------------+-----------------------------------+ | 14 | 2101704 | 3 | 1x | 98000 | 151 -> 53 (2.8x) | 1849.06 | 87 -> 29 (3.0x) | 43 -> 4 (10.8x) | 43 -> 20 (2.1x) | +--------+------------+--------------+--------+---------+--------------------------------+-----------+-------------------------------------+---------------------------------------+-----------------------------------+ | 15 | 2099580 | 2 | 1x | 82000 | 128 -> 46 (2.8x) | 1782.61 | 72 -> 22 (3.3x) | 44 -> 5 (8.8x) | 40 -> 18 (2.2x) | +--------+------------+--------------+--------+---------+--------------------------------+-----------+-------------------------------------+---------------------------------------+-----------------------------------+ | 16 | 2107104 | 3 | 1x | 114000 | 180 -> 66 (2.7x) | 1727.27 | 104 -> 38 (2.7x) | 69 -> 23 (3.0x) | 53 -> 22 (2.4x) | +--------+------------+--------------+--------+---------+--------------------------------+-----------+-------------------------------------+---------------------------------------+-----------------------------------+ | 17 | 2101644 | 2 | 1x | 73000 | 116 -> 43 (2.7x) | 1697.67 | 68 -> 23 (3.0x) | 47 -> 18 (2.6x) | 33 -> 16 (2.1x) | +--------+------------+--------------+--------+---------+--------------------------------+-----------+-------------------------------------+---------------------------------------+-----------------------------------+ | 18 | 2099548 | 3 | 1x | 116000 | 185 -> 69 (2.7x) | 1681.16 | 109 -> 37 (2.9x) | 72 -> 20 (3.6x) | 50 -> 26 (1.9x) | +--------+------------+--------------+--------+---------+--------------------------------+-----------+-------------------------------------+---------------------------------------+-----------------------------------+ | 19 | 2101320 | 2 | 1x | 83000 | 133 -> 50 (2.7x) | 1660 | 77 -> 26 (3.0x) | 47 -> 7 (6.7x) | 37 -> 18 (2.1x) | +--------+------------+--------------+--------+---------+--------------------------------+-----------+-------------------------------------+---------------------------------------+-----------------------------------+ | 20 | 2099560 | 2 | 1x | 78000 | 128 -> 50 (2.6x) | 1560 | 72 -> 26 (2.8x) | 44 -> 5 (8.8x) | 40 -> 20 (2.0x) | +--------+------------+--------------+--------+---------+--------------------------------+-----------+-------------------------------------+---------------------------------------+-----------------------------------+ | 21 | 2099572 | 2 | 1x | 55000 | 121 -> 66 (1.8x) | 833.33 | 73 -> 38 (1.9x) | 50 -> 21 (2.4x) | 30 -> 24 (1.2x) | +--------+------------+--------------+--------+---------+--------------------------------+-----------+-------------------------------------+---------------------------------------+-----------------------------------+ ```
Scripts
Set up (from the project root):
python3 -m venv .venv
source .venv/bin/activate
pip install -r autoprecompiles/scripts/requirements.txt