0% found this document useful (0 votes)
62 views

Gshare and Pshare Branch Predictors

The document provides a comprehensive analysis of Gshare and Pshare branch predictors, highlighting their mechanisms, advantages, and disadvantages. Gshare utilizes global history for branch prediction while Pshare focuses on local history, making them suitable for different scenarios in modern processors. Both predictors are employed in various CPU architectures, with ongoing research aimed at enhancing their performance through hybrid models and advanced techniques.

Uploaded by

maneabhishek5355
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
62 views

Gshare and Pshare Branch Predictors

The document provides a comprehensive analysis of Gshare and Pshare branch predictors, highlighting their mechanisms, advantages, and disadvantages. Gshare utilizes global history for branch prediction while Pshare focuses on local history, making them suitable for different scenarios in modern processors. Both predictors are employed in various CPU architectures, with ongoing research aimed at enhancing their performance through hybrid models and advanced techniques.

Uploaded by

maneabhishek5355
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Gshare and Pshare Branch

Predictors: A Comprehensive
Analysis
Branch prediction is crucial for high-performance superscalar and out-of-order processors.
Two widely used index-sharing predictors are Gshare and Pshare, both of which attempt
to improve accuracy while managing aliasing in Pattern History Tables (PHTs).

1. Gshare Branch Predictor


Gshare (Global Sharing Predictor) was introduced by Scott McFarling (1993) and is a
global-history-based branch predictor. Instead of using a simple concatenation of global
history and PC (GAg predictor), Gshare XORs the PC with the global history register to
create a more distributed PHT index.

How Gshare Works

1. Branch History Register (BHR) stores recent branch outcomes (e.g., last 12
branches).
2. The lower bits of the program counter (PC) are XORed with the BHR.
3. The result is used to index the PHT, which contains 2-bit saturating counters for
branch predictions.
4. The PHT counter updates based on actual branch behavior, adjusting over time.

📌 Key Idea: XORing spreads out PHT index entries more evenly, reducing aliasing
conflicts.

📌 Pros of Gshare

✔ Better utilization of PHT entries: The XOR operation reduces destructive aliasing
compared to GAg.
✔ Effective for correlated branches: Captures global branch behavior efficiently.
✔ Simple implementation: Only modifies the index function, making it hardware-
friendly.

❌ Cons of Gshare

✖ Not ideal for local branch patterns: Since it uses global history, it may fail for
branches that are locally dependent.
✖ Increased indexing complexity: The XOR operation adds latency, impacting access
speed in deep pipelines.
✖ Aliasing still exists: While less than GAg, some branches still overwrite each other's
history.

2. Pshare Branch Predictor


Pshare (Per-Address Sharing Predictor) is a local-history-based version of Gshare. Instead of
a global history register, Pshare maintains per-address branch history (BHT) entries.

How Pshare Works

1. Each static branch address maps to a unique history register (BHT).


2. The BHT stores the recent outcomes of a given branch.
3. The stored history is XORed with the PC to index the PHT.
4. The PHT counter predicts the branch outcome and updates accordingly.

📌 Key Idea: Instead of relying on a single global history, Pshare tracks each branch
individually.

📌 Pros of Pshare

✔ Less interference between different branches: Since each branch stores its own history,
there is less aliasing compared to Gshare.
✔ Better for loops and repetitive patterns: Works well when a branch is dependent on its
own previous executions.
✔ More accurate in localized patterns: Avoids mixing up unrelated branch histories.

❌ Cons of Pshare

✖ Higher storage cost: Each branch needs its own BHT entry, consuming more memory
than Gshare.
✖ Poor at capturing global correlations: If a branch depends on other branches'
outcomes, Pshare fails to predict accurately.
✖ More complex hardware implementation: Since each branch address maintains a
separate history register, BHT lookups increase latency.

3. Gshare vs. Pshare: Key Differences


Feature Gshare Pshare
Branch History Type Global Per-Address (Local)
Indexing Method BHR ⊕ PC (XOR) BHT ⊕ PC (XOR)
Aliasing Reduction Moderate High (avoids global aliasing)
Hardware Simple Higher (requires BHT)
Feature Gshare Pshare
Complexity
Correlated branches (global Localized branch behavior
Best For
patterns) (loops)
Weakness Fails for local patterns Fails for correlated branches
Storage Cost Low High

4. Real-Life Use Cases


Both Gshare and Pshare are used in modern processors to improve instruction
throughput.

🔹 Gshare Use Cases

1. Intel Processors (Pentium Pro, Pentium 4, Core series)


o Pentium 4 (NetBurst Architecture) used a modified Gshare-based
predictor.
o Modern Intel Core i7 processors still use Gshare-inspired tournament
predictors.
2. AMD Athlon & Ryzen
o AMD CPUs favor global history-based predictors like Gshare due to
efficient aliasing management.
3. IBM POWER4 and Alpha 21264
o Used Gshare-based predictors with large PHT tables to handle deep
pipelines.

🔹 Pshare Use Cases

1. IBM POWER4 (2002)


o IBM implemented Pshare-like per-address history tracking to improve
loop prediction.
2. AI & Gaming Processors
o Some AI accelerators and GPUs (e.g., NVIDIA & AMD) use Pshare-style
predictors for repetitive control logic.
3. Embedded Processors (ARM)
o ARM-based mobile processors implement Pshare variants for power-
efficient branch prediction.

5. Latest Research Papers (Post-2000)


Here are some recent research papers discussing Gshare and Pshare advancements:

1. Jiménez & Lin (2003) - "Neural Methods for Dynamic Branch Prediction"
oThis paper compared Gshare and Perceptron-based predictors and found
that Perceptron predictors outperform Gshare for linearly separable
branches.
2. Tendler et al. (2002) - "IBM Power4 Architecture"
o Describes how IBM POWER4 used global-history and per-address branch
predictors in a hybrid approach.
3. Seznec et al. (2006) - "The TAGE Predictor"
o TAGE (TAgged GEometric) predictors improve upon Gshare by using
multiple tables with varying history lengths.

6. Summary & Takeaways


🔹 Gshare is a global-history-based predictor that XORs PC and history to reduce
aliasing.
🔹 Pshare is a per-address-history-based predictor that tracks each branch separately,
improving local prediction accuracy.
🔹 Gshare is better for globally correlated branches, while Pshare excels in loops and
repetitive execution patterns.
🔹 Modern CPUs use hybrid predictors, combining Gshare (global) and Pshare (local) for
optimal performance.
🔹 Recent research (post-2000) focuses on hybrid models that integrate neural networks,
TAGE, and machine learning to further enhance prediction accuracy.

In the future, branch prediction will likely evolve to include AI-driven and statistical
models, further reducing misprediction penalties in deep pipelines. 🚀

You might also like