15. Computer Architecture: Von Neumann Model, Memory Bottleneck, and Memory Hierarchy
Von Neumann Architecture and Instruction Execution
The Von Neumann Model serves as the foundational architectural blueprint for modern computing platforms, including laptops, mobile devices, and high-end enterprise servers.
System Architecture Structure:
Central Processing Unit (CPU): Executes operational instructions.
Memory Subsystem: Stores both program instructions and data operands (variables operated upon by instructions).
Phases of Instruction Execution:
Instruction Fetch (): Retrieves the target instruction from memory.
Instruction Decode (): Interprets the instruction within the CPU to identify required operations and operand requirements.
Operand Fetch (): Retrieves required data variables from memory (e.g., fetching variables and for an addition operation).
Instruction Execution (): Performs the decoded operation inside the CPU (e.g., adding and ).
Result Writeback (): Stores the execution output back into memory (e.g., writing the result into variable ).
Instruction Operand Variations:
Standard multi-operand instructions perform operations across multiple memory variables.
Single-operand or zero-operand control instructions (e.g.,
stoporhalt) execute without needing operand fetch phases.
Timing Categorization of Execution Phases:
Memory Access Time (): Aggregates memory-bound operations, where .
CPU Processing Time (): Aggregates internal CPU operations, where .
Total Instruction Execution Time (): Evaluated as .
Memory Bottleneck and Amdahl's Law
The Von Neumann / Memory Bottleneck Principle:
As CPU hardware performance scales higher () through frequency scaling or multi-core integration (e.g., 4-core, 8-core, 16-core configurations), the overall execution time approaches memory latency ().
Total instruction execution speed shifts from being CPU-bound to being memory-bound.
Relationship to Amdahl's Law:
Optimizing CPU speed without optimizing memory latency causes the unoptimized memory subsystem to dominate total execution time.
Quantitative Acceleration Example:
Baseline system: and , yielding .
CPU sped up by : and , yielding .
CPU sped up by : and , yielding .
CPU sped up by : and , yielding .
Limit: Instruction execution time cannot drop below the memory floor regardless of CPU speed improvements.
Multi-Core Performance Implications:
Adding CPU cores turns the processor into a larger, higher-throughput compute engine that requires data and instruction delivery at proportional speeds.
Neglecting memory latency starves multi-core processors, turning memory bandwidth into a primary bottleneck.
Cost-Performance Analysis of All-SRAM Memory
Pure Static RAM (SRAM) Memory System Feasibility:
Fabricating main memory using the fast transistor technology of CPUs eliminates memory latency bottlenecks but introduces severe financial constraints.
Back-of-the-Envelope Cost Derivation:
High-end microprocessor chip retail price: to (evaluated at for order-of-magnitude analysis).
Microprocessor transistor density: transistors ().
Cost per CPU transistor: per transistor.
SRAM cell design constraints: Requires transistors per bit cell (comprising 4 transistors across 2 cross-coupled NOR gates, plus clocking/access logic gates).
Cost per bit of SRAM: per bit.
Storage cost calculation for SRAM:
.
Cost of SRAM:
System cost scale for a typical system memory: (approaching to ).
System Cost Balance Principle:
Balanced computer engineering allocates system budgets across three equal tiers:
Central Processing Unit (CPU).
Memory and Storage systems.
Input/Output (I/O) interfaces (displays, keyboards, joysticks, VR/AI goggles).
Spending on a CPU and to on memory destroys balanced economic trade-offs.
Locality Principles and Working Set Hypothesis
Optimal Design Goal:
Construct a memory system delivering an effective latency matching fast SRAM () while maintaining a cost per bit matching dynamic RAM (DRAM, per GB).
The Principle of Locality:
Execution locality dictates memory system throughput, analogous to how geographic location dictates real estate value.
Spatial Locality:
Definition: If a program accesses memory address at time , memory accesses during a small subsequent time window will be clustered in the address range in memory space.
Causes: Sequential program instruction execution () and linear traversal of continuous data structures (such as arrays and matrices).
Temporal Locality:
Definition: If a program accesses memory address at time , the same address is highly likely to be accessed repeatedly within time interval .
Causes: Program execution loops repeating code blocks, reused variables, and induction variables inside loop conditions.
Destruction of Locality and System Stress Testing:
Unstructured programs containing random
gotojumps continuously branch across non-contiguous memory locations, destroying spatial and temporal locality.Synthetic stress-test workloads purposefully inject random jump operations to force worst-case memory latency performance.
The Working Set Hypothesis:
Although a program's total address space (all instructions and data) spans gigabytes, the program actively accesses only a localized subset—the working set (kilobytes to megabytes)—during any given phase of execution .
Operational Analogies:
Home Library vs. Nightstand: A reader owns 1,000 books in a library, but keeps only 2 active books on a nightstand for immediate bed-time reading.
Pantry vs. Kitchen Counter: A cook keeps bulk goods in a pantry, but places active tools and ingredients directly on the counter.
Web Browser Caches: Browsers pre-fetch pages hyperlinked off an active web page and store them locally to accelerate navigation.
Memory Hierarchy Architecture
Hierarchy Levels (Ordered by Speed, Capacity, and Cost):
Registers and Caching Layer (SRAM): On-chip integration; latency of ; cost of thousands of dollars per GB; capacity in KB to MB.
Main Memory Layer (DRAM): System motherboard board integration; latency of ( clock cycles); cost of per GB; capacity in GB.
Solid State Storage (SSD / Flash Memory): Intermediate non-volatile storage layer situated between DRAM and mechanical media.
Magnetic Disk Storage: Secondary bulk media; high latency; high capacity in TB; used for archiving in servers and desktops.
Cloud / Network Storage: Remote server farms accessible via network interfaces; infinite scale; used purely for long-term archiving.
Physical Proximity Rule:
Memory levels with the lowest latency are positioned physically closest to the processor (e.g., registers and cache on the CPU die, DRAM on the main system board).
System Virtualization and Memory Transparency:
Multi-tiered hardware structures operate transparently to software developers.
Applications operate across a unified virtual memory space without needing manual instructions to move variables between registers, cache, DRAM, or secondary storage.
Cache Operations and Average Memory Access Time
Line/Block Transfer Units:
Data transfers between main memory (DRAM) and cache (SRAM) occur in multi-word units called blocks or cache lines.
Transferring complete blocks exploits spatial locality by prefetching adjacent code and data operands.
Cache Operational Terminology:
Cache Hit: Requested memory location exists in cache; access completes in fast hit time .
Cache Miss: Requested memory location is absent; triggers a miss penalty while transferring the containing block from DRAM into cache.
Hit Rate (): The proportion of memory accesses satisfied directly by the cache:
Miss Rate (): The proportion of memory accesses that miss the cache:
Average Memory Access Time (AMAT) Equation:
Latency Performance Limits:
System designs target hit rates of ( or higher).
A hit rate of () is impossible because working sets dynamically shift over execution time (such as exiting a loop phase), triggering unavoidable transient miss spikes.
CPU Stall Calculations and Effective CPI
CPU Miss Handling Sequence:
On a cache miss, the CPU pipeline stalls (waits) while the required block transfers from DRAM into cache.
Instruction Cache Miss: Fetches the missing code block into the instruction cache (ICache) and restarts instruction fetch.
Data Cache Miss: Fetches the missing operand block into the data cache (DCache) and completes the pending load/store operation.
Total CPU Execution Time Formulation:
Memory Stall Cycle Breakdown: \text{Write Stall Cycles} = \text{Write Accesses} \times \text{Write Miss Rate} \n\times \text{Write Penalty}
Simplified Memory Stall Cycle Equations:
Assuming equivalent read and write penalties/miss rates:
Expressed via Instruction Count (IC):
Effective Cycles Per Instruction (CPI):
ICache Access Ratios:
Accesses per instruction equal under standard designs where instruction width matches cache bus width.
Requires multiple accesses per instruction (e.g., accesses) if instruction width exceeds cache width (e.g., fetching a instruction across a cache bus).