Skip to content

Bug fixes to master found while integrating the Vulkan graphics stack - #560

Merged
tinebp merged 12 commits into
masterfrom
fix/master-bugfixes
Dec 3, 2026
Merged

tinebp merged 12 commits into
masterfrom
fix/master-bugfixes

Conversation

@tinebp

@tinebp tinebp commented Dec 1, 2026 •

Copy link
Copy Markdown
Collaborator

Base: master cba70a4. Head: 2dafca1 (10 commits: 8 fixes, one baseline commit and one comment-only commit).

Rebased 2026-12-01 onto master cba70a4 (the pipeline-isolation rules). Each fix's tree equals its tested tree plus exactly that commit's delta (identical patch-id), so every result below carries over. Added on top: 2dafca1, a comment-only commit (classifier R0, cosmetic) that drops the pull-request number and the other layer's signal and module names from the fixes' comments (docs/coding_guidelines_cpp.md §10, AGENTS.md §6).
Depends on: nothing.
Merge order: feat/fpu-split-timing → this PR → feat/graphics-prereqs → feat/vulkan-graphics. feat/amo64 and feat/simx-tooling are stacked on this PR.

Each commit fixes one bug in master code and carries its trigger test. Every commit builds on its own (x32). The order is fixed: the rename first, F8 and F5 last, then the baselines. Two earlier fixes are now on master itself and are not part of this PR: the VX_cache_init -O0 build (master dc686d1) and the unit tests' VX_config.h include (master 925061a).

The fixes

F10 · 52b98ff — rename util.h's __assert macro to VX_ASSERT

  • Bug on master: on EL9 (glibc 2.34) every debug build fails in 39 translation units ("macro "__assert" passed 3 arguments").
  • Trigger: debug:demo-5 / demo-4 on EL9.
  • Master touch: UNGATED 53 changed hunks, a pure rename (cache.cpp, simobject.h, …); GATED 6 (VM). Behaviour unchanged.

F3 · 6ac1a44 — order a trap entry's mcause read behind an earlier mcause write

  • Bug on master: a handler reading mcause right after entry can read a stale value; SimX hung at 32 warps / SIMD 4.
  • Trigger: tests/regression/trap_order, CI trap-simd.
  • Master touch: UNGATED 2 hunks (a scoreboard slot in VX_decode, SimX decode).

F1 · ae6aa71 — a workgroup barrier drains the warp's memory requests, including those waiting at the local memory

  • Bug on master: across two LSU blocks (≥32 warps) a peer warp reads the old value. Seen as the nondeterministic dEQP-VK.ray_query BVH-build failure.
  • Trigger: bar_vis (bar-vis, -shared, -bank, -lmem-input(-timed)), model_parity-bar-vis.
  • Master touch: UNGATED 10/10 hunks (VX_lsu_mem_path, VX_wctl_unit, VX_decode, SimX core); MANUAL 2 (VX_core); GATED 5.
  • Timing: barriers take the drain (rtlsim async_barrier +3.6%, SimX sgemm2 +2.6% x32).

F2 · 124988f — a fence goes out on every lane and holds the block's input until answered (RTL and SimX)

  • Bug on master: a store on an inactive lane's path can pass the fence; in SimX a store retired under the fence.
  • Trigger: fence_mp (fence-mp-1c/-mc-l2/-mc-l3/-lanes/-ports, parity-fence-mp), vm-release.
  • Master touch: UNGATED 10/6 hunks (VX_lsu_block, SimX cache/LSU).
  • Timing: fences only (printf +0.035% SimX).

F6 · 4e9601b — compare-and-swap counters from a nonzero base

  • Bug: test only. Master's CAS tests compare against 0 and would pass a switch that drops the comparand.
  • Trigger: cas_counter, cas_counter_lmem.
  • Master touch: UNGATED 1 hunk, a stale comment in local_mem_switch.cpp.

F7 · cf74bee — SimX: time LLC and passthrough atomics as VX_cache_amo does

  • Bug on master: the model_parity cases on atomics fail the 5% tolerance (amoadd_scatter SimX 11740 vs RTL 5252).
  • Trigger: parity-amo-contended(-l2), parity-amo-scatter.
  • Master touch: SimX cache.cpp only, 24/18 hunks; the atomic paths need EXT_A, which is off by default.

F8 · 5eaf175 — #557 follow-ups: a write-back bank admits against an exact bound of the writebacks it can still owe

F5 · 58e743d — a misaligned atomic traps (address-misaligned) instead of touching memory

  • Bug on master: the RTL asserts "misaligned memory access" (on hardware it writes through a misaligned word), and SimX aborts.
  • Trigger: amo amo_misaligned, parity-amo-misaligned, misaligned-lsu-packets, amo-iw4-fw2.
  • Master touch: UNGATED 14/45 hunks (decode, dispatcher, issue/frontend plumbing; all act on atomics, which need EXT_A); MANUAL 8 (VX_core, VX_types trap causes); GATED 13.

Baselines · 4bdefdb — perf_gate and logic_gate goldens for this branch (see Baselines below).

F5: an imprecise trap

The trap is imprecise: the same class GPUs take for a misaligned access. NVIDIA's CUDA_EXCEPTION_6 "Warp Misaligned Address" is not precise, and on AMD a memory violation halts the wave.

  • There is no decode stall.
  • The faulting atomic performs no access and writes no register.
  • The warp traps with mcause 6 (4 for LR) and mepc = the atomic.
  • mtval stays read-only zero, exactly as Minor optimization + RTL fix #481 left it.
  • Younger instructions already past decode may complete; resuming after the trap is not supported.
  • SimX traps at the RTL's point: a cycle per SIMD slice after the atomic leaves operand collection.

Cost against F8 with the same amo test binary, so only the hardware differs: 0.00% on amoadd, scatter, contended, contended-l2, cas_counter, zacas-simd, the amo list and sgemm, on both simx and rtlsim. For comparison, the precise form (a decode stall on every atomic) cost +38% on amoadd and +15% on contended.

Area (Beacon) vs F8:

  • U55C core +860 LUT (+0.68%), depth 15 → 15.
  • ASIC +0.17% cells, 29 stages unchanged.

Master CI reds this PR turns green (run 46477391253 on 2496be3)

The debug, boundaries, integration and logic_gate gfx/gfxvm reds of that run are fixed on master itself (7470f62). The remaining ones:

red job cause fixed by proof
perf sgemv-nt16 +2.3% #557's reservation caps reads in flight F8 sgemv-nt16 on this branch = 285,869 cycles = master's golden (master CI: 292,363)
perf dxa "workload changed" (wgmma-dxa-mcast, sgemm2-dxa-mcast, copy-mcast) master's dxa goldens predate the v3.0.3 compiler baseline commit, recorded with CI's exact v3.0.3 toolchain this branch measures 172096 / 26944 / 3832848 / 958 instrs, the same as master's v3.0.3 CI run

Verification (all on this branch's final code)

Results name the commit they ran on. Runs before the rebase onto master 7470f62 differ from the final tree only by master's four commits (VX_cache_init's response tree rewritten as one always block, logic unchanged per master; test-only and baseline-data changes) and by dropping this branch's own fixes for those two bugs. Every commit up to F8 keeps its tree from the split (tree hashes 9b8559f4f … 59932df67, built x32 one by one in MERGE9's per-commit pass); messages changed only. F5's final tree differs from the runs on d27815d89 only in SimX's trap timing (sim/simx/core.cpp), and the last commit is baseline data.

check commit result
tip build x32 + x64 (sw, simx, rtlsim, xrtsim) 4bdefdb PASS (0 warnings)
lint / change_impact / boundaries 4bdefdb lint 1064 OK; change_impact 133 passed / 1 skipped; synth_gate_ref 6 passed; sw↔sim, simx-mt and config boundaries OK
perf config_hash of all 49 entries vs the resolved config 4bdefdb 0 mismatches
tip build + lint before the rebase 890275e91 PASS: 0 warnings; lint 1064 OK; change_impact 133 passed / 1 skipped; synth_gate_ref 6 passed; boundaries OK
F5 triggers: isa misaligned/amo-iw4/base/zacas simx+rtlsim x32/x64, regression trap simx+rtlsim, model_parity amo/fence/bar-vis (7), unit tests issue/cache-init d27815d89 (RTL = final) 8 cells PASS
F5 misaligned shapes after the SimX trap-timing fix (default, LSU 4, 32w/SIMD4, IW4/FW2) simx + rtlsim 22198fdea tree PASS; SimX/RTL 2708/2723, 3420/3450, 12575/14270
amo.yaml set (fence-mp, wb, mc-l2/l3, lrsc, zacas, misaligned, conformance) simx32 d27815d89, rtl32 22198fdea, simx64 a9a2a0df1 17/17, 17/17, 12/12
vm-release simx / rtlsim (vm_test uses atomics) 22198fdea / a9a2a0df1 PASS / PASS
bar-vis, trap-simd, wb_drain-l2-1, debug demo/demo-5, unit tests hw-cache-init/issue (MERGE9) 407c95b4e (differs from final only in F5's atomic paths, which these tests do not use) PASS
F5 cost vs F8 (same test binary) d27815d89 0.00% on all cases
Beacon U55C vs master (CI's v3.0.3 Beacon) d27815d89 RTL 10 PASS, 2 IMPROVED, 4 accepted (see depth items)
Beacon ASIC vs master (v3.0.4 Beacon, earlier pass) d27815d89 RTL 14/14 PASS

Baselines

Commit 4bdefdb, data only:

  • perf_gate, all 49 entries: this branch's resolved config changes (F5's trap causes in VX_types), so each entry gets the new config_hash (core:vecadd-nt4 898f99eb).
    • Cycles and instructions are this branch's rtlsim measurements (d27815d89 RTL).
    • Moves vs master: wgmma-dxa-mcast-nt4 +4.22% (its instruction count is master's own v3.0.3 CI value; master's golden predates it); sgemmx-nt16 +1.67%; wgmma-sparse +1.45%; wgmma-dxa-mcast-nt16 +1.31%; copy-mcast +1.02%; sgemm2-fp16 −1.93%; sgemv-nt16 back to master's golden.
  • logic_gate U55C: cache, vm, gfx and gfxvm are re-recorded with CI's v3.0.3 Beacon. Everything else is master's.
  • Not changed: ASIC goldens and gpu entries (gpu is not in CI's logic_gate set).

Risks, disclosed:

  • Four perf entries keep master's CI-measured values, re-stamped with this branch's config_hash: core:softmax-nt4/nt16 and dxa:perf_gate-copy-nt4/nt16.
    • Why: the recording machine's compiler (EL9 bundle, llvm a0df07abb) builds these four kernels differently from CI's v3.0.3 focal compiler (llvm f44a6bb2a), and master's CI passed them at master's values.
    • softmax: the pre-F1 point be316a17c measures the same as this branch, so the fixes don't move it.
    • copy-nt4/nt16: this branch measured about +1% over its own pre-F1 point (6632 → 6696 cycles, nt4). If F1/F2 move them more under CI's compiler, CI may read them over ±2%.
  • ASIC goldens were not re-run under the v3.0.3 Beacon. The earlier run with the v3.0.4 Beacon passed 14/14 vs master.
  • CI on this PR: run on master 7470f62 (its run 46625271560 was in progress at delivery).

Depth items accepted (user decision 2026-12-01)

All are measured with CI's Beacon (v3.0.3, 4060e3af4). The whole-GPU deepest path is unchanged at 29, and each entry's deepest path is unchanged.

  • F8: VX_cache_tags' dirty-sector buffers (g_dirty ex279/ex280) are new at 12 levels in cache, vm, gfx and gfxvm.
  • F8, gpu32_full's write-back L2: g_mreq_resv.resv_alm_full_r is new at 17 levels, and pop_r/any_pop_r at 14. Registering them would cost an admission cycle (sgemv) or a cycle of dirty-count latency.
  • F1, gpu32_full: the barrier unit's store_state_valid and the DXA completion FIFO's used_r go 11 → 12 levels.

Pipeline isolation (docs/coding_guidelines_verilog.md §13)

The change-impact classifier marks three commits pipeline-stage (R3).

F5, the misaligned-atomic trap. It is a fix for an atomics bug, made in shared stages: the warp scheduler, the dispatcher, the issue and slice wiring, and the SimX scheduler and core. The §13.4 items:

  1. Goal. A misaligned atomic must trap (cause 6, or 4 for LR) instead of touching memory, at no cost to aligned atomics. The trap state (the PC redirect to mtvec, mepc, mcause, mstatus) lives only in the warp scheduler. The fault is known only after operand collection, because the address comes from rs1. No extension point can raise it:
    • decode does not have the address;
    • the LSU has no path to the trap state;
    • the existing is_trap port belongs to the ALU's branch resolution.
  2. The isolated alternative, built and measured. A precise trap with a decode-only stall: decode holds a warp behind each atomic until the atomic clears operand collection. It cost +38% cycles on amoadd and +15.4% on contended atomics, on SimX and rtlsim with the same binaries. The other alternative, reusing the ALU branch port with an arbiter, was not built. It would share the port with branch resolution and cost a stall cycle on every collision, for no area saving.
  3. The gain. The imprecise trap costs 0.00% on amoadd, scatter, contended, contended-l2, cas_counter, zacas-simd, the amo list and sgemm, on SimX and rtlsim, against F8 with the same binaries.
  4. The cost (Beacon, core entry with EXT_A on):
    • U55C: +860 LUT (+0.68%) and +132 FF; deepest path 15 → 15.
    • ASIC: +0.17% cells; 29 stages → 29.
    • The new path is the sched_amo_t port, registered at the dispatcher's output, plus the trap_redirect_r register in the warp scheduler's context.
  5. Knob-off identity: NOT MET (rule 5).
    • The port's valid is driven only under VX_CFG_EXT_A_ENABLE, which is off by default. With A off it is constant 0.
    • But INST_ARGS_BITS grows by one bit in every configuration, to fit lsu_args_t.amo_fault. That widens the op_args packet through the ibuffer, the scoreboard, the operand collectors and the dispatch queues, even with A off.
    • Open fix: put the extra bit and amo_fault under VX_CFG_EXT_A_ENABLE, then prove identity with A off (Beacon top/core and perf_gate equal to master).
  6. Approval. Pending the maintainer.

F1, the barrier drain. The barrier unit's own bug: a peer warp could read a stale value across LSU blocks. The fix carries lsu_store_empty from each LSU block to the barrier, through the slice wiring (VX_issue*, VX_backend_slice, VX_compute_slice) and the SimX core. No existing hook carries the LSU blocks' store state to warp control. It is a correctness fix of the barrier, not a feature.

F10, the VX_ASSERT rename. A token rename in SimX core.cpp, with no logic change.

Default-behaviour impact (master's default build)

  • UNGATED, timing:
    • F1: barrier drain;
    • F2: fence timing.
  • UNGATED, no behaviour change:
    • F10: rename;
    • F6: comment.
  • Gated:
    • F5 and F7 (atomics need EXT_A);
    • F8 (write-back caches only);
    • F3 (trap-CSR ordering).

Known pre-existing gap (not fixed here; follow-up)

At 32 warps / SIMD 4 / 8 threads, master's ECALL trap test (trap -n512 -i8) is 14.7% apart between SimX and RTL: 19,401 vs 22,751 cycles on 2496be3. With one SIMD slice it is 0.1%. This is a master parity gap in the multi-slice trap handler / CSR path.

Follow-up note: perf_gate asserts exact retired instructions, and the polling DXA multicast kernels' instruction counts depend on the compiler (and potentially on timing). That makes the gate fragile for them. Report only; no change here.

🤖 Generated with Claude Code

@tinebp tinebp left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR #560 review: bug fixes to master (fix/master-bugfixes)

Base 7470f62, head 4bdefdb: 9 commits, 80 files, +3715/-422. The PR is unchanged
since the first review.

Rules applied (all read from origin/master):

  • AGENTS.md, coding_guidelines_{verilog,cpp}.md, bug_fixes.md,
    docs/review/code-review-policy.md;
  • the code-review, rtl-review and simx-review skills;
  • revision 2: master cba70a4, "pipeline isolation as a coding rule and an R3
    review contract": verilog §13, cpp §11, AGENTS.md §5, policy pipeline-stage
    contract, code-review hard rule, rtl/simx-review checklists, change-impact policy v4.

This is a static review: nothing was built or run.

Class

R3. The classifier was run from master cba70a4 (policy v4). The PR's base,
7470f62, predates v4, and CI classifies with the base revision's copy. CI will
therefore not report pipeline-stage until the PR is rebased onto cba70a4 or later.
This review applies v4 anyway.

The classifier's reasons:

  • rtl-interface: VX_warp_ctl_if.lsu_store_empty
  • gpu-pkg-types: sched_amo_t added; alu/br/lsu/tcu_args_t changed
  • isa-localparams: INST_ARGS_BITS 28 → 29
  • isa-encoding: VX_TRAP_CAUSE_{LOAD,AMO}_MISALIGNED
  • test-coverage: amo.yaml defaults, plus zacas-simd(-lsu1) args extended
  • golden-values: 8 perf files and 3 Beacon files
  • pipeline-stage, per commit:
commit files flagged verdict under §13
F10 52b98ff sim/simx/cta_dispatcher.cpp Classifier false positive: the hunk is __assert → VX_ASSERT only, and the detector's c_ignore_macros lists assert but not VX_ASSERT. That is a master policy gap, not a PR finding.
F3 6ac1a44 none Touches decode only, an extension point (§13.2).
F1 ae6aa71 VX_compute_slice, VX_frontend_xbar, sim/simx/core.{cpp,h} Slice wiring changed to carry a fix of warp-control/LSU behaviour. See P2 below. The core.cpp hunks are the LSU memory-path model, not a §13.1 stage.
F2, F6, F7, F8 none Each fixes the shared unit's own bug (LSU fence, cache bank, SimX cache), so only the bug-fix obligations apply.
F5 58e743d VX_dispatcher, VX_warp_sched, VX_warp_sched_ctx, VX_issue, VX_issue_slice, VX_frontend_slice, VX_frontend_xbar, VX_compute_slice, VX_backend_slice, sim/simx/{core.cpp,scheduler.cpp,scheduler.h} A fix of the atomics extension's behaviour, built inside the shared stages. See P1 below.

Pipeline-isolation findings (new in revision 2)

P1 · F3 high static-proof · 58e743d (misaligned atomic trap)

What: F5 handles misaligned atomics, a behaviour of the EXT_A extension, by editing
nine shared stages, and has no §13.4 justification. Rules broken:

  • §13.2.4. It adds a new scheduler port, sched_amo_t
    (VX_warp_sched.sv, VX_warp_sched_ctx.sv), plumbed through issue, the slices and the
    frontend crossbar. That is a port beside the existing trap hook (the branch port's
    is_trap/trap_cause), which §13.2 says to reuse ("do not add another port beside
    them").

  • §13.3.5 and §13.3.3. INST_ARGS_BITS grows by one bit in every configuration
    (VX_gpu_pkg.sv:1501; padding added to alu/br/tcu args) for lsu_args_t.amo_fault,
    a field only EXT_A uses. Every ibuffer, staging, operand-collector and dispatch entry
    of the default configuration widens, so knob-off identity fails by construction. That
    moves the default configuration's area, which makes this F3. It is consistent with the
    unattributed +476 to +596 FF on gfx and vm, both EXT_A off.

  • §13.3.2 and §13.3.4. A feature lives inside the dispatcher
    (VX_dispatcher.sv:44-112):

    • a per-lane alignment check on rs1_data;
    • a per-warp slice_fault_r;
    • a rewrite of op_args on the LSU's dispatch data;
    • a registered trap record.

    The scheduler gets a PC override: pc_n = mtvec while amo_hit || trap_redirect_r, at VX_warp_sched_ctx.sv:273-292. That sits after every other
    pc_n update, one more select on the scheduler's PC path for every warp. The
    rtl-review checklist names "an override of the PC" as a disguised form.

  • §13.3.6 / cpp §11. The SimX mirror does the same inside the pipeline models:
    Core::amo_check on the dispatch path in core.cpp, plus trap_redirect and the
    override in Scheduler::schedule.

§13.4 checklist, against the PR description:

item status
1. Goal, and why no extension point works Goal stated. No argument for why decode, the uop sequencer, the branch-port trap hook or the LSU cannot do it.
2. Isolated alternative built and measured Only the precise form was measured: a decode stall on every atomic, +38% amoadd, +15% contended, cycles only, no Beacon. That form sits at an extension point but is not the best isolated design. A better candidate is below.
3. Gain over it 0.00% versus +38% in cycles; no area or depth for the alternative.
4. Cost to every configuration Beacon core +860 LUT, depth 15 → 15, EXT_A on only. Nothing for the default configuration, and no per-stage paths named.
5. Knob-off identity Not shown, and false: op_args widened.
6. Maintainer approval Not recorded for the pipeline change (the PR records only the depth items).

Fix: Redesign at the extension points, then justify whatever shared-stage residue
is left. The isolated candidate to build and measure:

  • Detect in the LSU's EXT_A path. VX_lsu_block already computes full_addr per
    lane and asserts on misalignment. A faulted atomic retires writing nothing, as
    req_fault already does, but decides it locally. That needs no amo_fault bit in
    op_args, no dispatcher change and no INST_ARGS_BITS change.
  • Trap through the existing branch-port hook. Expand each atomic in the uop
    sequencer into an ALU check uop that raises is_trap with
    VX_TRAP_CAUSE_{AMO,LOAD}_MISALIGNED when rs1 is misaligned, plus the AMO uop.
    The scheduler's existing trap path writes mepc and mcause and redirects. That needs
    no new port and no PC override.
  • Measure it: perf_gate and model_parity amo cases (the extra ALU uop per atomic),
    Beacon core with EXT_A on and off, and knob-off identity.

If this alternative loses on numbers, the §13.4 table above is what the PR must fill
in. Even then, the op_args widening must be gated under EXT_A (§13.3.5), and the
new port must be justified against reusing is_trap.

P2 · F2 medium static-proof · ae6aa71 hw/rtl/core/VX_compute_slice.sv:249 · VX_frontend_xbar.sv:218 · hw/rtl/interfaces/VX_warp_ctl_if.sv:43

What: The barrier fix's own logic lives where the bug is: VX_wctl_unit (the
drain) and VX_lsu_mem_path (the local_empty term). Both are shared units fixing
their own behaviour, so the bug-fix rules apply. To carry lsu_store_empty to the
warp-control unit, though, F1 adds a new interface signal and edits two slice-wiring
stages, compute_slice and frontend_xbar. An isolated route already exists:

  • warp_ctl_if.lsu_sched_empty already reaches the barrier's drain check through
    those stages.
  • Its only other consumer, VX_core.sv:168, already ANDs the two signals
    (store_drained = (&lsu_sched_empty) && mem_unit_empty).
  • Driving the existing .all_lsu_sched_empty port in VX_core.sv (not a §13.1 stage)
    with the per-block lsu_sched_empty & lsu_store_empty gives the same drain. It needs
    no interface change (dropping the R3 rtl-interface contract) and no slice-wiring
    edit.

Scenario: As written, every configuration pays for two more wiring ports and an
interface signal, and the change carries an R3 contract it does not need. A strict
reading of the hard rule makes this F3, because F1 moves default cycles and depth.
Those moves, however, come from the warp-control drain (its own bug), not from the
wiring.

Fix: Route through the existing port, renamed if the name misleads, and drop the
lsu_store_empty interface signal. Otherwise, add the §13.4 justification for the
wiring.

P3 · F1 high static-proof · master cba70a4 docs/review/change-impact.yaml (pipeline-stage detector)

What: c_ignore_macros lacks VX_ASSERT, the project's own assertion macro (the
__assert rename happened in this PR). A pure rename of an assertion in a SimX
pipeline model is therefore classified R3.

Fix (on master, separately): add VX_ASSERT to c_ignore_macros, and add a
rename case to ci/test_change_impact.py.

Findings from revision 1 (still valid; the PR is unchanged)

F2 high static-proof · 4bdefdb ci/baselines/perf/core.json:117,128 · dxa.json:13,24

What: Four perf goldens were hand-edited. core:softmax-nt4/nt16 and
dxa:perf_gate-copy-nt4/nt16 keep master's cycle and instruction values, but carry this
branch's config_hash, which was written in by hand and never measured. The commit message
says so ("Kept at master's CI-measured values, re-stamped").

Scenario: On copy-nt4 the branch measured +1% (6632 → 6696) on the recording
toolchain. The golden now claims the branch equals master on CI's compiler, which nobody
measured. If F1 or F2 move copy-nt4/nt16 by more under CI's compiler, the gate absorbs
part of it or turns red with no recorded value to compare against. The PR itself lists
this as a risk.

Fix: Re-record these four entries with pytest ci -m perf_gate --update-baselines
using CI's toolchain (VERSION TOOLCHAIN_REV, v3.0.3, llvm f44a6bb2a). Record all 49
entries that way, not on the EL9 bundle (llvm a0df07abb). A human runs the command, per
AGENTS.md §4.

F2 high missing-test · 4bdefdb perf goldens

What: Several cycle regressions were re-recorded without the bug_fixes §6 table
(case → commit → mechanism → class):

  • core:sgemmx-nt16 +1.67%
  • tensor_wg:wgmma-sparse +1.45%
  • wgmma-dxa-mcast-nt16 +1.31%
  • copy-mcast +1.02%
  • wgmma-dxa-mcast-nt4 +4.22%, which is outside the ±2% gate

The first two are attributed jointly to "barrier drain (F1) and fence (F2)" with no
bisect. The DXA mcast moves are attributed to the compiler from instruction counts only;
no run separates the cycles (§6.1: same RTL, old and new compiler).

Scenario: F1 also turned vx_barrier_arrive into a stalling instruction (below). Any
part of the mcast cycle deltas that comes from F1 is filed under "compiler" and frozen
into the golden.

Fix: Bisect each slower case to F1, F2 or the toolchain. For the mcast kernels, run
master's RTL and the branch's RTL under the same v3.0.3 compiler. Put the table in the
baseline commit.

F2 high missing-test · 4bdefdb ci/baselines/synthesis/beacon/{core,graphics,vm}.json

What: Area growth was re-recorded unattributed. The commit explains only the depth
items. The area deltas versus master are:

entry LUT FF EXT_A
cache +289 +264 on
gfx +509 +476 off
gfxvm +510 +476 off
vm +572 +596 off

The policy's golden-values obligation requires every value that moved toward more area
to be attributed to a commit and justified.

Scenario: gfx and vm build without EXT_A, yet grow by about 500 LUT/FF. Part of that
is likely F5's unconditional INST_ARGS_BITS widening (next finding), which is pure cost
when atomics are off. The re-record hides that split.

Fix: Attribute each entry's LUT/FF delta to F1, F5 or F8 with per-commit Beacon
runs, and add the result to the baseline commit.

(Superseded by P1, which raises it to F3 under §13.3.5) F2 medium reasoned-risk · 58e743d hw/rtl/VX_gpu_pkg.sv:1501

What: INST_ARGS_BITS grows by one bit in every configuration to make room for
lsu_args_t.amo_fault. The padding bits added to alu/br/tcu args do the same. Every
queue and register that carries op_args (ibuffer, staging, operand collectors,
dispatch buffers) pays the bit, including builds where EXT_A is off and amo_fault is
tied to 0. bug_fixes §6.5 says: "a correctness fix is justified only for the cost that
correctness itself requires".

Scenario: The default build (EXT_A off) pays the widened op_args for a feature it
cannot use. The PR's only area figure (core +860 LUT) is measured with EXT_A on.

Fix: Make the extra bit conditional on EXT_A. INST_ARGS_BITS can add
VX_CFG_EXT_A_ENABLED, with the other structs' padding derived from INST_ARGS_BITS.
Alternatively, carry the fault outside op_args. AMOs have no immediate (decode sets
offset = 0), so the LSU can recognise amo_valid together with a marker in a field
AMOs leave unused. In either case, show the EXT_A-off cost before and after.

F2 high static-proof · comments that name the other layer's internals or a PR (several commits)

What: AGENTS.md §6 and coding guidelines §9/§10 forbid comments that name the other
layer's internals or a PR. SimX comments added by this PR name RTL modules, signals and
states:

  • sim/simx/mem/cache.cpp:491, 494, 1036, 2317, 2336, 2479, 2490, 2502, 2552, 2566:
    VX_cache_amo's WBQ, amo_pipe_cnt, fresh_r, req_input_defer, commit_busy,
    persist_amo_r, wbq_full, "WAIT1", "WAIT2 and DONE"
  • sim/simx/lsu_unit.cpp:650 and lsu_unit.h:186: VX_lsu_block fault_hold
  • sim/simx/core.cpp:1033: VX_dispatcher, sched_amo_t
  • sim/simx/scheduler.cpp:244: VX_warp_sched_ctx trap_redirect_r

These comments name PR #481:

  • hw/rtl/core/VX_dispatcher.sv:51
  • sim/simx/core.cpp:1087
  • sim/simx/scheduler.h:228
  • tests/regression/amo/kernel.cpp:538

Scenario: The next change to VX_cache_amo or VX_lsu_block renames a signal, and
the SimX comments silently describe hardware that no longer exists.

Fix: Describe the behaviour ("the bank's writeback queue", "the faulted last slice
waits in the LSU"), not the RTL names. Drop "#481" ("mtval stays read-only zero" is
enough).

F2 medium missing-test · ae6aa71 hw/rtl/core/VX_wctl_unit.sv:193,303 · sim/simx/decode.cpp:1155

What: vx_barrier_arrive now stalls its warp (is_wstall), and every BAR, the
arrival included, now waits for pending_alm_empty. That means all of the warp's
earlier instructions must have committed: loads returned, TCU and FPU done, not just
reached the LSU. The commit gives the reason: without the stall, a younger wait
deadlocked the drain.

The cost is a split arrive/wait that no longer overlaps any work, plus a full pipeline
drain on every barrier. A release barrier only needs the warp's earlier memory requests
to have entered the LSU, plus lsu_store_empty. The PR reports the cost (async_barrier
+3.6% rtlsim, sgemm2 +2.6% SimX), but not §6.5's "cheapest correct alternative". One
candidate is a per-warp count of LSU-bound instructions still before the LSU, used in
place of pending_alm_empty, which would also remove the need for the arrival stall.

Scenario: async_barrier, async_gbarrier, bar_slot_phase, gbar_phase, and any kernel
that overlaps work between arrive and wait (the documented use of arrive()) lose the
overlap for every barrier.

Fix: Either prove the alternative worse or unavailable, or narrow the drain to what
the release needs and restore the non-blocking arrival.

F1 high static-proof · ae6aa71 sw/kernel/include/vx_barrier.h:28,69

What: The installed API still documents arrive() as "Notify arrival at barrier
(non-blocking)". After F1 it blocks until the warp drains.

Scenario: A kernel author who relies on the documented overlap gets serialization
with no warning.

Fix: Update the comment, or resolve the finding above so it is true again.

F1 high static-proof · ae6aa71 hw/rtl/interfaces/VX_warp_ctl_if.sv:39-42

What: The new signal's comment says "BAR and FRAG_RELEASE also wait for it, so … the
next fragment's merge sees this warp's stores". No FRAG_RELEASE exists anywhere in
hw/rtl at the head. The text comes from the stacked graphics branch.

Scenario: A reader looks for a consumer that does not exist.

Fix: Drop the FRAG_RELEASE clause. Add it with the graphics PR that introduces the
consumer.

F1 medium reasoned-risk · 6ac1a44 hw/rtl/core/VX_decode.sv:127 · sim/simx/decode.cpp:904

What: The commit's causal story does not match what the change orders. The
scoreboard reserves XREG_2 only on wr_xregs (VX_scoreboard_table.sv:117; in SimX,
fcsr_writes). A trap entry (ecall, ebreak, illegal) only reads XREG_2, so making
csrr mcause an XREG_2 reader cannot order it behind the trap entry's mcause write.
That ordering already comes from the trap's is_wstall and the scheduler writing
mcause in the redirect cycle (VX_warp_sched_ctx; SimX raise_trap).

What the change actually adds:

  • csrw mcause now reserves XREG_2, so later traps, MRET and trap-CSR reads wait for
    it;
  • csrr mcause now waits for in-flight writes to mstatus, mtvec and mepc.

Scenario: The SimX hang at 32 warps × SIMD 4 may be hidden by a timing change rather
than fixed (bug_fixes §1). trap_order exercises neither of the two orderings the change
really adds, since its handler never writes mcause.

Fix: Name the reordering that hung, from a trace, and correct the commit message.
Make trap_order exercise it: for example, a handler that writes mcause before mret, or a
csrw mepc immediately followed by csrr mcause.

F1 high static-proof · 6ac1a44 sim/simx/instr.h:240

What: The comment says TRAP_CSRS "stands for mstatus/mtvec/mepc, which a trap and
MRET read". After this PR it also covers mcause, and atomics read it (F5).

Fix: Update the list.

F1 low reasoned-risk · 58e743d hw/rtl/core/VX_warp_sched_ctx.sv:286-292 (SimX: scheduler.cpp trigger_amo_misaligned)

What: The misaligned-atomic trap reaches the scheduler a cycle after the atomic's
last slice leaves operand collection. A younger instruction from the same warp can
complete in that window, because the trap is imprecise. If that instruction is a TMC to
zero, or anything that retires the warp, retire_hit comes first. The later amo_hit
then writes mepc/mcause and sets trap_redirect_r on a warp that is no longer active,
so the trap is never taken.

Scenario: A misaligned amoadd.w followed closely by a warp exit retires silently,
with the atomic dropped and no trap. Narrow trigger; the docs call the trap fatal or
diagnostic, which is exactly the use it loses.

Fix: Either state in the design note that a warp which retires before its trap
loses the trap, or hold the warp's retirement while it has a faulted atomic in flight.

F1 high static-proof · 5eaf175 hw/rtl/cache/VX_cache_bank.sv:1749-1751, 1841

What:

  • The three VX_popcount instances pack every parameter and port onto one line, which
    guidelines §12 bans.
  • for (integer i = 0; i < 2; ++i) dtag_hist[i] <= 0; has no begin/end, which §3
    requires on every loop.

Fix: Mechanical.

F1 medium reasoned-risk · ae6aa71 sim/simx/core.cpp:1393 · sim/simx/sfu_unit.cpp

What: Core::mem_req_drained() lets the SFU read the queue state of other units
directly (lmem_switch_, coalescers, local_mem_->ReqIn, dcache adapters, MMU),
outside ports and event links. That is the Cardinal Rule (AGENTS.md §5).
lsu_drained() was already a precedent, and this extends it to four more units. The RTL
carries the same information as a signal (lsu_store_empty).

Scenario: Under parallel SimX ticking, the value the SFU reads depends on whether
those units have already ticked in the cycle, so barrier release cycles become
order-dependent.

Fix: Have the LSU memory path publish its empty state through a SimEventLink or
port, mirroring lsu_store_empty.

Reviewed with no finding

  • F10 (__assert → VX_ASSERT): pure rename; no stray __assert is left in
    sim/sw/hw/tests at the head.
  • F2 RTL (fence on every lane at address 0, mem_req_mask all ones): matches the
    stated design, and SimX mirrors it (all-lane token, fence lock at input, release
    through two registers).
  • F8, two points:
    • The non-STALL_FREE lazy_fire is equivalent to mem_rsp_ready. Without a stall,
      fwd_head_ns == fwd_head and replay_link_hold_ns == replay_link_hold, so
      lazy_fire and fill_fire stay in lockstep.
    • The resv/pop_r split is consistent: the count is resv_r - pop_r, and the flag is
      chosen between TH and TH+1 by pop_r.
  • F5 wiring: every instantiation of the modules that gained ports is updated,
    including VX_core (both issue paths), the compute/frontend/backend slices and
    hw/unittest/issue. FETCH_ISSUE_PORTS ≥ 1 is guaranteed by the STATIC_ASSERT in
    VX_frontend_xbar.sv:86.
  • Test-coverage changes are all additions: zacas-simd(-lsu1) gain -t cas_counter -t cas_counter_lmem, and the touches: lists widen. No case was removed or loosened.

Not reviewed, and evidence not seen

  • I did not prove that every term of F8's write-back bound is aligned in latency
    (RELEASE_DELAY = 4 against the dirty-count pipeline of about 5 registers). The only
    evidence is the ifndef SYNTHESIS asserts, exercised by one case (wb_drain-l2-1).
  • F7's SimX cache atomics (cache.cpp) were only skimmed: queue bounds, asserts and
    comments.
  • Test host programs other than amo_misaligned and trap_order.
  • Nothing was run. Every result in the PR's verification table is not run from this
    review's point of view. The PR's CI run status was not checked.
  • ASIC goldens: the PR did not re-run them under the v3.0.3 Beacon.

Obligations still open (R3)

  1. golden-values: the per-entry delta attributed to commits (perf and Beacon area),
    the four hand-stamped entries re-measured, and every re-record run by a human with
    the update command named.
  2. isa-encoding: RTL, SimX and the tests agree on the trap causes. Runtime, kernel
    library and LLVM have no consumers, so nothing is owed there.
  3. rtl-interface / gpu-pkg-types: instantiations are complete; there is no SimX
    mirror of op_args. Beacon is clean only with the accepted depth items.
  4. Maintainer approval recorded in the PR for the R3 contracts. The PR records the
    depth items as accepted, but not the area or cycle moves above.
  5. pipeline-stage (v4):
    • F5 needs the full §13.4 justification, or a redesign at the extension points (P1).
    • F1's wiring needs §13.4, or the existing-port route (P2).
    • F10's flag is the classifier gap (P3).
    • To get CI to report this contract, rebase onto cba70a4 or later.

Verdict

Do not land as is.

  • F5 breaks pipeline isolation (P1, F3). It adds a new scheduler port and a PC
    override, puts a feature inside the dispatcher, and widens op_args in the default
    configuration, all with no §13.4 justification. Rework it at the extension points,
    or supply all six §13.4 items and gate the op_args width under EXT_A.
  • The other commits can land after the earlier F2 fixes, with P2 added. One option
    is to split F5 out of the PR, so F10, F3, F1, F2, F6, F7 and F8 can proceed once those
    fixes are in.

@tinebp tinebp left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#560: ratings for the review above (review policy v5)

Master 3fb83fd adds a 1-5 recommendation rating (5 = must fix) beside F0-F3, and requires an investigated alternative for every concern. This note rates the review above. The PR head is unchanged (4bdefdb).

Branch state: #564, #565 and #566 are stacked on a rebase of this branch onto cba70a4 that is not on fix/master-bugfixes yet. They also carry 2dafca1, which fixes most of the comment finding below. Fold 2dafca1 into this PR and push that rebase, so the children's base matches.

rating finding alternative (from the review)
5 Four perf goldens hand-restamped (softmax-nt4/nt16, dxa copy-nt4/nt16) Re-record with pytest ci -m perf_gate --update-baselines under CI's toolchain (v3.0.3, llvm f44a6bb2a), run by a human.
5 Cycle re-records without the case → commit → mechanism → class table (sgemmx-nt16, wgmma-sparse, dxa mcast) Bisect each case to F1, F2 or the toolchain; for the mcast kernels, run master's and this branch's RTL under the same compiler.
5 Beacon area growth (cache, gfx, gfxvm, vm) not attributed Per-commit Beacon for F1, F5 and F8, as the golden-values contract requires.
5 P1: F5 widens INST_ARGS_BITS in every configuration (§13.3.5) Widen only under VX_CFG_EXT_A_ENABLED, with the other args' padding derived from INST_ARGS_BITS, or carry the fault outside op_args.
4 P1: F5's trap goes through a new scheduler port (sched_amo_t), a PC override and dispatcher logic; no §13.4 justification Fault decided in the LSU's EXT_A path (it already computes full_addr), and the trap raised by a uop-sequencer ALU check uop through the existing branch-port is_trap. Build and measure it; if it loses, provide all six §13.4 items.
4 P2: F1 adds the lsu_store_empty interface signal and two slice-wiring edits Drive the existing .all_lsu_sched_empty port in VX_core with lsu_sched_empty & lsu_store_empty (store_drained already computes it). No interface or wiring change.
5 → 2 once 2dafca1 is folded in Comments naming RTL internals or #481 (SimX and RTL) 2dafca1 fixes most of them. Still left: sim/simx/mem/cache.cpp:2336 ("WAIT1", an RTL state name) and tests/regression/amo/kernel.cpp:538 ("#481").
3 F1: the barrier arrival now stalls and drains the whole pipeline; the cost (+3.6% async_barrier) is not shown to be inherent A per-warp count of LSU-bound instructions not yet at the LSU, in place of pending_alm_empty, which also removes the arrival stall. Not clearly cheaper without measuring, hence 3.
2 vx_barrier.h documents arrive() as non-blocking; VX_warp_ctl_if cites a nonexistent FRAG_RELEASE One-line comment fixes.
2 F3's commit message: XREG_2 read ordering cannot order behind a trap entry, which does not reserve XREG_2 Name the reordering that hung, from a trace, and make trap_order exercise it (a handler that writes mcause, or csrw mepc then csrr mcause).
2 F5: a warp that retires before its trap lands loses the trap State it in the design note, or hold retirement while a faulted atomic is in flight.
2 SimX Core::mem_req_drained() reads child units' queues (Cardinal Rule) Publish the LSU path's empty state through a SimEventLink, mirroring lsu_store_empty.
1 instr.h TRAP_CSRS comment omits mcause; F8 style (one-line VX_popcount, for without begin/end) Mechanical.

Verdict: do not land as is. The four rated-5 items are the must-fix set, two of them (the hand-restamped goldens and the unattributed cycle re-records) in the baseline commit alone. A fast path is to split F5 out, as the review suggests; the remaining commits then need the rated-5 golden-data items, P2, and 2dafca1.

tinebp and others added 12 commits December 3, 2026 02:12
…bug builds compile again

util.h defines a two-argument __assert macro. Double-underscore names are
reserved for the implementation, and glibc uses this one: its <assert.h>
declares `extern void __assert (const char *, const char *, int)`, and in
glibc 2.34 (RHEL/EL9) that declaration is not guarded, so every inclusion of
<assert.h>/<cassert> repeats it. In a debug build (no NDEBUG) any translation
unit that includes <cassert> after util.h then expands glibc's declaration
through the macro and fails: "macro "__assert" passed 3 arguments, but takes
just 2".

Measured on master 2496be3 on EL9 with every runtime driver built with
DEBUG=1 (make -k): 39 translation units fail (simx 33, rtlsim 2, xrt 2,
opae 2), through our own headers (sim/common/simobject.h, sw/common/
smallfunc.h, sw/common/mem_alloc.h, ...) and two third-party paths
(ramulator's spdlog in dram_sim.cpp, Verilator's verilated_vpi.h in
dpi_float.cpp). 38 product files include <cassert> or <assert.h>, so
reordering includes would have to cover every one of them, and any new
<cassert> after util.h would break again. debug:demo-5 (simx --debug=1) and
debug:demo-4 (xrtsim --debug=1) fail to build on EL9.

CI's runner (ubuntu-22.04, glibc 2.35) is not affected: debug:demo-5 passes
there. This is a host-portability fix, like #537's EL9 fixes.

Behaviour is unchanged: the same always-on check, the same message, the
same cold out-of-line report and abort. Every use is renamed (11 files).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…; trap_order test

Master orders a trap entry or return behind writes to mstatus, mtvec and
mepc (the XREG_2 slot in VX_decode, Instr::TRAP_CSRS in SimX decode), from
the upstream form of this fix. A handler that reads mcause right after the
entry is not covered: the trap entry writes mcause, and the CSR read is not
ordered behind it. VX_CSR_MCAUSE joins the trap-CSR set in both models.

Trigger test: tests/regression/trap_order, the branch version of trap with a
per-round mtvec handler that reads mepc and mcause, and the CI case trap-simd
(32 warps, SIMD 4, 8 threads, simx and rtlsim). Without the ordering SimX hung
("ring accepted but nothing executing") at several issue packets per warp.

Branch commit: 39193d0 (the rest of it is master's).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…g those waiting at the local memory

A workgroup barrier (vx_barrier, vx_barrier_arrive) is also a workgroup-scope
memory barrier, but BAR only waited for the LSU schedulers to empty. With 32
or more warps a core has two LSU blocks, and a store still between one block
and the L1, or waiting at the local memory's block input (arbitrated across
blocks while its write engine is busy), can lose to a load another block
issues after the barrier: a peer warp reads the old value.

BAR now also waits until the warp's earlier instructions have reached the
LSU, every request has left the LSU blocks, and the local memory has taken
every request off its block inputs:
- RTL: lsu_store_empty (VX_lsu_mem_path, with the local-memory input term)
  reaches VX_wctl_unit through VX_warp_ctl_if.
- SimX: Core::mem_req_drained (lmem switch, coalescer, dcache adapters, the
  local memory's inputs, the MMU).
A barrier arrival now stalls its warp until it executes, like the blocking
forms: a younger barrier wait queued behind the arrival deadlocked it
(gbar_phase on two cores).

Seen as the nondeterministic BVH-build failure of
dEQP-VK.ray_query.multiple_ray_queries.compute_shader (warp 0 read warp 5's
histogram total through workgroup memory before warp 5's store).

Trigger tests: tests/regression/bar_vis (CTA exchange across two LSU blocks,
global and workgroup memory, a same-bank variant, and mode 2: stores waiting
at the local memory's inputs while the read engine is busy); CI cases
bar-vis, bar-vis-shared, bar-vis-bank, bar-vis-lmem-input(-timed),
model_parity-bar-vis.

Default behaviour: barriers take the drain; rtlsim async_barrier +3.6%
cycles, SimX sgemm2 +2.6% (x32).

Logic depth (accepted, user decision 2026-12-01): in gpu32_full the barrier
unit's store_state_valid and the DXA completion FIFO's used_r go from 11 to 12
levels; the whole-GPU deepest path is unchanged at 29 levels.

Branch commits: 41c40ee, 4f3f54239, 2a891d488.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nd holds the block's input until answered

Master sends a fence to the coherence point as a flush token behind the
block's earlier requests. Three gaps remain:

- RTL: the fence goes out with the warp's thread mask and its lanes'
  register values as addresses. An inactive lane sends no copy, so a store
  on that lane's path can still pass the fence. The fence now goes out on
  every lane at address 0; the block joins every copy's response. SimX's
  flush token goes out on every LSU lane the same way (it used the lanes of
  the fence's last packet's thread mask).
- SimX: while a fence was out, the LSU still moved the block's later loads
  and stores into its request queue, where a store commits, so a store
  retired under the fence. The RTL's fence lock holds the block's input
  from the fence's request until its response; SimX now does the same.
- SimX timing of the fence's walk: the bank spends its quiescent cycle
  (WAIT1) before the first line and waits for the last line to leave its
  pipeline (WAIT2) before DONE, and the fence's answer retires through the
  response buffer and the result arbiter's register, as in the RTL
  (parity-fence-mp: SimX 13.6% fast before).

Trigger tests: tests/regression/fence_mp (modes 3 mirrored pairs, 4 lanes,
5 ports, -r rounds, -g plain guard) with the CI cases fence-mp-1c,
fence-mp-mc-l2, fence-mp-mc-l3, fence-mp-lanes (raw dcache set index),
fence-mp-ports and parity-fence-mp; tests/regression/vm_test mode 7
(release through a fence while the store parks on a TLB miss) with the
CI case vm-release. Design notes: docs/designs/multicache_amo_coherence.md.

Default behaviour: fence timing only (fences are rare in the default
regression; printf +0.035% SimX cycles at x32).

Branch commits: 3910921, c6163b52a, adcdffb21 (the rest of 3910921 is
master's).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…memory

The local memory switch once rebuilt each lane's request without the AMO
compare value, so every compare-and-swap to local memory compared against 0.
Master carries the value through (the upstream form of the fix), but the
regression's compare-and-swap cases still only ever compare against 0, so
they pass either way. cas_counter and cas_counter_lmem count up from a
nonzero base with a compare-and-swap of the last observed value: a comparand
that does not reach the memory side makes the count fall short. Both failed
on the switch without the compare value (SimX). They run under the existing
Zacas guard, in the zacas-simd and zacas-simd-lsu1 cases, on simx and
rtlsim.

Also drops local_mem_switch.cpp's stale note that the RTL has no
local-memory AMO path.

Branch commit: ab81ab3 (its Vulkan fp64 and atomic_float tests go with the
graphics branch).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
SimX's cache bank paced atomics differently from the RTL, which broke the
model_parity cases on atomics:

- SimX held core-request admission (amo_busy_) for every store-bearing LLC
  atomic from admission to commit, hit or miss, kept one pending writeback
  (a second commit overwrote it), and had no input ordering guard. It now
  models VX_cache_amo: commit_busy holds admission only from the S0 of a
  store-bearing atomic predicted to hit (or a replay) until its result has
  drained; a writeback queue (AMO_WBQ_SIZE 4, merging per word) drains
  through the core-request slot; a fill waits while that queue has no room
  (wbq_full); and the same-line input defer reads a registered MSHR probe
  (the request's first cycle at the input, and the S0, S1 and following
  cycle of an atomic that misses).
- A non-LLC (passthrough) atomic's response now crosses the bank pipe as a
  fill (AmoFill) and answers from its replay (AmoRsp), as in the RTL, instead
  of answering the core in the tick the response arrived.
- The LLC's MSHR asserts that no request links behind a pending atomic
  (amo_ordered_), the RTL's "request linked behind a pending AMO" check, and
  a full MSHR at enqueue is a named VX_ASSERT instead of a bare abort.

amo -n32, SimX / RTL cycles: amoadd_scatter 5011 / 5252 (11740 before);
contended amoadd+amoswap 7766 / 7761; the same at a shared L2 within the
parity tolerance (6.24% before).

Trigger tests: tests/regression/amo amoadd_scatter (atomics over more lines
than the dcache holds) and amo_line_burst (bursts into distinct words of
cold lines); CI cases parity-amo-contended, parity-amo-contended-l2,
parity-amo-scatter (model_parity), which fail the 5% tolerance without this
change. Design notes: multicache_amo_coherence.md 5.1.

Default behaviour: SimX timing of atomics only (EXT_A is off by default).
The RTL half of 6a3b7fc3f is master's.

Branch commits: 6ef985b38, 2269c5763, 6a3b7fc3f (SimX), e163ba841.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…cks it can still owe (#557 follow-ups)

#557 (a write-back bank takes every fill; each pending fill reserves its
writeback room in the memory request queue) has two defects:

- It caps reads in flight below the MSHR: every pending fill reserves SEC
  beats, dirty victim or not. core:sgemv-nt16 (rtlsim, perf_gate) goes from
  285,869 to 292,363 cycles (+2.27%, same 66,704 instructions).
- Its range assert "resv <= MREQ_QUEUE_SIZE + SEC" is a proxy, not an
  invariant: a 4-core write-back L2 with two sectors per line fires it
  ("memory request reservation out of range: 19"), first seen in msgpass on
  xrtsim x64.

The bank keeps the reservation and adds an exact bound on the writebacks
the queue may still have to take: its occupancy, the evicted dirty sectors
not yet queued, the tag store's dirty sectors (VX_cache_tags reports the
dirty-store transitions), the writes not yet among them, and the requests in
the pipe. Work is held only while both are over their limits. The reservation
count is kept as count + last write pop, so the memory side's ready loads one
register and the cache DUT's logic depth returns to master's (Beacon cache
13 -> 13 levels).

Logic depth in the whole GPU (accepted, user decision 2026-12-01): in
gpu32_full's write-back L2 the bank's new resv_alm_full_r sits at 17 levels and
pop_r/any_pop_r at 14. Registering the credit would cost an admission cycle on
the read stream that sgemv-nt16 measures; the whole-GPU deepest path is
unchanged at 29 levels.

Per logic_gate entry (CI's v3.0.3 Beacon 4060e3af4; accepted, user decision
2026-12-01): VX_cache_tags' dirty-sector buffers g_dirty ex279/ex280 are new at
12 levels (the fix threshold) in cache, vm, gfx and gfxvm; each entry's deepest
path is unchanged (cache 16, vm 21, gfx/gfxvm 19). A registered report would
cost a cycle of latency on the dirty-sector count the bound reads.

Branch commits: 7ef6630c8, 2fa55dc15, 1eba6cca7.

Trigger test: cache:wb_drain-l2-1 (rtlsim, 4 cores, 16 KB L2, two sectors per
line). It asserts at cycle 23,289 (x32) / 13,961 (x64) without this change.
perf_gate core:sgemv-nt16 rtlsim: 292,363 -> 285,869 cycles.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…omments

The misaligned-atomic trap, fence, barrier and LLC-atomic comments named a
pull request (#481) or the other layer's internals: SimX comments named RTL
modules and signals, and the barrier drain's interface comment named an
operation master does not have. They now describe the behaviour only, as
docs/coding_guidelines_cpp.md §10 and AGENTS.md §6 require. Comments only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Beacon (CI v3.0.3) on cache, vm, gfx and gfxvm records the write-back
bank's dirty-sector buffers (g_dirty ex279/ex280) new at 12 levels, accepted
on 2026-12-01; each build's deepest path is unchanged (cache 16, vm 21,
gfx/gfxvm 19) and the rest of their moves are improvements. core and
core_ldst pass and tensor and top_vortex improve on master's goldens, which
they keep.

perf_gate core:sgemv-nt16 is 285869 cycles again (292363 since #557): the
exact write-back bound removes #557's +2.2%. sgemmx-nt16 +1.7%, sgemm2-fp16
-1.9% and wgmma-sparse +1.5% stay within the 2% band on master's goldens.
Both recorded by the gates' own --update-baseline(s).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@tinebp
tinebp force-pushed the fix/master-bugfixes branch from 2dafca1 to 96ded66 Compare December 3, 2026 10:38
@tinebp
tinebp merged commit 44741f1 into master Dec 3, 2026
1 of 8 checks passed
@tinebp
tinebp deleted the fix/master-bugfixes branch December 3, 2026 10:39
tinebp added a commit that referenced this pull request Dec 3, 2026
…d of touching memory (#569)

An atomic (AMO, LR, SC, compare-and-swap) whose active lane names an address
not aligned to its size now raises the RISC-V address-misaligned exception:
store/AMO address misaligned (6), load address misaligned (4) for LR, mepc
the atomic, mtval read-only zero. On master the RTL asserts in simulation (on
hardware it writes through a misaligned word) and SimX aborts.

The trap is precise: no instruction after the atomic runs before the handler,
and the handler may return to mepc + 4. It uses the pipeline's extension
points only; no shared stage changes (coding guidelines §13).
- Decode marks every atomic wstall (EXT_A only), as it does a branch.
- The uop sequencer (VX_uop_amo) puts an alignment check ahead of every
  atomic: check [release fence] atomic [acquire fence]. The check is an ALU
  branch-port uop on rs1 (INST_BR_AMOCHK, INST_BR_LRCHK, two spare branch
  codes) that targets PC + 4 and reads the trap pseudo-register, as ECALL
  does, so an older mtvec write has landed when it traps.
- VX_alu_int (EXT_A only) raises is_trap with cause 6 or 4 and dest = the
  atomic's PC when an active lane is misaligned. The check's SIMD slices and
  packets reach a block back to back, so one flop holds a misaligned lane of
  an earlier one until the last. The branch port's existing trap path writes
  mepc, mcause and mstatus and redirects the stalled warp; its br_hit
  releases the warp's fetch.
- VX_lsu_block (EXT_A only) decides the same from rs1 on its own: from the
  packet holding the first misaligned lane on, the atomic's packets retire
  through the no-response path writing nothing (as a fence's skipped packets
  do); packets ahead of it have gone to memory. A faulted end-of-instruction
  packet waits for those packets' responses (fault_hold), so the next packet
  does not start in a slot still counting them.
- SimX in lockstep: decode marks the atomic macro wstall; LsuUopGen emits the
  check (BrType::AMOCHK) as uop 0; the sequencer gives a wstall uop its
  macro's fetch release; AluUnit holds a misaligned lane per block and calls
  the trap through the branch-control port (BranchCtl LOAD_MISALIGNED /
  AMO_MISALIGNED), which the scheduler applies as it releases the warp; LsuUnit drops the atomic from the faulted packet on
  and holds behind a partly faulted one.
- No VX_types change (the causes are local literals, as the ALU's other
  trap causes), so the resolved config and every perf golden are unchanged.

Cost: the atomic stalls its warp's fetch until the check resolves, as a
branch does. x32 cycles, control = master 3fb83fd with this commit's amo
test text, so only the hardware and model differ:

  case               simx                      rtlsim
  amoadd              5875 ->  8211 (+39.8%)    5888 ->  8224 (+39.7%)
  contended           7505 ->  8721 (+16.2%)    7522 ->  8738 (+16.2%)
  contended-l2       37487 -> 33539 (-10.5%)   37491 -> 37641  (+0.4%)
  zacas-simd         20239 -> 22129  (+9.3%)   21523 -> 21337  (-0.9%)
  amo list w/o trap  58579 -> 61244  (+4.5%)   62238 -> 66286  (+6.5%)
  sgemm             113803 -> 113803  (0.0%)   113814 -> 113814  (0.0%)

With EXT_A off (the default) nothing changes: Beacon (v3.0.3) core and
lmem with A off are identical to master on U55C (LUT 120383, FF 137138,
15 levels) and ASIC (723387 cells, 94018 FF, 30 stages). With A on: U55C
core LUT 127131 -> 127084, FF 140274 -> 140277, 15 -> 15 levels; ASIC core
745720 -> 745233 cells, FF 95842 -> 95845, 30 -> 30 stages.

Trigger test: tests/regression/amo amo_misaligned (amoadd.w, lr.w, sc.w,
amocas.w at misaligned addresses; lane 1 alone misaligned; a misaligned lane
opening the second LSU packet and the second SIMD slice; an aligned atomic),
checking mcause, mepc ^ mtval, rd, every word of memory, and that the
instruction after the atomic runs exactly once, after the handler. CI cases
parity-amo-misaligned and misaligned-simd-packets (8 threads, SIMD 4, ALU and
LSU lanes 2); the base, zacas, wb, threads8 and mc amo cases run it too. On
master the RTL asserts "misaligned memory access" and SimX aborts.

Rebased onto master after #574 and #560:
- SimX: #574's ALU reports branch outcomes through BranchCtl, so the check's
  trap goes there too (Scheduler::trigger_misaligned_amo, with the other
  traps' no-handler abort). parity-amo-misaligned: SimX 4593 / RTL 4610
  cycles (0.37%).
- Tests: #569's amo_misaligned is added next to #560's cas_counter and
  scatter tests (kernel table, host list and amo.yaml in the same order).
- Beacon top_vortex (dcache = shared LLC, A on): two registers one level
  deeper, max path 21 unchanged, LUT +71. LSU req_queue 14 -> 15: the fault
  must gate mem_req_valid, which meets the address-type compare at the LSU
  scheduler's client grant (shown by removing the term: back to 14).
  ibuffer pending_size 9 -> 10: with the dcache as the shared LLC master
  folds the AMO uop expander away; the check needs it for every atomic.
  Both follow from the chosen form (the LSU decides from rs1, no op_args
  fault bit); the goldens are re-recorded with the toolchain move.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
tinebp added a commit that referenced this pull request Dec 3, 2026
…hain v3.0.4

Toolchain v3.0.4 (#566) moved the Beacon version and some instruction
counts, so every golden is re-recorded on the final tree of the #560..#569
merge series, by the gates' own --update-baseline(s):

- logic_gate U55C (16 entries) and beacon_asic (14): no build deeper or
  slower than its previous golden; LUT flat except raster +1%.
- perf_gate (51 x32 entries): geomean +0.52% cycles.
  - dxa/wgmma (accepted): wgmma-dxa-mcast-nt4 +6.7%, copy-nt16/-nt4 +3.6%
    (+8 instructions), wgmma-dxa-mcast-nt16 +2.0%, wgmma-sparse +1.5%,
    the rest of dxa and wgmma under +1%.
  - core:sgemm2-wide +4.74% (313459 -> 328310, instructions equal): from #560,
    whose barrier and fence now drain the warp's memory requests (a
    correctness fix). rtlsim before #560 313459, after 328310; SimX moves
    the same way (312426 -> 324923). Later merges leave it unchanged (#569:
    328310; #568 equal on SimX).
  - sgemmx +0.4%, sgemm2-fp16 +0.3%, softmax -0.2% (-6,144 instructions);
    all other entries within +/-0.1%.

Not re-recorded (skipped for time): fpga_gate, asic_gate, and the opt-in
gpu logic_gate entries.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
tinebp added a commit that referenced this pull request Dec 3, 2026
…E_ENABLE at FLEN 64) (#568)

VX_CFG_EXT_LDST_WIDE_ENABLE required FLEN 32, where vx_flw.d/.q are macro-ops
of 2 or 4 flw uops. With 64-bit FP registers a vx_flw.d/.q is now one LSU
instruction, as NVIDIA's LDS.128 and AMD's DS_READ_B128 are: each lane reads
its 8 or 16 bytes in one memory access and one writeback writes the 2 or 4
registers, each word NaN-boxed in its own register. The address must be
naturally aligned (8 / 16 B). vx_fsw.d/.q stay fsw uops.

- RTL: decode carries the group size; the scoreboard reserves the aligned
  group; LSU lanes are 16 B with one addressed word in the low half; the LMEM
  engine reads whole lanes for a quad; VX_lsu_dcache_narrow (new) sends a quad
  to the D-cache in two half-lane passes; result/commit/writeback carry the
  upper 64 bits.
- SimX: the same model (IntrLsuArgs::wide, group scoreboard, one writeback,
  local memory serving a quad lane's two banks in one pass, two half-lane
  coalescer passes).
- Everything is under the derived LSU_WIDE_ENABLE (the extension on at
  FLEN 64); every other configuration elaborates master's logic.
- Profiles: on in the NVIDIA and AMD root profiles (derived ones inherit);
  tinygpu unchanged. a100, one core, SimX: sgemm -n64 -18.4%, sgemm2 -n64 -t4
  -24.0% cycles.
- Tests: tests/ldst_wide covers FLEN 64 (NaN-boxing, junk upper halves, end of
  the read-only words); parity-ldst-wide-x64 is a 64-bit model_parity case
  (testcase.py lets a model_parity case name its own xlen).

Rebased onto master after #565, #566 and #569: the LSU alignment assertion
keeps #569's fault exemption on both the wide and the normal path. On the
final tree: parity-ldst-wide-x64 instructions equal, cycle gap 0.01%.

CI goldens, re-recorded on this tree with toolchain v3.0.4 (#566 moved some
instruction counts and the Beacon version) by the gates' own update flags:
- logic_gate U55C (16 entries) and beacon_asic (14 entries): no build deeper
  or slower than its previous golden; LUT flat except raster +1%.
- perf_gate (51 x32 entries): geomean +0.52% cycles; dxa/wgmma up to +6.7%
  (accepted); core:sgemm2-wide +4.74% from #560's barrier/fence memory drain
  (a correctness fix; SimX moves the same way); everything else within
  +/-0.4%.
- parity on the paths where the merged PRs meet (atomics, fences, ldst-wide,
  ldst-matrix, lmem, barriers, traps): 13 of 14 pass. isa:parity-amo-scatter is
  5.52% (> 5%) on master since #569: the RTL uop sequencer spends a start
  cycle on every macro-op, which SimX does not model, and #569 made every
  atomic a macro-op. Fixed separately.
fpga_gate, asic_gate and the gpu logic_gate entries were not re-recorded
(skipped for time).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant