Skip to content

§ 6.6. Experiments

The questions, fixed before any run:

  1. How much faster is the computer with the matrix unit than the computer alone, on matrix multiplies and on the two networks?
  2. How does that change with the array size (4 × 4, 8 × 8, 16 × 16)?
  3. How does it change with the main memory (flip-flop, SRAM, DRAM)?
  4. What limits the unit: the multiplying, or moving data and commands?

Setup

Item Setting
Machines accelerator-machine-cpu (the CPU alone) and accelerator-machine with MatrixUnit<N>
Core RV32IM five-stage, multiplier=array on both machines, so the CPU is not held back by a 33-edge multiply
Bus The pipelined bus of 6.3.2 on both machines, except where a row says otherwise
Fidelity Compact (every part on the delays proven on its gates)
Timing The unit timing profile, 1000-tick clock; no setup violation in any run
Memories FF; SRAM, the clocked macro with its wait states at this clock; DRAM with the profile's 2-word rows and no refresh, and a row retention of 64 ms, a real DRAM's refresh period (below)
Programs 6.5: matrix multiply (three layers), MLP and CNN; two images with the unit, one on the CPU alone
Tool accelerator_experiment --program … --matrix … --memory … (then run with --array-multiplier --pipelined-bus, now the defaults), driven by tools/accelerator/run-campaign.py

Cycles are the program's own timer readings around each timed section; a cycle is one clock period on every machine, so this section reports cycles, not seconds. The safe-clock analyzer (AcceleratorMachineTimingTest) certifies the CPU-alone machine at 160 ticks in unit and 4,254 ps in embedded, and the unit machines on the chapter-5 bus at 162 ticks and 5,518 ps (the activation bank's write data); it cannot certify the unit machines on the pipelined bus, where two pipelined arbiters meet without a register between them (the state-dependent cycle of § 5.7). Every run below had no setup violation at its 1000-tick clock.

Results

Every run halted cleanly, with status 0 and no setup violation, and its outputs equal the host reference: the scores of model.json for the networks, and the CPU-alone products for the matrix multiplies.

1–2. Speedup and array size

Cycles of the timed section, SRAM main memory:

Workload CPU alone 4 × 4 8 × 8 16 × 16 Speedup at 16 × 16
Matrix multiply (3 layers) 2,851,206 71,167 29,984 26,614 107.1×
MLP, one image 1,636,072 462,490 137,032 117,321 13.9×
CNN, one image 2,643,442 106,281 49,697 46,111 57.3×

The CPU alone needs 32–45 cycles per multiply-add: a load of each operand, the multiply, the add and the loop. The 16 × 16 unit reaches 3.9 multiply-adds per cycle on the largest matrix multiply, 1.3 on the CNN and 0.43 on the MLP, against a peak of 256.

Going from 4 × 4 to 8 × 8 pays (2.1–3.4× fewer cycles); going on to 16 × 16 barely does (8–17 %). Each layer has too few rows and too few outputs to keep a 16-wide array full, and the work that does not shrink with the array (copying, commands) is already most of the time.

3. Main memory

Cycles of the timed section, 16 × 16 unit:

Workload FF SRAM DRAM
Matrix multiply (3 layers) 18,428 26,614 55,424
MLP, one image 89,462 117,321 208,728
CNN, one image 32,571 46,111 91,456

Every step to a slower memory costs the unit 30–110 %, because the unit waits on the copy engine, which holds one request at a time. The MLP is the extreme case: each weight is fetched once and used for one multiply-add. Two images as one batch cost little more than one (16 × 16, SRAM: 119,354 cycles against 117,321), because the weight tiles are loaded once for both; with batch 1, the MLP is bound by moving weights. The first TPU's own measurements show the same split: its MLPs and LSTMs were limited by weight memory bandwidth, its CNNs by the multipliers (Jouppi et al., In-Datacenter Performance Analysis of a Tensor Processing Unit, ISCA 2017).

4. What limits the unit

The edges in which the array, the shift engine or the activate engine is busy, counted from each layer's commands, against the measured cycles (SRAM):

Unit Layer Array, shift, activate edges Measured cycles Busy share
4 × 4 4 × 32 → 16 496 6,524 8 %
4 × 4 8 × 64 → 32 2,496 21,633 12 %
4 × 4 16 × 64 → 64 7,168 43,010 17 %
8 × 8 4 × 32 → 16 224 2,728 8 %
8 × 8 8 × 64 → 32 1,024 8,397 12 %
8 × 8 16 × 64 → 64 2,624 18,859 14 %
16 × 16 4 × 32 → 16 106 2,450 4 %
16 × 16 8 × 64 → 32 456 7,494 6 %
16 × 16 16 × 64 → 64 1,072 16,670 6 %

The array computes in at most a sixth of the time. The rest is the copy engine: one bus request in flight, one byte per cycle from a held word, and one byte write per request for results. The next steps for a faster unit are therefore on the data side: a wider or burst DMA (the router passes no bursts today), a router with two requests in flight, and reusing loaded weights across a batch, rather than a larger array.

The bus and the multiplier

The same matrix multiply on the chapter-5 bus with the iterative multiplier (-plain runs), cycles per layer:

Machine 4 × 32 → 16 8 × 64 → 32 16 × 64 → 64
CPU alone 73,721 555,762 2,221,723
CPU alone, chapter-5 bus and multiplier 155,425 1,185,409 4,739,849
16 × 16 2,450 7,494 16,670
16 × 16, chapter-5 bus and multiplier 3,107 8,389 18,146

The array multiplier and the pipelined bus together halve the CPU's time (the same 729,492 instructions in 3.23 million cycles instead of 6.56 million). The unit's layers take 8–21 % fewer cycles: its copy engine also waits longer for each request on the chapter-5 bus, and the processor issues its commands more slowly. Measured on the old setup, the 16 × 16 unit's speedup on the largest layer would have been 261× instead of 133×: an accelerator compared with a slowed-down CPU looks better than it is.

All runs

Run Cycles Instructions Unit commands Host seconds
cnn-cpu-sram 2,651,624 629,631 0 8,451
cnn-n4-sram 221,327 41,187 3,712 867
cnn-n8-sram 108,159 15,297 1,094 422
cnn-n16-sram 100,987 8,001 338 375
cnn-n16-ff 68,111 8,121 338 281
cnn-n16-dram 207,256 7,933 338 475
matmul-cpu-sram 3,228,143 729,492 0 11,168
matmul-cpu-sram-plain 6,557,573 729,492 0 13,829
matmul-n4-sram 770,297 197,560 1,335 3,559
matmul-n8-sram 697,536 177,403 357 3,352
matmul-n16-sram 681,185 170,809 102 3,563
matmul-n16-sram-plain 853,252 170,799 102 3,884
matmul-n16-ff 254,409 170,919 102 1,776
matmul-n16-dram 1,759,149 170,703 102 3,884
mlp-cpu-sram 1,638,908 359,005 0 4,629
mlp-n4-sram 1,393,529 281,950 28,833 5,636
mlp-n8-sram 417,495 73,274 7,296 1,812
mlp-n16-sram 358,446 20,492 1,851 1,309
mlp-n16-ff 271,580 20,670 1,851 1,068
mlp-n16-dram 641,726 20,394 1,851 1,511

Whole-run cycles include the untimed parts: making random operands and arranging weight tiles (matrix multiply), comparing results and writing the report. Runs with a unit compute two images (the MLP also the batch of two); CPU-alone runs compute one.

DRAM retention

When this campaign ran (2026-11-10), the unit timing profile gave DRAM 2-word rows, no refresh, and a retention of 10⁹ ticks: 1,000,000 cycles at this clock. A row that nobody opens for longer reads as unknown (X), as a real DRAM without refresh loses its data (DRAM device). The matrix-multiply program runs 1.76 million cycles, most of it making operands; with the profile's retention its last code (printing done and halting), untouched since it was loaded, read as X and the core stopped after cycle 1,758,436. The runner now reports such a run at once.

The DRAM runs therefore set the memory's retention_ticks to 64 ms, a real DRAM's refresh period (the realistic profiles' value). Retention decides only whether a row's data survives, not how long an access takes: the MLP and CNN runs gave the same cycles, instructions, outputs and simulation event counts with either retention. The cause was confirmed on the small demo-cpu program with the profile's retention and a 50 times longer clock period (retention: 20,000 cycles): it turns X at cycle 37,416 on the pipelined bus and at 24,715 on the chapter-5 bus, and halts cleanly in 78,291 cycles at the normal period.

Since 2026-11-13, 64 ms is the retention of every timing profile, unit included, so the runs no longer need to set it.

These DRAM figures include no refresh time. Refreshing all 32,768 rows within 64 ms would take one refresh (about ten cycles) every 1,953 cycles, about 0.5 % of the memory's time; the profile has no refresh interval to set it from.

Reproducing a run

With the built native tool, one run of the campaign is, for example:

build-accel/accelerator_experiment --program matmul-n16 --matrix 16 --memory dram

It runs a new simulation and prints the run as JSON (cycles, instructions, timed sections, outputs, unit commands, host time). tools/accelerator/run-campaign.py run runs every configuration of this page serially, each in its own memory-capped scope, and skips those with a result already; run-campaign.py table checks every saved run against the references and prints the tables above. Reformatting a table is not a new run.

Limits

  • Cycles, not seconds; the unit machines on the pipelined bus have no clock certificate (above).
  • The pipelined bus and the array multiplier are the machines' defaults since 2026-11-13 (--single-bus and --iterative-multiplier select the older ones); the campaign ran them as options before that, with the same results: three runs repeated on the defaults (cnn-n16 on SRAM, demo-cpu, demo-n4) gave the same cycles.
  • One timed run per configuration; the simulation is deterministic, so a repeat gives the same cycles.
  • The CPU-alone programs are plain C compiled with GCC -O2, not hand-tuned.

Source: experiment tool, campaign and tables, runner, guest programs.