Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,9 @@ jobs:
bash scripts/tests/run-heliodor-bench-results.sh
bash scripts/tests/run-heliodor-bench-gate.sh
python3 -m unittest discover -s .updatecli/tests -v
PYTHONDONTWRITEBYTECODE=1 python3 -m unittest discover -s scripts/tests -p test_rtlmeter_bench.py -v
python3 -m venv "$RUNNER_TEMP/rtlmeter-tests"
"$RUNNER_TEMP/rtlmeter-tests/bin/python" -m pip install -r benchmarks/rtlmeter/requirements.txt
PYTHONDONTWRITEBYTECODE=1 "$RUNNER_TEMP/rtlmeter-tests/bin/python" -m unittest discover -s scripts/tests -p test_rtlmeter_bench.py -v

# A new dependency edge can invalidate the NAPI exclusions or the
# backend and frontend variants that pull requests narrow celox to.
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/rtlmeter-bench.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
strategy:
fail-fast: false
matrix:
case: [e902, e906]
case: [e902, e906, e203]
steps:
- uses: actions/checkout@v7
- uses: actions/setup-python@v7
Expand Down Expand Up @@ -109,9 +109,9 @@ jobs:
path: artifacts
- name: Validate every report before publishing
run: |
for case in e902 e906; do
for case in e902 e906 e203; do
node scripts/publish-rtlmeter-bench.mjs "artifacts/rtlmeter-$case/result/results.json" "artifacts/rtlmeter-$case/host.txt" --validate-only
done
for case in e902 e906; do
for case in e902 e906 e203; do
node scripts/publish-rtlmeter-bench.mjs "artifacts/rtlmeter-$case/result/results.json" "artifacts/rtlmeter-$case/host.txt"
done
25 changes: 23 additions & 2 deletions benchmarks/rtlmeter/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,28 @@
"samples": 3,
"verilatorVersion": "5.052",
"cases": {
"e902": { "design": "XuanTie-E902", "test": "hello", "payload": "Hello Friend!", "maxCycles": 16384 },
"e906": { "design": "XuanTie-E906", "test": "hello", "payload": "Hello Friend!", "maxCycles": 32768 }
"e902": {
"design": "XuanTie-E902",
"test": "hello",
"payload": "Hello Friend!",
"maxCycles": 16384
},
"e906": {
"design": "XuanTie-E906",
"test": "hello",
"payload": "Hello Friend!",
"maxCycles": 32768
},
"e203": {
"design": "HummingbirdV2-E203",
"test": "hello",
"payload": "Hello World from HummingbirdV2 E203",
"maxCycles": 16384,
"configuration": "default",
"successMarker": "TEST_PASSED",
"inputFiles": [
"tests/hello/program.hex"
]
}
}
}
10 changes: 7 additions & 3 deletions docs/.vitepress/components/BenchmarkDashboard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -428,10 +428,14 @@ function shortDate(epoch: number): string {
return `${d.getMonth() + 1}/${d.getDate()}`;
}

function rtlmeterDesignName(name: string): string {
return name === "e203" ? "HummingbirdV2-E203" : `XuanTie-${name.toUpperCase()}`;
}

/** Format chart title from benchName */
function formatChartTitle(benchName: string): string {
const rtlmeter = benchName.match(/^rtlmeter_(e902|e906)_hello_v1_x64_(two-state|four-state)_total$/);
if (rtlmeter) return `XuanTie-${rtlmeter[1].toUpperCase()} hello · cold source-to-finish`;
const rtlmeter = benchName.match(/^rtlmeter_(e902|e906|e203)_hello_v1_x64_(two-state|four-state)_total$/);
if (rtlmeter) return `${rtlmeterDesignName(rtlmeter[1])} hello · cold source-to-finish`;
let s = benchName;
const rica = s.match(/^collection_rica_(kernel-[a-z-]+)_([a-f0-9]+)_(x64|arm64)_total$/);
if (rica) return `rica ${rica[1]} · total · ${rica[3]} · workload ${rica[2]}`;
Expand Down Expand Up @@ -902,7 +906,7 @@ onBeforeUnmount(() => {
<a :href="withBase('/benchmarks/rtlmeter.html')">Measurement details</a>.
</p>
<div v-for="entry in rtlmeterStatuses" :key="entry.rtlmeter!.case" class="bench-methodology">
<h3>XuanTie-{{ entry.rtlmeter!.case.toUpperCase() }} · latest qualification</h3>
<h3>{{ rtlmeterDesignName(entry.rtlmeter!.case) }} · latest qualification</h3>
<p><a :href="entry.rtlmeter!.run">Raw logs and versions</a> · {{ entry.cpu }} · {{ new Date(entry.date).toLocaleDateString() }}</p>
<table>
<thead><tr><th>Simulator</th><th>State</th><th>Status</th><th>Details</th></tr></thead>
Expand Down
2 changes: 1 addition & 1 deletion docs/benchmarks/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Celox/Verilator results for five fixed configurations (472 tests per sample).
Its tab separates test-body, whole-process and HDL compilation time.

The [RTLMeter comparison](./rtlmeter.md) measures cold source-to-finish latency for
XuanTie-E902/E906 hello programs in separate 2-state and 4-state charts, with
XuanTie-E902/E906 and HummingbirdV2-E203 hello programs in separate 2-state and 4-state charts, with
Verilator and the stable xezim release pinned by Nix. Unsupported modes and
failed qualifications remain visible in its status tables.

Expand Down
22 changes: 13 additions & 9 deletions docs/benchmarks/rtlmeter.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@

[Open the RTLMeter dashboard](./index.md?tab=rtlmeter).

The comparison runs the unmodified **XuanTie-E902** and **XuanTie-E906** `hello`
programs from [RTLMeter](https://github.com/verilator/rtlmeter), fixed at commit
The comparison runs the unmodified **XuanTie-E902**, **XuanTie-E906** and
**HummingbirdV2-E203** `hello` programs from [RTLMeter](https://github.com/verilator/rtlmeter), fixed at commit
`4fdd6c3fd154e9b99d3a9d713cf3f4977e284f94`. All tools receive the same ordered
source list, headers, defines, testbench and `case.pat`. Input hashes, tool
source list, headers, defines, testbench and firmware (`case.pat` for E902/E906;
`program.hex` for E203). E203 uses the upstream `default` configuration, including
its `#1` flip-flop delays, with assertions enabled and standard shared-variable
semantics. Input hashes, tool
versions, executable hashes and raw output are retained with each run.

## State models
Expand Down Expand Up @@ -38,15 +41,16 @@ These short programs measure iteration latency, **not steady-state simulation
throughput**.

All configurations for one design run sequentially on the same VM and logical
CPU, with tool order rotated between repetitions. The two designs may run on
CPU, with tool order rotated between repetitions. Different designs may run on
different hosts. Compare results within one design, state model and host.

A successful sample requires a zero exit status, exactly one `Hello Friend!`
and `TEST PASSED` line, no failure marker, and a positive final RTLMeter clock
count. Counts must be stable across repetitions and differ by at most one clock
A successful sample requires a zero exit status, the expected program output
and success marker exactly once, no failure marker, and a positive final
RTLMeter clock count. E902/E906 print `Hello Friend!` and `TEST PASSED`; E203
prints `Hello World from HummingbirdV2 E203` and `TEST_PASSED`. Counts must be stable across repetitions and differ by at most one clock
between tools, allowing for `$finish` and the counter on the same active edge.
A separate one-cycle negative control must stop before program success.
All tools use the same upstream `+max_cycles` limit (16,384 for E902; 32,768
All tools use the same upstream `+max_cycles` limit (16,384 for E902/E203; 32,768
for E906), so a stalled UART or CPU cannot count as a completed workload.
Unsupported modes, probe failures, simulation failures, timeouts and clock
mismatches appear in the table and contribute no performance points.
Expand All @@ -69,5 +73,5 @@ work/rtlmeter-python/bin/python scripts/run-rtlmeter-bench.py prepare work/rtlme
nix develop .#xezim --command work/rtlmeter-python/bin/python scripts/run-rtlmeter-bench.py run e902 work/rtlmeter-source work/rtlmeter-bin/celox work/rtlmeter-report
```

Repeat with `e906` and a fresh output directory. Local dirty-checkout results
Repeat with `e906` or `e203` and a fresh output directory. Local dirty-checkout results
are useful for investigation and cannot be published as release measurements.
2 changes: 1 addition & 1 deletion docs/ja/benchmarks/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,6 @@ Issue には実行へのリンクと、性能低下の場合は比較結果と
ローカル計測は、同じマシン上で 2 つのリビジョンを比較する場合に最も有効です。
CI 履歴は、単発の小さな差より長期的な傾向の確認に向いています。

[RTLMeter 比較](./rtlmeter.md)では XuanTie-E902/E906 hello を用い、
[RTLMeter 比較](./rtlmeter.md)では XuanTie-E902/E906 と HummingbirdV2-E203 の hello を用い、
2-state / 4-state を分けて Verilator・Nix 固定の安定版 xezim と比較します。
コンパイルから実行完了までを測り、未対応や失敗も表に表示します。
4 changes: 3 additions & 1 deletion docs/ja/benchmarks/rtlmeter.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

[RTLMeter ダッシュボード](./index.md?tab=rtlmeter)で、Celox・Verilator・xezim の
2-state / 4-state 比較を確認できます。対象は固定した RTLMeter の
XuanTie-E902 / E906 の `hello` です。
XuanTie-E902 / E906 と HummingbirdV2-E203 の `hello` です。
E203 は上流の `default` 構成(フリップフロップの `#1` 遅延を含む)を使用し、
assertion を有効にした通常の共有変数の意味論で実行します。

測定値は、同じ VM・論理 CPU 上で順番を入れ替えて実行した 3 回の中央値です。
HDL の読み込みからコンパイル、起動、実行完了までを含みます。Verilator には
Expand Down
6 changes: 4 additions & 2 deletions scripts/publish-rtlmeter-bench.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ const positive = value => Number.isSafeInteger(value) && value > 0;

export function rtlmeterMetrics(report, commit) {
assert.ok(manifest.cases[report.case], "Unknown RTLMeter case");
const spec = manifest.cases[report.case];
assert.deepEqual(report.caseSpec, spec, "Workload options must match the manifest");
assert.equal(report.schemaVersion, 1);
assert.equal(report.contract, manifest.contract);
assert.equal(report.status, "completed");
Expand Down Expand Up @@ -42,7 +44,7 @@ export function rtlmeterMetrics(report, commit) {
Object.fromEntries(Object.entries(report.inputSha256).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0)),
)).digest("hex"));
const design = manifest.cases[report.case].design;
for (const path of [`designs/${design}/descriptor.yaml`, `designs/${design}/tests/hello/case.pat`,
for (const path of [`designs/${design}/descriptor.yaml`, ...((spec.inputFiles ?? ["tests/hello/case.pat"]).map(file => `designs/${design}/${file}`)),
"rtl/__rtlmeter_utils.sv", "rtl/__rtlmeter_top_include.vh"]) {
assert.ok(digest(report.inputSha256[path]), `Missing input identity: ${path}`);
}
Expand Down Expand Up @@ -84,7 +86,7 @@ export function rtlmeterMetrics(report, commit) {
const times = row.samples.map(sample => sample.processNs).sort((a, b) => a - b);
return { name: `rtlmeter-${row.engine}/rtlmeter_${report.case}_hello_v1_x64_${row.stateModel}_total`,
unit: "us", value: times[Math.floor(times.length / 2)] / 1000,
extra: JSON.stringify({ contract: report.contract, rtlmeter: report.rtlmeterRevision,
extra: JSON.stringify({ caseSpec: report.caseSpec, contract: report.contract, rtlmeter: report.rtlmeterRevision,
state: row.stateModel, cycles: row.samples[0].cycles, maxCycles: report.maxCycles, samples: times,
configuration: report.configuration, versions: report.versions,
binarySha256: report.binarySha256, sourceSha256: report.sourceSha256, run }) };
Expand Down
25 changes: 19 additions & 6 deletions scripts/rtlmeter-benchmark.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,17 @@ import { rtlmeterMetrics } from "./publish-rtlmeter-bench.mjs";
const manifest = JSON.parse(readFileSync(new URL("../benchmarks/rtlmeter/manifest.json", import.meta.url)));
const locked = JSON.parse(readFileSync(new URL("../flake.lock", import.meta.url))).nodes.xezim;
const commit = 'a'.repeat(40);
function report() {
function report(name = "e902") {
const spec = manifest.cases[name];
const inputSha256 = Object.fromEntries([
...Array.from({ length: 110 }, (_, i) => `designs/XuanTie-E902/src/${i}.v`),
'designs/XuanTie-E902/descriptor.yaml', 'designs/XuanTie-E902/tests/hello/case.pat',
...Array.from({ length: 110 }, (_, i) => `designs/${spec.design}/src/${i}.v`),
`designs/${spec.design}/descriptor.yaml`,
...(spec.inputFiles ?? ["tests/hello/case.pat"]).map(file => `designs/${spec.design}/${file}`),
'rtl/__rtlmeter_utils.sv', 'rtl/__rtlmeter_top_include.vh',
].sort().map(path => [path, 'b'.repeat(64)]));
return { schemaVersion: 1, contract: manifest.contract, case: 'e902', status: 'completed',
return { schemaVersion: 1, contract: manifest.contract, case: name, caseSpec: spec, status: 'completed',
rtlmeterRevision: manifest.revision, celoxCommit: commit, dirty: false,
requestedSamples: 3, maxCycles: manifest.cases.e902.maxCycles, host: { architecture: 'x86_64', cpu: 'test CPU', affinityCpu: 0 },
requestedSamples: 3, maxCycles: spec.maxCycles, host: { architecture: 'x86_64', cpu: 'test CPU', affinityCpu: 0 },
xezimRelease: locked.original.ref, xezimRevision: locked.locked.rev,
versions: { celox: 'celox 0.12.0', verilator: 'Verilator 5.052', xezim: `xezim version ${locked.original.ref.replace(/^v/, '')}\ngit unknown` },
binarySha256: { celox: 'a'.repeat(64), verilator: 'b'.repeat(64), xezim: 'c'.repeat(64) },
Expand Down Expand Up @@ -73,11 +75,22 @@ test('RTLMeter runs daily/manual with locked tools, raw failures and master-only
assert.doesNotMatch(workflow, /^\s+(pull_request|push|merge_group):/m);
assert.match(workflow, /cancel-in-progress: false/);
assert.match(workflow, /fail-fast: false/);
assert.match(workflow, /case: \[e902, e906\]/);
assert.match(workflow, /case: \[e902, e906, e203\]/);
assert.match(workflow, /nix build --no-update-lock-file \.#xezim/);
assert.match(workflow, /revision: ea338be98e1e838d3518809ce8899f85a009963c/);
assert.match(workflow, /needs: comparison\n if: github.ref == 'refs\/heads\/master'/);
assert.doesNotMatch(workflow, /continue-on-error|--no-verify/);
assert.match(workflow, /if: always\(\)[\s\S]+retention-days: 30/);
assert.ok(workflow.indexOf('--validate-only') < workflow.lastIndexOf('node scripts/publish-rtlmeter-bench.mjs'));
});

test('E203 publishes the default hello workload and rejects altered options or image identities', () => {
const r = report('e203');
assert.ok(rtlmeterMetrics(r, commit).every(metric => metric.name.includes('rtlmeter_e203_hello_v1_')));
const wrongOptions = structuredClone(r);
wrongOptions.caseSpec.configuration = 'nodelay';
assert.throws(() => rtlmeterMetrics(wrongOptions, commit));
delete r.inputSha256['designs/HummingbirdV2-E203/tests/hello/program.hex'];
r.sourceSha256 = createHash('sha256').update(JSON.stringify(r.inputSha256)).digest('hex');
assert.throws(() => rtlmeterMetrics(r, commit), /Missing input identity:.*program\.hex/);
});
20 changes: 13 additions & 7 deletions scripts/run-rtlmeter-bench.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,16 @@ def specification(name, source):
descriptor = yaml.safe_load((design / 'descriptor.yaml').read_text())
compile_spec = descriptor['compile']
test = descriptor['execute']['tests'][spec['test']]
configurations = descriptor.get('configurations', {})
configuration = configurations[spec['configuration']] if 'configuration' in spec else configurations.get('default', {})
configured_compile = configuration.get('compile', {})
configured_execute = configuration.get('execute', {})
test = {**test, **configured_execute.get('tests', {}).get(spec['test'], {})}
sources = [design / p for p in compile_spec['verilogSourceFiles']]
sources.append(source / 'rtl/__rtlmeter_utils.sv')
files = [design / p for p in test.get('files', [])]
defines = {**compile_spec.get('verilogDefines', {}), '__RTLMETER_MAIN_CLOCK': compile_spec['mainClock']}
defines = {**compile_spec.get('verilogDefines', {}), **configured_compile.get('verilogDefines', {}),
'__RTLMETER_MAIN_CLOCK': compile_spec['mainClock']}
# Fingerprint all potential local headers, not only explicit compilation inputs.
inputs = sorted(set([*sources, *files, design / 'descriptor.yaml', *design.joinpath('src').rglob('*'),
source / 'rtl/__rtlmeter_top_include.vh']))
Expand Down Expand Up @@ -96,12 +102,12 @@ def execute(command, cwd, log, timeout, cpu):
return {'exitCode': code, 'timedOut': code in (124, 137), 'elapsedNs': time.monotonic_ns() - start}


def accept(stdout, cycles, outcome, payload):
def accept(stdout, cycles, outcome, payload, success_marker='TEST PASSED'):
if outcome['timedOut'] or outcome['exitCode'] != 0:
raise ValueError('process failed or timed out')
if re.search(r'TEST\s+FAIL(?:ED)?|simulation finished with error|\$fatal|%Error:', stdout, re.I):
if re.search(r'TEST[\s_]+FAIL(?:ED)?|Time Out !!!|simulation finished with error|\$fatal|%Error:', stdout, re.I):
raise ValueError('testbench reported failure')
if stdout.splitlines().count('TEST PASSED') != 1 or stdout.splitlines().count(payload) != 1:
if stdout.splitlines().count(success_marker) != 1 or stdout.splitlines().count(payload) != 1:
raise ValueError('missing unique upstream success marker or expected program output')
if not re.fullmatch(r'[1-9][0-9]*', cycles.strip()):
raise ValueError('missing valid final RTLMeter clock count')
Expand Down Expand Up @@ -168,7 +174,7 @@ def measure_case(name, source, celox, xezim, output, build_root, timeout=1800, s
release = locked['original'].get('ref')
if release is None or versions['xezim'].splitlines()[0] != f'xezim version {release.removeprefix("v")}':
raise ValueError('xezim must be built from the release fixed by flake.lock')
report = {'schemaVersion': 1, 'contract': MANIFEST['contract'], 'case': name,
report = {'schemaVersion': 1, 'contract': MANIFEST['contract'], 'case': name, 'caseSpec': MANIFEST['cases'][name],
'rtlmeterRevision': MANIFEST['revision'], 'sourceSha256': spec['sourceSha256'],
'inputSha256': spec['inputSha256'], 'celoxCommit': git(ROOT, 'rev-parse', 'HEAD'),
'dirty': bool(git(ROOT, 'status', '--porcelain')), 'requestedSamples': samples,
Expand Down Expand Up @@ -219,7 +225,7 @@ def save():
text = ''.join(p.read_text(errors='replace') for p in sorted((control / 'logs').glob('*.log')))
control_cycles = control / '_rtlmeter_cycles.txt'
if (outcome['exitCode'] == 0 and not outcome['timedOut']
and 'RTLMeter: +max_cycles reached, exiting' in text and 'TEST PASSED' not in text
and 'RTLMeter: +max_cycles reached, exiting' in text and spec.get('successMarker', 'TEST PASSED') not in text
and control_cycles.exists() and control_cycles.read_text().strip() == '1'):
row['negativeControl'] = 'passed'
else:
Expand All @@ -245,7 +251,7 @@ def save():
stdout = ''.join(p.read_text(errors='replace') for p in sorted((directory / 'logs').glob('*.log')))
cycles = directory / '_rtlmeter_cycles.txt'
try:
count = accept(stdout, cycles.read_text() if cycles.exists() else '', outcome, spec['payload'])
count = accept(stdout, cycles.read_text() if cycles.exists() else '', outcome, spec['payload'], spec.get('successMarker', 'TEST PASSED'))
if count >= spec['maxCycles']:
raise ValueError('Workload reached the cycle limit instead of completing normally')
row['samples'].append({'status': 'passed', 'processNs': outcome['elapsedNs'], 'cycles': count})
Expand Down
Loading
Loading