Skip to content
Tactiverge

Textbooks/Computer Architecture/Chapter 6Lite (plain text) version

6Parallelism and acceleration

Version 1 · Technically checked (automated checks only) · 4 source lessons · 8 practice items

Text
All chapters and search
  1. 1. Instruction-set design
  2. 2. The performance equation
  3. 3. Pipelining and hazards
  4. 4. Caches and the memory hierarchy
  5. 5. Input, output and the hardware–software boundary
  6. 6. Parallelism and acceleration
  7. 7. Energy and reduced precision
  8. 8. Measuring performance honestly

Introduction

When a single core cannot go faster, engineers add more cores or move a task into dedicated hardware. Amdahl's law is the reality check: the part you do not speed up limits the whole. This chapter applies it to loops and accelerators, weighs one fast core against several slow ones with the power, performance and area triangle, and counts the multiply–accumulate operations that make machine-learning inference a natural target for hardware.

speed-up of the accelerated part, soverall speed-uplimit 2limit 5limit 20dashed p = 0.5: 1.94 at s = 32solid p = 0.8: 4.44 at s = 32tinted p = 0.95: 12.55 at s = 32S = 1 / ((1 − p) + p/s); limit 1/(1 − p)
Figure 6.1. The serial part sets the ceiling. Amdahl's law curves for 50 %, 80 % and 95 % of the run time accelerated. At 32 times acceleration the overall speed-up is only 1.94, 4.44 and 12.55, approaching limits of 2, 5 and 20 however fast the accelerated part becomes.

Explanation

This chapter is built from 4 School lessons. Each part below is the lesson's own explanation; open the lesson for its predict-and-discover activities.

6.1 Project: then speed it up

One new instruction or one new gate path could make your multiply several times faster. Which change gives the most speed for the least hardware?

Three kinds of speed-up

Fewer instructions: a new instruction does the work of several (a combined 'decrement and jump if not zero', or a SHIFT for shift-and-add multiply). Fewer cycles per instruction: overlap fetch with execute. Shorter cycle: a faster adder (lookahead) shortens the critical path. The iron law, T = IC × CPI × T_clk, tells you which term each idea attacks.

Quantify it

Speed-up = old time ÷ new time, from your measured baseline. Changes that only touch the loop body help most when y is large; setup costs dominate when y is small. Always state the input you assumed. If a change also lengthens the clock period, include that: a 2× reduction in cycles with a 1.5× longer period is only a 1.33× speed-up.

Price it

New instructions need opcodes (Nibble has spare ones), control-table rows and possibly datapath blocks: a shifter, an extra register, a second adder. Carry lookahead uses more gates to shorten the path. A good design note gives the speed-up, the extra hardware and one risk, and recommends honestly, including 'not worth it'.

Common mix-ups

  • Cutting cycles always gives the same speed-up in time.
    ✓ If the change lengthens the clock period, time improves by less.
  • Optimising any part of a program helps a lot.
    ✓ Amdahl's law: the gain is capped by how much of the time that part takes.

Open the full lesson: Project: then speed it up →

6.2 Hardware or software? Partitioning a task

Moving one function into custom hardware makes it 50 times faster. Why might the whole program only get twice as fast?

What co-design means

Co-design decides together which functions run as software on a processor and which become dedicated hardware (an accelerator, a peripheral, an FPGA block), and designs the interface between them. Software is flexible and cheap to change; hardware is fast and energy-efficient for a fixed job but costs area, design effort and verification.

When hardware wins

Good candidates are hot (a large share of run time), stable (the algorithm won't change), regular (lots of parallel, simple operations, like filtering, encryption or matrix multiply) and data-local (little traffic in and out). Poor candidates are rarely run, branchy or still evolving.

Count before you build

Profile first: measure where time goes. Use Amdahl's law to bound the gain. Then estimate the hardware: gates or multipliers needed, its latency in gate delays or cycles, and the data movement cost. The parity example shows the typical shape: software Θ(n) instructions, hardware Θ(log n) gate delays but Θ(n) gates.

Derivation: Amdahl's law
  1. Let the original run time be 1, and let a fraction p of it be the part you accelerate.

  2. The accelerated part becomes s times faster, so it takes p/s. The rest still takes 1 − p.

  3. New time = (1 − p) + p/s, so overall speed-up S = 1 / ((1 − p) + p/s).

  4. As s → ∞, S → 1/(1 − p). If only 50% of the time is accelerated, no accelerator can beat 2×.

  5. Example: p = 0.8, s = 50: S = 1/(0.2 + 0.016) ≈ 4.6×. Doubling s to 100 only gives 4.8×: optimise the other 20% next.

  6. Add the cost of moving data to and from the accelerator to the new time and the speed-up falls further.

Common mix-ups

  • Making the slowest function 100× faster makes the program nearly 100× faster.
    ✓ Only the accelerated fraction shrinks; the rest sets a hard ceiling of 1/(1 − p).
  • Hardware is always better than software.
    ✓ Hardware is faster for fixed, regular work but costs area, energy for idle logic, design time and flexibility.

Open the full lesson: Hardware or software? Partitioning a task →

6.3 Power, performance and area

Two slow cores can do the work of one fast core and use less energy. Why don't chips always do that?

Dynamic and static power

Dynamic power comes from charging and discharging capacitance when signals switch: α·C·V²·f. Static (leakage) power flows even when nothing switches, because transistors never turn fully off; it grows with temperature, with area and as transistors shrink. Total P = P_dyn + P_leak.

DVFS

Dynamic voltage and frequency scaling picks the lowest voltage that supports the needed clock at each moment. Busy: high V, high f. Light load: lower both, saving cube-like power (V²·f). Phones and laptops do this hundreds of times a second.

PPA is a three-way trade

Performance can be bought with clock (costs power), with parallel units (costs area) or with smarter architecture (costs design effort and area). Area costs money through yield (week 22) and leakage. 'Race to idle' (finish fast at high V, then sleep) sometimes beats running slowly, when leakage or the rest of the system dominates.

Derivation: Why lowering voltage saves energy, and what it costs
  1. Each switching event charges a capacitance C to voltage V, drawing energy C·V² from the supply. With activity α and clock f: P_dyn = α·C·V²·f.

  2. Energy per operation = P/f = α·C·V²: independent of f, quadratic in V.

  3. But gates switch more slowly at lower V. A common model: f_max ∝ (V − V_t)^α_p / V, with threshold V_t and α_p ≈ 1.3–2.

  4. To keep throughput while lowering f, add parallel units: N units at f/N give the same operations per second.

  5. N units at lower V: power ≈ N·α·C·V_low²·(f/N) = α·C·V_low²·f, less than α·C·V²·f. The price is N× the area, plus leakage on every unit.

  6. Leakage P_leak ≈ I_leak·V is paid all the time and grows with area; at very low V and f it dominates, so energy per operation has a minimum.

Common mix-ups

  • Lower clock frequency always saves energy.
    ✓ It saves power, but energy per operation only falls if voltage falls too; leakage over a longer run can even raise it.
  • Parallel hardware is free performance.
    ✓ It costs area, leakage and money, and only helps if the work can be split.

Open the full lesson: Power, performance and area →

6.4 Training versus inference: counting the cost

Training a speech model took a data centre. Running it fits on a chip in a light switch. What makes the two so different?

Two phases

Training searches for weights that minimise a loss over a dataset, using many passes of forward computation, gradient computation and updates: expensive, done once on big hardware. Inference runs one forward pass with fixed weights on a new input: much cheaper, done millions of times, often on the device itself for latency, privacy or battery reasons.

Counting MACs

A multiply-accumulate does y ← y + w·x. A dense layer with a inputs and b outputs costs a·b MACs. A convolution producing an H×W×C_out output with k×k kernels over C_in channels costs H·W·C_out·k²·C_in. Add the layers. Activations (ReLU) and pooling are usually small by comparison.

Memory: weights and activations

Weights must be stored somewhere, usually flash: one value per connection. Activations (the intermediate results) must fit in RAM while a layer runs: roughly the largest input plus output of any layer. A microcontroller with 1 MB flash and 256 KB RAM sets hard limits on both.

From MACs to milliseconds

Latency ≈ MACs ÷ (MACs per cycle × clock rate), plus memory stalls. A core doing 1 MAC per cycle at 100 MHz runs a 2 million-MAC model in about 20 ms. Vector (SIMD) instructions or a small accelerator can do 4–8 MACs per cycle at 8 bits.

Common mix-ups

  • Running a model costs as much as training it.
    ✓ One inference is a single forward pass; training is many passes plus gradients over a whole dataset.
  • Only the number of weights matters.
    ✓ A convolution reuses few weights many times: MACs, not weights, set its time; activations set its RAM.

Open the full lesson: Training versus inference: counting the cost →

Worked examples

Project: then speed it up: example 1

Setup 2 cycles, 10 passes of 24 cycles. A change cuts a pass to 15 cycles but lengthens the clock period by 10 %. Speed-up?

Solution

Cycles: 242 → 152, ratio 1.59. Period ×1.1, so time ratio = 1.59/1.1 ≈ 1.45×.

Hardware or software? Partitioning a task: example 1

A rover's image pipeline spends 70% of its time in a 3×3 convolution. An accelerator makes convolution 30× faster but adds data copies costing 5% of the original time. Overall speed-up?

Solution

New time = 0.3 + 0.7/30 + 0.05 = 0.3 + 0.023 + 0.05 = 0.373. S ≈ 2.68×. Without the copies it would be 3.1×; the limit is 1/0.3 ≈ 3.3×.

Power, performance and area: example 1

α = 0.15, C = 2 nF, V = 0.9 V, f = 2 GHz. Dynamic power? Energy per cycle?

Solution

P = 0.15 × 2×10⁻⁹ × 0.81 × 2×10⁹ = 0.486 W. Energy per cycle = P/f = 0.243 nJ.

Training versus inference: counting the cost: example 1

A network: 49×10 audio features flattened (490 inputs) → dense 64 → dense 12. MACs and weights?

Solution

MACs = 490×64 + 64×12 = 31,360 + 768 = 32,128. Weights equal MACs for dense layers: 32,128 (plus 76 biases). At float32: about 126 KB; at int8: about 31 KB.

Interactive figures

Figure 6.2 from Power, performance and areaStart at 1 unit, 1.0 V, 3 GHz. Now set 2 units and lower the voltage until 1.5 GHz is still reachable. Compare throughput, power, area and energy per operation. Then find the lowest energy per operation you can reach at any throughput, and the leakage term that stops you going lower.
Can't use the interactive? Read a description instead

The PPA explorer reports throughput, power, area and energy per operation relative to one unit at 1 V and 3 GHz. Two units at about 0.7 V and 1.5 GHz give the same throughput for about 62% of the energy per operation but twice the area.

Interactive figure (online). Description: The PPA explorer reports throughput, power, area and energy per operation relative to one unit at 1 V and 3 GHz. Two units at about 0.7 V and 1.5 GHz give the same throughput for about 62% of the energy per operation but twice the area.

Laboratory

Everything runs in your browser. No kit, nothing mains-powered. Simulations are simplified educational models.

  • BUILD level

    BUILD: Virtual computer, level 5

    Speed up a program on the virtual computer, measure the gain and check it against Amdahl's law for the part you changed.

    Open BUILD: Virtual computer, level 5 →
  • Studio

    Silicon Studio

    Sketch the datapath of a small multiply–accumulate unit and estimate how many cycles it saves per filter tap.

    Open Silicon Studio →

Guided practice

Answers are checked on the server; wrong answers get a hint and another try. Signed in, solved items also count towards the source lesson.

Practice 1

As the loop count grows very large, the speed-up from shrinking the body from b to b' approaches…

Practice 2

A design halves cycle count but makes the clock period 1.5 times longer. Net effect?

Practice 3

Which function is the best candidate for a hardware accelerator in a drone?

Practice 4

A task is 40% accelerable. What is the best overall speed-up any accelerator can give?

Practice 5

Voltage drops from 1.1 V to 0.8 V and frequency from 2.4 GHz to 1.2 GHz. What fraction of the original dynamic power remains? (Answer as a decimal.)

Practice 6

Replacing one fast core with four slow low-voltage cores at equal throughput mainly costs…

Practice 7

Which phase normally runs on a battery-powered sensor?

Practice 8

A model needs 3,000,000 MACs. The core does 2 MACs per cycle at 80 MHz. Ignoring memory stalls, what is the latency in ms?

ms
  1. As the loop count grows very large, the speed-up from shrinking the body from b to b' approaches…
    • 1
    • b/b'
    • b − b'
    • The setup cost
  2. A design halves cycle count but makes the clock period 1.5 times longer. Net effect?
    • 2× faster
    • 1.33× faster
    • 1.5× slower
    • No change
  3. Which function is the best candidate for a hardware accelerator in a drone?
    • The menu system of its phone app
    • A fixed FIR filter run on every IMU sample at 8 kHz
    • The mission planner that changes every flight
    • Error logging that runs once per crash
  4. A task is 40% accelerable. What is the best overall speed-up any accelerator can give?
    • 1.4×
    • About 1.67×
    • 2.5×
    • Unlimited
  5. Voltage drops from 1.1 V to 0.8 V and frequency from 2.4 GHz to 1.2 GHz. What fraction of the original dynamic power remains? (Answer as a decimal.)
  6. Replacing one fast core with four slow low-voltage cores at equal throughput mainly costs…
    • Power
    • Area (and leakage), plus software that can use four cores
    • Nothing
    • Clock frequency of the cores is higher
  7. Which phase normally runs on a battery-powered sensor?
    • Training
    • Inference
    • Both, equally
    • Neither
  8. A model needs 3,000,000 MACs. The core does 2 MACs per cycle at 80 MHz. Ignoring memory stalls, what is the latency in ms? (ms)

Engineering applications

  • Multicore phones

    Phones pair fast cores with small efficient ones. Light work runs on the small cores at low voltage; only bursts wake the big ones, because power grows faster than performance.

  • Accelerators in sensors

    A camera chip may include a small neural-network engine. It earns its area only because inference is almost all multiply–accumulate operations, a large and regular fraction of the work.

Watch

Optional verified videos. Nothing loads from YouTube until you press play.

A plain introduction to classifiers and neural networks, enough context to reason about what inference on a small device must compute.

Length: see YouTube · captions on YouTube · source

Nothing loads from YouTube until you press play.

Dynamic, short-circuit and leakage power in one place, the physics behind every power–performance–area trade.

Length: see YouTube · captions on YouTube · source

Nothing loads from YouTube until you press play.

  • Machine Learning & Artificial Intelligence: Crash Course Computer Science #34 (CrashCourse)
  • Three Ways Your Chip Burns Power | CMOS Power Dissipation Explained (Abhijit Pethe)

Chapter summary

  • Amdahl: S = 1/((1 − p) + p/s); the unaccelerated fraction caps the speed-up at 1/(1 − p).
  • Profile first: accelerate only what takes a large share of the time.
  • Several slower, lower-voltage cores can match one fast core's throughput at lower power but more area.
  • Inference cost is dominated by multiply–accumulates; latency ≈ MACs ÷ (MACs per cycle × clock rate).

Glossary

Amdahl's law
Amdahl's law says the overall speed-up from improving part of a task is limited by the fraction of time that part takes.
Electrical power
The power transferred in a component is the voltage across it multiplied by the current through it. For a resistor this can also be written I²R or V²/R.
ALU (arithmetic logic unit)
The ALU is the part of a processor that performs arithmetic (add, subtract) and logic (AND, OR, XOR, shifts) on values from registers, and sets status flags such as zero and carry.

Definitions from the Field Guide.

Project: Is an accelerator worth it?

Choose one task in a robot or sensor (filtering, vision, inference). Estimate its share of run time with stated assumptions, the speed-up a dedicated unit could give and the overhead of moving data to it. Use Amdahl's law to recommend yes or no.

Deliverables

  • The workload breakdown with assumptions
  • Amdahl calculation including overhead
  • A recommendation with what would change it

Keep your work in your Engineering Journal; it stays private unless you choose to share it.

References

  • Gene M. Amdahl (1967). "Validity of the Single Processor Approach to Achieving Large Scale Computing Capabilities". AFIPS Spring Joint Computer Conference Proceedings 30, 483–485.
  • Samuel Williams et al. (2009). "Roofline: An Insightful Visual Performance Model for Multicore Architectures". Communications of the ACM 52(4), 65–76.
  • John L. Hennessy and David A. Patterson (2017). Computer Architecture: A Quantitative Approach, 6th edition. Morgan Kaufmann.

Publication record

Version
1
Status
Technically checked (automated checks only)
Technical review
Automated checks only, last run 2026-11-29. No human, educator or mentor review is claimed.src/content/textbooks/textbooks.test.ts: schema, every lesson, diagram, practice item, video, Field Guide entry, lab and reference resolves; figure numbers recomputed; no practice answers in client payloads.
Written by
Compiled and written by the Tactiverge team with AI assistance, from Tactiverge School lessons that were themselves written with AI assistance.
Licence
All rights reserved by the founders unless a licence is approved.
Corrections
None recorded yet.Spotted a mistake? Use “Report a problem” on any chapter, or see the corrections page.