tools/tune_cpu_sequences.py applies the same procedure to any plan item's supplied candidates. Each candidate
must have an independent correctness command. Build and check phases finish before timing starts. Builds run
in parallel only when candidates have distinct working directories; these must be isolated builds/worktrees.
All timings run serially, with two warmups and at least five shuffled measured rounds. Stop games, builds and
other profiling before timing. Diagnostic builds and timed builds must keep equivalent instrumentation costs.
Example manifest structure (replace these illustrative commands with the item's real checks and benchmark):
{
"item": "I15",
"candidates": [{
"name": "baseline",
"cwd": "/absolute/path/to/isolated-baseline",
"build": ["cmake", "--build", "build", "--target", "the-item-benchmark"],
"check": ["ctest", "--test-dir", "build", "-R", "the-item-correctness-tests", "--output-on-failure"],
"bench": {"ordinary": ["build/the-item-benchmark", "--bench", "ordinary"]},
"code_bytes": 684
}]
}
Add candidates with the same workload names and distinct output names. Each timed command must print a final JSON
line containing positive finite elapsed_ns and a result checksum. A different checksum aborts the comparison.
If code size is supplied, supply it for every candidate and measure the same code region. Record compiler, source,
feature and recompile settings in the manifest as additional metadata. Keep game-derived manifests and artifacts local.
python3 tools/cpu_plan.py run I15 /absolute/path/to/manifest.json --out /absolute/path/to/new-results
python3 tests/cpu_plan_tools.py
The report includes every raw observation, median, spread, MAD, failed candidate check, host affinity and manifest hash. Its Pareto set retains candidates that trade speed in one workload or code size for another. It does not claim a universal optimum, infer game FPS from instruction benchmarks, apply code, or mark a plan item complete. Small median differences within run-to-run variation remain inconclusive. Use the item's independent directed, differential, concurrency, module-contract, host and gameplay proofs before accepting a candidate.
The runner also computes paired bootstrap intervals for each workload and a weighted geometric aggregate. An
optional workload_weights object must give every workload a positive finite weight; the default is equal weights.
The recommendation requires a minimum aggregate improvement and a lower confidence bound within the regression
budget for every workload. A code-size budget requires measured code_bytes for every candidate:
python3 tools/tune_cpu_sequences.py /absolute/path/to/manifest.json --out /absolute/path/to/new-results \
--rounds 11 --baseline baseline --bootstrap-samples 10000 --min-speedup 0.01 --max-regression 0.02
--max-code-bytes adds the optional size constraint. Statistical calculations may use multiple processes after
timing finishes; timings remain serial. These are per-comparison intervals over supplied candidates and workloads,
not a proof of a global optimum. Keep the reference when no candidate clears the thresholds. Select instruction
families separately when one family regresses; do not relax the threshold to accept it.
ABI/register and atomic-loop redesigns still require T5's block-level fuzzer. A benchmark script is not that fuzzer. J1 stays deferred, L1 stays retired, and research items produce measured feasibility reports before implementation.
The reciprocal comparison is ready to run from the repository root after building:
python3 tools/cpu_plan.py run I8 tests/llvm_perf/recpe_candidates.json --out /absolute/path/to/reciprocal-results
python3 tools/cpu_plan.py run I15 tests/llvm_perf/shift_round_candidates.json --out /absolute/path/to/shift-round-results
python3 tools/cpu_plan.py run I11 tests/llvm_perf/half_candidates.json --out /absolute/path/to/half-results
It compares the actual emitted lane-helper path with integer-vector code at O0/O2. Both use the same target machine and helper library. The kernels use fixed raw inputs and preserve a checksum of the result and FPSR. They measure instruction throughput, not game frame rate, helper bodies compiled at a game's O0 setting, or a cold table's cost. The table and larger exceptional sequence increase code size, so faster execution is not a claim of smaller modules. LLVM may lower a table lookup into scalar loads on some CPUs at O0. Report the actual host and assembly along with the timing instead of assuming the IR gather guarantees one hardware gather on every AVX2 CPU.
Made from docs/history/cpu-translator-progress.md at 69237645142c. GPL-3.0-or-later.