Skip to content

Stream runs of whole-line writes past the caches - #371

Merged
willmccallion merged 2 commits into
mainfrom
cache/write-streaming
Nov 25, 2026
Merged

willmccallion merged 2 commits into
mainfrom
cache/write-streaming

Conversation

@willmccallion

Copy link
Copy Markdown
Owner

A cache can now stop allocating for a run of whole-line writes, as the Cortex-A72 does for a copy or a fill, instead of reading every line it is about to overwrite.

Mechanism

  • With write_streaming=WriteStreaming(skip_l1_from=…, skip_l2_from=…), the L1D counts a hart's whole-line writes to consecutive lines, in either direction. A partial-line write ends the run; reads do not, so a copy's loads leave its stores' run intact.
  • From skip_l1_from the line is written without a fetch and kept by the next level; from skip_l2_from no cache keeps it.
  • A streamed line travels as MemOp::WriteFull { allocate }, which memory controllers post like a writeback. Through the coherence fabric it is a CHI-style WriteUniqueFull that invalidates every other copy.
  • A coherent L2 asked to keep a line it does not hold fetches ownership (where CHI would send MakeUnique); a follow-up issue covers that.
  • New stats: streamed_writes and streamed_installs per cache, and requests.write_unique_full at the home. All are covered by accounting checks.
  • Off unless configured; the Python WriteStreaming config refuses skip_l2_from < skip_l1_from.

Cortex-A72 calibration

  • Turns on a 4-entry WCB (the TRM says the L1 merges stores, not into how many lines), streaming at the TRM's reset thresholds (CPUACTLR_EL1[28:25]: 4 and 12), and the L2's 16 outstanding writes (TRM table 7-4).
32 MB, MB/s Before Now Raspberry Pi 4
C copy 935 1,575 2,253
C fill 1,313 5,383 2,883

The remaining gap is memory: the calibration's Dram controller is fitted to the Pi's latency, not its bandwidth (#370). CoreMark/MHz moves from 5.12 to 5.05 (Pi 5.50) and DMIPS/MHz from 3.89 to 3.86.

Checked locally

  • Rust and Python suites and make accuracy (unchanged).
  • make lockstep-ci: 858/858.
  • riscv-tests on ref cortex-a72 and ref linux with 4 harts: 376/376.
  • Multicore smoke: 120/120.
  • A Linux boot and benchmarks on the A72 calibration.

A cache given a write-streaming configuration counts a hart's whole-line writes to consecutive lines, in either direction, and once a run is long enough writes them without fetching the line: kept by the next level from skip_l1_from, by no cache from skip_l2_from, as the Cortex-A72's load/store unit does (CPUACTLR_EL1[28:25]). A streamed line travels as MemOp::WriteFull, or through the coherence fabric as a CHI-style WriteUniqueFull that invalidates every other copy. Off unless configured.
A 4-entry write-combining buffer, write streaming at the TRM's reset thresholds and the L2's 16 outstanding writes. A 32 MB copy now runs at 1,575 MB/s and a fill at 5,383 MB/s, against 2,253 and 2,883 on a Raspberry Pi 4; the remaining gap is the DRAM model (#370).
@willmccallion
willmccallion merged commit 5db380d into main Nov 25, 2026
6 checks passed
@willmccallion
willmccallion deleted the cache/write-streaming branch November 25, 2026 00:05
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