🧠 Jin Hyun Park

Jin Hyun Park / Qual Exam Prep / Computer architecture

Computer architecture

Caches, pipelines, and how to count cycles.

Cache coherence

In a multicore processor, each core has its own L1 cache but they all share main memory. If two cores each hold a copy of the same memory block and one of them writes to it, the other core is now looking at stale data. Keeping the copies consistent is the cache coherence problem (ScienceDirect, ques10). There are two families of solutions.

Copy-on-write

Two processes sharing three pages in memory before process P modifies page 3 After process P modifies page 3, a private copy of page 3 is created for P
Copy-on-write: only page 3 is copied, and only when P writes to it. Source: GeeksforGeeks

The five-stage pipeline

Every instruction passes through the same five stages, in this order:

  1. IF, instruction fetch: read the instruction from memory.
  2. ID, instruction decode: figure out what the instruction is and read its source registers.
  3. EX, execute: do the arithmetic (or compute the memory address).
  4. MEM, memory access: load from or store to memory, if the instruction needs it.
  5. WB, write back: write the result into the destination register.

Single-cycle vs. multi-cycle vs. pipelined

Timing comparison of single-cycle, multiple-cycle, and pipelined implementations
Single cycle, multiple cycle, and pipeline. Source: Duke CPS 104 lecture slides

Cycles per instruction (CPI)

Worked example: CPI computed from an instruction mix of ALU ops, loads, stores, and branches equals 1.9
Worked example: 35% of instructions take 1 cycle, 25% take 2, 15% take 2, 25% take 3, so CPI = 0.35 + 0.5 + 0.3 + 0.75 = 1.9.

Subroutine

Stack-organized computer

Write-through vs. write-back caches

Memory-mapped I/O

RISC vs. CISC

RISC (e.g. ARM, RISC-V)CISC (e.g. x86)
Many registersFewer registers
Fixed-length instructionsVariable-length instructions
Simple instructions, typically one cycle eachComplex instructions that can take many cycles
Larger code size (more instructions to say the same thing)Smaller code size

Operand forwarding

Overview · Useful materials · Sample questions · Algorithms · OS · Networking · Databases · Automata · AI / ML · Things to remember