Advanced Computer Architecture MAKAUT Notes
Advanced Computer Architecture MAKAUT Notes
■
ADVANCED COMPUTER
ARCHITECTURE
Complete Exam Notes — MAKAUT
How to use these notes: Questions marked ★★ VERY IMPORTANT (gold banner) are the most frequently
asked in MAKAUT exams and highly likely this year. Read all concept boxes first, then study model answers. For
5-mark answers: definition + 3-4 points. For 15-mark: use all sections + diagrams/tables.
Unit Coverage
Computer Arch Review · Quantitative Design · Pipeline Concepts · Hazards · Exception Handling · Optimization
Pipeline: A technique where multiple instructions are overlapped in execution. Like an assembly line — while
instruction 1 is in stage 2, instruction 2 enters stage 1. 5 classic stages: IF (Instruction Fetch) → ID (Instruction
Decode) → EX (Execute) → MEM (Memory Access) → WB (Write Back).
Term Definition
CPI Cycles Per Instruction. Ideal pipelined CPI = 1. Hazards increase CPI.
Latency Time for one instruction to complete. Pipeline may increase latency.
AMAT Average Memory Access Time = Hit time + Miss rate × Miss penalty.
Data Hazard Instruction needs data not yet produced by previous instruction. Solved by:
Forwarding/Bypassing, Stalls (NOPs), Compiler reordering.
Control Hazard Branch instruction causes wrong instructions to be fetched. Solved by: Branch prediction,
Delayed branching, Flush pipeline.
Structural Hazard Two instructions need the same hardware resource at same time. Solved by: Resource
duplication, Pipeline stalls.
RAW Hazard Read After Write — most common data hazard. Instruction reads before previous writes.
WAR Hazard Write After Read — anti-dependence. Instruction writes before previous reads.
WAW Hazard Write After Write — output dependence. Two writes to same register.
Exception: Unexpected event during execution (divide by zero, page fault, illegal instruction).
Problem: In a pipeline, multiple instructions are in different stages — which one caused the exception?
Solutions: (1) Precise exceptions — pipeline is drained, state saved exactly at exception point. (2) Imprecise
exceptions — faster but harder to handle. (3) Hardware saves PC of faulting instruction; OS handler is invoked;
pipeline flushed.
Definition: Pipelining is an implementation technique where multiple instructions are overlapped in execution,
similar to an assembly line.
Pipeline Stages (Classic 5-stage):
• IF — Instruction Fetch
• ID — Instruction Decode / Register Read
• EX — Execute / ALU operation
• MEM — Memory Access
• WB — Write Back
Advantages:
• Increases instruction throughput (instructions per second).
• Better utilisation of hardware resources.
• Ideal CPI = 1 (one instruction completes per cycle).
• Speedup proportional to number of pipeline stages.
Disadvantages:
• Hazards (data, control, structural) reduce performance.
• Complex control logic required.
• Does not reduce latency of a single instruction.
• All stages must complete in same time (slowest stage limits speed).
■ Exam Tip: Definition + 5 stages + advantages + disadvantages = 5/5.
Data Hazard: Occurs when an instruction depends on the result of a previous instruction still in the pipeline.
RAW (Read After Write) Most common. Instr 2 reads register before Instr 1 writes it. Solution: Forwarding.
WAR (Write After Read) Instr 2 writes before Instr 1 reads. Anti-dependence. Solution: Register renaming.
WAW (Write After Write) Both instructions write same register. Output dep. Solution: Stall or renaming.
Solutions:
• Forwarding/Bypassing: Route result directly from ALU output to next instruction input — no stall needed.
• Pipeline Stall (NOP): Insert bubble (do-nothing cycle) until data is available.
• Compiler Reordering: Rearrange instructions so independent instructions fill the gap.
■ Exam Tip: Table of 3 types + solutions = full marks. Always give an example.
Control Hazard: Arises due to branch instructions. When a branch is fetched, the pipeline doesn't know the next
instruction's address until branch is resolved (EX stage), causing wrong instructions to be fetched.
Solutions:
• Pipeline Flush: Cancel (squash) incorrectly fetched instructions when branch is resolved. Simple but wasteful.
• Delayed Branching: Always execute the instruction after the branch (delay slot). Compiler fills slot with useful
work.
• Static Branch Prediction: Always predict branch NOT taken (or always taken). Simple.
• Dynamic Branch Prediction: Use history of past branches. 2-bit saturating counter — changes prediction only
after 2 consecutive mispredictions. Accuracy: 85–95%.
• Branch Target Buffer (BTB): Cache of branch addresses and predicted targets. Reduces penalty.
■ Exam Tip: 4+ solutions with brief explanation = full marks.
5 Marks
Structural Hazard: Occurs when two or more instructions need the same hardware resource at the same time and
the hardware cannot support all combinations of instructions in simultaneous overlapped execution.
Classic Example:
• Both a LOAD instruction (stage MEM) and an instruction fetch (stage IF) need to access memory simultaneously
— but there is only one memory unit.
• Solution: Use separate Instruction Memory (I-cache) and Data Memory (D-cache) — eliminates this hazard.
Other Examples:
• Single write port in register file → two instructions both need to write back simultaneously.
• Single functional unit for floating point — two FP operations can't proceed together.
Solutions: Resource duplication (add more units), Pipeline stalls, Scheduling.
■ Exam Tip: Definition + classic example + solution = 5/5.
Q. What are Quantitative Techniques in computer design? Explain any two principles.
Quantitative Techniques (from Hennessy & Patterson) provide measurable ways to evaluate and improve
computer performance.
Key Principles:
• Amdahl's Law: Speedup from improving one part is limited by how much that part is used. Speedup = 1 / [(1-f)
+ f/S] where f = fraction enhanced, S = speedup of enhancement.
• Make the Common Case Fast: Optimise the operations that happen most frequently. Even a small
improvement in common case gives big overall gain.
• CPU Performance Equation: CPU Time = Instruction Count × CPI × Clock Cycle Time.
• Principle of Locality: Programs reuse recently accessed data/code (temporal) and access nearby addresses
(spatial) — basis of caches.
• MFLOPS, MIPS: Metrics for reporting performance (though MIPS can be misleading).
■ Exam Tip: Name 4-5 principles with formulas. Amdahl's Law is always asked.
Q. Explain all types of pipeline hazards in detail with solutions and techniques for pipeline
optimization.
Type Explanation
RAW Read After Write — true dependence. Instr j reads register written by instr i. Most common and dangerous.
WAR Write After Read — anti-dependence. Instr j writes before instr i reads. Solved by register renaming.
WAW Write After Write — output dependence. Both write same register. Solved by renaming or stall.
Technique Explanation
Loop Unrolling Replicate loop body N times. Exposes more ILP; reduces loop overhead branches.
Instruction Scheduling Reorder instructions (no semantic change) to fill delay slots and avoid hazards.
Register Renaming Map logical registers to physical registers. Eliminates WAR and WAW hazards.
Speculative Execution Execute instructions before knowing if they're needed (branch speculation).
Branch Prediction Predict branch direction early. Reduces control hazard penalty significantly.
Superscalar Issue Issue multiple instructions per cycle — further hides pipeline latencies.
Memory Hierarchy: Registers → L1 Cache → L2 Cache → L3 Cache → Main Memory (RAM) → Disk.
Goal: Give the illusion of large, fast, cheap memory.
Locality Principle: (1) Temporal — recently used data likely used again soon. (2) Spatial — if address X
accessed, nearby addresses likely accessed next.
Inclusion: Data in L1 is also in L2 and RAM. Coherence: All copies of data must be consistent.
Concept Explanation
Direct Mapped Each memory block maps to exactly ONE cache line. Fast but high conflict misses.
Fully Associative Block can go to ANY cache line. Lowest conflict misses but complex/expensive.
Set Associative N-way: Each block maps to one SET, can go to any of N lines in that set. Best balance.
3 C's of Misses Compulsory (first access), Capacity (cache too small), Conflict (mapping collision).
Write Through Write to cache AND memory simultaneously. Simple, no dirty bit needed.
Write Back Write only to cache; write to memory when block is evicted. Faster but needs dirty bit.
Virtual Memory: Allows programs to use more memory than physically available by using disk as extension of
RAM.
Page: Fixed-size block of virtual address space. Frame: Corresponding physical memory block.
Page Table: Maps virtual page number (VPN) → physical frame number (PFN).
TLB (Translation Lookaside Buffer): Fast cache for page table entries. Avoids full page table lookup on every
access.
Concept Explanation
Page Fault Required page not in RAM → OS loads it from disk. Very expensive (~millions of cycles).
TLB Miss Not in TLB → page table walk. Hardware or OS handles it.
Segmentation Divide memory into variable-size segments (code, data, stack). Each has base+limit.
LRU Least Recently Used — replace page not accessed for longest time. Best practical policy.
FIFO First In First Out — replace oldest loaded page. Simple, suffers Belady's anomaly.
Optimal Replace page not needed for longest future time. Theoretical best; impossible in practice.
Clock Algorithm Approximate LRU using reference bit. Efficient and practical.
Q. Explain cache memory organization. Compare Direct Mapped, Fully Associative, and Set
Associative.
Cache Memory is a small, fast memory between CPU and main memory that stores frequently used
data/instructions.
Type Properties
Direct Mapped 1-way. Block i → cache line (i mod cache_size). Fast, simple. High conflict misses.
Fully Associative Any block → any line. Most flexible. Lowest misses but needs complex comparator
hardware.
2-way Set Assoc. 2 lines per set. Balance of speed and miss rate. Industry standard (L1, L2 caches).
N-way Set Assoc. N lines per set. As N increases → approaches fully associative. L3 often 8 or 16-way.
Virtual Memory allows processes to use more address space than physical RAM. The OS manages mapping
virtual addresses to physical addresses.
Address Translation:
• CPU generates Virtual Address = VPN (Virtual Page Number) + Page Offset.
• TLB checked first: if hit → physical address immediately.
• TLB miss → page table walk to get PFN.
• If page not in RAM → Page Fault → OS loads from disk (swap space).
Mapping Techniques:
• Single-level Page Table: Simple but large for 64-bit address spaces.
• Multi-level Page Table: Hierarchical — only allocate tables for used virtual address space.
• Inverted Page Table: One entry per physical frame — efficient for large address spaces.
■ Exam Tip: Virtual address breakdown + TLB operation + mapping types = full marks.
Policy Comparison
Optimal (OPT) Replace page not needed for longest time in future. Theoretical — needs future knowledge. Best
possible miss rate.
FIFO Replace page that was loaded first. Easy to implement. Suffers Belady's Anomaly (more frames →
more faults!).
LRU Replace page not accessed for longest time. Best practical policy. Approximates OPT. Complex
hardware.
Clock (NRU) Approximate LRU. Reference bit set on access; clock hand sweeps, clears bits, replaces first 0-bit
page.
LFU Least Frequently Used. Replace page with lowest access count. Suffers with old popular pages.
Q. Explain hierarchical memory technology covering cache organization, virtual memory, and
memory replacement policies.
Organization Details
Direct Mapped Block maps to one line. Address = Tag + Index + Offset. Fastest, most conflict misses.
Set Associative N-way: maps to one set, any of N lines. 2-way and 4-way most common.
Fully Associative Maps anywhere. Needs content addressable memory (CAM). Lowest misses.
Write Through Write cache + memory together. Simple; write buffer used to reduce stall.
Write Back Write only to cache; use dirty bit; write to memory on eviction. Faster.
AMAT = Hit TimeL1 + Miss RateL1 × (Hit TimeL2 + Miss RateL2 × Miss PenaltyRAM)
Address Mapping:
• Virtual Address = [VPN | Page Offset].
• Physical Address = [PFN | Page Offset] (offset unchanged).
• Multi-level page tables used for large 64-bit address spaces.
Policy Details
OPT Replace page not needed furthest in future. Impossible in practice. Used as benchmark.
LFU Least frequently used. Can be stale with historical popular pages.
■ Exam Tip: 5 sections; use tables for cache types and replacement. Mention AMAT formula and Belady's
anomaly.
ILP = Instruction-Level Parallelism: Executing multiple instructions simultaneously within a single processor.
ILP Limit: Data dependencies, control hazards, resource conflicts limit actual ILP.
Two approaches: (1) Dynamic — hardware finds and exploits ILP at runtime. (2) Static — compiler finds ILP at
compile time (VLIW).
Concept Explanation
Superscalar Multiple pipelines. Issues 2-8 instructions/cycle. Hardware detects ILP dynamically.
Superpipelined Very deep pipeline (20-30 stages). Higher clock frequency. One issue/cycle but very fast
clock.
VLIW Very Long Instruction Word. Compiler packs multiple operations into one wide instruction
word.
In-order Issue Instructions issued in original program order. Simple, but stalls if hazard occurs.
Tomasulo Dynamic scheduling algorithm. Reservation stations, register renaming, CDB broadcast.
Vector Processor Applies single operation to entire vector (array) of data. SIMD principle.
Array Processor Multiple PEs (Processing Elements) operating in parallel on different data elements.
Superpipelined VLIW
Hardware Compiler (s
VLIW (Very Long Instruction Word): Architecture where the compiler packs multiple independent operations into
a single long instruction word, exploiting ILP statically.
Working: A 256-bit VLIW word might contain: [ALU op | ALU op | FP op | Load | Store | Branch]. All execute in
parallel in one cycle.
Advantages:
• Simple hardware — no dynamic scheduling needed.
• No complex hazard detection hardware.
• Lower power consumption than superscalar.
• Compiler can perform global optimisation.
Disadvantages:
• Complex compiler — must detect all parallelism at compile time.
• Code density problem — many NOP (no-operation) fields when parallelism is low.
• Binary incompatibility — different VLIW machines need different compiled code.
• Poor performance when dependencies limit ILP.
■ Exam Tip: Definition + working + 4 advantages + 4 disadvantages = 5/5.
Vector Processor: A processor that operates on entire arrays (vectors) of data with a single instruction.
• Example: ADD V1, V2, V3 — adds all elements of vector V2 and V3, stores in V1.
• Uses long vector registers (e.g., 64 elements of 64-bit floats).
• Efficient for scientific computing, signal processing, graphics.
• Avoids loop overhead — one instruction replaces an entire loop.
• Modern SIMD extensions (SSE, AVX in Intel) are descendents.
Vector Processor Single processor, vector registers, pipelined functional units. Sequential vector ops.
Array Processor Multiple PEs, one control unit, truly parallel. Each PE has own data.
Technique Description
Loop Unrolling Replicate loop body; schedule across copies; fills pipeline; reduces branch overhead.
Register Renaming Eliminate WAR/WAW; map logical→physical registers. Hardware does this (Tomasulo).
Branch Prediction Predict branch early; speculatively execute down predicted path.
Software Pipelining Compiler overlaps iterations of a loop (like pipelining across loop iterations).
Architecture Description
Superscalar Multiple parallel pipelines; hardware issues 2-8 instr/cycle; in-order or OOO; most modern
CPUs.
Superpipelined Very deep stages (20-30); high clock; one issue/cycle; Inter Pentium 4 style.
VLIW Compiler packs parallel ops in wide instruction; simple hardware; IA-64/DSPs.
EPIC Explicitly Parallel Instruction Computing; like VLIW but with stop bits; Intel Itanium.
• Vector: Pipelined FUs; chaining (result of one vector op fed to next); stride access patterns.
• Array (SIMD): N PEs in lockstep; one controller; massive data parallelism; GPU basis.
• Modern relevance: Intel AVX-512, ARM SVE, NVIDIA CUDA — all SIMD/vector principles.
■ Exam Tip: 5 sections; Tomasulo is very likely 15-mark topic. Draw reservation station diagram if possible.
Concept Explanation
UMA (SMP) Uniform Memory Access. All CPUs share same memory bus. Equal access time. Example:
multi-core desktop.
NUMA Non-Uniform Memory Access. Each CPU has local memory; remote access slower.
Cache Coherence Ensures all cached copies of shared data stay consistent. Protocols: Snooping (MSI, MESI),
Directory.
MESI Protocol States: Modified, Exclusive, Shared, Invalid. Used in Intel SMP systems.
Memory Consistency Specifies order in which memory ops appear to execute. Sequential consistency = all see
same order.
Interconnection How CPUs/memories connect: Bus, Crossbar, Mesh, Hypercube, Omega network.
Cluster Loosely coupled independent computers connected by high-speed LAN. MPI used.
Dataflow Computer Instruction executes when ALL its operands available (data-driven). No program counter.
Systolic Array Network of simple PEs. Data flows rhythmically through PEs. Used for matrix ops, signal
processing.
Reduction Machine Evaluate expressions by repeatedly applying reduction rules. Functional programming model.
SISD Single Instruction, Single Data. Traditional sequential CPU. Von Neumann. Example: Single-core CPU.
SIMD Single Instruction, Multiple Data. Same operation on many data. Example: GPU, Vector processor,
SSE/AVX.
MIMD Multiple Instruction, Multiple Data. Each CPU runs different instructions on different data. Example:
Multi-core, Cluster.
Flynn's Taxonomy (1966) classifies computer architectures based on the number of concurrent instruction
streams and data streams.
Class Description
SIMD 1 instruction, N data. Ideal for data-parallel problems. Example: GPU, MMX, SSE.
MIMD N instructions, N data. Most powerful and common. Example: Multi-core CPU, server clusters.
MIMD sub-types:
• Shared Memory MIMD: All processors access common memory (SMP, NUMA).
• Distributed Memory MIMD: Each has private memory; communicate via messages (cluster, MPP).
■ Exam Tip: Table + MIMD sub-types + examples = guaranteed 5/5.
Cache Coherence Problem: In multiprocessors, multiple caches hold copies of same memory location. If one
CPU modifies it, others see stale data — incoherence!
State Meaning
M — Modified Cache has only valid copy; memory is stale. Cache must write back before eviction.
E — Exclusive Cache has only copy; memory is up-to-date. Can modify without notifying others.
I — Invalid Cache line is invalid/stale. Must fetch from memory or another cache before use.
Snooping: Each cache controller monitors (snoops) the shared bus. On a write, other caches seeing same
address invalidate their copies (Write-Invalidate Protocol).
■ Exam Tip: MESI table + snooping explanation = full marks. Draw state diagram if time permits.
5 Marks
Interconnection Network: The communication fabric connecting processors and memories in a parallel system.
Network Properties
Bus Single shared wire. Simple, cheap. Bandwidth bottleneck. Works for 2-32 processors.
Crossbar Full N×N switch — every processor can connect to every memory simultaneously. Expensive:
O(N²) cost.
Mesh / Torus Processors at grid nodes; connect to neighbours. 2D mesh common in many-core chips. Scalable.
Hypercube N-dimensional cube. Each node connects to N neighbours. Diameter = log■(N). Excellent
bandwidth.
Omega Network Multi-stage interconnect. Log■N stages with N/2 switches per stage. Cost: O(N log N).
Fat Tree Tree with increasing bandwidth near root. Common in HPC clusters (InfiniBand).
Von Neumann Model: Instructions executed sequentially driven by a Program Counter (PC). Instruction flow is
controlled by the programmer.
Dataflow Model: An instruction executes as soon as ALL its input operands are available — no PC needed.
Execution is data-driven.
Parallelism Von Neumann: Sequential (unless parallel hardware added). Dataflow: Inherent, automatic.
Memory Von Neumann: Shared mutable state. Dataflow: No shared state — values passed as tokens.
Example Von Neumann: All conventional CPUs. Dataflow: MIT Tagged Token, Manchester Dataflow.
■ Exam Tip: Comparison table is the key — 6 features clearly compared = full marks.
Systolic Array: A network of tightly coupled simple Processing Elements (PEs) arranged in a regular pattern. Data
flows rhythmically (like heartbeats) from PE to PE, performing computation at each step.
Key Characteristics:
• Data flows in a pipeline-like manner through PEs.
• Each PE receives data, computes, and passes result to next PE.
• High throughput with simple, regular structure.
• Ideal for repetitive computations: matrix multiply, convolution, signal processing.
Applications: Signal processing chips, Google TPU (Tensor Processing Unit) uses systolic arrays for neural
network matrix multiplication.
■ Exam Tip: Definition + characteristics + example + application (TPU!) = 5/5.
Class Details
SIMD One instr, multiple data. GPU, vector. Ideal for graphics, ML.
Network Properties
Q. Explain Non-Von Neumann architectures: Dataflow, Reduction, and Systolic with their
advantages.
Systolic Rhythmic data flow. Regular PE mesh. High throughput. Matrix ops.
■ Exam Tip: 3 architectures × 4 marks + comparison table 3 marks = 15. Google TPU mention = bonus
impression.
UNIT
★
Master Cheat Sheet — Last Revision
■ Key Formulas
Formula Expression
Amdahl's Law Speedup = 1 / [(1-f) + f/S] where f = fraction improved, S = speedup of that part
Effective Access Time EAT = TLB hit rate × (TLB time + Mem time) + (1-hit rate) × (TLB + 2×Mem)
★★ Pipeline hazards (all 3 types) Data + Control + Structural. Solutions for each. Most repeated topic.
★★ Cache organization (3 types) Direct, Set-Associative, Fully Associative. AMAT formula. Always asked.
★★ Page replacement (LRU, FIFO, Table + Belady's anomaly. Numerical very likely.
OPT)
■ Revise starred topics first. Write tables wherever possible. Mention examples and
formulas. Best of luck for MAKAUT! ■