The processor clock and the machine cycle
A non-system unit · quantity: an interval of synchronisation and a measure of computing work
In the autumn of 2004 Intel cancelled the development of a processor meant to run at ten gigahertz, and this was not a technical failure but an admission of a physical wall: a die driven twice as fast demanded four times the power and simply melted. The frequency race, which had gone on for thirty years, ended in a single day, and with it went the habit of judging a machine by the number on its box.
The clock itself is the interval between two edges of the clock signal, the very step by which all the synchronous parts of the die switch at once. Its reciprocal is the frequency, and so a clock at five gigahertz lasts two tenths of a nanosecond, in which light manages six centimetres and a signal along a copper trace even less — less than the die is wide.
01 · Definition
The clock is the period of the clock signal, that is, the interval between two like edges at which the synchronous elements of the die change state together. The machine cycle is a whole number of clocks in which the processor performs a completed action; in a pipelined machine it is replaced by the reciprocal measure — the number of clocks per instruction, whose own reciprocal tells how many instructions leave the pipeline in one clock.
The length of a clock is set not by nature but by the wiring of the die: it must be no shorter than the slowest path between two flip-flops, including the flip-flop's own delay and a margin for the spread of parameters. Hence the designer's usual move — to cut a long logic path into two pipeline stages: the clock becomes twice as short, the frequency twice as high, and the instruction now walks the whole flight of stairs.
What limits the frequency, however, is not the logic but the power: dynamic consumption grows with the frequency and with the square of the voltage, and the voltage has to be raised so that the circuit keeps up at the higher frequency. Heat therefore goes roughly as the cube of the frequency, and on this cubic dependence the gigahertz race came to a halt at about four.
Finally, the clock is a unit whose length is not constant. Power management changes the frequency hundreds of times a second, adapting to load and temperature, and so the number of clocks tells nothing about elapsed time — but it does tell about work done: the clock counter counts not seconds but steps of computation, and therein lies its real worth.
Lead the frequency with the slider and watch two curves that part in opposite directions. The green one is the distance a signal manages in a single clock: the higher the frequency, the shorter that path, and at five gigahertz it turns out smaller than the die itself. The crimson one is what a trip to memory costs in clocks: its latency in nanoseconds hardly changes, so in clocks it only grows.
Having cut the work into stages, the designer shortens the clock, but a single instruction now walks that whole flight of stairs, and its own latency does not fall — it rises. The gain appears only when the stages are filled with different instructions, and on a mispredicted branch the pipeline has to be flushed entirely — the deeper it is, the dearer that costs.
02 · Conversion
Frequency, period, work
Enter a frequency or a clock length, and the sheet will show the reciprocal, the signal's path in one clock and the cost of memory accesses in clocks. The first family is exact by definition, the second rests on average figures for a core, the third on the typical latencies of today's memory hierarchy.
The signal's speed along a trace is taken as six tenths of the speed of light; in the sheet's finer settings it can be changed to a half.
Only identical cores may be compared by frequency, because the number of clocks per instruction differs several-fold between architectures: one machine takes four instructions in a clock, another barely one. That is exactly why the gigahertz figure left the advertisements, and its place was taken by sets of benchmarks that measure not clocks but work done.
| Value | Note | ||
|---|---|---|---|
| {u} | {name} | {value} | {note} |
03 · Orders of magnitude
logarithmic scale: from a clock to the scheduler's quantum04 · Measuring instruments
What sets the clock and what counts it
The source of the clock is a slip of quartz, oscillating usually at a few tens of megahertz with an accuracy of about ten parts in a million. The gigahertz on the die come not from it but from multiplying that reference, so the stability of the whole machine is inherited from a piece of mineral the size of a grain of rice.
The phase-locked loop compares the divided frequency of the oscillator with the reference and nudges it until the phases agree; changing the divider changes the frequency on the fly. It is precisely this that lets power management drop the clock to a few hundred megahertz at idle and lift it into boost for a matter of seconds, as long as thermal headroom remains.
Inside the core sit registers counting clocks, retired instructions, cache misses and mispredicted branches, and they can be read from a running program. From these numbers comes the count of clocks per instruction — the only honest measure of how well the code has fitted a particular die.
To see the clock itself one needs an instrument that catches edges with a resolution of a few picoseconds, and it also shows the things that keep the frequency from rising further: phase jitter, skew in the signal's arrival at different corners of the die, and the slumping of an edge along a long line.
05 · Writing rules
Clocks and hertz are not the same thing
Frequency is written in hertz with the prefix capitalised for mega and giga, while a number of clocks is written as a plain integer with no unit at all, since the clock is not an SI unit. Performance figures are written in capitals without periods and with a note of which core they refer to; mixing frequency and throughput in one quantity is not allowed.
The first writing muddles two different quantities: a number of clocks is dimensionless, whereas the hertz measures frequency. The second breaks the case of the prefix, obligatory for mega and giga. The third compares by frequency architectures whose clocks per instruction differ several-fold, and so nothing follows from such a comparison. The fourth takes a varying quantity for a constant.
06 · Neighbouring units
Beside it stand the units that measure the same work from other sides: the hertz as the frequency of the signal itself, the number of floating-point operations per second and the number of instructions falling to one clock. All of them follow from one another once the frequency and the behaviour of the pipeline are known.
frequency, an SI unit
a dimensionless measure
a measure of computing work
Of the Simetrium data sheets nearby stand hertz, which sets the frequency, second and its submultiple prefixes, unix time, where the limit is likewise set by the machine word, and the bit s the byte, by which what a clock carries is measured.
07 · Historical section
Thirty years of the race and one day of cancellation
The first single-chip processor ran at a frequency that a present-day die passes through in a fraction of a microsecond, and one instruction took it eight clocks. The machine cycle was then a literal notion: fetching the instruction, decoding, fetching the data, computing and writing — each stage took its own clock, and all of them followed strictly in turn.
As soon as the stages learned to work on different instructions at once, the familiar measure broke: an instruction still took five clocks, but one left the pipeline every clock. The count had to be turned over and spoken of as clocks per instruction, which in a good machine became less than one — that is, more than one instruction completes in a single clock.
An architecture with a pipeline of thirty-one stages was built for the sake of frequency and ran into heat: the promised ten gigahertz demanded cooling unthinkable in a desktop case. The project was closed and the industry turned to many cores — not because that is better, but because the cubic growth of consumption left no other way.
A present-day core has no single frequency: at idle it drops to a few hundred megahertz, under load it climbs towards five gigahertz and holds that as long as thermal headroom lasts. The figure on the box became a promise under favourable conditions, and both makers and reviewers stopped comparing machines by it.
A unit whose length changes in the course of the measurement
The clock is awkwardly arranged for a metrologist: its length is set not by a standard but by the wiring of the die, and it changes in one and the same processor hundreds of times a second, since power management fits the frequency to load and temperature. Hence the clock counter is no good for measuring time, although outwardly it looks like a timer, and a program that trusts it will be wrong by the amount the frequency has moved.
For the task it appeared for, however, the clock suits better than any unit of time. Counting clocks, we measure not duration but the volume of computing work, and so the number of clocks per instruction stays comparable under any change of frequency — it speaks of how well the code has fitted the die, not of how many seconds have gone by.
Catalogue · units of measurement
A data sheet for every quantity
Seven SI base units, twenty-two derived ones with names of their own, and the non-SI quantities that neither science nor daily life does without. Each gets its own sheet: definition, conversion, instruments, writing rules, history. In 36 languages.