Computer Organization and Architecture
Comprehensive exam revision notes for BCA-207N Unit 5 (Parallel Processing, Pipelining & Multiprocessor Systems). Includes Section A (2M), Section B (5M), and Section C (15M) questions, answers, and diagrams.
Computer Organization and Architecture
Parallel Processing, Pipelining & Multiprocessor Systems
Core Definitions & Key Concepts
Parallel Processing and distinguish between Spatial and Temporal Parallelism
Parallel Processing is the execution of concurrent computational tasks across simultaneous hardware units to increase throughput. Spatial Parallelism uses multiple physical hardware units (e.g., multiple ALUs or CPU cores) processing multiple tasks simultaneously. Temporal Parallelism uses a single hardware pipeline where different processing stages overlap execution on different stream elements over time.
Classify computer architectures according to Flynn's Taxonomy
- SISD (Single Instruction Single Data): Traditional Von Neumann single CPU core.
- SIMD (Single Instruction Multiple Data): Vector/array processors; GPU shaders executing same instruction across matrix elements.
- MISD (Multiple Instruction Single Data): Theoretical; redundant fault-tolerant systems voting on same input stream.
- MIMD (Multiple Instruction Multiple Data): Modern multi-core processors, server clusters, distributed supercomputers.
Pipelining in computer architecture
Pipelining is an implementation technique where multiple instructions are overlapped in execution, analogous to an industrial factory assembly line. The computational path is partitioned into sequential sub-operations (stages) separated by clock-synchronized interface registers.
What is the theoretical maximum Speedup of a k-stage pipeline
For a k-stage pipeline operating on n instructions as n \to \infty, the theoretical maximum speedup over a non-pipelined processor is equal to the number of pipeline stages, $k$: $S_{max} = \lim_{n \to \infty} \frac{n \cdot k}{k + n - 1} = k$
List the three categories of Pipeline Hazards
- Structural Hazards (Resource Conflicts): Hardware cannot support all overlapped stage combinations simultaneously (e.g., single memory port for both instruction fetch and operand read).
- Data Hazards (Data Dependencies): An instruction depends on the result of a prior instruction still in the pipeline (RAW, WAR, WAW).
- Control Hazards (Branch Penalties): Caused by conditional branches that change the Program Counter, requiring the pipeline to flush.
State Amdahl's Law in parallel computing
Amdahl's Law states that the maximum speedup achievable by parallelizing a program is bounded by the sequential (serial) fraction (S) of the workload that cannot be parallelized: $Speedup = \frac{1}{S + \frac{1 - S}{N}} where N$ is the number of parallel processor cores.
Conceptual & Architectural Analysis
Illustrate the Space-Time Diagram of a 4-stage instruction pipeline executing 6 instructions
Space-Time Diagram for 4-Stage Pipeline
Let the 4 stages be:
- FI: Fetch Instruction
- DA: Decode Instruction & Address
- FO: Fetch Operand
- EX: Execute Instruction
Clock Cycle Grid for 6 Instructions (I_1 to I_6):
Stage | Clock Cycles ->
| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
------+-----+-----+-----+-----+-----+-----+-----+-----+-----+
FI | I1 | I2 | I3 | I4 | I5 | I6 | - | - | - |
DA | - | I1 | I2 | I3 | I4 | I5 | I6 | - | - |
FO | - | - | I1 | I2 | I3 | I4 | I5 | I6 | - |
EX | - | - | - | I1 | I2 | I3 | I4 | I5 | I6 |- Execution Time Analysis:
- In a non-pipelined system: Total time = n × k = 6 × 4 = \mathbf{24 clock cycles}.
- In our 4-stage pipeline: First instruction I_1 takes k = 4 cycles. Each subsequent instruction completes at the rate of 1 per cycle.
- Total time = k + (n - 1) = 4 + (6 - 1) = \mathbf{9 clock cycles}.
- Speedup achieved = \frac{24}{9} = \mathbf{2.67×}.
Data Hazards: RAW, WAR, and WAW dependencies, and how Operand Forwarding eliminates stalls
Data Hazards & Operand Forwarding
A Data Hazard arises when instruction I_2 requires the output of instruction I_1 before I_1 has committed its result to the register file.
1. Data Dependency Classifications:
- RAW (Read-After-Write / True Dependency): I_2 attempts to read a register before I_1 writes it. (Most common hazard).
1 I1: ADD R1, R2, R3 ; R1 written in EX/WB stage2 I2: SUB R4, R1, R5 ; R1 read in ID stage- WAR (Write-After-Read / Anti-Dependency): I_2 attempts to write before I_1 reads.
- WAW (Write-After-Write / Output Dependency): I_2 attempts to write before I_1 writes, risking overwriting the newer value with an older one.
2. Hardware Solution: Operand Forwarding (Bypassing)
Instead of stalling the pipeline for 2 clock cycles until I_1 reaches the Write-Back (WB) stage, Operand Forwarding adds direct multiplexer feedback wires from the ALU output register of the EX stage directly into the ALU input of the next stage. The calculated value is consumed immediately without waiting for register file writes.
Arithmetic Pipelining for Floating-Point Addition
Arithmetic Pipeline: Floating-Point Addition
Consider adding two normalized floating-point numbers: $X = A × 2^a, \quad Y = B × 2^b$
Floating-point addition requires a 4-segment arithmetic pipeline:
[ Input Operands X, Y ]
|
v
+-------------------------------+
| Segment 1: Compare Exponents | ===> Finds exponent difference: d = |a - b|
+-------------------------------+
|
v
+-------------------------------+
| Segment 2: Align Mantissas | ===> Shifts smaller mantissa right by 'd' bits
+-------------------------------+
|
v
+-------------------------------+
| Segment 3: Add Mantissas | ===> High-speed parallel adder computes sum
+-------------------------------+
|
v
+-------------------------------+
| Segment 4: Normalize Result | ===> Adjusts exponent, shifts mantissa to 1.xxx
+-------------------------------+
|
v
[ Normalized Output Result ]Each stage takes 1 clock cycle. Once the pipeline is primed, floating-point additions finish at the rate of one operation per clock cycle.
In-Depth Analysis & Implementation
Derive the performance metrics of a Linear Pipeline Processor: Clock cycle time, Total execution time, Speedup Ratio (S_k), Efficiency (E), and Throughput (P). Solve: A non-pipeline system takes 50 ns to process a task. The same task can be processed in a 5-stage pipeline with each stage taking 10 ns. For 100 tasks, calculate: (1) Total time in both systems, (2) Speedup ratio, (3) Efficiency, and (4) Throughput
Comprehensive Performance Derivation & Numerical on Pipelining
Part 1: Mathematical Derivation of Metrics
Let:
- k = Number of pipeline stages
- \tau_i = Delay of stage i
- \tau_m = Maximum stage delay = \max(\tau_i)
- d = Register delay (latch setup time)
- Clock cycle time \tau = \tau_m + d
- n = Number of tasks (instructions)
1. Total Time in Non-Pipelined System (T_n):
Let t_n be total time per task without pipelining: $T_n = n × t_n$
2. Total Time in Pipelined System (T_k):
First task takes k clock cycles. Remaining (n - 1) tasks complete at 1 task per clock cycle: $T_k = [k + (n - 1)] × \tau$
3. Speedup Ratio (S_k):
$S_k = \frac{T_n}{T_k} = \frac{n \cdot t_n}{[k + (n - 1)] \cdot \tau} If tn \approx k \cdot \tau$, then as $n \to \infty$: $$S{\text{max}} = \frac{n \cdot k \cdot \tau}{n \cdot \tau} = \mathbf{k}$$
4. Pipeline Efficiency (E):
Fraction of hardware busy time over total available time slots: $E = \frac{S_k}{k} = \frac{n}{k + n - 1} As n \to \infty, E \to 1 (100\%$).
5. Pipeline Throughput (P):
Number of tasks completed per unit time: $P = \frac{n}{T_k} = \frac{n}{[k + (n - 1)] \cdot \tau}$
Part 2: Numerical Problem Solution
Given Data:
- Non-pipelined task time: t_n = 50 ns
- Number of pipeline stages: k = 5
- Stage clock cycle time: \tau = 10 ns
- Number of tasks: n = 100
Calculations:
- Total Execution Time:
- Non-Pipelined: T_n = n × t_n = 100 × 50 ns = \mathbf{5000 ns} (5.0\;µs).
- Pipelined: T_k = [k + (n - 1)] × \tau = [5 + (100 - 1)] × 10 = [5 + 99] × 10 = 104 × 10 = \mathbf{1040 ns} (1.04\;µs).
- Speedup Ratio ($S_k$):
$S_k = \frac{T_n}{T_k} = \frac{5000 ns}{1040 ns} = \mathbf{4.808} *(Very close to theoretical maximum of k = 5$).*
- Pipeline Efficiency ($E$):
$E = \frac{S_k}{k} = \frac{4.808}{5} = 0.9615 = \mathbf{96.15\%}$
- Pipeline Throughput ($P$):
$P = \frac{100}{1040 ns} = \frac{100}{1040 × 10^{-9} s} = \mathbf{96.15 × 10^6 tasks/second} \quad (96.15 MIPS)$
Critically analyze Pipeline Hazards in modern superscalar processors: Structural Hazards, Data Hazards, and Branch Hazards. Discuss solutions including Delayed Branching, Static and Dynamic Branch Prediction (2-bit saturating counter)
Detailed Analysis of Pipeline Hazards and Mitigation Strategies
A hazard prevents the next instruction in the instruction stream from executing during its designated clock cycle, inducing pipeline stalls (bubbles).
1. Structural Hazards
- Cause: Two instructions demand the same physical hardware resource simultaneously.
- Example: A unified memory cache where Instruction Fetch (stage 1) conflicts with Data Memory Access (stage 4).
- Mitigation:
- Harvard Architecture: Split L1 cache into separate Instruction Cache (I-Cache) and Data Cache (D-Cache).
- Multiple ALU execution units.
2. Data Hazards & Stalls
- RAW Hazard Bubble Insertion: If operand forwarding cannot fully bridge the latency gap (e.g., LOAD followed immediately by dependent ALU instruction), the pipeline hardware interlock stalls the consumer by inserting a 1-cycle bubble.
3. Control (Branch) Hazards
When a conditional branch (BEQ, BNE) is decoded, the target PC is unknown until stage 3 or 4. If the pipeline continues fetching sequential instructions, it may fetch instructions from the wrong execution path!
1Clock: 1 2 3 4 5 62Branch: FI DA FO EX (Branch condition evaluated: TAKEN!)3Next (Seq): FI DA FO ===> FLUSHED! (Wasted 3 cycles)4Target: FI DA FO EXBranch Mitigation Strategies:
- Delayed Branching: The instruction immediately following the branch (in the Branch Delay Slot) is always executed, regardless of whether the branch is taken or not. Compilers reorder code to place a useful, independent instruction into this slot.
- Static Branch Prediction: Assumes all backward branches (loops) are Taken and all forward branches (error handling) are Not Taken.
- Dynamic Branch Prediction (2-Bit Saturating Counter):
- Uses a Branch History Table (BHT) indexed by lower PC bits.
- Each entry is a 2-bit state machine:
11= Strongly Taken10= Weakly Taken01= Weakly Not Taken00= Strongly Not Taken- Requires two consecutive mispredictions to flip the prediction, preventing single-loop exit anomalies from corrupting the prediction history.
Important Exam Points & Quick Revision
Examiner Insights & University Exam Strategy:
- Guaranteed 10/15-Mark Problem: Numerical calculation of Speedup (S_k), Efficiency (E), and Throughput (P) for a pipelined vs non-pipelined processor. Show the formula T_k = [k + (n-1)] \tau clearly.
- Space-Time Diagram: Always draw the 2D grid of stages versus clock cycles when explaining pipelining.
- Flynn's Taxonomy: Write definitions for all four classes (SISD, SIMD, MISD, MIMD) with real-world examples (Vector/GPU, Multi-core).
100% left on this page — finishing it closes the gap for Parallel Processing, Pipelining & Multiprocessor Systems.
Parallel Processing, Pipelining & Multiprocessor Systems still counts as a weak topic until you finish this note and answer its questions.
Practise this unitTest Your Understanding
Now that you've read through these notes, practice unit MCQs to identify weak points and solidify your learning before exams.