diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3d600f6daa..d1ec4e9a8c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -258,6 +258,12 @@ jobs: CELL: ${{ matrix.category }}-${{ matrix.driver }}-${{ matrix.xlen }}${{ matrix.shards && format('-{0}of{1}', matrix.shard, matrix.shards) || '' }} steps: - uses: actions/checkout@v4 + with: + # logic_gate builds its pull request's merge base, so it needs history and + # the submodules' git data (the third_party cache holds only their working + # trees, whose .git files point into an uncached .git/modules). + fetch-depth: ${{ matrix.category == 'logic_gate' && github.event_name == 'pull_request' && '0' || '1' }} + submodules: ${{ matrix.category == 'logic_gate' && github.event_name == 'pull_request' && 'recursive' || 'false' }} - name: Setup Vortex uses: ./.github/actions/setup-vortex with: @@ -292,6 +298,51 @@ jobs: run: | (cd build${{ matrix.xlen }} && bash ci/toolchain_install.sh --foldsim) pip install --quiet "pyslang>=11,<13" + # logic_gate on a pull request: every build is also compared with the + # same build on the merge base's RTL (ci/logic_gate.py --against-rev, + # through BEACON_AGAINST_REV). The checkout is the merge of the pull + # request into its target, so the merge base is the target's head this + # run merged into, and the diff is exactly what the pull request adds. + # The reference's builds are cached by that SHA and the flow it was + # measured under, so the pull request's next push reuses them. + # + # A maintainer may grant the label `beacon-skip-reference` (a reviewed + # decision) when a flow change cannot elaborate the merge base's RTL, + # which would otherwise read REF-FAIL on every push. The label is read + # from the event's payload, so it takes effect on the next push. + - name: Merge base + id: mb + if: matrix.category == 'logic_gate' && github.event_name == 'pull_request' && !contains(github.event.pull_request.labels.*.name, 'beacon-skip-reference') + env: + TARGET: ${{ github.base_ref }} + run: | + set -euo pipefail + git fetch --no-tags origin "+refs/heads/$TARGET:refs/remotes/origin/$TARGET" + base=$(git merge-base HEAD "origin/$TARGET") + flow=$(python3 -c "import sys; sys.path.insert(0, 'ci'); import synth_gate; print(synth_gate.flow_fingerprint('.'))") + echo "merge base: $base (origin/$TARGET), flow $flow" + echo "BEACON_AGAINST_REV=$base" >> "$GITHUB_ENV" + echo "base=$base" >> "$GITHUB_OUTPUT" + echo "flow=$flow" >> "$GITHUB_OUTPUT" + - name: Merge base skipped + if: matrix.category == 'logic_gate' && github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'beacon-skip-reference') + run: | + msg="beacon-skip-reference: the merge-base comparison is SKIPPED by a maintainer's label; logic_gate's verdict is against the baselines only" + echo "::warning title=logic_gate::$msg" + printf '> [!WARNING]\n> %s\n\n' "$msg" >> "$GITHUB_STEP_SUMMARY" + # The newest entry for this merge base and flow; a later save only ever + # adds one with more finished reference builds (see the save below). + - name: Restore the merge base's Beacon builds + id: refcache + if: steps.mb.outputs.base + uses: actions/cache/restore@v4 + with: + path: .beacon_ref + key: beacon-ref-${{ steps.mb.outputs.base }}-${{ steps.mb.outputs.flow }}- + restore-keys: beacon-ref-${{ steps.mb.outputs.base }}-${{ steps.mb.outputs.flow }}- + - name: List the restored reference builds + if: steps.mb.outputs.base + run: python3 -c "import sys; sys.path.insert(0, 'ci'); import synth_gate; print('\n'.join(synth_gate.reference_cache_done('.beacon_ref')))" > "$RUNNER_TEMP/beacon_ref_done" - name: Run cell run: | cd build${{ matrix.xlen }} @@ -309,6 +360,60 @@ jobs: with: name: junit-${{ env.CELL }} path: junit-*.xml + # The gate's verdicts in the job summary, and per build the evidence a + # verdict names: the diff against the merge base, the area by unit, the + # calibrated risk, the deepest paths. + - name: Summarize logic_gate + if: always() && matrix.category == 'logic_gate' + run: | + for r in build${{ matrix.xlen }}/logic_gate.json build${{ matrix.xlen }}/logic_gate_asic.json; do + [ -f "$r" ] && python3 ci/synth_report.py "$r" >> "$GITHUB_STEP_SUMMARY" || true + done + - uses: actions/upload-artifact@v4 + if: always() && matrix.category == 'logic_gate' + with: + name: logic-gate-${{ env.CELL }} + path: | + build${{ matrix.xlen }}/logic_gate*.json + build${{ matrix.xlen }}_logic_gate/hw/syn/xilinx/dut/logic_gate_*/build.log + build${{ matrix.xlen }}_logic_gate/hw/syn/xilinx/dut/logic_gate_*/beacon_*.txt + build${{ matrix.xlen }}_logic_gate/hw/syn/xilinx/dut/logic_gate_*/beacon_*.json + build${{ matrix.xlen }}_logic_gate_asic/hw/syn/yosys/logic_gate_asic_*/build.log + build${{ matrix.xlen }}_logic_gate_asic/hw/syn/yosys/logic_gate_asic_*/beacon_diff.* + build${{ matrix.xlen }}_logic_gate_asic/hw/syn/yosys/logic_gate_asic_*/beacon/report.txt + build${{ matrix.xlen }}_logic_gate_asic/hw/syn/yosys/logic_gate_asic_*/beacon/area.txt + if-no-files-found: ignore + # Saved even when the cell fails, so a pull request's next push reuses + # every reference build that finished. The cache keeps what a later + # comparison reads (end points, instances, area, the stamps); a build + # that did not finish is dropped whole, so it reruns clean. A new entry + # is saved only when the finished set grew past what was restored, keyed + # by that set: cache entries are immutable, and none with fewer builds + # than the one restored is added after it. + - name: Trim the merge base's Beacon builds + id: refsave + if: always() && steps.mb.outputs.base + run: | + python3 - <<'PY' + import os, sys + sys.path.insert(0, "ci") + import synth_gate + synth_gate.trim_reference_cache(".beacon_ref") + with open(os.path.join(os.environ["RUNNER_TEMP"], "beacon_ref_done")) as fh: + before = {line for line in fh.read().splitlines() if line} + after = synth_gate.reference_cache_done(".beacon_ref") + grew = set(after) > before + print("reference builds: %d restored, %d finished%s" + % (len(before), len(after), "" if grew else "; nothing new to save")) + with open(os.environ["GITHUB_OUTPUT"], "a") as fh: + fh.write("id=%s\n" % (synth_gate.reference_cache_id(after) if grew else "")) + PY + - name: Save the merge base's Beacon builds + if: always() && steps.refsave.outputs.id + uses: actions/cache/save@v4 + with: + path: .beacon_ref + key: beacon-ref-${{ steps.mb.outputs.base }}-${{ steps.mb.outputs.flow }}-${{ steps.refsave.outputs.id }} complete: runs-on: ubuntu-22.04 diff --git a/.github/workflows/logic_gate.yml b/.github/workflows/logic_gate.yml index 71f53cd4cb..c93675059a 100644 --- a/.github/workflows/logic_gate.yml +++ b/.github/workflows/logic_gate.yml @@ -10,7 +10,8 @@ # # The gate itself runs in ci.yml, as the logic_gate cell planned with # perf_gate's rtlsim cells. This workflow is the manual entry point: a subset of -# the catalog on a hosted runner, or the full-GPU builds (group gpu), which need +# the catalog on a hosted runner, on the FPGA or the ASIC flow, optionally +# against another revision; or the full-GPU builds (group gpu), which need # ~95 GB per build and run only on the self-hosted machine. # # See docs/designs/continuous_integration.md §4.6. @@ -23,6 +24,13 @@ on: builds: description: "build ids/groups, space separated (blank = all)" default: "" + asic: + description: "measure asic_gate.yaml's builds on the ASIC flow (case gate_asic) instead" + type: boolean + default: false + against: + description: "also compare each build with the same build on this revision's RTL (blank = none)" + default: "" gpu: description: "run the full-GPU builds (group gpu) on the self-hosted machine instead" type: boolean @@ -40,10 +48,14 @@ jobs: if: ${{ !inputs.gpu }} runs-on: ubuntu-22.04 timeout-minutes: 90 + env: + CASE: ${{ inputs.asic && 'gate_asic' || 'gate' }} + REPORT: ${{ inputs.asic && 'logic_gate_asic.json' || 'logic_gate.json' }} steps: - uses: actions/checkout@v4 with: submodules: recursive + fetch-depth: ${{ inputs.against && '0' || '1' }} # Restores the prebuilt toolchain (CIRCT among it) and exports TOOLDIR; # prepare=true installs it on a cache miss. @@ -60,22 +72,24 @@ jobs: ../configure --tooldir=$TOOLDIR ci/toolchain_install.sh --foldsim - # The command is the one the catalog declares (the `gate` case of - # ci/testcases/logic_gate.yaml), so what CI runs and what the catalog - # says cannot drift apart. + # The command is the one the catalog declares (the `gate` or `gate_asic` + # case of ci/testcases/logic_gate.yaml), so what CI runs and what the + # catalog says cannot drift apart. - name: Gate id: run env: IN_BUILDS: ${{ github.event.inputs.builds }} + IN_AGAINST: ${{ github.event.inputs.against }} run: | set -uo pipefail - CMD=$(python3 -c "import yaml; print(next(t['run'] for t in yaml.safe_load(open('ci/testcases/logic_gate.yaml'))['tests'] if t['id'] == 'gate'))") + CMD=$(python3 -c "import os, yaml; print(next(t['run'] for t in yaml.safe_load(open('ci/testcases/logic_gate.yaml'))['tests'] if t['id'] == os.environ['CASE']))") # Dispatch inputs reach the shell through an env var, never # interpolated into the script. ARGS=() for b in ${IN_BUILDS:-}; do ARGS+=(-b "$b"); done + [ -n "${IN_AGAINST:-}" ] && ARGS+=(--against-rev "$IN_AGAINST") rc=0 - $CMD "${ARGS[@]}" --timeout 3600 --report logic_gate.json || rc=$? + $CMD "${ARGS[@]}" --timeout 3600 || rc=$? echo "rc=$rc" >> "$GITHUB_OUTPUT" exit 0 @@ -83,27 +97,31 @@ jobs: if: always() run: | set -uo pipefail - python3 ci/synth_report.py --annotate error logic_gate.json \ + python3 ci/synth_report.py --annotate error "$REPORT" \ > logic_gate_report.md || true cat logic_gate_report.md >> "$GITHUB_STEP_SUMMARY" - uses: actions/upload-artifact@v4 if: always() with: - name: logic-gate + name: logic-gate${{ inputs.asic && '-asic' || '' }} path: | - logic_gate.json + logic_gate*.json logic_gate_report.md build32_logic_gate/hw/syn/xilinx/dut/logic_gate_*/build.log build32_logic_gate/hw/syn/xilinx/dut/logic_gate_*/beacon_* build32_logic_gate/hw/syn/xilinx/dut/logic_gate_*/beacon/report.txt + build32_logic_gate_asic/hw/syn/yosys/logic_gate_asic_*/build.log + build32_logic_gate_asic/hw/syn/yosys/logic_gate_asic_*/beacon_* + build32_logic_gate_asic/hw/syn/yosys/logic_gate_asic_*/beacon/report.txt + build32_logic_gate_asic/hw/syn/yosys/logic_gate_asic_*/beacon/area.txt if-no-files-found: warn - name: Verdict run: | case "${{ steps.run.outputs.rc }}" in 0) echo "logic_gate passed" ;; - 1) echo "::error::logic_gate FAILED — a unit got deeper than its baseline"; exit 1 ;; + 1) echo "::error::logic_gate FAILED — a unit got deeper or the design grew (see the summary)"; exit 1 ;; *) echo "::error::logic_gate build error (see logs)"; exit 1 ;; esac diff --git a/AGENTS.md b/AGENTS.md index da903b39b7..f340ab9813 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -88,9 +88,9 @@ See [docs/testing.md](docs/testing.md) and [docs/debugging.md](docs/debugging.md - **RTL coverage path is `xrt`, not `rtlsim`.** When discussing or planning RTL verification, `xrt` is the canonical path — `rtlsim` bypasses the AFU surface. `rtlsim` remains useful for fast iteration on processor RTL; `xrt` is what proves the full integration. - **`ci/regression.sh` is the canonical source of tested configurations.** Use it to discover supported parameter combinations before inventing ad hoc ones. - **Perf-regression baselines (`ci/baselines/perf/*.json`) are golden data — never hand-edit them, and never "fix" a red perf gate by bumping the number.** They are regenerated only by `pytest ci -m perf_gate --update-baselines` (a human-run, reviewed step), and CI must never pass that flag. A `perf_gate` failure means real cycles moved: root-cause it, or — if the change is intended — regenerate the baseline so the diff shows the perf delta for review. Same rule as image goldens and `known_issue:`. -- **Synthesis baselines (`ci/baselines/synthesis/{xilinx,yosys,beacon}/*.json`) are golden data under the same rule** — never hand-edited, regenerated only by a human running `ci/fpga_gate.py --update-baseline` / `ci/asic_gate.py --update-baseline` / `ci/logic_gate.py --update-baseline`, never by CI. A red `fpga_gate`/`asic_gate` means real Fmax or area moved; a red `logic_gate` means a unit got deeper or the design's area grew past 5 %, and its reasons name the unit or the resource (`beacon_area.txt` has the area by unit and each memory's placement). Note the two gates measure the *same* `hw/unittest/*/VX_*_top.sv` wrappers through different flows, so a divergence between them is a finding, not noise — keep `hw/syn/{xilinx,yosys}/dut/catalog.mk` in step when you add or rename a DUT. See [docs/designs/continuous_integration.md §3.5](docs/designs/continuous_integration.md). -- **Beacon first for any RTL change that can move timing; synthesis only to confirm.** A change to a pipeline, arbiter, queue, interface or datapath can add logic levels that only the nightly `fpga_gate` would find, hours later. Beacon finds them in minutes, so iterate on it, not on Vivado or Yosys: run `ci/logic_gate.py -b ` on the parent revision once (its own build tree, e.g. `git worktree add ../ref HEAD` and `--build-dir build32_beacon_ref`), then `ci/logic_gate.py -b --against build32_beacon_ref` after each edit, and fix what `/beacon_diff.txt` reports until nothing fails (`ci/beacon.py paths` shows a deep unit's paths op by op). Run synthesis once per change, on the DUTs whose depth moved, and feed the result back with `ci/beacon.py validate`. A change to the cluster, socket, L2 or anything only the whole GPU assembles also runs the `gpu` group (`ci/logic_gate.py -b gpu -j 1`, ~30 min and ~95 GB per build). A unit that gets deeper is fixed or, if intended, re-recorded with the reason in the commit message. `beacon_diff.txt` also lists each resource of the design (LUT, FF, distributed and block RAM, DSP) and the units whose area moved, so a memory that leaves block RAM shows in minutes. Beacon does not see wires, placement or congestion; a change that moves those still needs synthesis. See [docs/designs/beacon.md §6.3](docs/designs/beacon.md). -- **`logic_gate` runs with `perf_gate`, and is treated the same way.** CI plans its cell whenever it plans perf_gate's rtlsim cells (every pull request, every push that touches the RTL or the config): perf_gate guards cycles, logic_gate guards logic depth and area. A red logic_gate means a unit got deeper or the design grew; fix it, or re-record with `ci/logic_gate.py --update-baseline` on the final tree, with the reason in the commit message. A change of CIRCT or foldsim reads `STALE` and needs the same re-record. +- **Synthesis baselines (`ci/baselines/synthesis/{xilinx,yosys,beacon,beacon_asic}/*.json`) are golden data under the same rule** — never hand-edited, regenerated only by a human running `ci/fpga_gate.py --update-baseline` / `ci/asic_gate.py --update-baseline` / `ci/logic_gate.py --update-baseline`, never by CI. A red `fpga_gate`/`asic_gate` means real Fmax or area moved; a red `logic_gate` means a unit got deeper or the design's area grew past 5 %, and its reasons name the unit or the resource (`beacon_area.txt` has the area by unit and each memory's placement). Note the two gates measure the *same* `hw/unittest/*/VX_*_top.sv` wrappers through different flows, so a divergence between them is a finding, not noise — keep `hw/syn/{xilinx,yosys}/dut/catalog.mk` in step when you add or rename a DUT. See [docs/designs/continuous_integration.md §3.5](docs/designs/continuous_integration.md). +- **Beacon first for any RTL change that can move timing; synthesis only to confirm.** A change to a pipeline, arbiter, queue, interface or datapath can add logic levels that only the nightly `fpga_gate` would find, hours later. Beacon finds them in minutes, so iterate on it, not on Vivado or Yosys: run `ci/logic_gate.py -b --against-rev HEAD` after each edit (the parent's reference is built once, under `.beacon_ref/`; `--tool beacon_asic` for the ASIC flow, which alone elaborates the STD FPU and the ASIC multiplier), and fix what `/beacon_diff.txt` reports until nothing fails (`ci/beacon.py paths` shows a deep unit's paths op by op). Run synthesis once per change, on the DUTs whose depth moved, and feed the result back with `ci/beacon.py validate`. A change to the cluster, socket, L2 or anything only the whole GPU assembles also runs the `gpu` group (`ci/logic_gate.py -b gpu -j 1`, ~30 min and ~95 GB per build). A unit that gets deeper is fixed or, if intended, re-recorded with the reason in the commit message. `beacon_diff.txt` also lists each resource of the design (LUT, FF, distributed and block RAM, DSP) and the units whose area moved, so a memory that leaves block RAM shows in minutes. Beacon does not see wires, placement or congestion; a change that moves those still needs synthesis. See [docs/designs/beacon.md §6.3](docs/designs/beacon.md). +- **`logic_gate` runs with `perf_gate`, and is treated the same way.** CI plans its cell whenever it plans perf_gate's rtlsim cells (every pull request, every push that touches the RTL or the config): perf_gate guards cycles, logic_gate guards logic depth and area. A red logic_gate means a unit got deeper, the design grew, or a harness changed what it ties off; fix it, or re-record with `ci/logic_gate.py --update-baseline` (and `--tool beacon_asic`) on the final tree, with the reason in the commit message. On a pull request the cell also compares every build with the merge base, so a re-record there must run with `--against-rev $(git merge-base HEAD origin/master)`: that writes the accepted regressions into the baseline, and the baseline diff is their review. A change of CIRCT or foldsim reads `STALE` and needs the same re-record. - **SimX is the RTL's timing model — keep them in lockstep.** Any change that moves RTL cycles (pipeline structure, arbitration, queue depths, cache/memory behavior) must land together with the matching SimX timing-model update, and vice-versa. The `model_parity` CI gate enforces this: a `check: model_parity` case (`ci/testcases/core.yaml` + per-extension parity categories) runs the same app/args/configs on simx and rtlsim and asserts exact retired-instruction match plus cycle agreement within the case tolerance (default 5%). Never widen a tolerance to absorb a divergence — model the behavior. When adding a hardware feature, add or extend a parity case that exercises it. - **When RTL debugging stalls, switch to the SimX-as-oracle pattern.** For numerical bugs, deep pipeline races, or any failure mode where rtlsim is "close but wrong": (1) build/extend the SimX C++ model so it mirrors the *new* RTL architecture and gets to PASS; (2) add matching trace dumps to both SimX and RTL (cycle, FU events, SRAM addresses+data, hazards) — same CSV format on both sides; (3) diff trace files — the first divergence is the bug. Don't keep guessing from output values; localize via trace diff. See [docs/debugging.md](docs/debugging.md#simx-as-oracle-for-rtl-debug). diff --git a/CHANGELOG.md b/CHANGELOG.md index 57c58a52cb..d51123df89 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,7 +40,7 @@ follows the version pins recorded in [VERSION](VERSION) (`VORTEX_VERSION`, DRAM reads -33%. - **Command-processor DMA through the shared LLC (`VX_CFG_CP_LLC_CLIENT`, on by default).** When one LLC serves every core, the CP's transfers enter it on their own client slot, so host transfers need only an L1 flush, not a walk of the whole LLC; transfers - of at least half the LLC write around it. A launch behind DMA writes waits for an L1-only flush token sent on the slot. The runtime + of at least half the LLC write around it. A launch behind DMA writes waits for a device-scope flush token sent on the slot. The runtime sees the new `DMA_LLC_CLIENT` CP capability. *Why:* rtlsim at 2 clusters + L2 + L3: dogfood -30%, multikernel -42.7%; dogfood -64% with an 8 MB L3. - **Foldsim: threaded FPGA simulation of Vortex on the Alveo V80, built on CIRCT.** Every class of identical units (sockets, issue slices, ALUs, FPUs, load-store units) is time-multiplexed through one physical copy, cycle-exact against the RTL, with no Yosys or sv2v: `circt-verilog` imports Vortex, Foldsim's `foldsim-extract-models` / `foldsim-compose` cut it into threaded models joined by one token fabric (Foldsim is its own project on CIRCT, installed by `ci/toolchain_install.sh --foldsim`; [hw/syn/foldsim/](hw/syn/foldsim/)), and the V80's native flow packages it with a latency-bandwidth memory endpoint and a command-queue control block ([hw/rtl/afu/foldsim/](hw/rtl/afu/foldsim/)). `--driver=foldsim` runs it on the card (`TARGET=hw`, VRT + QDMA) or in-process in Verilator (`avedsim`, the default). Vortex's RTL is unchanged: units get plain-port boundaries and instance IDs as ports from a source-to-source pass on the flow's copy ([hw/syn/foldsim/lift_boundaries.py](hw/syn/foldsim/lift_boundaries.py)). See [docs/designs/foldsim.md](docs/designs/foldsim.md). @@ -89,13 +89,15 @@ follows the version pins recorded in [VERSION](VERSION) (`VORTEX_VERSION`, flush token down every memory port and answers once all ports have; every independently buffered write path (each dcache lane, each OM input of the ocache) carries its own token. Read-only caches (icache, tcache, rtcache, rcache) no longer forward flushes. `DBG_FLUSH_STALL` adds random input backpressure to the flush path for stress tests. -- **L1-only flush between launches.** When a single LLC serves every memory client it is the point of coherence, so a launch - boundary cleans only the L1s: `CMD_CACHE_FLUSH` gains an L1-only flag, carried as a flush-token kind that a shared LLC answers - without a walk. Replicated LLCs and LLCs with peer clients (TEX, RTU, RASTER, OM, DXA) still walk. The runtime posts flushes +- **Device-scope flush between launches.** When a single LLC serves every memory client it is the point of coherence, so a launch + boundary cleans only the levels above it. One typed fence operation (`VX_FENCE_ACQ`/`REL`/`SYS`/`IO` in `VX_types.toml`) carries + the cache work from the `CMD_CACHE_FLUSH` header through the `CACHE_FLUSH` DCR write to every flush token, and a shared LLC + answers a device-scope (`ACQ|REL`) token without a walk. Replicated LLCs and LLCs with peer clients (TEX, RTU, RASTER, OM, DXA) still walk. The runtime posts flushes lazily and flushes fully before any device-memory transfer, and device busy stays high until every core write, uncached IO stores included, is visible in memory. *Why:* per-launch flush cost at 4 cores + L2 drops from 2,750 to 180 cycles. -- **Targeted fences.** A memory fence sends an L1-only flush token that the shared LLC answers without a walk. A fence that orders - only device (I/O) accesses decodes as its own LSU op, and its token makes each level drain to its memory ports without walking. +- **Targeted fences.** A memory fence sends its fence operation (acquire, release or both) in a flush token that the shared LLC + answers without a walk. A fence that orders only device (I/O) accesses sends an `IO` token, which makes each level drain to its + memory ports without walking. *Why:* printf, which fences after each device write, runs 13.6x faster on rtlsim at 2 cores + L2. - **LMEM DMA arbitration.** DXA writes into shared memory and the TCU's WGMMA operand reads now share the local-memory DMA port round-robin. DXA had fixed priority and starved the TCU for about 510 cycles per tiled-scatter transfer. *Why:* rtlsim WGMMA with diff --git a/VX_config.toml b/VX_config.toml index 352e6bd3eb..a79426767e 100644 --- a/VX_config.toml +++ b/VX_config.toml @@ -399,9 +399,10 @@ tcu_latency_dsp = "expr: 1 + 8 + clog2(2 * $tcu_tc_k + 1) * 11" tcu_latency_bhf = "expr: 4 + clog2(2 * $tcu_tc_k + 1) * 3" tcu_latency_fpnew = "expr: 14 + clog2(2 * $tcu_tc_k) * 7" tcu_latency_dpi = 4 -# TFR = mul stages + align + accumulate + round: 5 = 2-stage multiply -# (DSP48 PREG on FPGA), 4 = single-cycle multiply used in simulation. -tcu_latency_tfr = "expr: 5 if ($VIVADO or $QUARTUS) else 4" +# TFR = mul stages + align + accumulate + round: 5 = 2-stage multiply, the +# hardware build (DSP48 PREG on FPGA, a product register on ASIC); +# 4 = single-cycle multiply used in simulation. +tcu_latency_tfr = "expr: 5 if ($VIVADO or $QUARTUS or $ASIC) else 4" VX_CFG_TCU_LATENCY = "expr: $tcu_latency_dsp if $VX_CFG_TCU_TYPE_DSP else ($tcu_latency_bhf if $VX_CFG_TCU_TYPE_BHF else ($tcu_latency_fpnew if $VX_CFG_TCU_TYPE_FPNEW else ($tcu_latency_dpi if $VX_CFG_TCU_TYPE_DPI else $tcu_latency_tfr)))" # Tensor throughput divider: the FEDP array holds TC_M x TC_N / ratio dot # products and a micro-op occupies it for `ratio` cycles. A power of two that diff --git a/VX_types.toml b/VX_types.toml index 3bb610637c..4babbab5f2 100644 --- a/VX_types.toml +++ b/VX_types.toml @@ -82,10 +82,21 @@ VX_DCR_BASE_CACHE_FLUSH = 0x000 VX_DCR_BASE_MPM_VALUE = 0x001 VX_DCR_BASE_STATE_END = 0x002 -[cache_flush] -# VX_DCR_BASE_CACHE_FLUSH write value: flush only the levels above the -# last-level cache, which stays the point of coherence for the next kernel. -VX_CACHE_FLUSH_L1_ONLY = 0x10000 +# Fence operation: the cache work a memory fence or a cache flush owes, carried +# by the CMD_CACHE_FLUSH header, the VX_DCR_BASE_CACHE_FLUSH write value and +# every flush token. Device scope ends at the shared last-level cache, system +# scope at memory. +[fence_op] +VX_FENCE_ACQ = 0x1 # acquire: later reads see writes made visible at the scope +VX_FENCE_REL = 0x2 # release: earlier writes reach the scope's point of coherence +VX_FENCE_SYS = 0x4 # system scope +VX_FENCE_IO = 0x8 # also order the non-cacheable (IO) path +VX_FENCE_OP_BITS = 4 +# CMD_CACHE_FLUSH carries its fence operation in the header flags, above the +# flags every command shares. A cache flush, as a command and as the +# VX_DCR_BASE_CACHE_FLUSH write value, is ACQ|REL at device scope or +# ACQ|REL|SYS at system scope; any other value is illegal. +VX_CP_FLUSH_OP_SHIFT = 2 [dcr_mmu] VX_DCR_MMU_STATE_BEGIN = 0x004 diff --git a/ci/baselines/perf/core.json b/ci/baselines/perf/core.json index 00eb37259f..9e35eab6ba 100644 --- a/ci/baselines/perf/core.json +++ b/ci/baselines/perf/core.json @@ -1,23 +1,23 @@ { "core:raycast-nt16:rtlsim": { "32": { - "cycles": 11130596, + "cycles": 7506695, "instrs": 2234919 }, "app": "raycast", "args": "", - "config_hash": "b8c6981a97ccadea", + "config_hash": "55cc313a7e04e175", "configs": "-DVX_CFG_NUM_THREADS=16", "driver": "rtlsim" }, "core:raycast-nt4:rtlsim": { "32": { - "cycles": 20929742, + "cycles": 18395107, "instrs": 5636759 }, "app": "raycast", "args": "", - "config_hash": "c01be3e7a6d583f9", + "config_hash": "dd27d4e019b1ce48", "configs": "-DVX_CFG_NUM_THREADS=4", "driver": "rtlsim" }, @@ -28,7 +28,7 @@ }, "app": "sgemm", "args": "-n128", - "config_hash": "9a2a587319b4b6ff", + "config_hash": "bb3179476f050efd", "configs": "-DVX_CFG_NUM_WARPS=8 -DVX_CFG_NUM_CORES=2 -DVX_CFG_NUM_THREADS=16 -DVX_CFG_L2_ENABLE", "driver": "rtlsim" }, @@ -39,7 +39,7 @@ }, "app": "sgemm", "args": "-n128", - "config_hash": "4779eb308b6a3d8b", + "config_hash": "d7960926dfeeeb1a", "configs": "-DVX_CFG_NUM_WARPS=8 -DVX_CFG_NUM_CORES=2 -DVX_CFG_NUM_THREADS=4 -DVX_CFG_L2_ENABLE", "driver": "rtlsim" }, @@ -50,7 +50,7 @@ }, "app": "sgemm", "args": "-n128", - "config_hash": "c6dd8e74c685a837", + "config_hash": "fa3eb81110539fb3", "configs": "-DVX_CFG_NUM_THREADS=16", "driver": "rtlsim" }, @@ -61,18 +61,18 @@ }, "app": "sgemm", "args": "-n128", - "config_hash": "f059fa051adfdc5b", + "config_hash": "faa73f4f1a81a3d0", "configs": "-DVX_CFG_NUM_THREADS=4", "driver": "rtlsim" }, "core:sgemmx-nt16:rtlsim": { "32": { - "cycles": 1023552, + "cycles": 1019849, "instrs": 266832 }, "app": "sgemmx", "args": "-n128", - "config_hash": "4db5fdf810c124a4", + "config_hash": "5e051358cb6705f1", "configs": "-DVX_CFG_NUM_THREADS=16", "driver": "rtlsim" }, @@ -83,7 +83,7 @@ }, "app": "sgemmx", "args": "-n128", - "config_hash": "06a7a885f48e581c", + "config_hash": "0286292d319c5b4e", "configs": "-DVX_CFG_NUM_THREADS=4", "driver": "rtlsim" }, @@ -94,7 +94,7 @@ }, "app": "sgemv", "args": "-m512 -n512", - "config_hash": "ff06318f7623e442", + "config_hash": "2a1bbb428f8d6870", "configs": "-DVX_CFG_NUM_THREADS=16", "driver": "rtlsim" }, @@ -105,7 +105,7 @@ }, "app": "sgemv", "args": "-m512 -n512", - "config_hash": "0c627fc4764b369d", + "config_hash": "575d72e47c1c0daa", "configs": "-DVX_CFG_NUM_THREADS=4", "driver": "rtlsim" }, @@ -116,7 +116,7 @@ }, "app": "softmax", "args": "-n64", - "config_hash": "df3574042b185c85", + "config_hash": "d656cb5ba22d494f", "configs": "-DVX_CFG_NUM_THREADS=16", "driver": "rtlsim" }, @@ -127,18 +127,18 @@ }, "app": "softmax", "args": "-n64", - "config_hash": "94464970e4cd1c5b", + "config_hash": "f5c775b6c4dbc1cf", "configs": "-DVX_CFG_NUM_THREADS=4", "driver": "rtlsim" }, "core:stencil3d-nt16:rtlsim": { "32": { - "cycles": 2092014, + "cycles": 2091224, "instrs": 888848 }, "app": "stencil3d", "args": "-n32", - "config_hash": "a804702659ffd39b", + "config_hash": "5082708220a3aab3", "configs": "-DVX_CFG_NUM_THREADS=16", "driver": "rtlsim" }, @@ -149,7 +149,7 @@ }, "app": "stencil3d", "args": "-n32", - "config_hash": "32be34a2a2b4ea2d", + "config_hash": "7c57f7380ccb6a94", "configs": "-DVX_CFG_NUM_THREADS=4", "driver": "rtlsim" }, @@ -160,7 +160,7 @@ }, "app": "vecadd", "args": "-n16384", - "config_hash": "480840182f56a552", + "config_hash": "37045d524c1e46ce", "configs": "-DVX_CFG_NUM_THREADS=16", "driver": "rtlsim" }, @@ -171,7 +171,7 @@ }, "app": "vecadd", "args": "-n16384", - "config_hash": "5831ed3e27f15597", + "config_hash": "d353d7d15f65b5fd", "configs": "-DVX_CFG_NUM_THREADS=4", "driver": "rtlsim" } diff --git a/ci/baselines/perf/dxa.json b/ci/baselines/perf/dxa.json index ffa0a2fba5..926c0cef32 100644 --- a/ci/baselines/perf/dxa.json +++ b/ci/baselines/perf/dxa.json @@ -6,7 +6,7 @@ }, "app": "dxa_copy_mcast", "args": "", - "config_hash": "d4a511b0581f21b7", + "config_hash": "902d06551db54908", "configs": "-DVX_CFG_EXT_DXA_ENABLE", "driver": "rtlsim" }, @@ -17,7 +17,7 @@ }, "app": "dxa_copy", "args": "-d1", - "config_hash": "4b9316ca9d0b35f7", + "config_hash": "07394e6aa480a2d8", "configs": "-DVX_CFG_EXT_DXA_ENABLE -DVX_CFG_NUM_THREADS=16", "driver": "rtlsim" }, @@ -28,7 +28,7 @@ }, "app": "dxa_copy", "args": "-d1", - "config_hash": "5ee196af8bf42639", + "config_hash": "2bb76314b3aac79b", "configs": "-DVX_CFG_EXT_DXA_ENABLE -DVX_CFG_NUM_THREADS=4", "driver": "rtlsim" }, @@ -39,7 +39,7 @@ }, "app": "sgemm2_dxa_mcast", "args": "-n128", - "config_hash": "39a0c9828b778fc1", + "config_hash": "cbfcd136a9cbf5f3", "configs": "-DVX_CFG_EXT_DXA_ENABLE -DVX_CFG_NUM_THREADS=16", "driver": "rtlsim" }, @@ -50,7 +50,7 @@ }, "app": "sgemm2_dxa_mcast", "args": "-n128", - "config_hash": "6322a9e16a8b225c", + "config_hash": "4c813805db4d6ceb", "configs": "-DVX_CFG_EXT_DXA_ENABLE -DVX_CFG_NUM_THREADS=4", "driver": "rtlsim" }, @@ -61,7 +61,7 @@ }, "app": "sgemm2_dxa", "args": "-n128 -t4 -m1", - "config_hash": "c00cf17500da51f3", + "config_hash": "dc6a4fb24203f236", "configs": "-DVX_CFG_EXT_DXA_ENABLE -DVX_CFG_NUM_THREADS=16", "driver": "rtlsim" }, @@ -72,7 +72,7 @@ }, "app": "sgemm2_dxa", "args": "-n128 -t4 -m1", - "config_hash": "f569976a86025971", + "config_hash": "c0117149996966a4", "configs": "-DVX_CFG_EXT_DXA_ENABLE -DVX_CFG_NUM_THREADS=4", "driver": "rtlsim" }, @@ -83,7 +83,7 @@ }, "app": "sgemm_tcu_wg_dxa_mcast", "args": "-m 128 -n 128 -k 64", - "config_hash": "0594d82d1ae694cd", + "config_hash": "4578525b3dad120a", "configs": "-DVX_CFG_EXT_TCU_ENABLE -DVX_CFG_EXT_DXA_ENABLE -DVX_CFG_NUM_ALU_BLOCKS=1 -DVX_CFG_NUM_LSU_BLOCKS=1 -DVX_CFG_NUM_FPU_BLOCKS=1 -DVX_CFG_NUM_THREADS=16", "driver": "rtlsim" }, @@ -94,7 +94,7 @@ }, "app": "sgemm_tcu_wg_dxa_mcast", "args": "-m 128 -n 128 -k 64", - "config_hash": "10302ae69ccd6853", + "config_hash": "cf9987cc4e0ec4b6", "configs": "-DVX_CFG_EXT_TCU_ENABLE -DVX_CFG_EXT_DXA_ENABLE -DVX_CFG_NUM_ALU_BLOCKS=1 -DVX_CFG_NUM_LSU_BLOCKS=1 -DVX_CFG_NUM_FPU_BLOCKS=1 -DVX_CFG_NUM_THREADS=4", "driver": "rtlsim" }, @@ -105,7 +105,7 @@ }, "app": "sgemm_tcu_wg_dxa", "args": "-m 128 -n 128 -k 64", - "config_hash": "c117cba295eb7b8f", + "config_hash": "2dfa43c0ffd2af2a", "configs": "-DVX_CFG_ISSUE_WIDTH=4 -DVX_CFG_EXT_TCU_ENABLE -DVX_CFG_TCU_WGMMA_ENABLE -DVX_CFG_EXT_DXA_ENABLE -DWGMMA_NRC=16 -DVX_CFG_NUM_ALU_BLOCKS=1 -DVX_CFG_NUM_LSU_BLOCKS=1 -DVX_CFG_NUM_FPU_BLOCKS=1 -DVX_CFG_NUM_WARPS=8 -DVX_CFG_NUM_THREADS=32", "driver": "rtlsim" }, @@ -116,7 +116,7 @@ }, "app": "sgemm_tcu_wg_sp_dxa", "args": "-m 128 -n 128 -k 128", - "config_hash": "8752070400cc4bad", + "config_hash": "5cb40c33773fc66c", "configs": "-DVX_CFG_ISSUE_WIDTH=4 -DVX_CFG_EXT_TCU_ENABLE -DVX_CFG_TCU_WGMMA_ENABLE -DVX_CFG_TCU_SPARSE_ENABLE -DVX_CFG_EXT_DXA_ENABLE -DWGMMA_NRC=32 -DVX_CFG_NUM_ALU_BLOCKS=1 -DVX_CFG_NUM_LSU_BLOCKS=1 -DVX_CFG_NUM_FPU_BLOCKS=1 -DVX_CFG_NUM_WARPS=8 -DVX_CFG_NUM_THREADS=32", "driver": "rtlsim" } diff --git a/ci/baselines/perf/graphics.json b/ci/baselines/perf/graphics.json index bb7d57ad37..73bb427b9d 100644 --- a/ci/baselines/perf/graphics.json +++ b/ci/baselines/perf/graphics.json @@ -1,34 +1,34 @@ { "graphics:perf_gate-draw3d-mc:rtlsim": { "32": { - "cycles": 517064, + "cycles": 517338, "instrs": 200238 }, "app": "gfx_draw3d", "args": "-w 128 -h 128 -t box.cgltrace -r box_ref_128.png", - "config_hash": "d066e997351d6091", + "config_hash": "89c0128e9ca4f6fd", "configs": "-DVX_CFG_EXT_TEX_ENABLE -DVX_CFG_EXT_RASTER_ENABLE -DVX_CFG_EXT_OM_ENABLE -DVX_CFG_NUM_CORES=2 -DVX_CFG_NUM_THREADS=4 -DVX_CFG_L2_ENABLE", "driver": "rtlsim" }, "graphics:perf_gate-draw3d-nt16:rtlsim": { "32": { - "cycles": 139077, + "cycles": 139072, "instrs": 50917 }, "app": "gfx_draw3d", "args": "-w 128 -h 128 -t box.cgltrace -r box_ref_128.png", - "config_hash": "7f821662bcd9350b", + "config_hash": "e624b9b51f6baef3", "configs": "-DVX_CFG_EXT_TEX_ENABLE -DVX_CFG_EXT_RASTER_ENABLE -DVX_CFG_EXT_OM_ENABLE -DVX_CFG_NUM_THREADS=16", "driver": "rtlsim" }, "graphics:perf_gate-draw3d-nt4:rtlsim": { "32": { - "cycles": 519787, + "cycles": 520421, "instrs": 200238 }, "app": "gfx_draw3d", "args": "-w 128 -h 128 -t box.cgltrace -r box_ref_128.png", - "config_hash": "abeea1f4bd5835b8", + "config_hash": "270685a4f2b573e4", "configs": "-DVX_CFG_EXT_TEX_ENABLE -DVX_CFG_EXT_RASTER_ENABLE -DVX_CFG_EXT_OM_ENABLE -DVX_CFG_NUM_THREADS=4", "driver": "rtlsim" }, @@ -39,7 +39,7 @@ }, "app": "gfx_om", "args": "-w 128 -h 128 -r whitebox_128.png", - "config_hash": "f8b4772627f6694e", + "config_hash": "8f81b9cbea824821", "configs": "-DVX_CFG_EXT_OM_ENABLE -DVX_CFG_NUM_THREADS=16", "driver": "rtlsim" }, @@ -50,29 +50,29 @@ }, "app": "gfx_om", "args": "-w 128 -h 128 -r whitebox_128.png", - "config_hash": "83fe586e0324c98c", + "config_hash": "96b6e6d47c8f0e6f", "configs": "-DVX_CFG_EXT_OM_ENABLE -DVX_CFG_NUM_THREADS=4", "driver": "rtlsim" }, "graphics:perf_gate-raster-nt16:rtlsim": { "32": { - "cycles": 12958, + "cycles": 12912, "instrs": 4028 }, "app": "gfx_raster", "args": "-w 128 -h 128 -t triangle.cgltrace -r triangle_ref_128.png", - "config_hash": "01c927e4cd4d2f16", + "config_hash": "465f2e520f475df5", "configs": "-DVX_CFG_EXT_RASTER_ENABLE -DVX_CFG_NUM_THREADS=16", "driver": "rtlsim" }, "graphics:perf_gate-raster-nt4:rtlsim": { "32": { - "cycles": 49818, + "cycles": 49808, "instrs": 15920 }, "app": "gfx_raster", "args": "-w 128 -h 128 -t triangle.cgltrace -r triangle_ref_128.png", - "config_hash": "5752a6abf8f5525e", + "config_hash": "f672749b1816d04d", "configs": "-DVX_CFG_EXT_RASTER_ENABLE -DVX_CFG_NUM_THREADS=4", "driver": "rtlsim" }, @@ -83,7 +83,7 @@ }, "app": "gfx_tex", "args": "-i toad.png -r toad_ref_f0.png -f 0 -g 0", - "config_hash": "1d6f815855946df8", + "config_hash": "54f35f4d8236a2f5", "configs": "-DVX_CFG_EXT_TEX_ENABLE -DVX_CFG_NUM_THREADS=16", "driver": "rtlsim" }, @@ -94,7 +94,7 @@ }, "app": "gfx_tex", "args": "-i toad.png -r toad_ref_f0.png -f 0 -g 0", - "config_hash": "dd425127b83cf5d7", + "config_hash": "dba2310b8ed2bc68", "configs": "-DVX_CFG_EXT_TEX_ENABLE -DVX_CFG_NUM_THREADS=4", "driver": "rtlsim" } diff --git a/ci/baselines/perf/raytracing.json b/ci/baselines/perf/raytracing.json index 91995894eb..75021c4780 100644 --- a/ci/baselines/perf/raytracing.json +++ b/ci/baselines/perf/raytracing.json @@ -1,34 +1,34 @@ { "raytracing:perf_gate-rt_raycast-mc:rtlsim": { "32": { - "cycles": 83800, + "cycles": 75908, "instrs": 39346 }, "app": "rt_raycast", "args": "", - "config_hash": "acf96f38d26b37ee", + "config_hash": "926004202e1230cc", "configs": "-DVX_CFG_EXT_RTU_ENABLE -DVX_CFG_NUM_CORES=2 -DVX_CFG_NUM_THREADS=4 -DVX_CFG_L2_ENABLE", "driver": "rtlsim" }, "raytracing:perf_gate-rt_raycast-nt16:rtlsim": { "32": { - "cycles": 52892, + "cycles": 50995, "instrs": 11372 }, "app": "rt_raycast", "args": "", - "config_hash": "f219bd68b8919361", + "config_hash": "cde0e92d03a53a87", "configs": "-DVX_CFG_EXT_RTU_ENABLE -DVX_CFG_NUM_THREADS=16", "driver": "rtlsim" }, "raytracing:perf_gate-rt_raycast-nt4:rtlsim": { "32": { - "cycles": 157980, + "cycles": 147867, "instrs": 39330 }, "app": "rt_raycast", "args": "", - "config_hash": "917af3d6cb8141f1", + "config_hash": "fffab4e1c8cfe28a", "configs": "-DVX_CFG_EXT_RTU_ENABLE -DVX_CFG_NUM_THREADS=4", "driver": "rtlsim" } diff --git a/ci/baselines/perf/tensor.json b/ci/baselines/perf/tensor.json index 7915568887..3c907caa8b 100644 --- a/ci/baselines/perf/tensor.json +++ b/ci/baselines/perf/tensor.json @@ -1,45 +1,45 @@ { "tensor:perf_gate-fp16-isw4:rtlsim": { "32": { - "cycles": 158780, + "cycles": 156748, "instrs": 129824 }, "app": "sgemm_tcu", "args": "-m 128 -n 128 -k 128", - "config_hash": "a7561a368b57a589", + "config_hash": "4fbb4f6c32f0fac9", "configs": "-DVX_CFG_NUM_THREADS=8 -DVX_CFG_NUM_WARPS=8 -DVX_CFG_ISSUE_WIDTH=4 -DVX_CFG_EXT_TCU_ENABLE -DITYPE=fp16 -DOTYPE=fp32 -DVX_CFG_NUM_ALU_BLOCKS=1 -DVX_CFG_NUM_LSU_BLOCKS=1 -DVX_CFG_NUM_FPU_BLOCKS=1", "driver": "rtlsim" }, "tensor:perf_gate-fp16-mc-nt16:rtlsim": { "32": { - "cycles": 37191, + "cycles": 36319, "instrs": 46912 }, "app": "sgemm_tcu", "args": "-m 128 -n 128 -k 128", - "config_hash": "b9e30456c7f28a6b", + "config_hash": "2dcf0a1b4eea6c29", "configs": "-DVX_CFG_NUM_WARPS=8 -DVX_CFG_EXT_TCU_ENABLE -DITYPE=fp16 -DOTYPE=fp32 -DVX_CFG_NUM_CORES=2 -DVX_CFG_NUM_THREADS=16 -DVX_CFG_L2_ENABLE", "driver": "rtlsim" }, "tensor:perf_gate-fp16-mc-nt4:rtlsim": { "32": { - "cycles": 219517, + "cycles": 219890, "instrs": 334912 }, "app": "sgemm_tcu", "args": "-m 128 -n 128 -k 128", - "config_hash": "1024fbfdcdc8ddfe", + "config_hash": "234a9a6ed54055b5", "configs": "-DVX_CFG_NUM_WARPS=8 -DVX_CFG_EXT_TCU_ENABLE -DITYPE=fp16 -DOTYPE=fp32 -DVX_CFG_NUM_CORES=2 -DVX_CFG_NUM_THREADS=4 -DVX_CFG_L2_ENABLE", "driver": "rtlsim" }, "tensor:perf_gate-fp16:rtlsim": { "32": { - "cycles": 245149, + "cycles": 246051, "instrs": 129808 }, "app": "sgemm_tcu", "args": "-m 128 -n 128 -k 128", - "config_hash": "82bd11eb91545e71", + "config_hash": "1a511d0897922770", "configs": "-DVX_CFG_NUM_THREADS=8 -DVX_CFG_EXT_TCU_ENABLE -DITYPE=fp16 -DOTYPE=fp32", "driver": "rtlsim" }, @@ -50,7 +50,7 @@ }, "app": "sgemm2_tcu", "args": "-m 128 -n 128 -k 64", - "config_hash": "f99117358868d147", + "config_hash": "2a6b68d4c73246ad", "configs": "-DVX_CFG_NUM_THREADS=8 -DVX_CFG_NUM_WARPS=8 -DVX_CFG_ISSUE_WIDTH=4 -DVX_CFG_EXT_TCU_ENABLE -DITYPE=fp16 -DOTYPE=fp32 -DVX_CFG_NUM_ALU_BLOCKS=1 -DVX_CFG_NUM_LSU_BLOCKS=1 -DVX_CFG_NUM_FPU_BLOCKS=1", "driver": "rtlsim" } diff --git a/ci/baselines/perf/tensor_mx.json b/ci/baselines/perf/tensor_mx.json index ea2521a7df..a22d3341af 100644 --- a/ci/baselines/perf/tensor_mx.json +++ b/ci/baselines/perf/tensor_mx.json @@ -1,12 +1,12 @@ { "tensor_mx:perf_gate-mxfp8:rtlsim": { "32": { - "cycles": 76299, + "cycles": 76260, "instrs": 36112 }, "app": "sgemm_tcu_mx", "args": "-m 128 -n 128 -k32", - "config_hash": "510fb15505c2186c", + "config_hash": "2d2b1b822bd13001", "configs": "-DVX_CFG_NUM_THREADS=8 -DVX_CFG_EXT_TCU_ENABLE -DVX_CFG_TCU_MX_ENABLE -DVX_CFG_TCU_FP8_ENABLE -DITYPE=mxfp8 -DOTYPE=fp32 -DVX_CFG_TCU_TYPE_DPI", "driver": "rtlsim" } diff --git a/ci/baselines/perf/tensor_sp.json b/ci/baselines/perf/tensor_sp.json index 18a11f1abe..715eea6d87 100644 --- a/ci/baselines/perf/tensor_sp.json +++ b/ci/baselines/perf/tensor_sp.json @@ -6,7 +6,7 @@ }, "app": "sgemm_tcu_sp", "args": "-m 128 -n 128 -k 128", - "config_hash": "d0478f5845022094", + "config_hash": "3f34e8ee3f7f7e13", "configs": "-DVX_CFG_NUM_THREADS=8 -DVX_CFG_EXT_TCU_ENABLE -DVX_CFG_TCU_SPARSE_ENABLE", "driver": "rtlsim" } diff --git a/ci/baselines/perf/tensor_wg.json b/ci/baselines/perf/tensor_wg.json index d0e015b3db..561ab5adac 100644 --- a/ci/baselines/perf/tensor_wg.json +++ b/ci/baselines/perf/tensor_wg.json @@ -6,7 +6,7 @@ }, "app": "sgemm_tcu_wg", "args": "-m64 -n64 -k64", - "config_hash": "efde633399f4c558", + "config_hash": "242cd0e42b1e6d8d", "configs": "-DVX_CFG_NUM_THREADS=8 -DVX_CFG_NUM_WARPS=8 -DVX_CFG_ISSUE_WIDTH=4 -DVX_CFG_EXT_TCU_ENABLE -DVX_CFG_TCU_WGMMA_ENABLE -DVX_CFG_NUM_ALU_BLOCKS=1 -DVX_CFG_NUM_LSU_BLOCKS=1 -DVX_CFG_NUM_FPU_BLOCKS=1 -DVX_CFG_TCU_FEDP2K -DITYPE=fp16 -DOTYPE=fp32 -DWGMMA_NRC=8 -DWGMMA_RS", "driver": "rtlsim" }, @@ -17,7 +17,7 @@ }, "app": "sgemm_tcu_wg", "args": "-m 128 -n 128 -k 128", - "config_hash": "bc6a525dae9193f4", + "config_hash": "731fefa477a89198", "configs": "-DVX_CFG_NUM_THREADS=8 -DVX_CFG_NUM_WARPS=8 -DVX_CFG_ISSUE_WIDTH=4 -DVX_CFG_EXT_TCU_ENABLE -DVX_CFG_TCU_WGMMA_ENABLE -DITYPE=fp16 -DOTYPE=fp32 -DWGMMA_NRC=32 -DWGMMA_SS -DVX_CFG_NUM_ALU_BLOCKS=1 -DVX_CFG_NUM_LSU_BLOCKS=1 -DVX_CFG_NUM_FPU_BLOCKS=1", "driver": "rtlsim" }, @@ -28,7 +28,7 @@ }, "app": "sgemm_tcu_wg_sp", "args": "-m 128 -n 128 -k 128", - "config_hash": "e4b8228c0dca994e", + "config_hash": "b5b5adc71557d418", "configs": "-DVX_CFG_NUM_THREADS=8 -DVX_CFG_NUM_WARPS=8 -DVX_CFG_ISSUE_WIDTH=4 -DVX_CFG_EXT_TCU_ENABLE -DVX_CFG_TCU_WGMMA_ENABLE -DVX_CFG_TCU_SPARSE_ENABLE -DWGMMA_NRC=32 -DVX_CFG_NUM_ALU_BLOCKS=1 -DVX_CFG_NUM_LSU_BLOCKS=1 -DVX_CFG_NUM_FPU_BLOCKS=1", "driver": "rtlsim" } diff --git a/ci/baselines/synthesis/beacon/core.json b/ci/baselines/synthesis/beacon/core.json index ce8254476e..63f907709a 100644 --- a/ci/baselines/synthesis/beacon/core.json +++ b/ci/baselines/synthesis/beacon/core.json @@ -36,6 +36,8 @@ "max_levels": 16, "pred_fmax_mhz": 291.3, "risk_endpoints": 4, + "tied_bits": 0, + "tied_ports": [], "units": { "": 11, "cache/g_cache_cache/core_req_xbar/g_multi_inputs_g_multiple_outputs_g_xbar_arbs_*_xbar_arb/g_input_select_g_arbiter_arbiter/g_round_robin_rr_arbiter": 9, @@ -117,6 +119,19 @@ "max_levels": 15, "pred_fmax_mhz": 285.6, "risk_endpoints": 11, + "tied_bits": 2, + "tied_ports": [ + { + "bits": 1, + "port": "core.core_id", + "width": 1 + }, + { + "bits": 1, + "port": "core.dcache_path_drained", + "width": 1 + } + ], "units": { "core/g_compute_slices_g_slices_*_compute_slice/backend_slice/execute_slice/alu_block/alu_int/rsp_buf/g_eb1_pipe_buffer/g_register_g_pipe_regs_*_pipe_register": 13, "core/g_compute_slices_g_slices_*_compute_slice/backend_slice/execute_slice/alu_block/muldiv_unit/g_multiplier_*_multiplier/pipe_reg": 8, @@ -195,6 +210,14 @@ "max_levels": 9, "pred_fmax_mhz": 324.3, "risk_endpoints": 0, + "tied_bits": 17, + "tied_ports": [ + { + "bits": 17, + "port": "dma_req_buf.data_in", + "width": 607 + } + ], "units": { "lmem_unit/g_data_store_*_g_dual_port_lmem_store": 9 }, @@ -253,6 +276,39 @@ "max_levels": 23, "pred_fmax_mhz": 268.8, "risk_endpoints": 187, + "tied_bits": 6, + "tied_ports": [ + { + "bits": 1, + "port": "__buffer_ex496.enable", + "width": 1 + }, + { + "bits": 1, + "port": "g_clusters_0.cluster.cluster_id", + "width": 1 + }, + { + "bits": 1, + "port": "g_clusters_0.cluster.cp_mem_if_req_valid", + "width": 1 + }, + { + "bits": 1, + "port": "g_clusters_0.cluster.cp_mem_if_rsp_ready", + "width": 1 + }, + { + "bits": 1, + "port": "g_clusters_0.cluster.dev_ptw_mem_if_req_valid", + "width": 1 + }, + { + "bits": 1, + "port": "g_clusters_0.cluster.dev_ptw_mem_if_rsp_ready", + "width": 1 + } + ], "units": { "dev_ptw/walk_cache": 8, "g_clusters_*_cluster/__buffer_ex645": 8, diff --git a/ci/baselines/synthesis/beacon/dxa.json b/ci/baselines/synthesis/beacon/dxa.json index 5ab16b9eaa..2e22b25e36 100644 --- a/ci/baselines/synthesis/beacon/dxa.json +++ b/ci/baselines/synthesis/beacon/dxa.json @@ -36,6 +36,14 @@ "max_levels": 15, "pred_fmax_mhz": 298.6, "risk_endpoints": 0, + "tied_bits": 1, + "tied_ports": [ + { + "bits": 1, + "port": "dxa_core.smem_bus_if_0_rsp_valid", + "width": 1 + } + ], "units": { "dxa_core/desc_table/desc_store": 8, "dxa_core/g_workers_*_worker/addr_gen": 15, diff --git a/ci/baselines/synthesis/beacon/graphics.json b/ci/baselines/synthesis/beacon/graphics.json index 6eaf5e90b9..4fd2f3a012 100644 --- a/ci/baselines/synthesis/beacon/graphics.json +++ b/ci/baselines/synthesis/beacon/graphics.json @@ -1,13 +1,30 @@ { "gfx": { + "accepted": { + "against": "26d2bc4b5409a35a111e8316ac3a87d07b15fc80", + "regressions": [ + { + "after": 14, + "before": null, + "kind": "new", + "name": "graphics/g_raster_core_0.raster_core/raster_slices_0.raster_earlyz/quad_zprod.d" + }, + { + "after": 1071, + "before": 1073, + "kind": "ties", + "name": "tied_bits" + } + ] + }, "clock_mhz": 250, "config_hash": "d39e5baadbeea03c", "configs": "-DVX_CFG_NUM_THREADS=16 -DVX_CFG_NUM_WARPS=16", "dut": "gfx", "result": { "bram": 183.5, - "build_time_s": 166, - "deep_endpoints": 1818, + "build_time_s": 155, + "deep_endpoints": 1738, "deepest_paths": [ "19 g_rtu_core_0.rtu_core/scheduler/g_recip_pe.recip_tags/g_shift.g_partial_reset.pipe_free[219] -> g_rtu_core_0.rtu_core/scheduler/g1_idx.d[4]", "19 g_rtu_core_0.rtu_core/scheduler/g_recip_pe.recip_tags/g_shift.g_partial_reset.pipe_free[219] -> g_rtu_core_0.rtu_core/scheduler/lvl_q_arr.ra[4]", @@ -21,21 +38,59 @@ "18 g_rtu_core_0.rtu_core/scheduler/g_recip_pe.recip_tags/g_shift.g_partial_reset.pipe_free[219] -> g_rtu_core_0.rtu_core/scheduler/ctx_arbiter/g_model1.reqs_mask.d[29]" ], "dsp": 1140, - "endpoints": 314111, + "endpoints": 314280, "env": { "circt": "CIRCT 892a65a01", "device": "xcu55c-fsvh2892-2L-e", "foldsim": "foldsim d8350bc0f", "xlen": 32 }, - "ff": 400294, + "ff": 400445, "fix_levels": 12, "interfaces": {}, - "lut": 319599, + "lut": 319803, "lutram": 14119, "max_levels": 19, "pred_fmax_mhz": 264.7, "risk_endpoints": 471, + "tied_bits": 1071, + "tied_ports": [ + { + "bits": 533, + "port": "g_mem_bus_if_0.g_i0.mem_arb.bus_in_if_0_req_data", + "width": 636 + }, + { + "bits": 533, + "port": "g_mem_bus_if_0.g_i0.mem_arb.bus_in_if_4_req_data", + "width": 636 + }, + { + "bits": 1, + "port": "graphics.cluster_id", + "width": 1 + }, + { + "bits": 1, + "port": "rtu_socket_arb.bus_in_if_0_arm_data", + "width": 120 + }, + { + "bits": 1, + "port": "rtu_socket_arb.bus_in_if_0_req_data", + "width": 550 + }, + { + "bits": 1, + "port": "rtu_socket_arb.bus_in_if_1_arm_data", + "width": 120 + }, + { + "bits": 1, + "port": "rtu_socket_arb.bus_in_if_1_req_data", + "width": 550 + } + ], "units": { "g_rtu_core_*_rtu_core": 10, "g_rtu_core_*_rtu_core/cache_bus_reg/req_buf/g_eb2_stream_buffer": 10, @@ -72,7 +127,7 @@ "graphics/g_om_steer_*_steer_pending": 9, "graphics/g_raster_core_*_raster_core/packer": 8, "graphics/g_raster_core_*_raster_core/raster_mem": 14, - "graphics/g_raster_core_*_raster_core/raster_slices_*_raster_earlyz": 16, + "graphics/g_raster_core_*_raster_core/raster_slices_*_raster_earlyz": 14, "graphics/g_raster_core_*_raster_core/raster_slices_*_raster_slice/block_evaluator/pipe_reg": 9, "graphics/g_raster_core_*_raster_core/raster_slices_*_raster_slice/block_evaluator/quad_evaluator/pipe_reg": 12, "graphics/g_raster_core_*_raster_core/raster_slices_*_raster_slice/tile_evaluator/g_fifo_queue_*_fifo_queue/g_ebN_fifo_queue/g_depth_n_dp_ram": 8, @@ -129,19 +184,36 @@ "tcache/g_cache_wrap_*_cache_wrap/g_cache_cache/g_banks_*_bank/reg_s1": 10 }, "uram": 0, - "watch_endpoints": 17383, + "watch_endpoints": 17007, "watch_levels": 8 } }, "gfxvm": { + "accepted": { + "against": "26d2bc4b5409a35a111e8316ac3a87d07b15fc80", + "regressions": [ + { + "after": 14, + "before": null, + "kind": "new", + "name": "graphics/g_raster_core_0.raster_core/raster_slices_0.raster_earlyz/quad_zprod.d" + }, + { + "after": 1073, + "before": 1075, + "kind": "ties", + "name": "tied_bits" + } + ] + }, "clock_mhz": 250, "config_hash": "dda6e15b71ddde55", "configs": "-DVX_CFG_NUM_THREADS=16 -DVX_CFG_NUM_WARPS=16", "dut": "gfxvm", "result": { "bram": 183.5, - "build_time_s": 196, - "deep_endpoints": 1969, + "build_time_s": 160, + "deep_endpoints": 1889, "deepest_paths": [ "19 g_rtu_core_0.rtu_core/scheduler/g_recip_pe.recip_tags/g_shift.g_partial_reset.pipe_free[219] -> g_rtu_core_0.rtu_core/scheduler/g1_idx.d[4]", "19 g_rtu_core_0.rtu_core/scheduler/g_recip_pe.recip_tags/g_shift.g_partial_reset.pipe_free[219] -> g_rtu_core_0.rtu_core/scheduler/lvl_q_arr.ra[4]", @@ -155,21 +227,69 @@ "18 g_rtu_core_0.rtu_core/scheduler/g_recip_pe.recip_tags/g_shift.g_partial_reset.pipe_free[219] -> g_rtu_core_0.rtu_core/scheduler/ctx_arbiter/g_model1.reqs_mask.d[29]" ], "dsp": 1140, - "endpoints": 328768, + "endpoints": 328937, "env": { "circt": "CIRCT 892a65a01", "device": "xcu55c-fsvh2892-2L-e", "foldsim": "foldsim d8350bc0f", "xlen": 32 }, - "ff": 415143, + "ff": 415294, "fix_levels": 12, "interfaces": {}, - "lut": 330949, + "lut": 331144, "lutram": 14557, "max_levels": 19, "pred_fmax_mhz": 256.3, "risk_endpoints": 475, + "tied_bits": 1073, + "tied_ports": [ + { + "bits": 533, + "port": "g_mem_bus_if_0.g_i0.mem_arb.bus_in_if_0_req_data", + "width": 636 + }, + { + "bits": 533, + "port": "ummu.core_bus_if_2_req_data", + "width": 636 + }, + { + "bits": 1, + "port": "graphics.cluster_id", + "width": 1 + }, + { + "bits": 1, + "port": "l2cache.core_bus_if_3_req_valid", + "width": 1 + }, + { + "bits": 1, + "port": "l2cache.core_bus_if_3_rsp_ready", + "width": 1 + }, + { + "bits": 1, + "port": "rtu_socket_arb.bus_in_if_0_arm_data", + "width": 120 + }, + { + "bits": 1, + "port": "rtu_socket_arb.bus_in_if_0_req_data", + "width": 550 + }, + { + "bits": 1, + "port": "rtu_socket_arb.bus_in_if_1_arm_data", + "width": 120 + }, + { + "bits": 1, + "port": "rtu_socket_arb.bus_in_if_1_req_data", + "width": 550 + } + ], "units": { "": 8, "cmmu": 9, @@ -212,7 +332,7 @@ "graphics/g_om_steer_*_steer_pending": 9, "graphics/g_raster_core_*_raster_core/packer": 8, "graphics/g_raster_core_*_raster_core/raster_mem": 14, - "graphics/g_raster_core_*_raster_core/raster_slices_*_raster_earlyz": 16, + "graphics/g_raster_core_*_raster_core/raster_slices_*_raster_earlyz": 14, "graphics/g_raster_core_*_raster_core/raster_slices_*_raster_slice/block_evaluator/pipe_reg": 9, "graphics/g_raster_core_*_raster_core/raster_slices_*_raster_slice/block_evaluator/quad_evaluator/pipe_reg": 12, "graphics/g_raster_core_*_raster_core/raster_slices_*_raster_slice/tile_evaluator/g_fifo_queue_*_fifo_queue/g_ebN_fifo_queue/g_depth_n_dp_ram": 8, @@ -278,7 +398,7 @@ "ummu/tlb/mshr/reqpool": 10 }, "uram": 0, - "watch_endpoints": 18681, + "watch_endpoints": 18305, "watch_levels": 8 } }, @@ -319,6 +439,19 @@ "max_levels": 13, "pred_fmax_mhz": 364.6, "risk_endpoints": 0, + "tied_bits": 3, + "tied_ports": [ + { + "bits": 2, + "port": "om_core.om_bus_if_req_data", + "width": 59 + }, + { + "bits": 1, + "port": "om_core.dcr_bus_if_req_data", + "width": 45 + } + ], "units": { "om_core": 8, "om_core/mem_req_buf/g_ebN_fifo_queue/pending_size": 8, @@ -370,6 +503,19 @@ "max_levels": 14, "pred_fmax_mhz": 332.9, "risk_endpoints": 0, + "tied_bits": 2, + "tied_ports": [ + { + "bits": 1, + "port": "raster_core.dcr_bus_if_req_data", + "width": 45 + }, + { + "bits": 1, + "port": "raster_core.instance_idx", + "width": 1 + } + ], "units": { "raster_core/packer": 8, "raster_core/raster_mem": 14, @@ -420,6 +566,8 @@ "max_levels": 15, "pred_fmax_mhz": 304.5, "risk_endpoints": 0, + "tied_bits": 0, + "tied_ports": [], "units": { "rtu_core": 10, "rtu_core/cache_bus_reg/req_buf/g_eb2_stream_buffer": 9, @@ -447,7 +595,7 @@ "dut": "tex", "result": { "bram": 0.0, - "build_time_s": 60, + "build_time_s": 70, "deep_endpoints": 0, "deepest_paths": [ "11 tex_core/tex_addr/pipe_reg0/g_pipe.g_partial_reset.pipe_free[4197] -> tex_core/tex_addr/pipe_reg1/g_pipe.g_partial_reset.pipe_free.d[831]", @@ -477,6 +625,14 @@ "max_levels": 11, "pred_fmax_mhz": 292.6, "risk_endpoints": 2, + "tied_bits": 1, + "tied_ports": [ + { + "bits": 1, + "port": "tex_core.dcr_bus_if_req_data", + "width": 45 + } + ], "units": { "tex_core/tex_addr/pipe_reg0": 10, "tex_core/tex_addr/pipe_reg1": 11, diff --git a/ci/baselines/synthesis/beacon/tensor.json b/ci/baselines/synthesis/beacon/tensor.json index 2126ee506b..78b4e48cc7 100644 --- a/ci/baselines/synthesis/beacon/tensor.json +++ b/ci/baselines/synthesis/beacon/tensor.json @@ -36,6 +36,8 @@ "max_levels": 25, "pred_fmax_mhz": 277.7, "risk_endpoints": 17, + "tied_bits": 0, + "tied_ports": [], "units": { "tcu_shared/wgmma": 10, "tcu_shared/wgmma/tbuf/bbuf": 10, @@ -60,14 +62,25 @@ } }, "tensor": { + "accepted": { + "against": "26d2bc4b5409a35a111e8316ac3a87d07b15fc80", + "regressions": [ + { + "after": 4, + "before": 6, + "kind": "ties", + "name": "tied_bits" + } + ] + }, "clock_mhz": 250, "config_hash": "f4269536f1b2647b", "configs": "-DVX_CFG_NUM_THREADS=16 -DVX_CFG_NUM_WARPS=16", "dut": "tensor", "result": { "bram": 114.5, - "build_time_s": 110, - "deep_endpoints": 4737, + "build_time_s": 85, + "deep_endpoints": 4761, "deepest_paths": [ "25 g_cores_0.tcu_unit/g_blocks_0.tcu_block/tcu_core/g_i_0.g_j_0.fedp/pipe_acc/g_pipe.g_no_reset.pipe[39] -> g_cores_0.tcu_unit/g_blocks_0.tcu_block/tcu_core/g_i_0.g_j_0.fedp/pipe_norm_round/g_pipe.g_no_reset.pipe.d[14]", "25 g_cores_0.tcu_unit/g_blocks_0.tcu_block/tcu_core/g_i_0.g_j_0.fedp/pipe_acc/g_pipe.g_no_reset.pipe[39] -> g_cores_0.tcu_unit/g_blocks_0.tcu_block/tcu_core/g_i_0.g_j_0.fedp/pipe_norm_round/g_pipe.g_no_reset.pipe.d[17]", @@ -81,21 +94,44 @@ "25 g_cores_0.tcu_unit/g_blocks_0.tcu_block/tcu_core/g_i_0.g_j_1.fedp/pipe_acc/g_pipe.g_no_reset.pipe[39] -> g_cores_0.tcu_unit/g_blocks_0.tcu_block/tcu_core/g_i_0.g_j_1.fedp/pipe_norm_round/g_pipe.g_no_reset.pipe.d[18]" ], "dsp": 267, - "endpoints": 170624, + "endpoints": 170647, "env": { "circt": "CIRCT 892a65a01", "device": "xcu55c-fsvh2892-2L-e", "foldsim": "foldsim d8350bc0f", "xlen": 32 }, - "ff": 161523, + "ff": 161531, "fix_levels": 12, "interfaces": {}, - "lut": 260189, + "lut": 259747, "lutram": 12672, "max_levels": 25, "pred_fmax_mhz": 253.4, "risk_endpoints": 411, + "tied_bits": 4, + "tied_ports": [ + { + "bits": 1, + "port": "g_cores_0.mem_unit.dcr_flush_if_req", + "width": 1 + }, + { + "bits": 1, + "port": "g_cores_1.mem_unit.dcr_flush_if_req", + "width": 1 + }, + { + "bits": 1, + "port": "g_mem_bus_if_0.g_i0.mem_arb.bus_in_if_0_req_valid", + "width": 1 + }, + { + "bits": 1, + "port": "g_mem_bus_if_0.g_i0.mem_arb.bus_in_if_0_rsp_ready", + "width": 1 + } + ], "units": { "dcache/g_cache_wrap_*_cache_wrap/g_cache_cache/g_banks_*_bank/cache_data/g_data_slice_*_data_store": 9, "dcache/g_cache_wrap_*_cache_wrap/g_cache_cache/g_banks_*_bank/cache_mshr": 9, @@ -162,7 +198,7 @@ "l2cache/g_cache_cache/g_core_req_skid_*_req_skid": 9 }, "uram": 0, - "watch_endpoints": 26226, + "watch_endpoints": 26346, "watch_levels": 8 } } diff --git a/ci/baselines/synthesis/beacon/vm.json b/ci/baselines/synthesis/beacon/vm.json index 2cf7e28295..79e7e301e0 100644 --- a/ci/baselines/synthesis/beacon/vm.json +++ b/ci/baselines/synthesis/beacon/vm.json @@ -36,6 +36,39 @@ "max_levels": 23, "pred_fmax_mhz": 251.5, "risk_endpoints": 573, + "tied_bits": 118, + "tied_ports": [ + { + "bits": 57, + "port": "g_sockets_0.g_immu.immu.core_bus_if_0_req_data", + "width": 93 + }, + { + "bits": 57, + "port": "g_sockets_1.g_immu.immu.core_bus_if_0_req_data", + "width": 93 + }, + { + "bits": 1, + "port": "g_sockets_0.mmu_snoop.dcr_bus_out_if_rsp_valid", + "width": 1 + }, + { + "bits": 1, + "port": "g_sockets_1.mmu_snoop.dcr_bus_out_if_rsp_valid", + "width": 1 + }, + { + "bits": 1, + "port": "l2cache.core_bus_if_2_req_valid", + "width": 1 + }, + { + "bits": 1, + "port": "l2cache.core_bus_if_2_rsp_ready", + "width": 1 + } + ], "units": { "g_sockets_*_dcache/g_cache_wrap_*_cache_wrap/g_bypass_cache_bypass/mem_bus_out_arb/req_arb/g_input_select_g_arbiter_g_out_buf_*_out_buf/g_eb2_stream_buffer": 8, "g_sockets_*_dcache/g_cache_wrap_*_cache_wrap/g_cache_cache/cache_init": 10, diff --git a/ci/baselines/synthesis/beacon_asic/core.json b/ci/baselines/synthesis/beacon_asic/core.json new file mode 100644 index 0000000000..c26d1de552 --- /dev/null +++ b/ci/baselines/synthesis/beacon_asic/core.json @@ -0,0 +1,174 @@ +{ + "cache": { + "clock_mhz": 1000, + "config_hash": "77b79d6c7d9a6fdf", + "configs": "", + "dut": "cache", + "result": { + "build_time_s": 25, + "cells": 282062, + "endpoints": 32478, + "env": { + "circt": "CIRCT 892a65a01", + "foldsim": "foldsim d8350bc0f", + "pdk": "asap7", + "xlen": 32 + }, + "ff": 93166, + "fmax_mhz": 1107.4, + "macros": 36, + "max_stages": 28, + "overhead_ps": 231, + "period_ps": 903, + "stage_ps": 24, + "tied_bits": 0, + "tied_ports": [] + } + }, + "core": { + "clock_mhz": 1000, + "config_hash": "847ad31605be03dd", + "configs": "-DVX_CFG_NUM_THREADS=8 -DVX_CFG_NUM_WARPS=8", + "dut": "core", + "result": { + "build_time_s": 60, + "cells": 769936, + "endpoints": 73708, + "env": { + "circt": "CIRCT 892a65a01", + "foldsim": "foldsim d8350bc0f", + "pdk": "asap7", + "xlen": 32 + }, + "ff": 102791, + "fmax_mhz": 1051.5, + "macros": 16, + "max_stages": 30, + "overhead_ps": 231, + "period_ps": 951, + "stage_ps": 24, + "tied_bits": 2, + "tied_ports": [ + { + "bits": 1, + "port": "core.core_id", + "width": 1 + }, + { + "bits": 1, + "port": "core.dcache_path_drained", + "width": 1 + } + ] + } + }, + "lmem": { + "clock_mhz": 1000, + "config_hash": "8190e614d4e4d3b6", + "configs": "-DVX_CFG_NUM_THREADS=16 -DVX_CFG_ISSUE_WIDTH=2 -DVX_CFG_EXT_A_ENABLE", + "dut": "lmem", + "result": { + "build_time_s": 25, + "cells": 120110, + "endpoints": 18134, + "env": { + "circt": "CIRCT 892a65a01", + "foldsim": "foldsim d8350bc0f", + "pdk": "asap7", + "xlen": 32 + }, + "ff": 23721, + "fmax_mhz": 1564.9, + "macros": 32, + "max_stages": 17, + "overhead_ps": 231, + "period_ps": 639, + "stage_ps": 24, + "tied_bits": 17, + "tied_ports": [ + { + "bits": 17, + "port": "dma_req_buf.data_in", + "width": 607 + } + ] + } + }, + "top": { + "clock_mhz": 1000, + "config_hash": "ce21223ae8e4d63c", + "configs": "-DVX_CFG_NUM_THREADS=4 -DVX_CFG_NUM_WARPS=4", + "dut": "top", + "result": { + "build_time_s": 80, + "cells": 1438152, + "endpoints": 169931, + "env": { + "circt": "CIRCT 892a65a01", + "foldsim": "foldsim d8350bc0f", + "pdk": "asap7", + "xlen": 32 + }, + "ff": 305204, + "fmax_mhz": 749.1, + "macros": 82, + "max_stages": 46, + "overhead_ps": 231, + "period_ps": 1335, + "stage_ps": 24, + "tied_bits": 630, + "tied_ports": [ + { + "bits": 512, + "port": "g_multi_port.vortex.cp_mem_req_data", + "width": 512 + }, + { + "bits": 64, + "port": "g_multi_port.vortex.cp_mem_req_byteen", + "width": 64 + }, + { + "bits": 26, + "port": "g_multi_port.vortex.cp_mem_req_addr", + "width": 26 + }, + { + "bits": 12, + "port": "cp_core.dbg_host_r_counts", + "width": 32 + }, + { + "bits": 9, + "port": "g_multi_port.vortex.cp_mem_req_tag", + "width": 9 + }, + { + "bits": 2, + "port": "cp_core.dbg_host_w_counts", + "width": 32 + }, + { + "bits": 1, + "port": "cp_core.gpu_if_dcr_req_ready", + "width": 1 + }, + { + "bits": 1, + "port": "g_multi_port.vortex.cp_mem_req_noalloc", + "width": 1 + }, + { + "bits": 1, + "port": "g_multi_port.vortex.cp_mem_req_rw", + "width": 1 + }, + { + "bits": 1, + "port": "g_multi_port.vortex.cp_mem_req_valid", + "width": 1 + } + ] + } + } +} diff --git a/ci/baselines/synthesis/beacon_asic/dxa.json b/ci/baselines/synthesis/beacon_asic/dxa.json new file mode 100644 index 0000000000..76e9bb3a9f --- /dev/null +++ b/ci/baselines/synthesis/beacon_asic/dxa.json @@ -0,0 +1,34 @@ +{ + "dxa": { + "clock_mhz": 1000, + "config_hash": "878aaaf618bd3f3c", + "configs": "", + "dut": "dxa", + "result": { + "build_time_s": 20, + "cells": 84969, + "endpoints": 11408, + "env": { + "circt": "CIRCT 892a65a01", + "foldsim": "foldsim d8350bc0f", + "pdk": "asap7", + "xlen": 32 + }, + "ff": 25280, + "fmax_mhz": 977.5, + "macros": 0, + "max_stages": 33, + "overhead_ps": 231, + "period_ps": 1023, + "stage_ps": 24, + "tied_bits": 1, + "tied_ports": [ + { + "bits": 1, + "port": "dxa_core.smem_bus_if_0_rsp_valid", + "width": 1 + } + ] + } + } +} diff --git a/ci/baselines/synthesis/beacon_asic/graphics.json b/ci/baselines/synthesis/beacon_asic/graphics.json new file mode 100644 index 0000000000..559a510439 --- /dev/null +++ b/ci/baselines/synthesis/beacon_asic/graphics.json @@ -0,0 +1,207 @@ +{ + "gfx": { + "accepted": { + "against": "26d2bc4b5409a35a111e8316ac3a87d07b15fc80", + "regressions": [ + { + "after": 1063, + "before": 1065, + "kind": "ties", + "name": "tied_bits" + } + ] + }, + "clock_mhz": 1000, + "config_hash": "f49712b842f2f234", + "configs": "-DVX_CFG_NUM_THREADS=4 -DVX_CFG_NUM_WARPS=4", + "dut": "gfx", + "result": { + "build_time_s": 100, + "cells": 1875217, + "endpoints": 239287, + "env": { + "circt": "CIRCT 892a65a01", + "foldsim": "foldsim d8350bc0f", + "pdk": "asap7", + "xlen": 32 + }, + "ff": 420724, + "fmax_mhz": 874.9, + "macros": 76, + "max_stages": 38, + "overhead_ps": 231, + "period_ps": 1143, + "stage_ps": 24, + "tied_bits": 1063, + "tied_ports": [ + { + "bits": 529, + "port": "g_mem_bus_if_0.g_i0.mem_arb.bus_in_if_0_req_data", + "width": 630 + }, + { + "bits": 529, + "port": "g_mem_bus_if_0.g_i0.mem_arb.bus_in_if_4_req_data", + "width": 630 + }, + { + "bits": 1, + "port": "graphics.cluster_id", + "width": 1 + }, + { + "bits": 1, + "port": "rtu_socket_arb.bus_in_if_0_arm_data", + "width": 106 + }, + { + "bits": 1, + "port": "rtu_socket_arb.bus_in_if_0_req_data", + "width": 140 + }, + { + "bits": 1, + "port": "rtu_socket_arb.bus_in_if_1_arm_data", + "width": 106 + }, + { + "bits": 1, + "port": "rtu_socket_arb.bus_in_if_1_req_data", + "width": 140 + } + ] + } + }, + "om": { + "clock_mhz": 1000, + "config_hash": "3ff478591f29ccf9", + "configs": "", + "dut": "om", + "result": { + "build_time_s": 15, + "cells": 35595, + "endpoints": 5135, + "env": { + "circt": "CIRCT 892a65a01", + "foldsim": "foldsim d8350bc0f", + "pdk": "asap7", + "xlen": 32 + }, + "ff": 8692, + "fmax_mhz": 1169.6, + "macros": 0, + "max_stages": 26, + "overhead_ps": 231, + "period_ps": 855, + "stage_ps": 24, + "tied_bits": 3, + "tied_ports": [ + { + "bits": 2, + "port": "om_core.om_bus_if_req_data", + "width": 59 + }, + { + "bits": 1, + "port": "om_core.dcr_bus_if_req_data", + "width": 45 + } + ] + } + }, + "raster": { + "clock_mhz": 1000, + "config_hash": "f0a4c760f765a429", + "configs": "", + "dut": "raster", + "result": { + "build_time_s": 15, + "cells": 76084, + "endpoints": 12792, + "env": { + "circt": "CIRCT 892a65a01", + "foldsim": "foldsim d8350bc0f", + "pdk": "asap7", + "xlen": 32 + }, + "ff": 18195, + "fmax_mhz": 1277.1, + "macros": 4, + "max_stages": 23, + "overhead_ps": 231, + "period_ps": 783, + "stage_ps": 24, + "tied_bits": 2, + "tied_ports": [ + { + "bits": 1, + "port": "raster_core.dcr_bus_if_req_data", + "width": 45 + }, + { + "bits": 1, + "port": "raster_core.instance_idx", + "width": 1 + } + ] + } + }, + "rtu": { + "clock_mhz": 1000, + "config_hash": "473d8b33a18f36fd", + "configs": "", + "dut": "rtu", + "result": { + "build_time_s": 130, + "cells": 1060729, + "endpoints": 105631, + "env": { + "circt": "CIRCT 892a65a01", + "foldsim": "foldsim d8350bc0f", + "pdk": "asap7", + "xlen": 32 + }, + "ff": 152086, + "fmax_mhz": 874.9, + "macros": 4, + "max_stages": 38, + "overhead_ps": 231, + "period_ps": 1143, + "stage_ps": 24, + "tied_bits": 0, + "tied_ports": [] + } + }, + "tex": { + "clock_mhz": 1000, + "config_hash": "4d47fbece8804eb8", + "configs": "-DVX_CFG_NUM_THREADS=8 -DVX_CFG_NUM_WARPS=8", + "dut": "tex", + "result": { + "build_time_s": 45, + "cells": 376164, + "endpoints": 49445, + "env": { + "circt": "CIRCT 892a65a01", + "foldsim": "foldsim d8350bc0f", + "pdk": "asap7", + "xlen": 32 + }, + "ff": 72266, + "fmax_mhz": 1239.2, + "macros": 0, + "max_stages": 24, + "overhead_ps": 231, + "period_ps": 807, + "stage_ps": 24, + "tied_bits": 1, + "tied_ports": [ + { + "bits": 1, + "port": "tex_core.dcr_bus_if_req_data", + "width": 45 + } + ] + } + } +} diff --git a/ci/baselines/synthesis/beacon_asic/tensor.json b/ci/baselines/synthesis/beacon_asic/tensor.json new file mode 100644 index 0000000000..4fabf553fa --- /dev/null +++ b/ci/baselines/synthesis/beacon_asic/tensor.json @@ -0,0 +1,97 @@ +{ + "tcu": { + "accepted": { + "against": "28fc2c581262d2d7d4e1dc432d50cc303e3dea2e", + "regressions": [ + { + "after": 66855.0, + "before": 47446.0, + "kind": "area", + "name": "ff" + } + ] + }, + "clock_mhz": 1000, + "config_hash": "1d6c72424d1a993d", + "configs": "", + "dut": "tcu", + "result": { + "build_time_s": 120, + "cells": 1320372, + "endpoints": 44630, + "env": { + "circt": "CIRCT 892a65a01", + "foldsim": "foldsim d8350bc0f", + "pdk": "asap7", + "xlen": 32 + }, + "ff": 66855, + "fmax_mhz": 893.7, + "macros": 0, + "max_stages": 37, + "overhead_ps": 231, + "period_ps": 1119, + "stage_ps": 24, + "tied_bits": 0, + "tied_ports": [] + } + }, + "tensor": { + "accepted": { + "against": "26d2bc4b5409a35a111e8316ac3a87d07b15fc80", + "regressions": [ + { + "after": 4, + "before": 6, + "kind": "ties", + "name": "tied_bits" + } + ] + }, + "clock_mhz": 1000, + "config_hash": "2992cc36d736afff", + "configs": "-DVX_CFG_NUM_THREADS=8 -DVX_CFG_NUM_WARPS=8", + "dut": "tensor", + "result": { + "build_time_s": 65, + "cells": 860583, + "endpoints": 89468, + "env": { + "circt": "CIRCT 892a65a01", + "foldsim": "foldsim d8350bc0f", + "pdk": "asap7", + "xlen": 32 + }, + "ff": 188243, + "fmax_mhz": 977.5, + "macros": 28, + "max_stages": 33, + "overhead_ps": 231, + "period_ps": 1023, + "stage_ps": 24, + "tied_bits": 4, + "tied_ports": [ + { + "bits": 1, + "port": "g_cores_0.mem_unit.dcr_flush_if_req", + "width": 1 + }, + { + "bits": 1, + "port": "g_cores_1.mem_unit.dcr_flush_if_req", + "width": 1 + }, + { + "bits": 1, + "port": "g_mem_bus_if_0.g_i0.mem_arb.bus_in_if_0_req_valid", + "width": 1 + }, + { + "bits": 1, + "port": "g_mem_bus_if_0.g_i0.mem_arb.bus_in_if_0_rsp_ready", + "width": 1 + } + ] + } + } +} diff --git a/ci/baselines/synthesis/beacon_asic/tfu.json b/ci/baselines/synthesis/beacon_asic/tfu.json new file mode 100644 index 0000000000..9567710d52 --- /dev/null +++ b/ci/baselines/synthesis/beacon_asic/tfu.json @@ -0,0 +1,28 @@ +{ + "tfu": { + "clock_mhz": 1000, + "config_hash": "fd7c2ca30634d513", + "configs": "", + "dut": "tfu", + "result": { + "build_time_s": 15, + "cells": 15143, + "endpoints": 2332, + "env": { + "circt": "CIRCT 892a65a01", + "foldsim": "foldsim d8350bc0f", + "pdk": "asap7", + "xlen": 32 + }, + "ff": 1806, + "fmax_mhz": 913.2, + "macros": 0, + "max_stages": 36, + "overhead_ps": 231, + "period_ps": 1095, + "stage_ps": 24, + "tied_bits": 0, + "tied_ports": [] + } + } +} diff --git a/ci/baselines/synthesis/beacon_asic/vm.json b/ci/baselines/synthesis/beacon_asic/vm.json new file mode 100644 index 0000000000..f007f60c6a --- /dev/null +++ b/ci/baselines/synthesis/beacon_asic/vm.json @@ -0,0 +1,59 @@ +{ + "vm": { + "clock_mhz": 1000, + "config_hash": "d06ba9a368334b96", + "configs": "-DVX_CFG_NUM_THREADS=8 -DVX_CFG_NUM_WARPS=8", + "dut": "vm", + "result": { + "build_time_s": 65, + "cells": 1156412, + "endpoints": 115494, + "env": { + "circt": "CIRCT 892a65a01", + "foldsim": "foldsim d8350bc0f", + "pdk": "asap7", + "xlen": 32 + }, + "ff": 297476, + "fmax_mhz": 749.1, + "macros": 66, + "max_stages": 46, + "overhead_ps": 231, + "period_ps": 1335, + "stage_ps": 24, + "tied_bits": 114, + "tied_ports": [ + { + "bits": 55, + "port": "g_sockets_0.g_immu.immu.core_bus_if_0_req_data", + "width": 90 + }, + { + "bits": 55, + "port": "g_sockets_1.g_immu.immu.core_bus_if_0_req_data", + "width": 90 + }, + { + "bits": 1, + "port": "g_sockets_0.mmu_snoop.dcr_bus_out_if_rsp_valid", + "width": 1 + }, + { + "bits": 1, + "port": "g_sockets_1.mmu_snoop.dcr_bus_out_if_rsp_valid", + "width": 1 + }, + { + "bits": 1, + "port": "l2cache.core_bus_if_2_req_valid", + "width": 1 + }, + { + "bits": 1, + "port": "l2cache.core_bus_if_2_rsp_ready", + "width": 1 + } + ] + } + } +} diff --git a/ci/baselines/synthesis/yosys/core.json b/ci/baselines/synthesis/yosys/core.json index 7d640d4ff2..899dd7b151 100644 --- a/ci/baselines/synthesis/yosys/core.json +++ b/ci/baselines/synthesis/yosys/core.json @@ -1,13 +1,13 @@ { "cache": { - "clock_mhz": 800, - "config_hash": "4fd77575a6f5f52c", + "clock_mhz": 1000, + "config_hash": "243f3272b030bf88", "configs": "", "dut": "cache", "result": { - "build_time_s": 296, - "cell_area_um2": 59584.48, - "cell_count": 547028, + "build_time_s": 231, + "cell_area_um2": 50318.467, + "cell_count": 460847, "env": { "corner": "tt", "pdk": "asap7", @@ -16,23 +16,23 @@ "xlen": 32, "yosys": "Yosys 0.69" }, - "fmax_mhz": 1291.823, - "power_mw": 161.0, - "seq_area_um2": 28618.499, - "sram_area_um2": 16307.2, + "fmax_mhz": 1265.182, + "power_mw": 169.0, + "seq_area_um2": 23986.724, + "sram_area_um2": 18345.6, "tns_ns": 0.0, - "wns_ns": 0.476 + "wns_ns": 0.21 } }, "core": { - "clock_mhz": 800, - "config_hash": "67eb0ef49175ab38", + "clock_mhz": 1000, + "config_hash": "6eb9c40627fdf1e9", "configs": "-DVX_CFG_NUM_THREADS=8 -DVX_CFG_NUM_WARPS=8", "dut": "core", "result": { - "build_time_s": 803, - "cell_area_um2": 76015.6, - "cell_count": 731009, + "build_time_s": 773, + "cell_area_um2": 76102.687, + "cell_count": 731229, "env": { "corner": "tt", "pdk": "asap7", @@ -41,21 +41,21 @@ "xlen": 32, "yosys": "Yosys 0.69" }, - "fmax_mhz": 1019.992, - "power_mw": 832.0, - "seq_area_um2": 25929.947, + "fmax_mhz": 1036.269, + "power_mw": 1010.0, + "seq_area_um2": 25935.779, "sram_area_um2": 27814.4, "tns_ns": 0.0, - "wns_ns": 0.27 + "wns_ns": 0.035 } }, "lmem": { - "clock_mhz": 800, - "config_hash": "47081ee86b993ce8", + "clock_mhz": 1000, + "config_hash": "0fcc12bd8d9372df", "configs": "-DVX_CFG_NUM_THREADS=16 -DVX_CFG_ISSUE_WIDTH=2 -DVX_CFG_EXT_A_ENABLE", "dut": "lmem", "result": { - "build_time_s": 110, + "build_time_s": 100, "cell_area_um2": 17137.142, "cell_count": 166236, "env": { @@ -66,23 +66,23 @@ "xlen": 32, "yosys": "Yosys 0.69" }, - "fmax_mhz": 2003.606, - "power_mw": 42.2, + "fmax_mhz": 2023.882, + "power_mw": 52.8, "seq_area_um2": 6527.758, "sram_area_um2": 55628.8, "tns_ns": 0.0, - "wns_ns": 0.751 + "wns_ns": 0.506 } }, "top": { - "clock_mhz": 800, - "config_hash": "23d795386c3e20c0", + "clock_mhz": 1000, + "config_hash": "f73eafd49ee4e963", "configs": "-DVX_CFG_NUM_THREADS=4 -DVX_CFG_NUM_WARPS=4", "dut": "top", "result": { - "build_time_s": 1376, - "cell_area_um2": 172526.117, - "cell_count": 1609348, + "build_time_s": 1331, + "cell_area_um2": 172608.8, + "cell_count": 1610034, "env": { "corner": "tt", "pdk": "asap7", @@ -91,12 +91,12 @@ "xlen": 32, "yosys": "Yosys 0.69" }, - "fmax_mhz": 1028.807, - "power_mw": 247.0, - "seq_area_um2": 72499.05, + "fmax_mhz": 1040.366, + "power_mw": 309.0, + "seq_area_um2": 72506.048, "sram_area_um2": 72302.4, "tns_ns": 0.0, - "wns_ns": 0.278 + "wns_ns": 0.039 } } } diff --git a/ci/baselines/synthesis/yosys/dxa.json b/ci/baselines/synthesis/yosys/dxa.json index b981098265..5dd6faf9ce 100644 --- a/ci/baselines/synthesis/yosys/dxa.json +++ b/ci/baselines/synthesis/yosys/dxa.json @@ -1,11 +1,11 @@ { "dxa": { - "clock_mhz": 800, - "config_hash": "1333820f22e64ab6", + "clock_mhz": 1000, + "config_hash": "d44055ed50a07e29", "configs": "", "dut": "dxa", "result": { - "build_time_s": 90, + "build_time_s": 80, "cell_area_um2": 12868.366, "cell_count": 121130, "env": { @@ -16,12 +16,12 @@ "xlen": 32, "yosys": "Yosys 0.69" }, - "fmax_mhz": 1128.668, - "power_mw": 36.4, + "fmax_mhz": 1135.074, + "power_mw": 45.5, "seq_area_um2": 5658.206, "sram_area_um2": 0.0, "tns_ns": 0.0, - "wns_ns": 0.364 + "wns_ns": 0.119 } } } diff --git a/ci/baselines/synthesis/yosys/graphics.json b/ci/baselines/synthesis/yosys/graphics.json index dc5d66875a..36b38cc276 100644 --- a/ci/baselines/synthesis/yosys/graphics.json +++ b/ci/baselines/synthesis/yosys/graphics.json @@ -1,13 +1,13 @@ { "gfx": { - "clock_mhz": 800, - "config_hash": "e37c317b7e74dff1", + "clock_mhz": 1000, + "config_hash": "b4c6dde8e27a55c7", "configs": "-DVX_CFG_NUM_THREADS=4 -DVX_CFG_NUM_WARPS=4", "dut": "gfx", "result": { - "build_time_s": 1632, - "cell_area_um2": 188729.556, - "cell_count": 1727374, + "build_time_s": 1582, + "cell_area_um2": 190520.52, + "cell_count": 1739654, "env": { "corner": "tt", "pdk": "asap7", @@ -16,17 +16,17 @@ "xlen": 32, "yosys": "Yosys 0.69" }, - "fmax_mhz": 868.206, - "power_mw": 1100.0, - "seq_area_um2": 77183.604, + "fmax_mhz": 1046.792, + "power_mw": 1350.0, + "seq_area_um2": 78460.52, "sram_area_um2": 35811.2, "tns_ns": 0.0, - "wns_ns": 0.098 + "wns_ns": 0.045 } }, "om": { - "clock_mhz": 800, - "config_hash": "09a643af0223b91f", + "clock_mhz": 1000, + "config_hash": "1407877236a20841", "configs": "", "dut": "om", "result": { @@ -41,21 +41,21 @@ "xlen": 32, "yosys": "Yosys 0.69" }, - "fmax_mhz": 1166.997, - "power_mw": 25.2, + "fmax_mhz": 1173.847, + "power_mw": 30.8, "seq_area_um2": 2482.099, "sram_area_um2": 0.0, "tns_ns": 0.0, - "wns_ns": 0.393 + "wns_ns": 0.148 } }, "raster": { - "clock_mhz": 800, - "config_hash": "f8ed08b239870bd8", + "clock_mhz": 1000, + "config_hash": "756874a837a20709", "configs": "", "dut": "raster", "result": { - "build_time_s": 65, + "build_time_s": 60, "cell_area_um2": 10207.312, "cell_count": 92158, "env": { @@ -66,23 +66,23 @@ "xlen": 32, "yosys": "Yosys 0.69" }, - "fmax_mhz": 1221.299, - "power_mw": 56.7, + "fmax_mhz": 1228.803, + "power_mw": 70.6, "seq_area_um2": 3983.839, "sram_area_um2": 3728.0, "tns_ns": 0.0, - "wns_ns": 0.431 + "wns_ns": 0.186 } }, "rtu": { - "clock_mhz": 800, - "config_hash": "37dd15cd75261ada", + "clock_mhz": 1000, + "config_hash": "5d89e24dd85fbb34", "configs": "", "dut": "rtu", "result": { - "build_time_s": 1130, - "cell_area_um2": 97093.979, - "cell_count": 893398, + "build_time_s": 1044, + "cell_area_um2": 95949.347, + "cell_count": 881230, "env": { "corner": "tt", "pdk": "asap7", @@ -91,21 +91,21 @@ "xlen": 32, "yosys": "Yosys 0.69" }, - "fmax_mhz": 959.785, - "power_mw": 628.0, - "seq_area_um2": 38161.692, + "fmax_mhz": 1131.734, + "power_mw": 736.0, + "seq_area_um2": 38202.516, "sram_area_um2": 4598.4, "tns_ns": 0.0, - "wns_ns": 0.208 + "wns_ns": 0.116 } }, "tex": { - "clock_mhz": 800, - "config_hash": "c90d90099c96a888", + "clock_mhz": 1000, + "config_hash": "5a9b1eef7ff43cb4", "configs": "-DVX_CFG_NUM_THREADS=8 -DVX_CFG_NUM_WARPS=8", "dut": "tex", "result": { - "build_time_s": 281, + "build_time_s": 241, "cell_area_um2": 58598.755, "cell_count": 553165, "env": { @@ -116,12 +116,12 @@ "xlen": 32, "yosys": "Yosys 0.69" }, - "fmax_mhz": 1225.49, - "power_mw": 260.0, + "fmax_mhz": 1233.046, + "power_mw": 325.0, "seq_area_um2": 19287.007, "sram_area_um2": 0.0, "tns_ns": 0.0, - "wns_ns": 0.434 + "wns_ns": 0.189 } } } diff --git a/ci/baselines/synthesis/yosys/tensor.json b/ci/baselines/synthesis/yosys/tensor.json index b59fd09221..b62c378bb4 100644 --- a/ci/baselines/synthesis/yosys/tensor.json +++ b/ci/baselines/synthesis/yosys/tensor.json @@ -1,13 +1,13 @@ { "tcu": { - "clock_mhz": 800, - "config_hash": "5110889c4c9985a1", + "clock_mhz": 1000, + "config_hash": "8ede09784dc2eeb0", "configs": "", "dut": "tcu", "result": { - "build_time_s": 2210, - "cell_area_um2": 74231.737, - "cell_count": 760362, + "build_time_s": 1150, + "cell_area_um2": 76124.702, + "cell_count": 744692, "env": { "corner": "tt", "pdk": "asap7", @@ -16,23 +16,23 @@ "xlen": 32, "yosys": "Yosys 0.69" }, - "fmax_mhz": 870.549, + "fmax_mhz": 1101.686, "power_mw": 359.0, - "seq_area_um2": 12099.067, + "seq_area_um2": 17121.877, "sram_area_um2": 0.0, "tns_ns": 0.0, - "wns_ns": 0.101 + "wns_ns": 0.092 } }, "tensor": { - "clock_mhz": 800, - "config_hash": "5e33a96e107c9a6b", + "clock_mhz": 1000, + "config_hash": "f7974ef5771ec154", "configs": "-DVX_CFG_NUM_THREADS=8 -DVX_CFG_NUM_WARPS=8", "dut": "tensor", "result": { - "build_time_s": 834, - "cell_area_um2": 96735.909, - "cell_count": 888126, + "build_time_s": 718, + "cell_area_um2": 100009.454, + "cell_count": 914743, "env": { "corner": "tt", "pdk": "asap7", @@ -41,12 +41,12 @@ "xlen": 32, "yosys": "Yosys 0.69" }, - "fmax_mhz": 1119.445, - "power_mw": 236.0, - "seq_area_um2": 41783.364, + "fmax_mhz": 1124.986, + "power_mw": 305.0, + "seq_area_um2": 43771.493, "sram_area_um2": 52361.6, "tns_ns": 0.0, - "wns_ns": 0.357 + "wns_ns": 0.111 } } } diff --git a/ci/baselines/synthesis/yosys/tfu.json b/ci/baselines/synthesis/yosys/tfu.json index a2289a92b0..9377ad18c7 100644 --- a/ci/baselines/synthesis/yosys/tfu.json +++ b/ci/baselines/synthesis/yosys/tfu.json @@ -1,7 +1,7 @@ { "tfu": { - "clock_mhz": 800, - "config_hash": "e22492d24465c10d", + "clock_mhz": 1000, + "config_hash": "5e071e2419b516e2", "configs": "", "dut": "tfu", "result": { @@ -16,12 +16,12 @@ "xlen": 32, "yosys": "Yosys 0.69" }, - "fmax_mhz": 1026.167, - "power_mw": 15.6, + "fmax_mhz": 1031.46, + "power_mw": 19.2, "seq_area_um2": 507.384, "sram_area_um2": 0.0, "tns_ns": 0.0, - "wns_ns": 0.276 + "wns_ns": 0.03 } } } diff --git a/ci/baselines/synthesis/yosys/vm.json b/ci/baselines/synthesis/yosys/vm.json index 80a9234b8f..070d89b9b7 100644 --- a/ci/baselines/synthesis/yosys/vm.json +++ b/ci/baselines/synthesis/yosys/vm.json @@ -1,13 +1,13 @@ { "vm": { - "clock_mhz": 800, - "config_hash": "45673f23cbf3b123", + "clock_mhz": 1000, + "config_hash": "b76c79624308b9cc", "configs": "-DVX_CFG_NUM_THREADS=8 -DVX_CFG_NUM_WARPS=8", "dut": "vm", "result": { - "build_time_s": 889, - "cell_area_um2": 133457.913, - "cell_count": 1190756, + "build_time_s": 733, + "cell_area_um2": 135877.056, + "cell_count": 1212964, "env": { "corner": "tt", "pdk": "asap7", @@ -16,12 +16,12 @@ "xlen": 32, "yosys": "Yosys 0.69" }, - "fmax_mhz": 1265.983, - "power_mw": 348.0, - "seq_area_um2": 63571.424, + "fmax_mhz": 1213.445, + "power_mw": 437.0, + "seq_area_um2": 64770.484, "sram_area_um2": 103470.4, "tns_ns": 0.0, - "wns_ns": 0.46 + "wns_ns": 0.176 } } } diff --git a/ci/beacon.py b/ci/beacon.py index c10900a5e9..a71e86c8f7 100755 --- a/ci/beacon.py +++ b/ci/beacon.py @@ -583,18 +583,22 @@ def top_mean(regs, n=50): return sum(depths) / len(depths) if depths else 0.0 area_before, area_after = load_area(args.before), load_area(args.after) + unit_name = 'stages' if _asic_area(args.after) else 'levels' area_head = '' if bool(area_before) != bool(area_after): print('area: only the %s run counted it; not compared' % ('reference' if area_before else 'changed')) if area_before and area_after: tb, ta = area_before[''], area_after[''] + keys = area_keys(tb) area_head = '; ' + ', '.join( - f'{k} {tb[k]:g} -> {ta[k]:g}' for k in ('lut', 'bram', 'dsp')) - print(f'deepest path {deepest(before)} -> {deepest(after)} levels; ' - f'mean of the 50 deepest {top_mean(before):.1f} -> {top_mean(after):.1f}; ' - f'registers at or above {args.min_levels} levels ' - f'{watched(before)} -> {watched(after)}{area_head}') + f'{area_label(k, tb)} {tb[k]:g} -> {ta[k]:g}' + for k in (keys if 'macros' in tb else ('lut', 'bram', 'dsp'))) + head = (f'deepest path {deepest(before)} -> {deepest(after)} {unit_name}; ' + f'mean of the 50 deepest {top_mean(before):.1f} -> {top_mean(after):.1f}; ' + f'registers at or above {args.min_levels} {unit_name} ' + f'{watched(before)} -> {watched(after)}{area_head}') + print(head) deeper, shallower, new, gone = [], [], [], [] for key, (lv, start) in after.items(): @@ -655,18 +659,44 @@ def show(title, rows, moved): for b, a, (cls, u) in moved[:args.top]: print(f'{b:4d} -> {a:<4d} {cls + ": " if cls else ""}{u}') - area_regress = False + area_regress = [] if area_before and area_after: area_regress = show_area(area_before, area_after, args) # A register the reference lacks may be a renamed one, so it fails only at # the fix threshold, as a new unit does in logic_gate. - if regress or any(r[0] >= args.fix_levels for r in new): + new_regress = [r for r in new if r[0] >= args.fix_levels] + if args.json: + with open(args.json, 'w') as fh: + json.dump({'headline': head, + 'deeper': [{'register': name(k), 'before': old, 'after': lv} + for lv, old, k, _ in regress], + 'new': [{'register': name(k), 'after': lv} + for lv, k, _ in new_regress], + 'area': [{'resource': k, 'before': b, 'after': a} + for k, b, a in area_regress]}, + fh, indent=2) + fh.write('\n') + if regress or new_regress: return 1 return 3 if area_regress else 0 AREA_KEYS = ('lut', 'ff', 'lutram', 'bram', 'uram', 'dsp') +# An ASIC run (target=asap7) counts standard cells in the `lut` column, +# flip-flops, and SRAM macros; it has no distributed or block RAM or DSPs. +# Its macros are shown, not held to the tolerance: a memory that moves into +# a macro adds one and takes its flip-flops out. +ASIC_AREA_KEYS = ('lut', 'ff', 'macros') +ASIC_GATED = ('lut', 'ff') + + +def area_keys(res): + return ASIC_AREA_KEYS if 'macros' in res else AREA_KEYS + + +def area_label(key, res): + return 'cells' if key == 'lut' and 'macros' in res else key def load_area(run_dir): @@ -679,49 +709,66 @@ def load_area(run_dir): return None units = {} with open(path) as fh: + keys = AREA_KEYS + (('macros',) if _asic_area(run_dir) else ()) for row in csv.DictReader(fh): prefix = 'total_' if not row['path'] else '' - res = {k: float(row[prefix + k]) for k in AREA_KEYS} + res = {k: float(row[prefix + k]) for k in keys} res['lut'] += res['lutram'] key = unit(norm(row['path']) + '/x') if row['path'] else '' if key in units: - for k in AREA_KEYS: + for k in keys: units[key][k] += res[k] else: units[key] = res return units if '' in units else None +def _asic_area(run_dir): + """Whether the run's area count is an ASIC one: area.txt's first line + reads ` on : N cells, ...` there, and LUTs on an FPGA.""" + try: + with open(f'{run_dir}/area.txt') as fh: + return ASIC_AREA_RE.search(fh.readline()) is not None + except OSError: + return False + + def show_area(before, after, args): - """The design's resources before and after, and the units whose own LUTs, - memories or DSPs moved most; True if a resource of the design grew more - than --area-tolerance.""" + """The design's resources before and after, and the units whose own LUTs + (cells), memories or DSPs moved most; the resources of the design that + grew more than --area-tolerance, as (resource, before, after).""" tb, ta = before[''], after[''] + keys = area_keys(tb) print('\narea (design)') - regress = False - for k in AREA_KEYS: - b, a = tb[k], ta[k] + regress = [] + for k in keys: + b, a = tb[k], ta.get(k, 0.0) pct = (a - b) / b * 100 if b else (100.0 if a else 0.0) flag = '' - if pct > 100 * args.area_tolerance: - flag, regress = ' REGRESSION', True - print(f' {k:7s} {b:10g} -> {a:<10g} {pct:+6.1f}%{flag}') + if pct > 100 * args.area_tolerance and \ + ('macros' not in tb or k in ASIC_GATED): + flag = ' REGRESSION' + regress.append((area_label(k, tb), b, a)) + print(f' {area_label(k, tb):7s} {b:10g} -> {a:<10g} {pct:+6.1f}%{flag}') + # Units rank by LUTs (cells) moved, a memory or DSP counting as 100, and + # on an ASIC by flip-flops too: a memory there is either a macro or flops. + weight = {'lut': 1, 'bram': 100, 'uram': 100, 'dsp': 100, 'macros': 100, + 'ff': 1 if 'macros' in tb else 0} moved = [] + zero = dict.fromkeys(keys, 0.0) for key in set(before) | set(after): if not key: continue - b = before.get(key, dict.fromkeys(AREA_KEYS, 0.0)) - a = after.get(key, dict.fromkeys(AREA_KEYS, 0.0)) - if any(abs(a[k] - b[k]) >= 0.5 for k in AREA_KEYS): - moved.append((abs(a['lut'] - b['lut']) + 100 * ( - abs(a['bram'] - b['bram']) + abs(a['uram'] - b['uram']) - + abs(a['dsp'] - b['dsp'])), key, b, a)) + b, a = before.get(key, zero), after.get(key, zero) + if any(abs(a.get(k, 0.0) - b.get(k, 0.0)) >= 0.5 for k in keys): + moved.append((sum(abs(a.get(k, 0.0) - b.get(k, 0.0)) * weight.get(k, 0) + for k in keys), key, b, a)) if moved: moved.sort(key=lambda r: -r[0]) print(f'\nunits whose own area moved ({len(moved)}), all copies') for _, key, b, a in moved[:args.top]: - parts = [f'{k} {b[k]:g} -> {a[k]:g}' for k in AREA_KEYS - if abs(a[k] - b[k]) >= 0.5] + parts = [f'{area_label(k, tb)} {b.get(k, 0.0):g} -> {a.get(k, 0.0):g}' + for k in keys if abs(a.get(k, 0.0) - b.get(k, 0.0)) >= 0.5] print(f' {key}: ' + ', '.join(parts)) return regress @@ -1133,6 +1180,165 @@ def cmd_score(args): +# report.txt of an ASIC run: `deepest path N stages: clk2q + path + N x cell +# + setup = P ps (F MHz)`. +PERIOD_RE = re.compile(r'^deepest path (\d+) stages: (\d+) \+ (\d+) \+ \d+ x (\d+) ' + r'\+ (\d+) = (\d+) ps') +ASIC_AREA_RE = re.compile(r' on \S+: (\d+) cells, (\d+) flip-flops, (\d+) macros') + + +def cmd_asic_summary(args): + """One CSV row for an ASIC run (target=$(PDK)): the deepest path's stages, + the period report.txt converts them to and its Fmax, the per-stage and + fixed delays of that conversion, and the cells, flip-flops and SRAM + macros of area.txt.""" + row = {} + with open(f'{args.run_dir}/report.txt') as fh: + for line in fh: + m = PERIOD_RE.match(line) + if m: + row.update(max_stages=m[1], period_ps=m[6], + fmax_mhz=f'{1e6 / int(m[6]):.1f}', + stage_ps=m[4], + overhead_ps=int(m[2]) + int(m[3]) + int(m[5])) + break + with open(f'{args.run_dir}/area.txt') as fh: + m = ASIC_AREA_RE.search(fh.readline()) + if m: + row.update(cells=m[1], ff=m[2], macros=m[3]) + if 'period_ps' not in row or 'ff' not in row: + sys.exit(f'{args.run_dir}: no period in report.txt or no area in area.txt') + row['endpoints'] = sum(1 for _ in endpoints(args.run_dir)) + with open(args.out, 'w', newline='') as fh: + w = csv.DictWriter(fh, fieldnames=list(row)) + w.writeheader() + w.writerow(row) + + +# --- harness constant ties --------------------------------------------------- + +INT_TYPE = re.compile(r'^i(\d+)$') +SSA = r'%[\w.]+' + + +def _split_top(text, sep=','): + """`text` split at `sep` outside <> and ().""" + out, depth, cur = [], 0, '' + for ch in text: + if ch in '<(': + depth += 1 + elif ch in '>)': + depth -= 1 + if ch == sep and depth == 0: + out.append(cur.strip()) + cur = '' + else: + cur += ch + if cur.strip(): + out.append(cur.strip()) + return out + + +def _type_bits(t): + t = t.strip() + m = INT_TYPE.match(t) + if m: + return int(m[1]) + if t.startswith('!hw.array<'): + n, elem = t[len('!hw.array<'):-1].split('x', 1) + return int(n) * _type_bits(elem) + if t.startswith('!hw.struct<'): + return sum(_type_bits(f.split(':', 1)[1]) + for f in _split_top(t[len('!hw.struct<'):-1])) + return 1 if t == '!seq.clock' else 0 + + +def netlist_top(run_dir): + """The run's top module: the design row of area.csv, else the netlist's + last module.""" + try: + with open(f'{run_dir}/area.csv') as fh: + for row in csv.DictReader(fh): + if not row['path']: + return row['module'] + except (OSError, KeyError): + pass + return None + + +def const_ties(netlist, top=None): + """The instance-input bits `top` ties to constants, as (bits, width, port) + rows, most first. Constants are followed through concatenation, bitcast + and struct and array creation, which is how a harness zero-extends or + ties off a port. + + A harness that ties an input lets Vivado and Yosys fold the logic behind + it, while Beacon maps module by module and keeps it, so the synthesis + gates and Beacon then measure different designs. The count moves when + the harness ties more or fewer bits, and when the RTL widens or narrows + a port the harness ties: either way the synthesis gates now fold a + different amount of logic.""" + mods, cur = {}, None + with open(netlist) as fh: + for line in fh: + m = re.match(r'\s*hw\.module (?:private )?@(\S+)\(', line) + if m: + cur = m[1] + mods[cur] = [] + elif cur and re.match(r'\s*} loc', line): + cur = None + elif cur: + mods[cur].append(line) + if not mods: + raise ValueError(f'{netlist}: no hw.module') + top = top or list(mods)[-1] + if top not in mods: + raise ValueError(f'{netlist}: no module {top}') + + const, rows = {}, [] + for line in mods[top]: + line = re.sub(r' loc\(#loc\d*\)\s*$', '', line.strip()) + m = re.match(rf'({SSA}) = hw\.constant (?:true|false)\b', line) + if m: + const[m[1]] = 1 + continue + m = re.match(rf'({SSA}) = hw\.constant \S+ : (\S+)', line) + if m: + const[m[1]] = _type_bits(m[2]) + continue + m = re.match(rf'({SSA}) = comb\.concat (.*) : ', line) + if m: + const[m[1]] = sum(const.get(o.strip(), 0) for o in m[2].split(',')) + continue + m = re.match(rf'({SSA}) = hw\.bitcast ({SSA})', line) + if m: + const[m[1]] = const.get(m[2], 0) + continue + m = re.match(rf'({SSA}) = hw\.(?:struct|array)_create \((.*)\) :', line) + if m: + const[m[1]] = sum(const.get(o.strip(), 0) for o in m[2].split(',')) + continue + m = re.search(r'hw\.instance "(\S+)" @(\S+)\((.*)\) -> ', line) + if m: + for arg in _split_top(m[3]): + port, rest = arg.split(':', 1) + val, ty = rest.split(':', 1) + bits = const.get(val.strip(), 0) + if bits: + rows.append((bits, _type_bits(ty), f'{m[1]}.{port.strip()}')) + rows.sort(key=lambda r: (-r[0], r[2])) + return rows + + +def cmd_ties(args): + """Instance-input bits the DUT top ties to constants, per port.""" + rows = const_ties(f'{args.run_dir}/netlist.mlir', + args.top or netlist_top(args.run_dir)) + for bits, width, port in rows: + print(f'{bits:8d} of {width:6d} {port}') + print(f'{sum(r[0] for r in rows)} instance input bits tied to constants') + + def main(): ap = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter) @@ -1207,6 +1413,9 @@ def main(): p.add_argument('--area-tolerance', type=float, default=0.05, help="a resource of the design that grows by more than this " "fraction fails (exit 3)") + p.add_argument('--json', metavar='FILE', + help="also write the headline and the failing registers " + "and resources here") p.set_defaults(fn=cmd_diff) p = sub.add_parser("buffers", help="elastic buffers that pass deep paths") @@ -1242,6 +1451,17 @@ def main(): p.add_argument('--csv', help="also write every register's prediction here") p.set_defaults(fn=cmd_score) + p = sub.add_parser("asic-summary", help="period and area of an ASIC run, as CSV") + p.add_argument('run_dir') + p.add_argument('out') + p.set_defaults(fn=cmd_asic_summary) + + p = sub.add_parser("ties", help="instance-input bits the DUT top ties to " + "constants") + p.add_argument('run_dir') + p.add_argument('--top', help="top module (default: the run's design)") + p.set_defaults(fn=cmd_ties) + args = ap.parse_args() return args.fn(args) or 0 diff --git a/ci/logic_gate.py b/ci/logic_gate.py index 79f1f33ce6..79373a314a 100755 --- a/ci/logic_gate.py +++ b/ci/logic_gate.py @@ -20,6 +20,13 @@ beacon_risk.txt: the learned calibration's slowest registers and its Fmax, reported, not gated +With --tool beacon_asic it measures ci/testcases/asic_gate.yaml's builds on +the ASIC flow instead (hw/syn/yosys/dut, ASAP7 cell stages, flip-flops and +SRAM macros; baselines in ci/baselines/synthesis/beacon_asic/). With +--against-rev REV, each build is also compared register by register with the +same build on REV's RTL, measured under this checkout's flow: CI passes a +pull request's merge base (BEACON_AGAINST_REV). + It needs CIRCT and foldsim (ci/toolchain_install.sh --circt --foldsim); the Xilinx environment is not used. @@ -27,6 +34,8 @@ ci/logic_gate.py --list ci/logic_gate.py # all builds, gate against baselines ci/logic_gate.py -b cache -b tcu # explicit builds + ci/logic_gate.py --tool beacon_asic # asic_gate's builds, ASIC flow + ci/logic_gate.py --against-rev $(git merge-base HEAD origin/master) ci/logic_gate.py --update-baseline # re-record (human-reviewed, never in CI) Beacon runs by hand through the flow's own entry point -- diff --git a/ci/synth_gate.py b/ci/synth_gate.py index b986ac225e..1aaecc699f 100755 --- a/ci/synth_gate.py +++ b/ci/synth_gate.py @@ -7,12 +7,13 @@ post-synthesis timing and area against the recorded numbers, so an RTL change that quietly costs timing closure or area cannot land green. -Three backends, one gate. Everything that is not "how do I drive the tool and +Four backends, one gate. Everything that is not "how do I drive the tool and what does it call its numbers" is shared: - --tool=xilinx Vivado synthesis + place-and-route -> ci/fpga_gate.py - --tool=yosys Yosys + OpenSTA on an ASIC PDK -> ci/asic_gate.py - --tool=beacon logic levels per RTL unit, no synthesis -> ci/logic_gate.py + --tool=xilinx Vivado synthesis + place-and-route -> ci/fpga_gate.py + --tool=yosys Yosys + OpenSTA on an ASIC PDK -> ci/asic_gate.py + --tool=beacon logic levels per RTL unit, no synthesis -> ci/logic_gate.py + --tool=beacon_asic Beacon's cell stages on asic_gate's builds (ASAP7) Spec : ci/testcases/.yaml (what to build) Baselines : ci/baselines/synthesis//.json (last accepted metrics) @@ -30,10 +31,13 @@ import argparse import concurrent.futures import csv +import fcntl +import glob import hashlib import json import os import re +import shlex import shutil import signal import subprocess @@ -63,7 +67,11 @@ # Verdicts that do not fail the run. KNOWN-ISSUE is a tracked expected failure # (see gate()); XPASS is one that stopped reproducing -- reported loudly, but a # gate that hard-failed on an unexpected PASS would be the wrong incentive. -PASSING = ("PASS", "RECORDED", "KNOWN-ISSUE", "XPASS") +# Against a reference (--against-rev), ACCEPTED is a regression the baseline's +# re-record accepted, and NO-REFERENCE a build the reference revision does not +# have at all (a DUT the change adds), judged against its baseline alone. REF-FAIL, a reference that failed to measure the build, fails. +PASSING = ("PASS", "RECORDED", "KNOWN-ISSUE", "XPASS", "ACCEPTED", + "NO-REFERENCE") POLL_INTERVAL = 5 HEARTBEAT = 300 # seconds between "still alive, here is where it is" lines @@ -90,6 +98,7 @@ class Tool: name = "" # --tool value, and ci/baselines/synthesis// gate = "" # ci/testcases/.yaml, and the build-dir/prefix/stamp name + spec = "" # another gate's ci/testcases/.yaml, if not the gate's own flow = "" # DUT entry point, relative to a configured build tree metrics = () # recorded, in report order; build_time_s is bookkeeping @@ -107,11 +116,22 @@ class Tool: metric_tolerance = {} integral = () # recorded as ints; every other metric is a rounded float columns = () # (header, metric, format, width) for the report table + # Whether the build's clock_mhz is part of config_hash: it is an input of + # a synthesis run, but only a gate threshold for an estimate that does not + # read it, where raising the target must not invalidate the measurements. + clock_in_hash = True + # What a register's depth is counted in, for the reasons --against gives. + depth_unit = "levels" + # The dut/catalog.mk variable naming a DUT's top module (). + top_var = "_PRJ" # Scheduling weights (seconds) for a build with no recorded build_time_s yet. # Only ever used to ORDER the queue, so a rough magnitude is enough. weights = {} fallback_weight = 1800 + # Peak memory (GB) of a build, for admission: builds start together only if + # their peaks fit in the machine. A DUT not listed is not limited. + mem_gb = {} job_label = "tool" # what --tool-jobs buys, in the schedule banner # Log lines that mark a phase transition, in order. Progress is reported @@ -169,6 +189,18 @@ def evidence(self, work): """Files of a finished build that explain its reasons.""" return [] + def notes(self, build, metrics, args): + """Advisory lines printed under the report table; never a verdict.""" + return [] + + def top_module(self, dut_root, dut): + """The DUT's top module, from dut/catalog.mk ("" if not declared).""" + return _make_var(_catalog(dut_root), dut + self.top_var) + + def diff_levels(self, build, metrics): + """(watch, fix) thresholds for `beacon.py diff` against a reference.""" + return metrics.get("watch_levels") or 8, metrics.get("fix_levels") or 12 + def incomplete(self, metrics): """Whether a cached result predates something this tool now records. @@ -208,6 +240,41 @@ def dut_names(dut_root): return set(_make_var(_catalog(dut_root), "DUTS").split()) +# --- Beacon, both targets ---------------------------------------------------- + +def harness_ties(work): + """The instance-input bits the DUT top ties to constants, from the Beacon + run's netlist (ci/beacon.py ties): the count and the ports that carry + the most. A finished run always has its netlist, so a missing or + unreadable one is a build error, never a count of zero.""" + run = os.path.join(work, "beacon") + netlist = os.path.join(run, "netlist.mlir") + if not os.path.exists(netlist): + raise BuildError("no %s to count the harness's constant ties in" % netlist) + import beacon + try: + rows = beacon.const_ties(netlist, beacon.netlist_top(run)) + except ValueError as e: + raise BuildError("counting the harness's constant ties: %s" % e) + return {"tied_bits": sum(r[0] for r in rows), + "tied_ports": [{"port": p, "bits": n, "width": w} + for n, w, p in rows[:10]]} + + +def ties_reasons(metrics, base): + """A harness whose constant ties changed: the synthesis gates fold the + logic behind a tied input and Beacon does not, so they now measure a + different design than the one their budgets were set on. Either way it + needs a reviewed re-record; a baseline without the count is not gated.""" + now, was = metrics.get("tied_bits"), base.get("tied_bits") + if now is None or was is None or now == was: + return [] + return ["harness: %d -> %d instance-input bits tied to constants -- " + "CHANGED: the synthesis gates now fold %s of the logic Beacon " + "counts; review the fpga_gate/asic_gate budget, then re-record" + % (was, now, "more" if now > was else "less")] + + class Xilinx(Tool): """Vivado synthesis + place-and-route (hw/syn/xilinx/dut).""" @@ -330,6 +397,7 @@ class Yosys(Tool): name = "yosys" gate = "asic_gate" flow = "hw/syn/yosys/dut" + top_var = "_TOP" metrics = ("fmax_mhz", "wns_ns", "tns_ns", "cell_area_um2", "seq_area_um2", "sram_area_um2", "cell_count", "power_mw", "build_time_s") @@ -502,13 +570,16 @@ class Beacon(Tool): ("lutram", "lutram", "%d", 9), ("bram", "bram", "%g", 8), ("uram", "uram", "%d", 6), ("dsp", "dsp", "%d", 6), ("p_fmax", "pred_fmax_mhz", "%.1f", 8), - ("risk", "risk_endpoints", "%d", 6)) + ("risk", "risk_endpoints", "%d", 6), + ("tied", "tied_bits", "%d", 6)) # Elaboration and mapping of the widest DUTs; the level count itself is # seconds. weights = {"top": 600, "vortex": 600, "gfx": 600, "core": 300, "tensor": 300, "tcu": 300} fallback_weight = 120 + # Measured peaks: together they exceed a 16 GB hosted runner. + mem_gb = {"gfx": 9.5, "gfxvm": 10.0} job_label = "make" # The netlist exists once foldsim-opt starts mapping it; a typo in a define @@ -584,6 +655,7 @@ def extras(self, work): "fix_levels": doc.get("fix_levels"), "watch_levels": doc.get("watch_levels")} out.update(self.risk(work)) + out.update(harness_ties(work)) return out def risk(self, work): @@ -624,19 +696,29 @@ def risk(self, work): return {"pred_fmax_mhz": round(fmax, 1), "risk_endpoints": risky} def incomplete(self, metrics): - return metrics.get("units") is None + return metrics.get("units") is None or "tied_bits" not in metrics + + def notes(self, build, metrics, args): + # The calibrated Fmax against the clock is a pointer, not a verdict: + # held to it, it failed known-good builds as often as bad ones. + pfmax, clock = metrics.get("pred_fmax_mhz"), build.get("clock_mhz") + if pfmax is None or not clock or pfmax >= clock: + return [] + return ["p_fmax %.1f MHz is %.1f%% below the %g MHz clock; slowest " + "registers in %s (advisory, not gated)" + % (pfmax, 100.0 * (clock - pfmax) / clock, clock, self.RISK)] def compare(self, metrics, base): """Per unit: deeper than its baseline fails; a new unit at the fix threshold fails; shallower, or gone from the watch list, is an improvement to lock in. Per interface output: more bits reached combinationally from outside its instance fails, fewer is an - improvement.""" + improvement. A harness whose constant ties changed fails.""" + reasons = ties_reasons(metrics, base) cur, ref = metrics.get("units"), base.get("units") if cur is None or ref is None: - return [] + return reasons fix = metrics.get("fix_levels") or 0 - reasons = [] for unit in sorted(set(cur) | set(ref)): now, was = cur.get(unit), ref.get(unit) if was is None: @@ -684,7 +766,159 @@ def describe_baseline(self, base): return "max %d levels" % base["max_levels"] -TOOLS = {t.name: t for t in (Xilinx(), Yosys(), Beacon())} +class BeaconAsic(Tool): + """Beacon on the ASIC flow (hw/syn/yosys/dut, target `beacon`, + target=$(PDK)): asic_gate's builds, DUT for DUT and config for config, in + minutes instead of hours. + + foldsim-estimate-timing counts cell stages (docs/designs/beacon.md 4.3) + and converts the deepest path to a period with the library's delays; + foldsim-estimate-area counts cells, flip-flops and SRAM macros, a memory + without a macro as flip-flops. Flip-flops and cells are held to the + baseline (5 %), so a memory that leaves its SRAM macro, or one Yosys must + build from flip-flops, fails here before the nightly synthesis. The + predicted Fmax is held to the build's clock_mhz with a wide band (see + FMAX_BAND): a backstop for a path far too deep to close, not a timing + verdict. The sensitive timing check is register by register against a + reference (--against-rev), where a path that got deeper fails by name. + """ + + name = "beacon_asic" + gate = "logic_gate_asic" + spec = "asic_gate" + flow = "hw/syn/yosys/dut" + top_var = "_TOP" + + metrics = ("fmax_mhz", "period_ps", "max_stages", "cells", "ff", "macros", + "endpoints", "stage_ps", "overhead_ps", "build_time_s") + gated = ("ff", "cells") + integral = ("period_ps", "max_stages", "cells", "ff", "macros", + "endpoints", "stage_ps", "overhead_ps", "build_time_s") + key_metric = "period_ps" + summary = "beacon_asic_summary.csv" + # The predicted Fmax fails only more than FMAX_BAND below clock_mhz. + # Beacon's period runs 0.59-1.05x OpenSTA's on the 14 DUTs (it prices + # vm's L2 TLB MRU update at 46 stages where STA closes it at 1266 MHz), + # so a tight band fails designs that close. Over every validated (design, + # target) pair, the lowest prediction of a design STA closes is 0.749 of + # its target (vm and the fixed top, 749 MHz at 1 GHz), and the highest of + # one that misses badly is 0.615 (core and top before their FPU fixes, + # 492 MHz at 800). 0.32 splits that gap evenly in ratio (about 10 % margin + # each side) and holds at both the 800 MHz and the 1 GHz target. + FMAX_BAND = 0.32 + metric_tolerance = {"fmax_mhz": FMAX_BAND} + # Beacon reads no clock: the target only sets the band and the stage + # thresholds, so a new target must not invalidate the measurements. + clock_in_hash = False + depth_unit = "stages" + columns = (("fmax", "fmax_mhz", "%.0f", 7), + ("stages", "max_stages", "%d", 7), + ("cells", "cells", "%d", 9), + ("ff", "ff", "%d", 8), + ("macros", "macros", "%d", 7), + ("tied", "tied_bits", "%d", 6)) + weights = {"top": 600, "gfx": 600, "core": 300, "tensor": 300, "vm": 300} + fallback_weight = 120 + job_label = "make" + elab_done = "foldsim-beacon-map" + phases = ( + ("gen_sources.sh", "sources"), + ("circt_elaborate.sh", "elaboration"), + (elab_done, "mapping"), + ("foldsim-estimate-timing", "stages"), + ("foldsim-estimate-area", "area"), + ("asic-summary", "reporting"), + ) + error_re = re.compile(r"^(?:ERROR|FATAL|Error)\b|: error:|^\S+: \*\*\* ") + + REPORT = os.path.join("beacon", "report.txt") + AREA = os.path.join("beacon", "area.txt") + + def env(self, args): + return {"circt": tool_version("circt-verilog", "--version", + package="circt", line_prefix="CIRCT"), + "foldsim": tool_version("foldsim-opt", "--version", + package="foldsim", + line_prefix="foldsim"), + "pdk": os.environ.get("PDK", "asap7"), + "xlen": args.xlen} + + def hash_key(self, env): + return [env["circt"], env["foldsim"], env["pdk"], str(env["xlen"])] + + def env_warning(self, build, env): + return Beacon.env_warning(self, build, env) + + tops = Yosys.tops + work_dir = Yosys.work_dir + + def diff_levels(self, build, metrics): + """(watch, fix) stages for `beacon.py diff`: the most that fit 90 % + and 100 % of the target period, plus one, with the run's own delays + (period = overhead + stages x stage).""" + period = 1e6 / float(build["clock_mhz"]) + stage = metrics.get("stage_ps") or 24 + over = metrics.get("overhead_ps") or 231 + return (int((0.9 * period - over) // stage) + 1, + int((period - over) // stage) + 1) + + def _make(self, dut_root, build, target): + return ["make", "-C", dut_root, build["dut"], "TARGET=" + target, + "PREFIX=%s_%s" % (self.gate, build["id"]), + "CONFIGS=" + build["configs"]] + + def clean(self, dut_root, work, build, benv): + shutil.rmtree(work, ignore_errors=True) + os.makedirs(work, exist_ok=True) + + def build_command(self, dut_root, work, build, env, args): + os.makedirs(work, exist_ok=True) + script = os.path.join(os.path.dirname(os.path.abspath(__file__)), + "beacon.py") + make = " ".join(shlex.quote(a) for a in self._make(dut_root, build, "beacon")) + return ["sh", "-c", "%s && echo asic-summary && %s %s asic-summary %s %s" + % (make, shlex.quote(sys.executable), shlex.quote(script), + shlex.quote(os.path.join(work, "beacon")), + shlex.quote(os.path.join(work, self.summary)))], {} + + def extras(self, work): + return harness_ties(work) + + def incomplete(self, metrics): + return "tied_bits" not in metrics + + def compare(self, metrics, base): + return ties_reasons(metrics, base) + + def notes(self, build, metrics, args): + # Below the target but inside the band: worth a look, not a verdict. + # Beyond the band, gate() already failed it. + fmax, clock = metrics.get("fmax_mhz"), build.get("clock_mhz") + if fmax is None or not clock or fmax >= clock: + return [] + band = threshold(build, "fmax_mhz", args) + shortfall = (clock - fmax) / float(clock) + if shortfall > band: + return [] + return ["predicted Fmax %.0f MHz is %.1f%% below the %g MHz target, " + "inside the %.0f%% band; deepest path in %s (advisory)" + % (fmax, 100 * shortfall, clock, 100 * band, self.REPORT)] + + def evidence(self, work): + return [p for p in (os.path.join(work, self.REPORT), + os.path.join(work, self.AREA)) + if os.path.exists(p)] + + def describe(self, m): + return "Fmax=%.0f MHz (%d stages) %d cells, %d FFs" % ( + m.get("fmax_mhz") or 0, m.get("max_stages") or 0, + m.get("cells") or 0, m.get("ff") or 0) + + def describe_baseline(self, base): + return "Fmax=%.0f MHz %d FFs" % (base.get("fmax_mhz") or 0, base.get("ff") or 0) + + +TOOLS = {t.name: t for t in (Xilinx(), Yosys(), Beacon(), BeaconAsic())} def tool_version(name, flag, package=None, line_prefix=None): @@ -742,15 +976,18 @@ def spec_path(root, gate): return os.path.join(root, "ci", "testcases", gate + ".yaml") -def baseline_dir(root, tool): - return os.path.join(root, "ci", "baselines", "synthesis", tool) +def baseline_dir(root, tool, override=None): + """ci/baselines/synthesis/, or / to read and write + proposed baselines outside the tree.""" + return os.path.join(override or os.path.join(root, "ci", "baselines", + "synthesis"), tool) -def baseline_path(root, tool, group): - return os.path.join(baseline_dir(root, tool), group + ".json") +def baseline_path(root, tool, group, override=None): + return os.path.join(baseline_dir(root, tool, override), group + ".json") -def load_catalog(root, tool, xlen=32): +def load_catalog(root, tool, xlen=32, baselines_from=None): """Builds keyed by id: the SPEC from ci/testcases/.yaml, joined to its recorded metrics from ci/baselines/synthesis//.json. @@ -758,8 +995,12 @@ def load_catalog(root, tool, xlen=32): (and is hand-authored, commented, reviewed), the baseline says what the last accepted answer was (and is machine-written). Neither file can be mistaken for the other's job. + + A tool that measures another gate's builds (`spec`) takes their designs + and targets, not their verdict policy: that gate's `known_issue` and + `thresholds` describe its own tool's numbers. """ - with open(spec_path(root, tool.gate)) as fh: + with open(spec_path(root, tool.spec or tool.gate)) as fh: doc = yaml.safe_load(fh) defaults = doc.get("defaults") or {} # `builds:`, not `tests:` -- a synthesis build is not a pytest case (no @@ -768,11 +1009,11 @@ def load_catalog(root, tool, xlen=32): # is ours. spec = doc.get("builds") if not spec: - sys.exit("ERROR: no `builds:` block in %s" % spec_path(root, tool.gate)) + sys.exit("ERROR: no `builds:` block in %s" % spec_path(root, tool.spec or tool.gate)) baselines = {} for group in {e.get("group", "default") for e in spec}: - path = baseline_path(root, tool.name, group) + path = baseline_path(root, tool.name, group, baselines_from) if os.path.exists(path): with open(path) as fh: baselines[group] = json.load(fh) @@ -782,7 +1023,7 @@ def load_catalog(root, tool, xlen=32): bid = entry["id"] if bid in builds: sys.exit("ERROR: duplicate build id '%s' in %s" - % (bid, spec_path(root, tool.gate))) + % (bid, spec_path(root, tool.spec or tool.gate))) required = {"dut", "clock_mhz", "configs"} | ({tool.budget_key} if tool.budget_key else set()) missing = required - set(entry) if missing: @@ -797,10 +1038,11 @@ def load_catalog(root, tool, xlen=32): build["xlen"] = entry.get("xlen", xlen) build["profile"] = entry.get("profile", "") build["opt_in"] = bool(entry.get("opt_in", False)) - build["known_issue"] = entry.get("known_issue", - defaults.get("known_issue", "")) - build["thresholds"] = entry.get("thresholds", - defaults.get("thresholds", {})) + borrowed = bool(tool.spec) + build["known_issue"] = "" if borrowed else entry.get( + "known_issue", defaults.get("known_issue", "")) + build["thresholds"] = {} if borrowed else entry.get( + "thresholds", defaults.get("thresholds", {})) recorded = baselines.get(group, {}).get(bid, {}) result = recorded.get("result") or {} # An all-null skeleton means "never recorded" -- the file ships with the @@ -809,6 +1051,9 @@ def load_catalog(root, tool, xlen=32): else None build["baseline_env"] = result.get("env") or {} build["config_hash"] = recorded.get("config_hash") + # Regressions against a reference that the last re-record accepted + # (--update-baseline with --against-rev); see compare_against(). + build["accepted"] = recorded.get("accepted") or {} builds[bid] = build return builds @@ -833,7 +1078,8 @@ def select(builds, selectors): def config_hash(build, env, tool): """Fingerprint the synthesis inputs; a change invalidates the stored metrics.""" - key = "|".join([build["dut"], str(build["clock_mhz"]), build["configs"]] + clock = [str(build["clock_mhz"])] if tool.clock_in_hash else [] + key = "|".join([build["dut"]] + clock + [build["configs"]] + tool.hash_key(dict(env, xlen=build["xlen"]))) # Appended only when set, so builds without a strategy override or a # profile keep the hash their baselines were recorded under. @@ -846,7 +1092,7 @@ def config_hash(build, env, tool): return hashlib.sha256(key.encode()).hexdigest()[:16] -def save_baselines(root, tool, results, env): +def save_baselines(root, tool, results, env, override=None): """Write measured metrics to the golden baselines (never done by CI). Each entry records the GPU configuration it represents -- dut, target clock, @@ -855,13 +1101,17 @@ def save_baselines(root, tool, results, env): source of truth for what to build; config_hash fingerprints that spec and invalidates the metrics if it drifts, so the recorded config cannot be hand-edited to disagree with the numbers next to it without failing the gate. + + Recorded against a revision (--against-rev), an entry also lists the + regressions against it as `accepted`: what the re-record decided, in the + diff a reviewer reads, and what compare_against() lets pass. """ by_group = {} for r in results: by_group.setdefault(r["build"]["group"], []).append(r) - os.makedirs(baseline_dir(root, tool.name), exist_ok=True) + os.makedirs(baseline_dir(root, tool.name, override), exist_ok=True) for group, rs in by_group.items(): - path = baseline_path(root, tool.name, group) + path = baseline_path(root, tool.name, group, override) entries = {} if os.path.exists(path): with open(path) as fh: @@ -879,6 +1129,11 @@ def save_baselines(root, tool, results, env): entries[b["id"]]["impl_strategy"] = b["impl_strategy"] if b.get("profile"): entries[b["id"]]["profile"] = b["profile"] + against = r.get("against") or {} + if against.get("rev") and against.get("regressions"): + entries[b["id"]]["accepted"] = { + "against": against["rev"], + "regressions": against["regressions"]} with open(path, "w") as fh: json.dump(entries, fh, indent=2, sort_keys=True) fh.write("\n") @@ -1142,6 +1397,17 @@ def run_build(build, build_dir, env, args, tool): if not tool.incomplete(stamp["metrics"]): say(build, "cache", "already built for this config -- reusing") return stamp["metrics"] + # The diagnostics are read from the finished build's own files, + # so they can usually be brought up to date without the tool. + try: + metrics = dict(stamp["metrics"], **tool.extras(work)) + except BuildError: + metrics = stamp["metrics"] + if not tool.incomplete(metrics): + save_stamp(work, chash, "done", stamp_file, metrics) + say(build, "cache", "already built for this config -- reusing, " + "diagnostics re-read") + return metrics say(build, "resum", "built, but its diagnostics predate this gate -- " "re-reporting from checkpoint") resume = True @@ -1209,6 +1475,20 @@ def weight(build, tool): return recorded or tool.weights.get(build["dut"], tool.fallback_weight) +def mem_need(build, tool): + """Peak memory (GB) a build is admitted with; 0 when not estimated.""" + return tool.mem_gb.get(build["dut"], 0) + + +def mem_budget(): + """GB the builds may hold at once: 85 % of the machine's memory.""" + with open("/proc/meminfo") as fh: + for line in fh: + if line.startswith("MemTotal:"): + return 0.85 * int(line.split()[1]) / (1024 * 1024) + return float("inf") + + def run_all(builds, build_dir, env, args, tool): """Longest-processing-time-first list scheduling. @@ -1228,26 +1508,44 @@ def run_all(builds, build_dir, env, args, tool): tool.prepare_flow(tool.dut_root(build_dir), env) + # Each free slot takes the longest pending build whose peak fits next to + # the running ones; a build that fits nowhere runs alone. + budget = mem_budget() results = [] + pending = list(order) + running = {} with concurrent.futures.ThreadPoolExecutor(max_workers=args.jobs) as pool: - futures = {pool.submit(run_build, b, build_dir, env, args, tool): b - for b in order} - for fut in concurrent.futures.as_completed(futures): - b = futures[fut] - work = build_work(b, build_dir, tool) - try: - metrics = fut.result() - say(b, "done", "%s (%dm)" % (tool.describe(metrics), - metrics["build_time_s"] // 60)) - results.append({"build": b, "metrics": metrics, "error": None, - "work": work}) - except (BuildError, subprocess.CalledProcessError) as e: - say(b, "FAIL", str(e)) - results.append({"build": b, "metrics": None, "error": str(e), - "work": work}) + while pending or running: + used = sum(mem_need(b, tool) for b in running.values()) + for b in list(pending): + if len(running) >= args.jobs: + break + if running and used + mem_need(b, tool) > budget: + continue + pending.remove(b) + used += mem_need(b, tool) + running[pool.submit(run_build, b, build_dir, env, args, tool)] = b + done, _ = concurrent.futures.wait( + running, return_when=concurrent.futures.FIRST_COMPLETED) + for fut in done: + b = running.pop(fut) + results.append(finish_build(fut, b, build_dir, tool)) return sorted(results, key=lambda r: r["build"]["id"]) +def finish_build(fut, b, build_dir, tool): + """A finished build's result row, reported as it lands.""" + work = build_work(b, build_dir, tool) + try: + metrics = fut.result() + say(b, "done", "%s (%dm)" % (tool.describe(metrics), + metrics["build_time_s"] // 60)) + return {"build": b, "metrics": metrics, "error": None, "work": work} + except (BuildError, subprocess.CalledProcessError) as e: + say(b, "FAIL", str(e)) + return {"build": b, "metrics": None, "error": str(e), "work": work} + + # --------------------------------------------------------------------------- # gate # --------------------------------------------------------------------------- @@ -1369,15 +1667,18 @@ def report_entry(r, env, tool): entry["xlen"] = b["xlen"] if b.get("profile"): entry["profile"] = b["profile"] + if r.get("against"): + entry["against"] = r["against"] return entry -def report(results, env, args, gated, tool, record=False): +def report(results, env, args, gated, tool, mode="gate"): """Print the metric table; return the list of failing verdicts. In record mode the table is the review artifact for the baseline update, so the per-metric deltas are still shown (that is the diff a human signs off on) - but they are not verdicts -- recording IS the intent. + but they are not verdicts -- recording IS the intent. In measure mode (a + reference run for --against-rev) nothing is judged at all. """ head = "%-10s %-8s" + "".join(" %%%ds" % c[3] for c in tool.columns) title = head % (("build", "dut") + tuple(c[0] for c in tool.columns)) \ @@ -1389,9 +1690,10 @@ def report(results, env, args, gated, tool, record=False): failures = [] for r in results: b = r["build"] - if record: - verdict, reasons = ("RECORDED", []) if r["metrics"] \ - else ("BUILD-FAIL", [r["error"]]) + if mode != "gate": + verdict, reasons = (("RECORDED" if mode == "record" else "MEASURED", + []) if r["metrics"] + else ("BUILD-FAIL", [r["error"]])) else: verdict, reasons = gate(r, env, args, gated, tool) r["verdict"] = verdict @@ -1425,47 +1727,487 @@ def cell(key, fmt): "NO-BASELINE"): for path in tool.evidence(works[bid]): print(" see %s" % path) + notes = [(r["build"]["id"], n) for r in results if r["metrics"] + for n in tool.notes(r["build"], r["metrics"], args)] + if notes: + print("\nadvisory (not gated):") + for bid, note in notes: + print(" %-10s %s" % (bid, note)) return failures -def compare_against(results, ref_dir, tool): - """Each finished build's Beacon run against the same build in ref_dir: - end points register by register, and area by unit; return the builds a - register got deeper in, or whose area grew past the tolerance, as failing - verdicts.""" + + +# --------------------------------------------------------------------------- +# reference runs (--against, --against-rev) +# --------------------------------------------------------------------------- + +# Where --against-rev's reference takes REV's files: the RTL, the harnesses, +# the RTL the flows add (DPI headers, the ASIC RAM stubs) and the +# configuration; submodules are taken at the commit REV pins. Every other +# file is this checkout's, so both sides are measured by the same flow and +# the same tools. +REF_PATHS = ("hw/rtl", "hw/unittest", "hw/dpi", "hw/syn/libs/no_mem", + "VX_config.toml", "VX_types.toml") +# Tracked paths no Beacon run reads: the reference stays valid across them. +FLOW_EXCLUDE = ("docs", "sim", "tests", "**/*.md") +# The default of --against-rev: how CI passes a pull request's merge base. +AGAINST_REV_ENV = "BEACON_AGAINST_REV" +# The default of --ref-cache. +REF_CACHE_ENV = "BEACON_REF_CACHE" +# Reference trees kept in the cache, the one in use among them. +REF_KEEP = 4 +# Regressions listed per build against a reference; beacon_diff.txt has all. +REASONS_SHOWN = 10 + + +class RefError(Exception): + """The reference cannot be staged; the run is not gated (exit 2).""" + + +def git(root, *argv): + return subprocess.check_output(["git", "-C", root] + list(argv)) + + +def submodules(root): + """Paths of this checkout's submodules (gitlinks).""" + return [line.split(b"\t", 1)[1].decode() + for line in git(root, "ls-files", "-s", "-z").split(b"\0") + if line.startswith(b"160000 ")] + + +def paths_at(root, rev, paths): + """The ones of `paths` that exist at REV.""" + return [p for p in paths if git(root, "ls-tree", "--name-only", rev, "--", p)] + + +def flow_fingerprint(root): + """This checkout's flow, as staged and as edited: every tracked file but + REF_PATHS, the submodules and FLOW_EXCLUDE. A reference measured under + another flow is rebuilt; under this one it is reused whatever the RTL + here does, which is what an RTL iteration loop wants.""" + spec = ["--", "."] + [":(exclude,glob)%s" % p if "*" in p else ":(exclude)%s" % p + for p in REF_PATHS + tuple(submodules(root)) + FLOW_EXCLUDE] + h = hashlib.sha256() + h.update(git(root, "ls-files", "-s", *spec)) + h.update(git(root, "diff", "--binary", *spec)) + return h.hexdigest()[:16] + + +def _extract(argv, dst): + """`argv` (a git archive) unpacked into dst; False if it failed.""" + os.makedirs(dst, exist_ok=True) + archive = subprocess.Popen(argv, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + tar = subprocess.run(["tar", "-C", dst, "-xf", "-"], stdin=archive.stdout, + stderr=subprocess.DEVNULL) + archive.stdout.close() + return archive.wait() == 0 and tar.returncode == 0 + + +def stage_reference(root, rev, src): + """A source tree of this checkout's tracked files with REV's REF_PATHS and + REV's submodule commits: REV's design under this checkout's flow.""" + shutil.rmtree(src, ignore_errors=True) + os.makedirs(src) + subs = submodules(root) + skip = tuple(p + "/" for p in REF_PATHS) + for line in git(root, "ls-files", "-s", "-z").split(b"\0"): + if not line: + continue + path = line.decode().split("\t", 1)[1] + if path in REF_PATHS or path.startswith(skip) or path in subs: + continue + dst = os.path.join(src, path) + os.makedirs(os.path.dirname(dst), exist_ok=True) + if os.path.isfile(os.path.join(root, path)): + shutil.copy2(os.path.join(root, path), dst) + paths = paths_at(root, rev, REF_PATHS) + if not paths: + raise RefError("%s has none of %s: not a revision of this design" + % (rev, ", ".join(REF_PATHS))) + if not _extract(["git", "-C", root, "archive", rev] + paths, src): + raise RefError("git archive %s %s failed" % (rev, " ".join(paths))) + for path in subs: + dst = os.path.join(src, path) + pinned = git(root, "ls-tree", rev, "--", path).split() + if len(pinned) < 3 or pinned[1] != b"commit": + # REV does not pin it: the flow finds this checkout's copy there. + os.makedirs(os.path.dirname(dst), exist_ok=True) + os.symlink(os.path.join(root, path), dst) + continue + stage_submodule(os.path.join(root, path), pinned[2].decode(), dst, rev) + open(os.path.join(src, ".ready"), "w").close() + + +def stage_submodule(repo, sha, dst, rev): + """The submodule checked out at `repo`, at commit `sha`, into dst, with + its own submodules at the commits it pins. One not checked out here is + left empty, as it is in this checkout.""" + os.makedirs(dst, exist_ok=True) + if not os.path.exists(os.path.join(repo, ".git")): + return + if not _extract(["git", "-C", repo, "archive", sha], dst): + raise RefError("%s does not have %s, the commit %s pins (git -C %s fetch)" + % (repo, sha[:12], rev, repo)) + for line in git(repo, "ls-tree", "-r", "-z", sha).split(b"\0"): + meta, _, path = line.decode().partition("\t") + if meta.split()[:2] == ["160000", "commit"]: + stage_submodule(os.path.join(repo, path), meta.split()[2], + os.path.join(dst, path), rev) + + +def defines_module(root, module, rev=None): + """Whether REF_PATHS define `module`, at REV or in this checkout.""" + pattern = r"^[[:space:]]*module[[:space:]]+%s([^A-Za-z0-9_$]|$)" % re.escape(module) + where = ([rev, "--"] + paths_at(root, rev, REF_PATHS) if rev + else ["--"] + list(REF_PATHS)) + rc = subprocess.run(["git", "-C", root, "grep", "-q", "-E", pattern] + where, + stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL).returncode + if rc not in (0, 1): + raise RefError("git grep %s failed (exit %d)" % (rev or "", rc)) + return rc == 0 + + +def absent_at(root, rev, tool, dut): + """Whether REV has no such DUT at all: neither the DUT in its catalog nor + its top module. Conclusive only for a top this checkout's REF_PATHS + define; a top generated or kept elsewhere, or one the catalog names by + configuration, counts as present. A DUT REV has under another top (a + renamed harness) is present, so its failed reference reads REF-FAIL.""" + catalog = os.path.join(root, *tool.flow.split("/")) + top = tool.top_module(catalog, dut) + if not top or "$" in top or not defines_module(root, top): + return False + try: + text = git(root, "show", "%s:%s/catalog.mk" % (rev, tool.flow)).decode() + except subprocess.CalledProcessError: + return False + if dut in _make_var(text, "DUTS").split(): + return False + return not defines_module(root, top, rev) + + +def prune_references(cache, keep): + """Remove the cache's reference trees beyond the REF_KEEP most recently + used; `keep` is always kept, and one another run holds is skipped.""" + trees = [] + for d in os.listdir(cache): + try: + if re.fullmatch(r"[0-9a-f]{12}", d) and d != keep: + trees.append((os.path.getmtime(os.path.join(cache, d)), d)) + except OSError: + continue # removed by another run since the listing + for _, d in sorted(trees, reverse=True)[REF_KEEP - 1:]: + with open(os.path.join(cache, d + ".lock"), "a") as fh: + try: + fcntl.flock(fh, fcntl.LOCK_EX | fcntl.LOCK_NB) + except OSError: + continue + shutil.rmtree(os.path.join(cache, d), ignore_errors=True) + + +def reference_tree(root, rev, args, tool, builds, xlen): + """Measure `builds` on REV's design under this checkout's flow; return + (the build tree to compare against, REV's SHA, the ids of the builds + REV does not have (absent_at), the reference run's exit code, the held + lock). + + The reference lives in //: `src/` is the staged source tree + and `build_/` its builds, resumable like any gate session, so + a second run against the same REV reuses every finished build. CI keeps + the build trees in its cache keyed by the merge base's SHA. A change of + this checkout's flow (flow_fingerprint) discards both. .lock is held + exclusively while the tree is checked, staged and built, and shared + while it is read, so runs on one cache (the FPGA and the ASIC flow, or + worktrees sharing BEACON_REF_CACHE) never remove each other's files.""" + try: + sha = subprocess.check_output( + ["git", "-C", root, "rev-parse", "--verify", "%s^{commit}" % rev], + stderr=subprocess.DEVNULL).decode().strip() + except subprocess.CalledProcessError: + raise RefError("--against-rev %s is not a commit in %s (fetch it first)" + % (rev, root)) + cache = os.path.abspath(args.ref_cache or os.environ.get(REF_CACHE_ENV) or + os.path.join(root, ".beacon_ref")) + os.makedirs(cache, exist_ok=True) + ref = os.path.join(cache, sha[:12]) + lock = open(ref + ".lock", "a") + fcntl.flock(lock, fcntl.LOCK_EX) + src = os.path.join(ref, "src") + build_dir = os.path.join(ref, "build%d_%s" % (xlen, tool.gate)) + stamp = os.path.join(ref, "flow") + flow = flow_fingerprint(root) + try: + with open(stamp) as fh: + same = fh.read().strip() == flow + except OSError: + same = False + if not same: + shutil.rmtree(ref, ignore_errors=True) + os.makedirs(ref, exist_ok=True) + os.utime(ref) + prune_references(cache, sha[:12]) + if not os.path.exists(os.path.join(src, ".ready")): + print("reference: staging %s (%s) in %s" % (rev, sha[:12], src), flush=True) + stage_reference(root, sha, src) + with open(stamp, "w") as fh: + fh.write(flow + "\n") + + absent = {b["id"] for b in builds if absent_at(root, sha, tool, b["dut"])} + for bid in sorted(absent): + print("reference: %s has no DUT for %s" % (sha[:12], bid), flush=True) + present = [b["id"] for b in builds if b["id"] not in absent] + rc = 0 + if present: + argv = [sys.executable, os.path.join(src, "ci", "logic_gate.py"), + "--tool", tool.name, "--build-dir", build_dir, "--resume", + "--measure-only", "--xlen", str(xlen), "-j", str(args.jobs), + "--timeout", str(args.timeout)] + if args.tool_jobs: + argv += ["--tool-jobs", str(args.tool_jobs)] + if args.configs: + argv.append("--configs=" + args.configs) + for bid in present: + argv += ["-b", bid] + env = dict(os.environ) + env.pop(AGAINST_REV_ENV, None) + print("reference: %s (%s) in %s" % (rev, sha[:12], build_dir), flush=True) + rc = subprocess.run(argv, env=env).returncode + if rc: + print("ERROR: the reference run failed (exit %d)" % rc, flush=True) + fcntl.flock(lock, fcntl.LOCK_SH) + return build_dir, sha, absent, rc, lock + + +def live_acceptance(build, root, rev, tool): + """The baseline's accepted regressions, unless the reference already has + them: a re-record's acceptance holds until it lands, and once the + reference revision's baseline carries the same entry the change it + accepted is part of the reference and the acceptance has done its job.""" + accepted = build.get("accepted") or {} + if not accepted or not rev: + return accepted + path = "ci/baselines/synthesis/%s/%s.json" % (tool.name, build["group"]) + try: + landed = json.loads(git(root, "show", "%s:%s" % (rev, path))) + except (subprocess.CalledProcessError, ValueError): + return accepted + return {} if (landed.get(build["id"]) or {}).get("accepted") == accepted \ + else accepted + + +def accepted_by(accepted, reg): + """Whether the baseline's last re-record accepted this regression: the + same register, resource or harness, and no worse than then.""" + for a in (accepted or {}).get("regressions", ()): + if a.get("kind") == reg["kind"] and a.get("name") == reg["name"]: + if reg["kind"] == "ties": + return a.get("after") == reg["after"] + return reg["after"] <= a.get("after", float("-inf")) + return False + + +def regression_reason(reg, tool, fix): + kind, name, unit = reg["kind"], reg["name"], tool.depth_unit + if kind == "deeper": + return ("%s: %d -> %d %s -- DEEPER than the reference" + % (name, reg["before"], reg["after"], unit)) + if kind == "new": + return ("%s: new at %d %s (fix threshold %d) -- DEEPER than the " + "reference" % (name, reg["after"], unit, fix)) + if kind == "area": + return ("%s: %g -> %g (%+.1f%%) -- AREA grown past the tolerance " + "against the reference" + % (name, reg["before"], reg["after"], + 100.0 * (reg["after"] - reg["before"]) / reg["before"] + if reg["before"] else 100.0)) + return ties_reasons({"tied_bits": reg["after"]}, + {"tied_bits": reg["before"]})[0] + + +def compare_against(results, ref_dir, tool, env, root, rev=None, absent=()): + """Each finished build's Beacon run against the same build in ref_dir + (ci/beacon.py diff): register by register, area by resource, and the + harness's constant ties. Sets each result's `against`: its verdict, + the regressions, and the reasons. + + A build the reference revision does not have (a DUT the change adds, + absent_at) reads NO-REFERENCE and is judged against its baseline alone. Any + other build without a finished reference of the same config is REF-FAIL: + a reference that timed out or crashed must not pass for one that agrees. + + A regression the baseline's re-record accepted (--update-baseline with + --against-rev, stored in the baseline entry) reads ACCEPTED until that + acceptance reaches the reference (live_acceptance). One the re-record + did not see fails.""" script = os.path.join(os.path.dirname(os.path.abspath(__file__)), "beacon.py") - failures = [] + label = rev[:12] if rev else ref_dir + rows = [] for r in results: b, work = r["build"], r.get("work") if not r["metrics"] or not work: continue - ref = os.path.join(build_work(b, ref_dir, tool), "beacon") - cur = os.path.join(work, "beacon") - if not os.path.exists(os.path.join(ref, "endpoints.csv")): - print("\n%s: no reference run in %s" % (b["id"], ref)) + against = {"reference": label, "rev": rev, "regressions": []} + r["against"] = against + if b["id"] in absent: + against.update(verdict="NO-REFERENCE", reasons=[ + "%s has no %s DUT (neither in its catalog nor its top module): " + "judged against its baseline only" % (label, b["dut"])]) + rows.append((b["id"], "NO-REFERENCE", "-")) + continue + ref_work = build_work(b, ref_dir, tool) + ref = os.path.join(ref_work, "beacon") + try: + with open(os.path.join(ref_work, tool.gate + ".json")) as fh: + stamp = json.load(fh) + except (OSError, ValueError): + stamp = {} + problem = (None if stamp.get("status") == "done" and stamp.get("metrics") + and os.path.exists(os.path.join(ref, "endpoints.csv")) + else "no finished reference build in %s (see its build.log)" + % ref_work) + if not problem and stamp.get("config_hash") != config_hash(b, env, tool): + problem = ("the reference in %s was measured under another " + "configuration (config hash %s, this build %s)" + % (ref_work, stamp.get("config_hash"), + config_hash(b, env, tool))) + if problem: + against.update(verdict="REF-FAIL", reasons=[problem]) + rows.append((b["id"], "REF-FAIL", "-")) continue + ref_metrics = stamp["metrics"] out = os.path.join(work, "beacon_diff.txt") + doc_path = os.path.join(work, "beacon_diff.json") + if os.path.exists(doc_path): + os.remove(doc_path) + watch, fix = tool.diff_levels(b, r["metrics"]) with open(out, "w") as fh: - m = r["metrics"] - rc = subprocess.run([sys.executable, script, "diff", ref, cur, - "--min-levels", str(m.get("watch_levels") or 8), - "--fix-levels", str(m.get("fix_levels") or 12)], + rc = subprocess.run([sys.executable, script, "diff", ref, + os.path.join(work, "beacon"), + "--min-levels", str(watch), + "--fix-levels", str(fix), + "--json", doc_path], stdout=fh, stderr=subprocess.STDOUT).returncode - with open(out) as fh: - head = fh.readline().strip() - print("\n%s against %s: %s%s\n see %s" - % (b["id"], ref_dir, head, " -- REGRESSION" if rc in (1, 3) else "", - out)) - if rc == 1: - failures.append((b["id"], "DEEPER", ["a register got deeper than in " - "the reference: %s" % out])) - elif rc == 3: - failures.append((b["id"], "AREA", ["the design's area grew past the " - "tolerance against the " - "reference: %s" % out])) - elif rc: - failures.append((b["id"], "BUILD-FAIL", ["beacon.py diff failed: %s" % out])) - return failures + against["diff"] = out + try: + with open(doc_path) as fh: + doc = json.load(fh) + except (OSError, ValueError): + doc = None + if rc not in (0, 1, 3) or doc is None: + against.update(verdict="BUILD-FAIL", + reasons=["beacon.py diff failed (exit %d): %s" % (rc, out)]) + rows.append((b["id"], "BUILD-FAIL", "-")) + continue + regs = [dict(kind="deeper", name=d["register"], before=d["before"], + after=d["after"]) for d in doc["deeper"]] + regs += [dict(kind="new", name=d["register"], before=None, + after=d["after"]) for d in doc["new"]] + regs += [dict(kind="area", name=d["resource"], before=d["before"], + after=d["after"]) for d in doc["area"]] + was, now = ref_metrics.get("tied_bits"), r["metrics"].get("tied_bits") + if was is not None and now is not None and was != now: + regs.append(dict(kind="ties", name="tied_bits", before=was, after=now)) + accepted = live_acceptance(b, root, rev, tool) + open_regs = [g for g in regs if not accepted_by(accepted, g)] + kinds = {g["kind"] for g in open_regs} + verdict = ("DEEPER" if kinds & {"deeper", "new"} else + "AREA" if "area" in kinds else + "HARNESS" if "ties" in kinds else + "ACCEPTED" if regs else "PASS") + # Generate copies of one register repeat its line; the diff has them all. + shown = open_regs[:REASONS_SHOWN] + reasons = [regression_reason(g, tool, fix) for g in shown] + covered = [g for g in regs if g not in open_regs] + reasons += ["accepted by the baseline's re-record against %s: %s" + % (accepted.get("against", "?")[:12], + regression_reason(g, tool, fix)) + for g in covered[:max(0, REASONS_SHOWN - len(shown))]] + hidden = len(regs) - len(reasons) + if hidden > 0: + reasons.append("... and %d more" % hidden) + if reasons: + reasons.append("see %s" % out) + against.update(verdict=verdict, regressions=regs, reasons=reasons, + headline=doc.get("headline", "")) + rows.append((b["id"], verdict, doc.get("headline", ""))) + + if rows: + print("\nagainst %s (%s):" % (label, ref_dir)) + for bid, verdict, head in rows: + print(" %-10s %-12s %s" % (bid, verdict, head)) + for r in results: + a = r.get("against") or {} + if a.get("verdict") not in (None, "PASS"): + print("\n%s against %s: %s" % (r["build"]["id"], label, a["verdict"])) + for reason in a["reasons"]: + print(" - %s" % reason) + + +def trim_reference_cache(cache): + """Shrink a reference cache to what a later comparison reads (stamps, end + points, instances, area) before CI saves it. A build that did not finish + is removed whole, so the next run under the same key rebuilds it clean + instead of resuming from a tree whose generated sources are gone.""" + for ref in glob.glob(os.path.join(cache, "[0-9a-f]" * 12)): + shutil.rmtree(os.path.join(ref, "src"), ignore_errors=True) + works = glob.glob(os.path.join(ref, "build*", "hw", "syn", "*", "logic_gate*_*")) \ + + glob.glob(os.path.join(ref, "build*", "hw", "syn", "*", "dut", "logic_gate*_*")) + for work in [w for w in works if os.path.isdir(w)]: + stamps = glob.glob(os.path.join(work, "logic_gate*.json")) + try: + with open(stamps[0]) as fh: + done = json.load(fh).get("status") == "done" + except (IndexError, OSError, ValueError): + done = False + if not done: + shutil.rmtree(work) + continue + for top, dirs, files in os.walk(work): + for d in [d for d in dirs if d == "src"]: + shutil.rmtree(os.path.join(top, d)) + dirs.remove(d) + for f in files: + if f.endswith((".mlir", ".mlirbc")) or \ + f in ("paths.jsonl", "sources.txt", "sources.f"): + os.remove(os.path.join(top, f)) + + +def reference_cache_done(cache): + """The finished reference builds in a cache, one line each: the stamp's + path and the config hash it was measured under.""" + done = [] + for stamp in glob.glob(os.path.join(cache, "*", "build*", "hw", "syn", "**", + "logic_gate*.json"), recursive=True): + try: + with open(stamp) as fh: + doc = json.load(fh) + except (OSError, ValueError): + continue + if doc.get("status") == "done": + done.append("%s %s" % (os.path.relpath(stamp, cache), doc.get("config_hash"))) + return sorted(done) + + +def reference_cache_id(done): + """A digest of reference_cache_done()'s lines: CI saves a cache under it + once the set has grown, so a later push can save the builds an earlier + one did not finish, under a new key.""" + return hashlib.sha256("\n".join(done).encode()).hexdigest()[:16] + + +def merge_against(results): + """Fold each build's verdict against the reference into its verdict: a + failing one replaces a passing baseline verdict, and every reason is + kept.""" + for r in results: + a = r.get("against") + if not a or a["verdict"] == "PASS": + continue + if a["verdict"] not in PASSING and r["verdict"] in PASSING: + r["verdict"] = a["verdict"] + r["reasons"] = r["reasons"] + ["against %s: %s" % (a["reference"], x) + for x in a["reasons"]] # --------------------------------------------------------------------------- @@ -1505,17 +2247,38 @@ def main(argv=None, default_tool="xilinx"): % (",".join(tool.gated), default_tool)) ap.add_argument("--update-baseline", action="store_true", help="record this run's metrics as the new golden baseline. " - "Human-reviewed; CI must never pass this.") + "Human-reviewed; CI must never pass this. With " + "--against-rev, the regressions against that revision " + "are recorded as accepted") + ap.add_argument("--baseline-dir", metavar="DIR", + help="read and write the baselines under DIR// " + "instead of ci/baselines/synthesis//, e.g. to " + "propose baselines for review outside the tree") ap.add_argument("--build-dir", metavar="DIR", help="build tree to synthesize in (default: " "/build_, configured on demand)") ap.add_argument("--against", metavar="DIR", help="Beacon only: the build tree of a reference run, " "typically the parent revision's; each build's end " - "points are compared register by register, and its " - "area by unit, with the same build there " - "(ci/beacon.py diff); a register that got deeper, or " - "area grown past the tolerance, fails the run") + "points are compared register by register, its " + "area by resource and unit (ci/beacon.py diff), and " + "its harness's constant ties, with the same build " + "there; a register that got deeper, area grown past " + "the tolerance, or changed ties fail the run") + ap.add_argument("--against-rev", metavar="REV", + default=os.environ.get(AGAINST_REV_ENV) or None, + help="Beacon only: as --against, with the reference built " + "here first from REV's RTL (%s) under this " + "checkout's flow, so a change is judged against its " + "merge base and not only against a baseline it may " + "have re-recorded itself (default: $%s)" + % (", ".join(REF_PATHS), AGAINST_REV_ENV)) + ap.add_argument("--ref-cache", metavar="DIR", + help="where --against-rev keeps its reference trees, one " + "per revision (default: $%s, else /.beacon_ref)" + % REF_CACHE_ENV) + ap.add_argument("--measure-only", action="store_true", + help=argparse.SUPPRESS) ap.add_argument("--configs", metavar="FLAGS", default="", help="extra -D flags appended to every selected build's " "configs, for a non-default configuration: run the " @@ -1566,7 +2329,7 @@ def main(argv=None, default_tool="xilinx"): args.metric_threshold = overrides root = source_root() - builds = load_catalog(root, tool, args.xlen) + builds = load_catalog(root, tool, args.xlen, args.baseline_dir) if args.matrix: # Ordered longest-first so the slowest DUT is dispatched into the fan-out @@ -1596,8 +2359,11 @@ def main(argv=None, default_tool="xilinx"): return 0 tool.check_env() - if args.against and tool.name != "beacon": - sys.exit("ERROR: --against compares Beacon runs; use it with --tool=beacon") + if args.measure_only: + args.against = args.against_rev = None + if (args.against or args.against_rev) and not tool.name.startswith("beacon"): + sys.exit("ERROR: --against compares Beacon runs; use it with --tool=beacon " + "or --tool=beacon_asic") if args.configs and args.update_baseline: sys.exit("ERROR: --configs cannot record a baseline: the catalog " "baselines are the catalog configurations") @@ -1623,10 +2389,22 @@ def main(argv=None, default_tool="xilinx"): # One configured build tree per ISA width: a build that pins its own xlen # runs in that width's tree. xlens = sorted({b["xlen"] for b in selected}) - if len(xlens) > 1 and (args.build_dir or args.against): + if len(xlens) > 1 and (args.build_dir or args.against or args.against_rev): sys.exit("ERROR: --build-dir/--against name one build tree, and the " "selected builds span xlen %s; select one width" % "/".join(map(str, xlens))) + if args.against and not os.path.isdir(args.against): + print("ERROR: --against %s is not a build tree" % args.against) + return 2 + # ref_lock stays held (shared) until the run ends, while the reference is read. + against_sha, absent, ref_rc, ref_lock = None, set(), 0, None + if args.against_rev and not args.dry_run: + try: + args.against, against_sha, absent, ref_rc, ref_lock = reference_tree( + root, args.against_rev, args, tool, selected, xlens[0]) + except (RefError, subprocess.CalledProcessError) as e: + print("ERROR: reference %s: %s" % (args.against_rev, e)) + return 2 results = [] for xlen in xlens: build_dir = args.build_dir or os.path.join( @@ -1640,14 +2418,18 @@ def main(argv=None, default_tool="xilinx"): results.sort(key=lambda r: r["build"]["id"]) gated = tuple(m for m in (args.gate.split(",") if args.gate else tool.gated) if m) - outcomes = report(results, env, args, gated, tool, args.update_baseline) - failures = [o for o in outcomes if o[1] not in PASSING] + mode = ("measure" if args.measure_only else + "record" if args.update_baseline else "gate") + report(results, env, args, gated, tool, mode) if args.against: - failures += compare_against(results, args.against, tool) + compare_against(results, args.against, tool, env, root, against_sha, + absent) + if mode == "gate": + merge_against(results) ok = [r for r in results if r["metrics"]] if args.update_baseline and ok: - save_baselines(root, tool, ok, env) + save_baselines(root, tool, ok, env, args.baseline_dir) if args.report: with open(args.report, "w") as fh: @@ -1655,21 +2437,32 @@ def main(argv=None, default_tool="xilinx"): "tolerance": args.threshold, "metric_thresholds": args.metric_threshold, "gated": list(gated), + "against": against_sha or args.against, "builds": [report_entry(r, env, tool) for r in results]}, fh, indent=2) fh.write("\n") print("\nwrote %s" % args.report) - - if args.update_baseline: + if mode != "gate": # Recording IS the intent; a delta is what we just wrote down. A build # that never produced metrics is still a failure, `known_issue` or not: # there is nothing to record, so excusing it would end the run claiming # a baseline it did not write. Same reasoning as the BUILD-FAIL verdict # in gate(). broken = [r for r in results if not r["metrics"]] - return 2 if broken else 0 - if any(v == "BUILD-FAIL" for _, v, _ in failures): + return 2 if broken or ref_rc else 0 + + counts = {} + for r in results: + counts[r["verdict"]] = counts.get(r["verdict"], 0) + 1 + failures = [r for r in results if r["verdict"] not in PASSING] + print("\n%s: %d builds%s%s -- %s" + % (tool.gate, len(results), + "".join(", %d %s" % (n, v) for v, n in sorted(counts.items())), + ", the reference run failed (exit %d)" % ref_rc if ref_rc else "", + "FAILED" if failures or ref_rc else "passed")) + # A build error on either side means the change was not gated. + if ref_rc or any(r["verdict"] in ("BUILD-FAIL", "REF-FAIL") for r in failures): return 2 return 1 if failures else 0 diff --git a/ci/synth_report.py b/ci/synth_report.py index dbfe8fa35b..4b94e06406 100755 --- a/ci/synth_report.py +++ b/ci/synth_report.py @@ -26,7 +26,8 @@ # Same contract as synth_gate.PASSING: a tracked known issue and an unexpected # pass are reported, not failed. -PASSING = ("PASS", "RECORDED", "KNOWN-ISSUE", "XPASS") +PASSING = ("PASS", "RECORDED", "KNOWN-ISSUE", "XPASS", "ACCEPTED", + "NO-REFERENCE") # Every metric any tool records, shown in this order when a build reports it. COLUMNS = (("Fmax (MHz)", "fmax_mhz", "%.1f"), @@ -45,7 +46,12 @@ ("DSP", "dsp", "%d"), ("Max levels", "max_levels", "%d"), ("End points >= 12", "deep_endpoints", "%d"), - ("End points >= 8", "watch_endpoints", "%d")) + ("End points >= 8", "watch_endpoints", "%d"), + ("p_fmax (MHz)", "pred_fmax_mhz", "%.1f"), + ("Stages", "max_stages", "%d"), + ("Cells (Beacon)", "cells", "%d"), + ("Macros", "macros", "%d"), + ("Tied bits", "tied_bits", "%d")) # Slack sits near zero by design, so a relative change of it says nothing. NO_DELTA = ("wns_ns", "tns_ns") diff --git a/ci/test_runner.py b/ci/test_runner.py index 446d12c1bb..e0eaecc315 100644 --- a/ci/test_runner.py +++ b/ci/test_runner.py @@ -189,5 +189,10 @@ def test_case(case, sim_build, request): _release_parity(case, xlen) return argv, env = case.run_command(xlen) - rc = tc.execute(argv, env) + capture = request.config.pluginmanager.getplugin("capturemanager") + if case.stream and capture is not None: + with capture.global_and_fixture_disabled(): + rc = tc.execute(argv, env) + else: + rc = tc.execute(argv, env) assert rc == 0, "{} failed (exit {}): {}".format(case.id, rc, " ".join(argv)) diff --git a/ci/testcase.py b/ci/testcase.py index 719aad87f4..d15c9de2fa 100644 --- a/ci/testcase.py +++ b/ci/testcase.py @@ -143,6 +143,10 @@ def __init__(self, category, entry, driver, defaults, suite=None): # VORTEX_RANDOMIZE_VA). Merged over the CONFIGS env; values are # strings passed through verbatim. self.env = {k: str(v) for k, v in dict(entry.get("env", {})).items()} + # A script case whose output is its report (a gate's verdict table) + # streams it into the CI log; pytest otherwise shows a passing case's + # output nowhere. + self.stream = bool(entry.get("stream", defaults.get("stream", False))) # Stable, unique id: :: self.id = "{}:{}:{}".format(category, entry["id"], self.marker_driver) @@ -626,6 +630,8 @@ def cmd_lint(args): errors.append("{}: make-run case needs 'dir' and 'target'".format(c.id)) if c.via == "script" and not c.run: errors.append("{}: script case missing 'run'".format(c.id)) + if c.stream and c.via != "script": + errors.append("{}: stream applies to script cases only".format(c.id)) if any(int(x) not in (32, 64) for x in c.xlens): errors.append("{}: xlen must be 32 and/or 64".format(c.id)) if c.release_parity: diff --git a/ci/testcases/asic_gate.yaml b/ci/testcases/asic_gate.yaml index 237fadea35..25515f511d 100644 --- a/ci/testcases/asic_gate.yaml +++ b/ci/testcases/asic_gate.yaml @@ -49,6 +49,10 @@ # `VX_cache_wrap #(.PASSTHRU(!`VX_CFG_L2_ENABLED))`, and the Yosys catalog was # missing L2_ENABLE. It now carries the real 256 KB L2, as `gfx` and `tensor` do. # +# logic_gate's `gate_asic` case (ci/logic_gate.py --tool beacon_asic) measures +# these same builds with Beacon on every pull request, in minutes: it takes +# their designs and clock_mhz, not their known_issue or thresholds. +# # See docs/designs/continuous_integration.md §3.5. category: asic_gate defaults: @@ -106,7 +110,7 @@ builds: - id: cache group: core dut: cache - clock_mhz: 800 + clock_mhz: 1000 area_budget_um2: 48726 configs: "" @@ -119,7 +123,7 @@ builds: - id: core group: core dut: core - clock_mhz: 800 + clock_mhz: 1000 area_budget_um2: 84624 configs: "-DVX_CFG_NUM_THREADS=8 -DVX_CFG_NUM_WARPS=8" @@ -128,7 +132,7 @@ builds: - id: lmem group: core dut: lmem - clock_mhz: 800 + clock_mhz: 1000 area_budget_um2: 17137 configs: "-DVX_CFG_NUM_THREADS=16 -DVX_CFG_ISSUE_WIDTH=2 -DVX_CFG_EXT_A_ENABLE" @@ -138,7 +142,7 @@ builds: - id: top group: core dut: top - clock_mhz: 800 + clock_mhz: 1000 area_budget_um2: 187230 # 11.2 GB Yosys peak at NT=NW=4 (8/8: 18.6 GB). configs: "-DVX_CFG_NUM_THREADS=4 -DVX_CFG_NUM_WARPS=4" @@ -149,7 +153,7 @@ builds: - id: dxa group: dxa dut: dxa - clock_mhz: 800 + clock_mhz: 1000 area_budget_um2: 12449 configs: "" @@ -160,7 +164,7 @@ builds: - id: tfu group: tfu dut: tfu - clock_mhz: 800 + clock_mhz: 1000 area_budget_um2: 2073 configs: "" @@ -171,7 +175,7 @@ builds: - id: tcu group: tensor dut: tcu - clock_mhz: 800 + clock_mhz: 1000 area_budget_um2: 74407 configs: "" @@ -180,7 +184,7 @@ builds: - id: tensor group: tensor dut: tensor - clock_mhz: 800 + clock_mhz: 1000 area_budget_um2: 104438 configs: "-DVX_CFG_NUM_THREADS=8 -DVX_CFG_NUM_WARPS=8" @@ -190,7 +194,7 @@ builds: - id: raster group: graphics dut: raster - clock_mhz: 800 + clock_mhz: 1000 area_budget_um2: 10527 configs: "" @@ -198,7 +202,7 @@ builds: - id: om group: graphics dut: om - clock_mhz: 800 + clock_mhz: 1000 area_budget_um2: 5926 configs: "" @@ -207,7 +211,7 @@ builds: - id: tex group: graphics dut: tex - clock_mhz: 800 + clock_mhz: 1000 area_budget_um2: 61159 configs: "-DVX_CFG_NUM_THREADS=8 -DVX_CFG_NUM_WARPS=8" @@ -215,7 +219,7 @@ builds: - id: rtu group: graphics dut: rtu - clock_mhz: 800 + clock_mhz: 1000 area_budget_um2: 98965 configs: "" @@ -224,7 +228,7 @@ builds: - id: gfx group: graphics dut: gfx - clock_mhz: 800 + clock_mhz: 1000 area_budget_um2: 242203 # 14.6 GB Yosys peak at NT=NW=4 (8/8: 19.5 GB). configs: "-DVX_CFG_NUM_THREADS=4 -DVX_CFG_NUM_WARPS=4" @@ -236,6 +240,6 @@ builds: - id: vm group: vm dut: vm - clock_mhz: 800 + clock_mhz: 1000 area_budget_um2: 146445 configs: "-DVX_CFG_NUM_THREADS=8 -DVX_CFG_NUM_WARPS=8" diff --git a/ci/testcases/logic_gate.yaml b/ci/testcases/logic_gate.yaml index 39c16efbde..b06b1105cb 100644 --- a/ci/testcases/logic_gate.yaml +++ b/ci/testcases/logic_gate.yaml @@ -33,14 +33,28 @@ # 300 MHz ones. # # The gate runs with perf_gate: a perf_gate regression is cycles, this one is -# depth and area, and both are asserted on every change to the RTL. Its case -# is on the rtlsim driver at tier smoke, so ci.yml plans its cell exactly when +# depth and area, and both are asserted on every change to the RTL. Its cases +# are on the rtlsim driver at tier smoke, so ci.yml plans its cell exactly when # it plans perf_gate's rtlsim cells (every pull request, every push that # touches the RTL or the config). The cell installs foldsim (`needs`). # +# Two cases, one cell: `gate` measures the builds below on the FPGA flow, and +# `gate_asic` measures asic_gate.yaml's builds on the ASIC flow +# (--tool beacon_asic, ASAP7 cell stages, flip-flops and SRAM macros; its +# baselines are ci/baselines/synthesis/beacon_asic/). On a pull request ci.yml +# also passes the merge base (BEACON_AGAINST_REV, the default of +# --against-rev): each build is compared register by register with the same +# build on the merge base's RTL, so a baseline the pull request re-records +# cannot hide its own deltas. Both stream their output, so the verdict table +# is in the CI log. +# # Run one by name: ci/logic_gate.py -b tcu +# Against master: ci/logic_gate.py -b tcu --against-rev $(git merge-base HEAD origin/master) # By hand, no gate: make -C hw/syn/xilinx/dut tcu-beacon # Re-record: ci/logic_gate.py --update-baseline (human-reviewed, never CI) +# In a pull request, add --against-rev : the +# regressions against it are recorded as accepted, and the +# baseline diff is their review. # --------------------------------------------------------------------------- category: logic_gate defaults: @@ -58,7 +72,19 @@ tests: driver: rtlsim needs: - foldsim - run: ci/logic_gate.py -j 2 + stream: true + run: ci/logic_gate.py -j 2 --report logic_gate.json + +# asic_gate.yaml's 14 builds: 7 minutes at -j 2, 5.4 GB peak per build. Its +# predicted Fmax is held to their clock_mhz with a wide band, as a backstop; +# flip-flops and cells to the baseline. +- id: gate_asic + tier: smoke + driver: rtlsim + needs: + - foldsim + stream: true + run: ci/logic_gate.py --tool beacon_asic -j 2 --report logic_gate_asic.json # The full-GPU builds (group gpu, below): ~30 min and ~95 GB of memory each, # so one at a time, on a large self-hosted machine -- never a hosted runner. diff --git a/ci/testcases/regression.yaml b/ci/testcases/regression.yaml index 40759e9f2f..686087444e 100644 --- a/ci/testcases/regression.yaml +++ b/ci/testcases/regression.yaml @@ -545,8 +545,9 @@ tests: cores: 2 l2cache: true # Kernel to kernel with no host transfer between (one command batch): the -# launch flushes are L1-only, so the last-level cache alone carries each -# round's writes to the next round, and the full flush runs before readback. +# launch flushes are device-scope, so the last-level cache alone carries each +# round's writes to the next round, and the system-scope flush runs before +# readback. - id: flush_coherence-chain-1 via: blackbox drivers: @@ -578,7 +579,7 @@ tests: l2cache: true l3cache: true # Replicated last-level caches (per-core dcaches without an L2, per-cluster L2s -# without an L3) are not a point of coherence, so an L1-only flush must still +# without an L3) are not a point of coherence, so a device-scope flush must still # invalidate them. - id: flush_coherence-chain-4 via: blackbox @@ -602,7 +603,7 @@ tests: l2cache: true # Each round loads its input with a DXA tile copy, which reaches memory beside # the single dcache, so that dcache is not a point of coherence and must still -# be written back on an L1-only flush. +# be written back on a device-scope flush. - id: flush_coherence-chain-6 via: blackbox drivers: @@ -661,7 +662,7 @@ tests: app: sgemm args: -n32 configs: -DVX_CFG_DCACHE_NUM_BANKS=16 -DVX_CFG_PLATFORM_MEMORY_NUM_BANKS=16 -# The shared L2 keeps its lines across the L1-only launch flushes. +# The shared L2 keeps its lines across the device-scope launch flushes. - id: model_parity-flush-chain check: model_parity via: blackbox diff --git a/docs/assets/img/mlp_cp_dma_llc.svg b/docs/assets/img/mlp_cp_dma_llc.svg index 58c436f523..acf2bca1b5 100644 --- a/docs/assets/img/mlp_cp_dma_llc.svg +++ b/docs/assets/img/mlp_cp_dma_llc.svg @@ -39,7 +39,7 @@ L2: coherent DRAM - L1-only flush + device-scope flush client slot diff --git a/docs/assets/img/mlp_fences.svg b/docs/assets/img/mlp_fences.svg index 5c4b1d5056..e51378b1ec 100644 --- a/docs/assets/img/mlp_fences.svg +++ b/docs/assets/img/mlp_fences.svg @@ -20,7 +20,7 @@ Before: full flush per fence - After: L1-only token + After: device-scope token core: fence L1: walk all lines @@ -34,7 +34,7 @@ L1: write back dirty L2 (LLC): ack, no walk DRAM: not touched - L1-only token + device-scope token dirty lines ack diff --git a/docs/assets/img/mlp_launch_flush.svg b/docs/assets/img/mlp_launch_flush.svg index 5d10af1f49..4e02a597e2 100644 --- a/docs/assets/img/mlp_launch_flush.svg +++ b/docs/assets/img/mlp_launch_flush.svg @@ -1,5 +1,5 @@ - - Flush cycles per launch, drawn to scale: a full flush walks the L2; an L1-only flush skips it. + + Flush cycles per launch, drawn to scale: a full flush walks the L2; a device-scope flush skips it.