Repository navigation
Conversation
…s on port B from a request register with 2+ LSU blocks); re-record: ci/logic_gate.py -j 1 -b lmem -b tensor [--tool beacon_asic] --update-baseline --against-rev $(git merge-base HEAD origin/master), pytest ci -m perf_gate -k 'dxa or wgmma or tensor or tcu or lmem or local' --update-baselines; Re-recorded by: agent at jel221's request 2026-12-03
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Human comment: There is no reason for the DXA (writes INTO the SMEM) and TCU (reads FROM the SMEM) to arbitrate over a single port. This is one of the bottlenecks identified working on WGMMA.
Summary
Gives
VX_lmem_unitseparate DMA ports for row writes and row reads, so a DXA write and a TCU read no longer compete for one port.On master, the DXA's row writes and the TCU tile buffers' row reads share one LMEM DMA port through a round-robin
VX_mem_bus_arbinVX_mem_unit, and every DMA access uses bank port A. With two or more LSU blocks the banks areVX_1rw1r_ram, and port B is idle in every DMA cycle: the slot that admits a DMA access holds both LSU passes off. A writer and a reader therefore queue behind each other for one port while a second port sits idle.VX_lmem_unithasdma_wr_if(row writes, from the DXA) anddma_rd_if(row reads, from the TCU) in place ofdma_if.VX_mem_unitconnects each agent to its own port, and its DMA arbiter is gone.VX_lmem_bankis unchanged.VX_sp_rambanks, one port). The two agents alternate round-robin inside the LMEM unit, as on master.LocalMemmodels the same: per DMA slot, one write and one read with two or more LSU blocks, round-robin with one.Impact and evidence
See docs/review/code-review-policy.md.
Impact class: R3. The classifier gives R3 (
golden-values) for the re-recorded baselines. The change also edits a shared unit (the local memory) for the DXA and TCU extensions, so it falls under V-ISO-6 (justification below).Contracts touched:
VX_lmem_unitports:dma_ifis replaced bydma_wr_ifanddma_rd_if. Both instantiations changed with it:VX_mem_unitand thelmemunit-test wrapperhw/unittest/lmem_unit/VX_lmem_unit_top.sv.VX_gpu_pkg:LMEM_DMA_DXA_IDX,LMEM_DMA_TCU_IDX,LMEM_DMA_INPUTS,LMEM_DMA_IN_TAG_MAXandLMEM_DMA_TAG_WIDTHare replaced byLMEM_DMA_WR_TAG_WandLMEM_DMA_RD_TAG_W. There are no other users.LocalMem::Config::dma_clients: each client now only writes or only reads. A client that mixes the two, or more than 32 clients, fails an assertion.lmemandtensorinbeaconandbeacon_asic; the perf baselines listed in the delta table.pytest ci -k "(dxa or lmem or wgmma or tensor_wg or tcu_wg or local or barrier) and not perf_gate", 171 passed (4 shards, separate build trees). xrt not run.model_paritymodel_parity-wgmma-dxa-lsu2(new) andmodel_parity-wgmma-sp-dxa-lsu2(new) pass; sparse gap 0.67 %. Alsomodel_parity-wgmma-dxa,model_parity-wgmma-sp-dxaandmodel_parity-wgmma-dxa-mcast(1 LSU block, round-robin).perf_gate-k "dxa or wgmma or tensor or tcu or lmem or local"), regenerated with--update-baselines. The 22 existing entries come out identical to master in cycles and instructions; the only change is the newperf_gate-wgmma-dxa-lsu2.logic_gatecore,lmemandtensor, both tools, against the merge-base. No path got deeper in any of them.lmem+69 LUT / +46 FF (attributed below).coreis identical.fpga_gate/asic_gate)LSU_MEM_WORD_SIZE, the same at both XLENs.Self-check:
ci/precheck.shsummary: precheck: 7 pass, 0 with findings, 0 fail, 0 not runDepartures from SHOULD rules: none
Design note: the V-ISO-6 justification below, and
docs/designs/mlp_optimizations.md(Local-memory banks and LMEM DMA round-robin sections), updated in this PR.V-ISO-6: a shared-unit change for the DXA and TCU
1. Goal. A DXA row write and a TCU row read go through the local memory in the same cycle. The two agents use the same banks and need nothing from each other. No extension point can do this. The banks' second port exists only inside
VX_lmem_unit, and on master both agents reach the banks through the one DMA port. Any design outside the unit can only choose which of the two waits.Today's WGMMA+DXA kernels are not DMA-bound, so the gain on master is small (item 3). An analytical model of the TMEM GEMM shows the port becomes the limit once operand fetch overlaps the MMA steps. On a 128×128×512 GEMM, DXA writes plus TCU reads come to 36,864 port cycles against 32,768 cycles of MMA work. With the split, the larger of the two is 20,480 cycles, below the MMA.
2. The isolated alternative. Master is the isolated design: one DMA port, with the arbiter in
VX_mem_unit. An arbitration policy can reorder who waits but cannot serve both in one cycle, so no isolated design does better than master here. To measure what that costs, I counted the cycles in which both agents had a request and only one was served. The count came from a temporary counter on master, not committed. Config: rtlsim, ISSUE_WIDTH=2, two LSU blocks, NRC=32, 32 threads × 8 warps.sgemm_tcu_wg_dxa128×128×64sgemm_tcu_wg_sp_dxa128×128×1283. The gain. Same configuration, rtlsim cycles (SimX in parentheses):
sgemm_tcu_wg_dxa128×128×64sgemm_tcu_wg_sp_dxa128×128×128The port-B request register costs nothing on the dense kernel (39,426 either way) and 20 cycles on the sparse one (79,110 without it).
4. The cost to every configuration. Beacon, against the merge-base:
core(no DXA, no TCU)tensor(1 LSU block, round-robin)tensor+NUM_LSU_BLOCKS=2 ISSUE_WIDTH=2(port B)lmemunit testVX_mem_unit(404 LUT, both cores) is gone.abufreaches the SRAM address pins combinationally, 7 levels fromfetch_base_r, through the arbiter. On this branch, port B's address is 2 levels from registers. The LMEM unit's deepest path goes from 10 to 9 levels.VX_mem_unit. The TCU request still reaches the DXA completion FIFO combinationally, at 8 levels, the same depth as master. This path predates this PR, and this PR does not lengthen it.lmemcost is in the delta table below. The FPGA cost is +58 LUT / +14 FF inlmem_unit(port-B mux, request register, round-robin bit) and +11 LUT / +32 FF in the unit-test wrapper, which registers the new read port like the write port.5. Knob-off identity. With neither
VX_CFG_EXT_DXA_ENABLEnorVX_CFG_TCU_WGMMA_ENABLE, the LMEM unit has no DMA logic. Beaconcoreis identical in both flows: area, depth and every endpoint. The perf gates of configurations without DXA or WGMMA do not move: every entry in the 23-gate run is identical to master, apart from the new one.6. Approval. Pending: needs the maintainer's approval on this PR.
X-CFG-5: each generate branch has a case
VX_lmem_unitDMA_RD_PORT_B(register + port B)model_parity-wgmma-dxa-lsu2,perf_gate-wgmma-dxa-lsu2,model_parity-wgmma-sp-dxa-lsu2DMA_SHARED(round-robin on port A)model_parity-wgmma-dxa,perf_gate-wgmma-dxa,perf_gate-wgmma-sp-dxa,perf_gate-wgmma-dxa-mcast*perf_gate-copy-*,perf_gate-sgemm2-dxa-*perf_gate-wgmma-fp16-ss,perf_gate-wgmma-sparselmemandcoreBeacon; the LMEM functional suiteGolden data re-recorded
Run with the
TOOLCHAIN_REVv3.0.4 prebuilts, XLEN 32. Re-recorded by: agent at jel221's request 2026-12-03. This is the PR author's request, not a maintainer delegation under X-EV-1. If the maintainer wants a re-run by a person, it is the three commands above.Per-entry deltas (B-3). Every change is in this PR's one commit.
lmem(FPGA)lmem_unit: per-bank port-B mux (+58 LUT); request register: valid, row address, tag (+14 FF). Wrapper: input register for the new read port (+11 LUT, +32 FF).lmem(ASIC)tensor(FPGA)VX_mem_unit's two-input arbiter removed; the round-robin moved into the LMEM unittensor(ASIC)perf_gate-wgmma-dxa-lsu2The
lmemtrade-off. The cost buys the −2.1 % / −1.6 % above and removes a combinational path from the TCU into the SRAM. Predicted before measuring: one mux per bank on port B's enable and address (the LUTs); one register of valid plus row address plus tag (the 14 FF); one buffer for the wrapper's second port (it registers every input port). The cheapest design that still serves a write and a read in the same cycle needs the same per-bank port-B mux. Without the request register it saves the 14 FF, but the TCU's request logic then reaches port B combinationally, which V-ISO-4 rules out. Master's shared port avoids both costs and keeps the conflict cycles of item 2.known_issue:, wider tolerance, smaller args, removed case) without a root-cause plan.