6.5.6 · D4Advanced & Emerging Architectures

Exercises — Domain-specific accelerators

3,083 words14 min readBack to topic

Before we start, one figure fixes the two pictures every problem leans on. We reuse it directly: the pie is the picture behind Exercise 1.1 and 2.1 (energy per op), and the roofline is the picture behind Exercises 2.2, 2.3, 3.3 and 5.1 (which wall).

Figure — Domain-specific accelerators

Read the left picture as: the actual add (teal sliver) is tiny; the fetch / decode / control (orange) is the bulk — this is exactly the waste Exercise 2.1 quantifies. Read the right picture as: your kernel is a dot placed by its intensity ; if it sits under the slanted line it is memory-bound (the orange dot of Ex 2.2), and the vertical line at is the ridge point of Ex 2.3 where the two ceilings cross.


Level 1 — Recognition

Recall Solution 1.1

Answer: (c) performance-per-watt. Once Dennard scaling died (~2006), voltage could no longer drop with each shrink, so power density rose. We can fit transistors but not power them all (Dark silicon). Therefore the binding constraint is energy per useful operation, not raw clock — look again at the energy pie in the figure: the teal ALU sliver is the only useful part. GHz (a) is limited by heat; transistor count (b) is limited by power; cache (d) is a means, not the goal.

Recall Solution 1.2

False. A systolic array typically runs at a lower clock than a CPU. Its win is massive parallelism ( MAC cells firing every cycle), deleted control overhead, lower precision, and data reuse (each loaded value is used many times — quantified in Ex 3.2). Clock speed is not the lever.


Level 2 — Application

Recall Solution 2.1

Efficiency ratio .

  • What we did: divided energy-per-op of the CPU by energy-per-op of the accelerator.
  • Why: ops/joule , so the ratio of energies is the ratio of efficiencies (units of pJ cancel). This is the correct metric because energy/op is the binding constraint (Exercise 1.1), and the figure's pie shows why the CPU number is so large — most of its joules go to the orange overhead a DSA deletes.
Recall Solution 2.2

First convert units so both ceilings are in ops/second: The bytes cancel, leaving ops/s = TOPS. Then Since , you are memory-bound — the orange dot in the figure sits under the slanted line. Only of peak is usable.

  • Why this step: Roofline tells you the bottleneck before you optimize — here more MACs would sit idle (assumption: compute and memory overlap perfectly; the real machine can only be worse); the fix is to raise (fuse layers, larger tiles).
Recall Solution 2.3

Set the two ceilings equal: , so (The "per second" cancels top and bottom, leaving ops/byte.) Below ops/byte you are memory-bound; at or above it you are compute-bound. Our kernel's is far below — deeply memory-bound. This is the vertical line in the figure.


Level 3 — Analysis

Recall Solution 3.1

(a) MACs/cycle (one multiply-add per cell per cycle). (b) Each loaded weight streams past all activations along one axis, so reuse factor the array dimension . (c) The "why" of : the output is an matrix, so it has output entries. Each output entry is a dot product of length , which costs multiply-adds. Total . Here : total MACs .

Recall Solution 3.2

Naive: total ops (from Ex 3.1c). If every operand is refetched from memory, bytes moved (two reads + one write per MAC). Systolic: you load data once into the grid and reuse each value times, so bytes moved while ops stay : Concretely: ; . Twice the width, twice the intensity.

  • Why it matters: intensity now grows with array size, so on the Roofline you slide right past the ridge point and become compute-bound — the whole point of the design.
Recall Solution 3.3

New memory ceiling TOPS. Since (Ex 2.3), you have crossed the ridge: Speedup over the un-fused TOPS: . Note the win came entirely from data reuse, not from buying hardware. Edge case : raising still higher (say ) buys nothing more — you are pinned at the flat TOPS compute ceiling; only more MACs help now.


Level 4 — Synthesis

Recall Solution 4.1

With parallel fraction and speedup on that fraction: Even a accelerator yields only overall because the untouched now dominates (the immovable stub). Lesson: DSAs are narrow; you need a CPU to orchestrate the serial/irregular parts. Real systems are heterogeneous — CPU + DSA — not DSA-only.

Recall Solution 4.2

Starting attainable TOPS. Option A (double MACs): raises but the kernel is memory-bound, so TOPS — no change. Wasted money. Option B (INT8): operands are smaller, so effective rises from to ops/byte. New ceiling TOPS = improvement. Choose B. Quantization attacks the actual bottleneck (bytes moved); adding MACs does not.


Level 5 — Mastery

Recall Solution 5.1

(a) TOPS TOPS ⇒ memory-bound, using of peak. (b) Ridge point ops/byte. You need to raise from to — a increase in reuse. (c) Decision: spend on scratchpad (option ii). The array is already starved; a bigger array raises (the flat ceiling) while the kernel is pinned to the slanted ceiling — the extra MACs sit idle. More scratchpad enables bigger tiles / operand reuse, pushing rightward toward the ridge, which is the only way to convert peak into attainable throughput. Edge case to respect: if a cold/too-small cache lowers effective , you slide down the slanted ceiling and lose even the TOPS — another reason the reuse (scratchpad) fix is the right lever.

Recall Solution 5.2

Scheme: Mixed precision training. Keep the sensitive parts — master weights and gradient accumulation — in higher precision (FP32), while doing the bulk matmuls (forward/backward) in low precision (bfloat16/FP16). Loss scaling prevents small gradients from underflowing. Why it works (domain tolerance): neural nets are statistical; the millions of forward-pass MACs average away rounding noise, so low precision there is nearly free (as in inference). But accumulation of tiny gradients is a sum where rounding errors compound — that step keeps high precision. You spend precision exactly where the domain is intolerant, and save it everywhere the domain is tolerant. That selective placement is the essence of domain-specific design.

Recall Solution 5.3

Pollack's Rule: single-core performance grows as . Doubling area gives , not — diminishing returns from a monolithic core. Contrast: the DSA instead spends that area on many small, identical MAC cells whose aggregate throughput scales roughly linearly with area (data-level parallelism), and deletes per-op control overhead. So the same transistors buy far more useful ops/mm² — provided arithmetic intensity keeps them fed (the Roofline caveat from Exercise 5.1).


Recall Self-check: which lever fixes which symptom?

Memory-bound kernel, MACs idle ::: Raise arithmetic intensity — bigger tiles, fused ops, more scratchpad, lower-precision operands. Serial fraction dominates total time ::: Amdahl limit — keep a CPU to orchestrate; heterogeneous system, not DSA-only. Gradient diverges in INT8 ::: Mixed precision — high precision only for sensitive accumulation. "Doubling core area = 2x speed" ::: False by Pollack's Rule; for a monolithic core. Kernel already right of the ridge () ::: Compute-bound — more reuse is wasted; only more MACs raise throughput now.