CPUs and architecture

What is the main purpose of pipelining in a CPU?

  1. ATo divide instruction processing into stages and overlap the stages of different instructions, increasing throughput
  2. BTo always shorten the execution time (latency) of each instruction
  3. CTo reduce the number of instructions and make programs smaller
Show answer and explanation

Answer: A. To divide instruction processing into stages and overlap the stages of different instructions, increasing throughput

Pipelining overlaps stages such as fetch, decode, execute, memory access and write-back like an assembly line, completing one instruction per clock to raise throughput—ideally about 5× for five stages. Each instruction's latency actually grows slightly. Data dependences, branches and resource conflicts disrupt the flow (hazards), handled with forwarding and branch prediction.

5-stage pipeline and a load-use hazard bubble Time (clock) 1 2 3 4 5 6 7 8 9 Instruction lw x1, 0(x2) IF ID EX MEM WB add x3, x1, x4 IF ID Bubble EX MEM WB sub x5, x6, x7 IF ID EX MEM WB or x8, x9, x10 IF ID EX MEM WB add uses x1 right after lw loads it (load-use hazard) Even with forwarding (arrow), a 1-cycle bubble remains Without stalls, one instruction completes per clock IF fetch · ID decode & register read EX execute · MEM memory access · WB write-back
5-stage pipeline and a load-use hazard bubble · View in diagrams