Lite / Textbooks / Computer Architecture / Chapter 6
6. Parallelism and acceleration
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.
Figure 6.1. The serial part sets the ceiling (described in words)
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
Built from 4 School lessons. Each part is the lesson's own explanation.
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 Lite 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
Let the original run time be 1, and let a fraction p of it be the part you accelerate.
The accelerated part becomes s times faster, so it takes p/s. The rest still takes 1 − p.
New time = (1 − p) + p/s, so overall speed-up S = 1 / ((1 − p) + p/s).
As s → ∞, S → 1/(1 − p). If only 50% of the time is accelerated, no accelerator can beat 2×.
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.
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 Lite 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
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.
Energy per operation = P/f = α·C·V²: independent of f, quadratic in V.
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.
To keep throughput while lowering f, add parallel units: N units at f/N give the same operations per second.
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.
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 Lite 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 Lite 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, in words
Figure 6.2 from Power, performance and area
Start 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.
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
These run in a browser on the full site (they need a faster connection). Simulations are simplified educational models.
- BUILD: Virtual computer, level 5 (BUILD level)
Speed up a program on the virtual computer, measure the gain and check it against Amdahl's law for the part you changed.
Open on the full site - Silicon Studio (Studio)
Sketch the datapath of a small multiply–accumulate unit and estimate how many cycles it saves per filter tap.
Open on the full site
Practice
Each question links to its Lite lesson, where your answer is checked on our server and a wrong answer gets a hint. Answers are never sent to your device.
- As the loop count grows very large, the speed-up from shrinking the body from b to b' approaches…
Answer it in “Project: then speed it up” - A design halves cycle count but makes the clock period 1.5 times longer. Net effect?
Answer it in “Project: then speed it up” - Which function is the best candidate for a hardware accelerator in a drone?
Answer it in “Hardware or software? Partitioning a task” - A task is 40% accelerable. What is the best overall speed-up any accelerator can give?
Answer it in “Hardware or software? Partitioning a task” - 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.)
Answer it in “Power, performance and area” - Replacing one fast core with four slow low-voltage cores at equal throughput mainly costs…
Answer it in “Power, performance and area” - Which phase normally runs on a battery-powered sensor?
Answer it in “Training versus inference: counting the cost” - 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?
Answer it in “Training versus inference: counting the cost”
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)
Streaming video uses a lot of data. Everything you need is in the text.
- “Machine Learning & Artificial Intelligence: Crash Course Computer Science #34” by CrashCourse
- “Three Ways Your Chip Burns Power | CMOS Power Dissipation Explained” by Abhijit Pethe
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. Field Guide
- 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. Field Guide
- 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. 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
Write it up on paper or in your own notes. Lite never stores what you write.
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.