5.3.10Advanced Microarchitecture

Tournament and TAGE predictors

3,046 words14 min readdifficulty · medium

Overview

Modern wide-issue processors retire only a handful of instructions per cycle (typically 4–8 per cycle), yet keep hundreds of instructions in flight across many pipeline stages. Branch instructions create fundamental uncertainty about what to fetch next—and a single wrong guess can flush all that in-flight work. Tournament and TAGE (Tagged Geometric History Length) predictors represent the evolution from simple adaptive schemes to hybrid meta-predictors that combine multiple prediction strategies. Classic tournament (hybrid) predictors reach ~90–93% accuracy; high-end TAGE variants push beyond 95% on real workloads.

Think of it like having multiple weather forecasters—one excels at predicting rain, another at temperature. You track their accuracy and listen to whoever's been right lately for the current question.

Tournament Predictors: The Meta-Prediction Architecture

What Is a Tournament Predictor?

A tournament predictor (also called hybrid or meta-predictor) combines two or more component predictors using a selector (or choice predictor) that tracks which component has been most accurate recently.

Selector: A2-bit saturating counter per branch (or per set indexed schemes) that votes:

  • 00, 01 → Use predictor 1
  • 10, 11 → Use predictor 2
  • Updated based on which predictor was correct

How Tournament Selection Works

For each branch at PC = 0x4000:

  1. Both predictors make predictions:

    • Local predictor → T
    • Global predictor → NT
  2. Selector reads its counter (say, selector[hash(PC)] = 01 → use local)

  3. Fetch proceeds with local's prediction (T)

  4. On resolution:

    • Actual outcome: T
    • Local was correct → increment selector toward local (01 → 01 stays)
    • Global was wrong → selector doesn't move toward global

The selector adapts: if global starts doing better, repeated correctness shifts the counter toward 10, 11.

Why saturating counters? Prevents oscillation—requires consistent evidence to switch, but adapts when behavior changes (e.g., entering a new loop).

Branch A: Local predictor learns the loop's T, T, .., NT pattern (strong on iteration count).

Branch B: Global predictor sees correlation—if many A's were T (high arr[i]), then B likely T (high sum).

Initially, selector might favor local for A. But B shows no local pattern—global wins for B, selector shifts. The processor ends up using local for A, global for B, achieving the best of both worlds.

Derivation: Why the Selector Works

Start from first principles of prediction error:

Error Rate=P(misprediction)\text{Error Rate} = P(\text{misprediction})

For a single predictor with accuracy a1a_1:

Error1=1a1\text{Error}_1 = 1 - a_1

For two predictors with accuracies a1,a2a_1, a_2:

Errororacle=min(1a1,1a2)\text{Error}_{\text{oracle}} = \min(1 - a_1, 1 - a_2)

An oracle selector (always picks the best) achieves this. A realistic selector with its own accuracy asa_s approximates it:

Errortournament(1as)max(1a1,1a2)+asmin(1a1,1a2)\text{Error}_{\text{tournament}} \approx (1 - a_s) \cdot \max(1 - a_1, 1 - a_2) + a_s \cdot \min(1 - a_1, 1 - a_2)

Why this is better: Even if as=0.8a_s =0.8 (selector is 80% accurate at choosing), you get weighted benefit from both predictors, typically better than either alone.

For real workloads:

  • Local: ~85% accurate
  • Global: ~87% accurate
  • Tournament: ~90–93% accurate (meta-learning exploits that different branches need different strategies)

TAGE: Tagged Geometric History Length

What Problem Does TAGE Solve?

Tournament predictors are limited by their fixed history lengths. Some branches need10 bits of history (nested loops), others need 50+ (complex corelated control flow). Using only one length wastes resources or underfits.

TAGE (Briz et al., 2006) uses multiple tables with geometrically increasing history lengths and tagged entries to match the right history length to each branch.

TAGE Architecture

Tagged Tables (T1, T2, .., Tn): Typically 4-6 tables, each indexed by:

indexi=hash(PC,GHR[0:Li1])\text{index}_i = \text{hash}(\text{PC}, \text{GHR}[0:L_i-1])

where LiL_i is the history length for table ii (e.g., L1=4,L2=8,L3=16,L4=32L_1=4, L_2=8, L_3=16, L_4=32—geometric series).

Each entry contains:

  • Tag: Partial PC + history hash (for collision detection)
  • Prediction counter: 3-bit signed counter (−4 to +3, predict T if≥ 0)
  • Useful bit: Tracks whether this entry has provided correct predictions

How TAGE Makes a Prediction

  1. Compute all indices for T0,T1,,TnT_0, T_1, \ldots, T_n using PC and varying history lengths.

  2. Check tags at each indexed entry. Find longest matching table (highest ii where tag matches).

  3. Use that table's prediction:

    • If T3T_3 matches: use T3T_3's counter
    • If only T1T_1 matches: use T1T_1's counter
    • If none match: use T0T_0 (base predictor)
  4. On resolution:

    • Update the provider component (the one that made the prediction)
    • If prediction was wrong, allocate a new entry in a longer-history table (give it a chance)
    • Update useful bits to track which tables are contributing
Allocate in Tm where m>k (longer history)\text{Allocate in } T_m \text{ where } m > k \text{ (longer history)}

Why allocate longer? The current history length wasn't enough. Try a more specific pattern.

Useful bit: Incremented when this entry predicts correctly and the next-shorter table would have predicted incorrectly. Decremented periodically. Low-useful entries can be replaced (victim selection).

Early in execution:

  • T0T_0 (base): Predicts weakly T (biased from other code)
  • Misprediction → allocate in T1T_1 (4-bit history)

After a few iterations:

  • T1T_1 learns the inner loop pattern (T, T, T, T, NT)
  • Correct predictions → useful bit incremented

When outer loop changes:

  • Outer loop iteration affects pattern (new i → different data values)
  • T1T_1 starts mispredicting → allocate in T2T_2 (8-bit history)
  • T2T_2 learns the two-level pattern (inner × outer)

Result: TAGE automatically discovers that this branch needs 8 bits of history, not 4, by trying progressively longer scales.

Derivation: Why Geometric History Lengths?

Consider the resource trade-off:

  • Total entries: NN (fixed hardware budget)
  • If using uniform lengths (all 16-bit), you have NN entries at one scale.
  • If using geometric (L1=2,L2=4,L3=8,L4=16,L5=32L_1=2, L_2=4, L_3=8, L_4=16, L_5=32), distribute NN entries across 5 tables.

Coverage: Geometric ensures you can match any history length LL by picking the table with LiL<Li+1L_i \leq L < L_{i+1}. The relative precision loss is bounded:

LLiLLi+1LiLi+1=11r\frac{L - L_i}{L} \leq \frac{L_{i+1} - L_i}{L_{i+1}} = 1 - \frac{1}{r}

where rr is the geometric ratio (typically r=2r=2). With r=2r=2, maximum relative error is 50%, but in practice, most branches have characteristic scales (loops are often powers of 2 in length).

Why not linear (4, 8, 12, 16)? Wastes entries on mid-range lengths. Branches either need very short or very long history—geometric spacing concentrates resources at extremes.

Tournament vs. TAGE: When to Use Each

Modern CPUs: Most use TAGE or TAGE variants (Intel Skylake onward, AMD Zen, ARM Neoverse). Tournament predictors were dominant in the 2000s (Alpha 21264, Pentium 4) but have been supplanted.

Why it feels right: The name "tournament" suggests a real-time competition where the best wins.

The fix: The selector uses past accuracy to predict future accuracy. It's a meta-predictor itself, with its own 2-bit state machine. During phase changes (e.g., entering a new function), the selector might still favor the wrong predictor for a few branches until it adapts.

Impact: Tournament accuracy≠ max(local, global) accuracy. It's typically better than either alone, but not perfect. Mispredictions still occur during selector adaptation.


Why it feels right: More information → better prediction, so TnT_n (longest) should dominate.

The fix: Longer history ≠ better prediction if the branch doesn't have that much correlation. A random branch with no pattern benefits from the base predictor (simple bias), not from64 bits of uncorrelated history. TAGE uses tag matching to ensure the history is relevant—if the tag doesn't match, that entry isn't about this branch's pattern.

Impact: Forcing longest history causes aliasing (unrelated branches collide in high-history tables, polluting predictions). TAGE's allocation policy ensures you only use long history when needed.


Recall Explain to a 12-Year-Old

Imagine you're trying to guess if your friend will want to play soccer after school. Sometimes you can tell by asking "Did they play yesterday?" (short history). But sometimes you need to know "Have they been tired all week? Did they have a big test?" (long history).

A tournament predictor is like having two friends who are good at guessing: one watches yesterday, one watches the whole week. You keep score: whoever's been right more lately, you listen to them.

TAGE is even smarter: it keeps five guessers, each watching different time scales—1 day, 3 days, a week, a month, a season. When you ask "Will they play today?", TAGE checks all five and uses the most specific one that has seen this exact situation before (like, "Last time they were tired all week AND had a test, they didn't play").

So TAGE can handle simple patterns (just look at yesterday) and complex patterns (need the whole season's data) without wasting space on the wrong time scale.


Connections

  • 5.3.8-Two-level-adaptive-predictors — TAGE extends two-level by using multiple history lengths
  • 5.3.9-Gshare-and-local-predictors — Tournament combines gshare (global) with local
  • 5.3.11-Branch-target-bufers — Predicted direction is useless without predicted target
  • 5.4.2-Speculative-execution — Wrong predictions waste all speculative work
  • 7.2.5-Cache-coherence-and-branch-predictors — Multi-core systems share branch history

For Tournament: "Two predictors duel, selector is the judge—judge uses past wins to pick the future winner."


#flashcards/hardware

What is the key innovation of a tournament predictor? :: It combines multiple component predictors (typically local + global) using a selector that tracks which has been more accurate recently, allowing the processor to use the best strategy for each branch type.

What does the selector in a tournament predictor actually store?
A 2-bit saturating counter per branch (or per set) that votes for predictor 1 (00, 01) or predictor 2 (10, 11), updated based on which predictor was correct.
Why can't a single fixed-history-length predictor achieve >95% accuracy?
Different branches need different history lengths: loops need short history (4-10 bits), corelated branches need medium (16-32 bits), deep call chains need long (64+ bits). Fixed length either wastes resources or underfits.
What does TAGE stand for and what is its core idea?
Tagged Geometric History Length. Uses multiple tables with geometrically increasing history lengths (4, 8, 16, 32 bits) and tagged entries; predicts using the longest matching history for each branch.
How does TAGE decide which table to use for a prediction?
Computes indices in all tables using PC + varying history lengths, checks tag matches, uses the highest-indexed (longest-history) table with a matching tag, falls back to base predictor if none match.
What happens in TAGE when a prediction is wrong?
The provider table is updated, and new entry is allocated in a longer-history table (one with more bits of GHR) to capture a more specific pattern that the current table missed.
Why does TAGE use geometric (2×) spacing instead of linear spacing for history lengths?
Branches typically need history at scale-invariant lengths (loops are powers of 2). Geometric spacing concentrates resources at short and long extremes where most branches cluster, avoiding waste on intermediate lengths.
What is the "useful bit" in a TAGE entry?
A bit tracking whether this entry has provided correct predictions that differed from the next-shorter table. Low-useful entries can be replaced to avoid wasting space on unhelpful patterns.
In a tournament predictor, when does the selector counter NOT change?
When both predictors agree (both correct or both wrong)—no evidence to prefer one over the other.
Why is TAGE more accurate than tournament predictors on modern workloads?
Modern code has diverse history needs (from simple loops to complex state machines). TAGE's multiple history lengths adapt to each branch's characteristic scale, while tournament is limited to two fixed lengths.
What is the typical accuracy range for tournament vs TAGE predictors?
Tournament: ~90-93%, TAGE: ~95-96% on SPEC benchmarks. The reduction in mispredictions significantly boosts performance on branch-heavy code (since mispredictions stall the pipeline).
How many instructions do modern wide-issue CPUs actually retire per cycle?
Only a handful (typically 4-8 per cycle), though hundreds may be in flight across the pipeline stages at once. This is why branch mispredictions are costly—they flush all that in-flight work.

Concept Map

create

solved by

combines

combines

uses

uses

chooses via

2-bit saturating

favors

reaches

evolves into

reaches

Branch instructions

Fetch uncertainty

Tournament predictor

Local predictor

Global predictor

Per-branch history

Global history GHR

Selector counter

Update rule

More accurate component

90-93% accuracy

TAGE predictor

95%+ accuracy

Hinglish (regional understanding)

Intuition Hinglish mein samjho

Dekho beta, yaha core idea bahut simple hai — koi bhi ek branch predictor sab situations me best nahi kaam karta. Kuch branches loop counters ki tarah local pattern follow karte hai (T, T, T, phir NT), kuch branches ek dusre se corelated hote hai (agar a > 0 hai toh usually b > 0 bhi hoga — ye global pattern hai), aur kuch branches almost hamesha ek hi taraf jaate hai jaise error-handling code. Toh Tournament predictor ka jugaad ye hai ki hum do ya zyada predictors ko saath rakhte hai aur ek chota sa "selector" (2-bit saturating counter) rakhte hai jo track karta hai ki recent me kaunsa predictor zyada sahi nikla. Jo bhi sahi rehta hai, uski baat sunte hai — bilkul jaise multiple weather forecasters me se jo consistently sahi bolta hai uspe trust karte ho.

Ab ye selector kaam kaise karta hai — jab dono predictors alag-alag prediction dete hai, tab jo correct nikalta hai uski taraf counter shift ho jaata hai. Saturating counter isliye use karte hai taaki thoda oscillation na ho — matlab ek-do galti se hi predictor switch na kare, evidence consistent hona chahiye. Lekin agar branch ka behaviour badalta hai (jaise naye loop me enter kar rahe ho), toh counter dheere-dheere adapt bhi kar leta hai. Result ye ki ek hi program me processor Branch A ke liye local predictor use karega aur Branch B ke liye global — dono duniya ka best mil jaata hai.

Ye matter kyu karta hai? Kyunki modern wide processors hundreds of instructions ko ek saath in-flight rakhte hai, aur agar branch ka ek bhi galat guess ho gaya toh saara kaam flush karna padta hai — huge performance loss. Simple predictors ~90-93% tak pahuch jaate hai, par TAGE jaise advanced hybrid predictors 95% se bhi upar chale jaate hai. Itne high stakes pe har 1% accuracy improvement real speed me convert hota hai, isiliye tournament aur TAGE predictors modern microarchitecture ka bahut important part hai.

Go deeper — visual, from zero

Test yourself — Advanced Microarchitecture

Connections