Processor architecture: RISC, CISC and pipelining

A-Level Computer Science · Advanced Architecture, Networks and Computational Thinking

Two design philosophies

CISC provides many complex instructions, each able to do a lot, so a program needs fewer instructions but each one may take several clock cycles and the hardware is complicated. RISC provides a small set of simple instructions, each designed to complete in one cycle, so programs are longer but the hardware is simpler, uses less power and is easier to pipeline.

Why RISC won in mobile devices

Simpler hardware means lower power consumption and less heat — decisive for a phone running on a battery. The compiler does more work to turn one complex operation into several simple instructions, and that is an acceptable trade because compilation happens once while execution happens billions of times.

Pipelining

Instead of finishing one instruction before starting the next, the processor overlaps them: while instruction $1$ is being executed, instruction $2$ is being decoded and instruction $3$ fetched. With $4$ stages, four instructions take $7$ cycles instead of $16$.

The catch is a branch. When a jump is taken, the instructions already in the pipeline are the wrong ones and must be discarded, which is why processors use branch prediction to guess which way a conditional jump will go.

Parallel processing

SISD is a single processor on a single data stream. SIMD applies the same instruction to many data items at once — the model behind graphics processors, image filters and much machine learning. MIMD runs different instructions on different data, which is what a multi-core general-purpose processor does.

Why more cores does not mean proportionally more speed

A program only speeds up if the work can be divided; the part that must run sequentially sets a floor on the total time no matter how many cores are added. Add the cost of coordinating cores and sharing memory, and doubling cores rarely halves the run time — that is the evaluation point.

Duong ong lenh — bon lenh chay CHONG NHAULenh 1Lenh 2Lenh 3Lenh 4napgiai mathuc hienghinapgiai mathuc hiennapgiai manapck 1ck 2ck 3ck 4Khong duong ong: 4 lenh x 4 ck = 16 ck · Co duong ong: 7 ckNhung mot lenh NHAY lam ca duong ong phai xoa va nap lai
The pipeline is a simple idea with a big benefit, but the last row of the figure is where the marks are: a jump instruction makes that whole benefit vanish for a few cycles.

Worked example: calculate the benefit of a pipeline and the limit of multiple cores

(a) A processor has a $5$-stage pipeline, each stage taking $1$ cycle. Calculate the number of cycles needed for $100$ instructions, with and without the pipeline.

(b) A program has $30\%$ of its workload that must run sequentially. Explain why going from $4$ to $8$ cores does not make the program twice as fast.

Solution

(a) Without a pipeline. Each instruction must go through all $5$ stages before the next one starts.

Number of cycles $=100\times5=\mathbf{500}$ cycles.

With a pipeline. The first instruction takes the full $5$ cycles to pass through the pipeline; after that, one more instruction completes every cycle.

Number of cycles $=5+(100-1)=\mathbf{104}$ cycles.

About $4.8$ times faster — close to the number of stages, and that is the general rule: with $n$ stages, the maximum benefit approaches $n$ times when the number of instructions is large enough.

But this is an ideal figure. In practice, each jump instruction that is taken forces the wrongly fetched instructions to be flushed and fetching to restart, costing about $4$ cycles. A program with many loops and branches will not reach this $4.8$ times.

(b) Why $8$ cores are not twice as fast as $4$ cores.

Only $70\%$ of the workload can be divided among multiple cores; the remaining $30\%$ must run sequentially and does not speed up at all however many cores there are.

Suppose one core takes $100$ units of time:

With $4$ cores: $30+\dfrac{70}{4}=30+17.5=47.5$ units.
With $8$ cores: $30+\dfrac{70}{8}=30+8.75=38.75$ units.

Doubling the number of cores reduces the time by only about $18\%$, not $50\%$.

Absolute limit: even with infinitely many cores, the time never falls below $30$ units — so the best possible speed-up is only $3.3$ times. The sequential part sets a floor that cannot be passed.

An additional practical cost: more cores also bring coordination overhead and contention for shared memory, so the real figure is even worse than the $38.75$ units calculated above.

Common mistake

Writing 'twice the cores makes the program run twice as fast'. Only the DIVISIBLE part of the work speeds up; the sequential part sets a floor, and the coordination cost between cores eats further into the benefit.

Key takeaway

RISC is simple and saves power, while CISC has fewer instructions in a program but more complex hardware. A pipeline gives a benefit approaching the number of stages but is wrecked by jump instructions. SIMD is single instruction multiple data, MIMD is multiple instruction multiple data. And more cores do not give a proportional speed-up.

← Software development and testing strategies · All A-Level Computer Science lessons · Practice A-Level Computer Science questions (free, instant scoring) · Modern networks, protocols and the internet of things →