electronics engineering
Course handbook · Fifth year · Edition with space for notes
Computer Architecture
Computer architecture: processors, pipelines, cache memory, virtual memory, instruction sets and parallel architectures.
- 8Topics
- 0Solved exercises
- 7Formula sheet
Free handbook generated from the lessons of the site and updated often, every time a lesson or an exercise changes: the latest version is always at www.electronics-engineering.com/handbook/computers-architecture. Links work in the PDF too.
1Instruction-level parallelism and dependences
The Computer Systems course showed the five-stage pipeline, which overlaps the execution of successive instructions. But a simple pipeline reaches at most one instruction per cycle, and stops every time an instruction waits for the result of another. To go further one must understand which instructions can really be executed together. In this lesson we classify dependences, prove that only true ones limit parallelism while the others are removed by renaming registers, write the performance equation with stalls and look at loop unrolling.
Instruction-level parallelism
Instruction-level parallelism (ILP) is the possibility of executing several instructions of the same sequential program at the same time. The programmer writes a sequence; the processor must guarantee that the result is the same as executing it one instruction at a time, but it is free to change the order and to overlap everything that does not change the result.
Dependences
Between two instructions,
preceding
in the program, there are three types of register dependence:
- true or data dependence (RAW, read after write):
reads a register written by
. The value must pass from one to the other:
cannot compute before
has produced its result; - anti-dependence (WAR, write after read):
writes a register that
reads. If
wrote first,
would read the wrong value; - output dependence (WAW, write after write): both write the same register. In the end the value of
must remain.
To these are added control dependences, on conditional branches, and dependences through memory, harder to see because addresses are known only during execution.

True dependences and name dependences
Anti-dependences and output dependences carry no data: they exist only because two different values use the same register name. In the example in the figure,
reuses
for a value that has nothing to do with that of
.
Theorem. If every instruction writes its result to a new physical register, never used before, and every read refers to the physical register of the last preceding write in the program, WAR and WAW dependences disappear and only RAW ones remain.
Proof. A WAW requires two writes to the same register: with a new physical register for every write there are none. A WAR requires
to write a register that
reads; but
reads the physical register of the write preceding
, while
writes a new register, different from all existing ones, hence different from the one read. Finally, every read finds the value of the write that precedes it in the program, i.e. the same value as in sequential execution: the result does not change. ∎
This is register renaming. The processor has many more physical registers (hundreds) than the architectural ones visible to the programmer (32 in RISC-V), and a register alias table (RAT) that says, for every architectural register, which physical register holds the most recent value. In the example, after renaming,
and
are independent and can be executed together: only the red arrows remain.
The performance equation with stalls
Execution time is
(lesson on von Neumann and performance). In a pipeline the ideal CPI is 1, and every stall increases it:
![]()
where
is the frequency (per instruction) of a certain type of hazard and
the number of cycles lost each time. For example, if 25 % of instructions are loads from memory and half of them are immediately followed by an instruction using the data, with one cycle lost each time, the contribution is
: the CPI goes from 1 to 1.125, and the processor is 12.5 % slower.
Loop unrolling
The compiler can increase the available ILP. Consider a loop that adds a constant to every element of an array: each iteration loads, adds, stores, increments the index and branches. The three useful instructions depend on one another, and empty cycles remain in between, waiting for results.
By unrolling the loop four times, i.e. writing four iterations in the body with different registers, four independent chains are obtained. The compiler interleaves them: while the first addition waits for its load, the loads of the other three are executed. The empty cycles disappear, and the index increment and the branch, executed once every four elements instead of at every element, weigh a quarter as much. The price is longer code and more registers in use. Compilers do it automatically with optimisation options, and the same idea underlies vectorisation (lesson on SIMD and GPUs).
How much ILP is there really
Studies of ideal processors, with infinite units and perfect prediction, find tens of instructions executable in parallel in common programs. Real processors, limited by prediction, windows and memory, exploit 2 to 5 per cycle. The next lessons show the techniques that approach this: out-of-order execution, branch prediction, superscalar processors.
2Out-of-order execution
An in-order pipeline stalls when an instruction waits for data, and with it all the following ones, even independent ones. An out-of-order processor lets ready instructions go ahead, and reorders the results at the end. This is the idea of Tomasulo’s algorithm (IBM 360/91, 1967), which with the addition of the reorder buffer is the heart of every high-performance processor today. In this lesson we look at reservation stations, the common data bus, the reorder buffer with the proof that it guarantees precise exceptions, speculative execution and memory disambiguation.
The idea
A load that misses the cache can cost hundreds of cycles. In an in-order pipeline the processor stays idle all that time. Yet behind the load there are often tens of instructions that have nothing to do with the awaited data. Out-of-order execution separates three moments that coincide in the simple pipeline:
- issue, in order: the instruction is decoded, its registers renamed, and it is put on hold;
- execution, out of order: it starts as soon as its operands are available;
- commit, again in order: the result becomes final, visible to the architecture.

Reservation stations and the common data bus
Each functional unit has a group of reservation stations in front of it: registers holding a waiting instruction, with its operands. For each operand the station contains the value, if already available, or the tag of the instruction that will produce it. The tags are in practice the physical registers of the previous lesson: renaming happens here, and WAR and WAW dependences disappear.
When a unit finishes, it puts the result and its tag on the common data bus (CDB). All the stations waiting for that tag capture it in the same cycle; an instruction with all operands ready is sent to its unit at the first opportunity, regardless of program order. True dependences are respected by construction, because no instruction starts without its operands.
The reorder buffer
In the original algorithm results wrote directly into the registers out of order. This creates a problem: if an instruction causes an exception (a division by zero, a page fault), some later instructions might already have modified the state, and the operating system would not know where to restart. The solution is the reorder buffer (ROB): a circular queue in which every instruction takes a slot, in program order, at issue. Results are written into the ROB; an instruction commits, i.e. writes to the architectural registers or to memory, only when it is at the head of the queue and has finished.
Theorem. With in-order commit from the ROB, exceptions are precise: when the exception of instruction
is handled, the architectural state contains the results of all instructions preceding
and of none following it.
Proof. The architectural state (registers and memory) changes only at commit, and instructions commit in program order, one after another from the head of the ROB. The exception of
is recorded in its ROB slot and handled when
reaches the head: at that moment all the preceding instructions have committed, because they were ahead in the queue, and none of the following ones has, because they are behind. The processor discards the contents of the ROB from
onwards and jumps to the handler. ∎
Speculative execution
The same mechanism allows instructions to be executed before knowing whether they should be executed. When a conditional branch is met, the processor predicts its direction (lesson on prediction) and keeps issuing instructions along that path. If the prediction was right, those instructions commit normally; if it was wrong, when the branch reaches the head of the ROB all the following instructions are discarded and execution restarts from the correct address. Nothing done by mistake has touched the architectural state.
The micro-architectural state, however, has been touched: instructions executed by mistake may have loaded data into the caches. This is the principle of the Spectre attacks (2018), which deduce secret data by measuring cache access times after speculative execution. The countermeasures (barriers, isolation, compiler changes) cost a few per cent of performance.
Memory
Dependences through memory are the trickiest: a load may read the address that an earlier store is about to write, but the address is known only after it has been computed. Stores wait for commit in a store queue; a load compares its address with those in the queue and, if it finds a write to the same address, takes the value directly from it (store-to-load forwarding). Modern processors dare more: they execute the load even before the addresses of earlier writes are known, predicting that there is no conflict, and if they are wrong they squash and re-execute.
Sizes
A 2025 high-performance processor has a ROB of 500-600 entries, a few hundred physical registers, about ten functional units and can have hundreds of instructions “in flight”. The large window serves above all to hide memory latency: while a load waits for DRAM, the processor finds useful work many instructions ahead.
3Branch prediction
In a typical program one instruction in five or six is a branch. In a processor with a deep pipeline and a wide out-of-order window, every branch whose direction is unknown would block the flow for tens of cycles. The solution is to guess, and to do it very well: modern predictors miss fewer than one branch in a hundred. In this lesson we look at the cost of a misprediction, two-bit counters with the proof of their advantage on loops, correlating predictors, target prediction and how to write code that predictors like.
The cost of a misprediction
When the processor finds out it predicted wrongly, it discards all the speculative instructions and restarts from the right address (lesson on out-of-order execution). The cycles lost, the penalty, are about as many as it takes from instruction fetch to branch resolution: 15-20 in modern processors. With the performance equation with stalls:
![]()
with
the fraction of instructions that are branches,
the fraction mispredicted and
the penalty. With 20 % branches, 5 % mispredictions and a 15-cycle penalty, 0.15 cycles per instruction are added: on a processor that could commit 4 per cycle (ideal CPI 0.25), execution time grows by 60 %. Every percentage point of accuracy counts.
Static prediction and one-bit counters
Static prediction decides without looking at history: for instance “backward branches are taken” (they are almost always loop closures) and “forward ones are not”. It works for about 70 % of branches.
The simplest dynamic prediction remembers, for each branch, what it did last time: one bit, in a table indexed by some bits of the branch address. It has an obvious flaw on loops.
The two-bit counter

The two-bit saturating counter counts from 0 to 3: it increases when the branch is taken, decreases when it is not, without going past the ends. It predicts “taken” in states 2 and 3, “not taken” in states 0 and 1.
Theorem. An inner loop with
iterations, executed repeatedly, has a closing branch taken
times and not taken at the last. The one-bit predictor mispredicts twice per execution of the loop, the two-bit one only once.
Proof. *One bit.* At the last iteration the bit says “taken” (it was last time) and the branch is not: first misprediction, and the bit becomes “not taken”. At the first iteration of the next execution the bit says “not taken” but the branch is taken: second misprediction. The other
iterations are predicted correctly. *Two bits.* After the taken iterations the counter is at 3. At the last iteration it predicts “taken” and is wrong, but it only drops to 2, which still predicts “taken”. At the first iteration of the next execution the prediction is right and the counter returns to 3. Only one misprediction per execution. ∎
With
, accuracy goes from 80 to 90 %. The hysteresis of the counter prevents an isolated exception from changing the prediction.
Correlating predictors
Many branches depend on what earlier branches did: if an if (x > 0) was taken, a following if (x < 0) will not be. A correlating predictor keeps a global history register, the outcomes of the last
branches executed (1 if taken, 0 if not), and uses it together with the branch address to choose the counter. In the gshare predictor the table index is the XOR of the address bits and the history bits: the same branch uses different counters in different contexts.
Today’s predictors, such as the TAGE family, combine tables with histories of different lengths, from a few branches to hundreds, and choose the prediction of the table with the longest history that has reliable information. They reach accuracies of 97-99 % on typical programs. Some also use small perceptrons, an elementary form of neural network.
Predicting where to jump too
Knowing that a branch is taken is not enough: one must know where it goes, even before the instruction has been decoded. The branch target buffer (BTB) is a cache indexed by the instruction address that returns last time’s destination address. Function returns have a dedicated predictor, the return address stack, which mimics the call stack: at every call the return address is pushed, at every return it is popped. Indirect branches (calls to virtual functions, switch statements compiled into tables) have predictors that also use history.
Writing predictable code
The predictor works no miracles with branches that depend on random data. The classic example: a loop that adds only the array elements greater than a threshold runs much faster if the array is sorted, because the branch becomes a long run of “not taken” followed by a long run of “taken”. On random data the predictor is wrong half the time. The countermeasures:
- turn the branch into a branch-free operation, with conditional moves (
cmovon x86, select in RISC-V with extensions) or with arithmetic:sum += (x > threshold) * x. Compilers do it by themselves when both branches are short; - reorder the data or the tests, putting the most frequent cases first;
- with execution profiles, let the compiler lay out the code so that the common path does not branch.
4Superscalar, VLIW and multithreading
A perfect pipeline completes one instruction per cycle. To do better, several instructions per cycle must be fetched, decoded and executed: this is the superscalar processor. Alternatively parallelism can be decided by the compiler and written explicitly in the instructions: the VLIW approach. Or the empty slots can be filled with instructions from another program: simultaneous multithreading. In this lesson we look at the three paths, prove why control complexity grows with the square of the width, and see the limits that pushed the industry towards multicore.
The superscalar processor
A
-way superscalar processor fetches and decodes up to
instructions per cycle, renames them and sends them to the functional units, of which there is more than one per type. In the ideal case it completes
instructions per cycle: the CPI drops to
, and one prefers to speak of its inverse, the IPC (instructions per cycle).

The real IPC is much lower than
: true dependences, mispredicted branches and above all memory waits leave many slots empty. A 6-8-way processor typically reaches an IPC between 2 and 4 on common programs.
The cost of control
Issuing several instructions together requires checking, in the same cycle, the dependences among the instructions of the group: if the second reads a register written by the first, it must receive the new physical register assigned to the first, not the old one from the rename table.
Theorem. Renaming in one cycle a group of
instructions with two source operands each requires
register comparisons.
Proof. The instruction in position
of the group (from 1 to
) must compare each of its two source registers with the destination register of each of the
instructions preceding it in the group. The total is
. ∎
The number of comparisons grows with the square of the width, and so do the read and write ports of the register file, the forwarding paths between units and the logic that selects which ready instructions to send. Power and the difficulty of meeting the clock cycle grow more than linearly, while IPC grows less than linearly. That is why widths have stopped between 4 and 10.
VLIW: leaving the work to the compiler
In the VLIW (very long instruction word) architecture every instruction is a bundle of operations that the compiler guarantees to be independent, one for each functional unit. The processor checks nothing: it executes the bundles as they are, with simple, low-power hardware. The compiler must find the parallelism with loop unrolling and instruction scheduling (lesson on dependences), filling with no-ops the slots it cannot use.
VLIW has been very successful in DSPs and accelerators, where code is made of regular, predictable loops. In general-purpose processors, instead, it ran into two problems: the compiler does not know memory latencies, which change at every run, and code compiled for one generation does not exploit the next one with different units. The best-known example is Intel and HP’s Itanium, discontinued in 2021.
Simultaneous multithreading
Even the best superscalar leaves many of its
slots empty in every cycle, because a single program does not have enough independent instructions. Simultaneous multithreading (SMT, marketed by Intel as Hyper-Threading) makes one core look like two (or more) processors: it has two copies of the architectural state (registers, program counter) and fetches instructions from both threads, mixing them in the same out-of-order window. The instructions of the two threads have no dependences between them, and fill the slots left free by the other, especially when one of the two waits for memory.
The typical gain is 15-30 % of overall throughput for a few per cent more area. The price is that the two threads compete for caches, predictors and units: each runs slower than alone, and one thread can spy on the other by measuring timing, which is why some systems disable it for security.
The limits and the multicore turn
Until the early 2000s processor performance grew by about 50 % a year thanks to higher frequencies and more ILP. Then it hit three walls:
- the ILP wall: beyond a certain width IPC no longer grows;
- the memory wall: DRAM has stayed slow, hundreds of cycles per access;
- the power wall: raising the frequency requires raising the voltage, and power grows roughly with the cube of the frequency (lesson on energy).
The industry’s answer was to put more cores on the same chip: instead of an ever larger and hotter core, several cores of reasonable size. But parallelism must become explicit, written by the programmer with threads, and shared memory brings the coherence and consistency problems of the lesson devoted to them.
5Cache hierarchies
A modern processor can execute an instruction in a third of a nanosecond, while a DRAM access takes about a hundred. Between the two lies a multi-level cache hierarchy, and performance depends on its effectiveness more than on anything else. The Computer Systems course introduced the cache, locality and average access time. In this lesson we look at multi-level hierarchies with the proof of the average access time formula, local and global miss rates, write policies, non-blocking caches and prefetching, and the blocking technique with the proof of the traffic saved.
The multi-level hierarchy

A typical processor has a level-one (L1) cache of 32-64 KB for data and one for instructions, accessible in 4-5 cycles; a private L2 per core of 1-2 MB, in about fifteen cycles; an L3 shared among the cores of tens of megabytes, in 40-60 cycles; then DRAM.
Theorem. With access times
and local miss rates
(the fraction of accesses reaching level
that do not find the data there), the average memory access time of a three-level hierarchy is
![]()
Proof. Every access spends
in L1. With probability
it does not find the data and continues: from there the expected time is the average access time of the hierarchy starting at L2, i.e.
plus, with probability
, the average time of the hierarchy starting at L3, and so on down to memory, where the data is always present. Applying the same rule at every level gives the nested expression. ∎
Example. With
ns,
,
ns,
,
ns,
,
ns:
![]()
The average time is close to that of L1, even though DRAM is 80 times slower.
Local and global rates
The local rate of a level often looks high: 30-40 % for an L2 or L3. It is not a defect: only the accesses that L1 has already missed, i.e. the difficult ones, reach those levels. What matters is the global rate, the fraction of all the processor’s accesses that reach memory:
, in the example
. To compare two L2s one must look at how many global accesses they save.
Caches are called inclusive if every datum of one level is also in the level below (it simplifies coherence), exclusive if a datum is in one level only (it makes better use of total capacity).
Writes
A write-through cache writes every change to the level below as well: simple and always coherent, but it generates a lot of traffic, mitigated by a write buffer that queues the writes. A write-back cache writes to memory only when the modified block is evicted, marking it with a “dirty” bit: much less traffic, because a datum modified a hundred times is written only once. Almost all processor caches are write-back; coherence among the cores then becomes the problem of the dedicated lesson.
To the three classic causes of misses (compulsory, capacity, conflict) multicores add a fourth: coherence misses, when another core has invalidated the block.
Non-blocking caches and prefetching
An out-of-order processor does not stop at a miss: it continues with independent instructions, and may generate further accesses. Non-blocking caches handle several misses at once, tracking them in dedicated registers (MSHRs): the waits overlap and the time lost on each shrinks. Memory-level parallelism matters as much as instruction-level parallelism.
Prefetching brings data into the cache before it is needed. Hardware prefetchers recognise constant-stride accesses (an array read sequentially, a column of a matrix) and request the following blocks in advance. Compilers can insert explicit prefetch instructions. It works if it is timely (the data arrives in time) and accurate (it does not evict useful data for useless data).
Writing cache-friendly code
The programmer can do a lot. The product of two
matrices in the classic three-loop form reads one of the two matrices by columns: if
is large, every element read is in a different block, and the number of misses is of the order of
.
Blocking (or tiling) divides the matrices into
submatrices small enough to fit in the cache together (
elements less than the capacity) and computes the product block by block.
Theorem. With blocking the number of elements transferred from memory is of the order of
, instead of
.
Proof. The product decomposes into
products of
blocks: for each block of the result
products are added, and there are
result blocks. Each block product loads one block of each matrix,
elements, and then works in the cache, performing
multiplications with no further transfers. The total is
, plus the
elements of the result. ∎
Traffic is reduced by a factor proportional to
: with a 32 KB L1 and 8-byte numbers,
, an order of magnitude less. Optimised linear algebra libraries apply blocking at several levels, one per cache, and come close to the processor’s peak performance. It is the same principle as arithmetic intensity in the roofline model (lesson on SIMD and GPUs).
6Coherence and consistency
In a multicore processor every core has its own caches, but memory is shared: when a core modifies a datum, the others must see the new value and not an old copy left in their caches. Two different questions must be kept apart: coherence, which concerns a single address, and consistency, which concerns the order in which operations on different addresses become visible. In this lesson we look at the MESI protocol, directory protocols, false sharing, the sequential consistency model with the proof of one of its properties, and why real processors violate it.
The coherence problem
Core 0 reads variable
, which ends up in its cache; core 1 reads it and modifies it in its own. If core 0 rereads
from its cache, it gets the old value. A system is coherent if, for every address, all cores see the writes in the same order and a read always returns the last value written according to that order. The Computer Systems course introduced the problem; here we see how hardware solves it.
The MESI protocol
In systems with few cores the caches are connected to a common medium that all of them observe (snooping): every cache “listens” to the requests of the others. Every block in a cache is in one of four states:
- M (modified): only this cache has the block, and it differs from memory;
- E (exclusive): only this cache has the block, equal to memory;
- S (shared): the block may be in several caches, all equal to memory;
- I (invalid): the block is not valid.

The fundamental rule is single writer or multiple readers. To write a block a cache must have it in state M or E: if it has it in S, it first sends an invalidation request, and all other copies go to I. When another cache asks to read a block that is in M, the owner supplies the up-to-date data and goes to S. The E state is an important optimisation: a datum read by a single core, a very frequent case, can then be written without any bus message, going straight to M.
Directory protocols
Snooping requires every request to reach every cache: with
cores each miss generates
lookups, and with tens of cores the common medium becomes the bottleneck. Large systems use a directory: for every memory block a record says which caches have a copy and in what state. Requests go to the directory, which forwards invalidations only to the caches concerned. Traffic no longer grows with the number of cores but with the number of actual copies, at the price of the memory occupied by the directory and an extra hop.
False sharing
Coherence works on blocks, typically 64 bytes, not on variables. If two cores modify two different variables that sit in the same block, for instance two adjacent counters in an array, every write by one invalidates the other’s copy, and the block bounces back and forth between the two caches, even though the two cores share no data. This is false sharing: a correct parallel program can run slower than the sequential one. It is solved by spacing the data used by different threads at least one block apart.
Sequential consistency
Coherence is not enough. Consider two threads, with
initially:
- thread 1:
; then 
- thread 2:
; then 
The most intuitive model is sequential consistency (Lamport, 1979): the result must be that of some interleaving of the operations of all threads in a single order, in which every thread keeps its own program order.
Theorem. Under sequential consistency, the outcome
is impossible.
Proof. Consider the last of the four operations in the global order. It cannot be a write, because in each thread the write precedes the read. If it is
, then
happened before, and
. If it is
, then
happened before, and
. In every case at least one of the two is 1. ∎
Why processors violate it
Yet on an x86 processor the outcome
is actually observed. The reason is the store buffer: so as not to stall, each core puts its write into a buffer and immediately goes on with the read, which goes to the cache. Both reads can happen while both writes are still in the buffers, invisible to the other core: both read 0. The x86 model, called TSO (total store order), allows exactly this reordering of a read before an earlier write to a different address. The ARM and RISC-V architectures have even more relaxed models, which allow almost all reorderings, in exchange for better performance.
The programmer restores order when needed with fences, instructions that force earlier operations to complete before later ones, and with atomic operations (read-modify-write such as compare-and-swap), on which locks and concurrent data structures are built. Modern languages (C11, C++11, Java, Rust) define their own memory model and translate atomic operations into the right fences for each processor: a data-race-free program, which protects every shared datum with a lock or an atomic operation, behaves as if consistency were sequential.
7SIMD, GPUs and roofline
Many programs spend almost all their time repeating the same operation on large amounts of data: filtering images, multiplying matrices, training neural networks, simulating physics. For this kind of work a different architecture pays off: a single instruction acting on many data at once. In this lesson we look at the SIMD vector extensions of processors, the GPU execution model with its constraints, and the roofline model, which with a two-line proof says whether a program is limited by computation or by memory.
SIMD in processors
In Flynn’s classification, SIMD (single instruction, multiple data) denotes a single instruction applied to several data. Modern processors have vector registers 128, 256 or 512 bits wide: a 256-bit register holds eight 32-bit floating-point numbers, and a single instruction adds them pairwise to those of another register. The main families are SSE and AVX on x86, NEON and SVE on ARM, the V extension on RISC-V.
SVE and RISC-V V are vector-length agnostic: the program asks the processor how many elements it can handle at a time and adapts, so the same code runs on processors with registers of different lengths. Compilers automatically vectorise simple loops, provided there are no dependences between iterations and the data are contiguous in memory.
The GPU model
A GPU pushes the idea to the extreme. It contains tens of streaming multiprocessors (SMs), each with tens of simple compute units, thousands in all. The programmer writes a function (the kernel) for a single element and launches it over millions of elements; the hardware groups threads in sets of 32 (warps) that execute the same instruction at the same time, each on its own data. This is the SIMT model (single instruction, multiple threads).
Two rules decide performance:
- divergence: if within a warp some threads take one branch of an
ifand others the other, the two branches are executed one after the other, with half the threads idle. GPU code must avoid branches that depend on the data of the single element; - coalesced accesses: if the 32 threads of a warp read 32 consecutive addresses, memory serves them with a single wide transfer; if they read scattered addresses, 32 transfers are needed.
GPUs do not hide memory latency with huge caches and out-of-order execution, but with numbers: each SM keeps tens of warps alive and, when one waits for memory, switches to another in one cycle. A great deal of parallelism is therefore needed, tens of thousands of active threads.
The roofline model
How fast can a program run on a given machine? Two limits matter: the peak compute performance
(operations per second) and the memory bandwidth
(bytes per second). The link between the two is given by the program’s arithmetic intensity, the ratio of operations performed to bytes transferred from memory:
![]()
Theorem (roofline). The attainable performance is bounded by
![]()
Proof. The program performs
operations and transfers
bytes in a time
. The operations cannot be executed faster than the peak, so
; the bytes cannot be transferred faster than the bandwidth, so
. Performance is
, and from the two inequalities
and
. ∎

On a logarithmic scale the plot has the shape of a roof: a slope on the left and a flat top on the right, meeting at the ridge point
. A program with intensity below
is memory-bound: improving computation is useless, transfers must be reduced. One with higher intensity is compute-bound.
Examples. A machine with
GFLOP/s and
GB/s has its ridge at 5 operations per byte.
- The dot product of two 64-bit vectors performs 2 operations (a multiplication and an addition) every 16 bytes read:
. Performance cannot exceed
GFLOP/s, 2.5 % of the peak, however optimised the code. - The matrix product with blocking (lesson on caches) performs
operations while transferring about
numbers: the intensity grows with the block side
, and with large enough blocks the program becomes compute-bound. That is why matrix multiplication is the operation on which GPUs and AI accelerators reach their advertised performance.
The model extends to several roofs (with and without vector units, with data in cache or in DRAM) and guides optimisation: first measure where the program lies, then decide whether to work on data locality or on computation.
8Energy and power
For thirty years every generation of processors was faster than the previous one almost for free. Then, around 2005, the limit became heat: a chip cannot dissipate more than about a hundred watts per square centimetre without impractical cooling, and a phone no more than a few watts. Today every architectural choice is measured in performance per watt. In this lesson we prove where the dynamic power of CMOS circuits comes from, why lowering frequency and voltage saves so much, the end of Dennard scaling and the industry’s answers: multicore, heterogeneous cores and accelerators.
Dynamic power
Every node of a CMOS circuit has a capacitance
(the gates it drives and the wires). When it goes from 0 to 1, the p transistor charges it from the supply
; when it returns to 0, the n transistor discharges it to ground (Electronic Devices lesson on CMOS logic).
Theorem. A complete charge and discharge cycle of a capacitance
at voltage
dissipates the energy
, whatever the resistance of the transistors.
Proof. During charging the supply delivers the charge
at the constant voltage
: the energy delivered is
. At the end the capacitor stores
; the other half,
, has been dissipated in the transistor’s resistance, whatever its value (a large resistance gives a small current for a long time, and the product does not change). During discharge the stored energy
is dissipated in the n transistor. In all,
per cycle. ∎
If a node switches from 0 to 1 in a fraction
of clock cycles (the activity factor), at frequency
:
![]()
To this is added static power, due to the transistors’ leakage currents even when they are off, which grows rapidly as the threshold voltage is lowered and with temperature.
Frequency and voltage
A transistor switches faster if driven with a higher voltage: over a reasonable operating range, the maximum frequency is roughly proportional to the voltage. Dynamic voltage and frequency scaling (DVFS) lowers both together when maximum speed is not needed.

Theorem. If voltage is proportional to frequency, dynamic power is proportional to
and energy per operation to
.
Proof. With
,
. The number of operations per second is proportional to
, so the energy per operation is
, i.e. proportional to
. ∎
The consequence for multicore. Lowering frequency and voltage by 20 %, a core’s power drops to
of the initial value. Two cores slowed down in this way consume about as much as a single core at full frequency, but, if the work can be parallelised, they deliver
times the performance. This is the energy argument that pushed towards multicore.
The end of Dennard scaling
In 1974 Robert Dennard showed that shrinking a transistor by a factor
, voltages and capacitances drop by
and frequency rises by
: power per transistor drops by
, exactly as much as the number of transistors in the same area grows. Power density stays constant, and every generation was faster without running hotter.
Around 2005 the rule broke: voltage can no longer drop, because transistor thresholds cannot drop without leakage currents exploding. Power density started to grow with every generation. The result is dark silicon: a modern chip has more logic than can be switched on all at once without exceeding the thermal limit.
The industry’s answers
- Multicore and frequencies stuck around 3-5 GHz, as the calculation above shows.
- Heterogeneous cores: big, fast cores for sequential parts, small efficient cores for background and parallel work (ARM’s big.LITTLE, Intel’s P and E cores). The operating system moves threads between them.
- Specialised accelerators: a circuit that does one thing only, such as video decoding, cryptography or neural network computation (NPU), can be 10 to 1000 times more efficient than a general-purpose processor, because it spends no energy fetching, decoding and reordering instructions. The “dark” silicon fills up with accelerators that switch on only when needed.
- Switching off what is idle: chip blocks with no clock (clock gating) or no supply (power gating) when inactive; it often pays to run a job at full speed and then switch everything off (race to idle) rather than run it slowly.
A last lesson from the numbers: moving data costs more than computing on it. A 64-bit floating-point addition costs a few picojoules; reading its operands from DRAM costs a hundred times more. The same techniques that improve performance, data locality, blocking, high arithmetic intensity, are those that save energy.
∑Formula sheet
Instruction-level parallelism and dependences
The performance equation with stalls
![]()
Branch prediction
The cost of a misprediction
![]()
Cache hierarchies
The multi-level hierarchy
![]()
![]()
SIMD, GPUs and roofline
The roofline model
![]()
![]()
Energy and power
Dynamic power
![]()