COA 2027 Rank-Decider: Write-Back Dirty Evictions, VIPT Cache Constraint & 2-Bit Branch Predictors
Write-Through vs Write-Back + Write-Allocate memory traffic numericals, Virtually Indexed Physically Tagged (VIPT) synonym-free page-size bound, 1-bit vs 2-bit saturating branch predictors, and MSI/MESI coherence.
1. Write-Through vs Write-Back Memory Traffic (Classic 2-Mark GATE NAT)
| Policy Pair | On Write Hit | On Write Miss | Extra Metadata per Cache Line |
|---|---|---|---|
| Write-Through + No-Write-Allocate | Updates Cache AND Main Memory | Writes directly to Main Memory only | Valid bit ( bit) |
| Write-Back + Write-Allocate | Updates Cache only, sets Dirty = 1 | Fetches block into Cache, then writes (Dirty = 1) | Valid () + Dirty () bits |
Dirty-Bit Eviction Trap: In a Write-Back cache, a read or write miss that evicts a clean block (Dirty = 0) performs memory block transfer (fetch new block). If the evicted victim is dirty (Dirty = 1), it performs memory block transfers (write back dirty victim + fetch new block)!
2. Virtually Indexed, Physically Tagged (VIPT) L1 Caches
Why do modern CPUs use VIPT for L1 caches? Because bits [Page_Offset - 1 : 0] are identical in Virtual and Physical addresses! If Set_Index + Block_Offset <= Page_Offset, the CPU indexes the L1 SRAM sets in parallel with the TLB translation — achieving virtual-cache speed with physical-cache tag safety and zero aliasing!
- Example: With () pages and an -way set-associative L1 cache, maximum alias-free VIPT cache size is (exact Intel/ARM L1 design!).
3. Dynamic Branch Prediction: 1-Bit vs 2-Bit Saturating Counter
Consider an inner loop executing iterations per outer-loop invocation:
- 1-Bit Predictor: Mispredicts twice per outer invocation — once when exiting the loop (), AND once upon re-entering the loop on the next outer pass! Steady-state misprediction rate .
- 2-Bit Saturating Counter (
00 SNT, 01 WNT, 10 WT, 11 ST): Requires two consecutive wrong outcomes to flip prediction! Exiting the loop moves11 (ST) -> 10 (WT)(still predicts Taken on next entry!), so steady-state misprediction rate drops in half to !
Practice Questions on This Chapter (3)
A processor uses virtual pages and a Virtually Indexed, Physically Tagged (VIPT) L1 data cache with cache blocks. To avoid virtual aliasing without OS page coloring (so Set Index + Block Offset Page Offset), what is the minimum set-associativity required for a L1 cache?
A Write-Back, Write-Allocate L1 cache has hit time and miss rate . Transferring one cache block to or from Main Memory takes , and of evicted cache blocks are dirty. What is the Average Memory Access Time (AMAT) in nanoseconds?
An inner for loop executes exactly iterations each time an outer while loop invokes it ( outer invocations). What are the steady-state branch prediction accuracies on the inner-loop backward branch for a 1-bit predictor vs a 2-bit saturating counter predictor?