This project implements multiple branch prediction strategies and provides tools for performance analysis and comparison.
- Overview
- Implemented Predictors
- Installation and Build
- Usage
- Performance Analysis
- Technical Details
- Results
This project implements and compares different branch prediction algorithms used in modern processors. Branch prediction is critical for processor performance as it helps predict whether conditional branches will be taken or not taken, allowing the processor to speculatively execute instructions along the predicted path.
The project includes:
- Static Predictor: Always predicts taken
- Gshare Predictor: Uses global history with XOR indexing
- Tournament Predictor: Combines global and local predictors with a chooser
- Custom TAGE Predictor: Advanced predictor using geometric history length
- Type:
--static - Description: Always predicts that branches will be taken
- Use Case: Baseline for comparison
- Type:
--gshare:<ghistory_bits> - Description: Uses global branch history XORed with PC bits to index a pattern history table
- Parameters:
ghistory_bits: Number of bits for global history (typically 10-13)
- Example:
--gshare:13
- Type:
--tournament:<ghistory>:<lhistory>:<index> - Description: Combines global and local predictors using a chooser table
- Parameters:
ghistory: Global history bitslhistory: Local history bitsindex: PC index bits
- Example:
--tournament:9:10:10
- Type:
--custom - Description: Advanced predictor using geometric history lengths and tagged entries
- Features:
- Multiple components with different history lengths
- Tagged entries to reduce aliasing
- Bimodal fallback predictor
- Memory usage: ~43KB (within 64KB limit)
- GCC compiler (version 5.4 or later recommended)
- Make utility
- Python 3 (for analysis scripts)
- bzip2 (for trace decompression)
# Navigate to the source directory
cd src/
# Clean previous builds
make clean
# Build the predictor
makeThis creates an executable named predictor in the src/ directory.
# Run on compressed trace file
bunzip2 -kc trace.bz2 | ./predictor --gshare:13
# Run with verbose output
bunzip2 -kc trace.bz2 | ./predictor --gshare:13 --verbose--help: Display usage information--verbose: Output all predictions to stdout--static: Use static predictor--gshare:<bits>: Use Gshare predictor with specified history bits--tournament:<g>:<l>:<i>: Use tournament predictor with specified parameters--custom: Use custom TAGE predictor
# Generate performance comparison chart
python analyze_results.pyThis shows the performance comparison across all predictors and trace files.
Based on the analysis script, the custom TAGE predictor typically achieves the lowest misprediction rates:
- Floating-point traces: 0.3-0.8% misprediction rate
- Integer traces: 0.2-8.1% misprediction rate
- Memory traces: 0.5-6.8% misprediction rate
- Uses global history register XORed with PC bits
- 2-bit saturating counters for predictions
- History updated by shifting in new outcomes
- Combines global and local predictors
- Chooser table selects between predictors
- All counters are 2-bit saturating counters
- Based on Alpha 21264 architecture
- Components: 6 geometric history length components
- Tags: Partial tags to reduce aliasing
- Bimodal: Fallback predictor for tag misses
- Memory: ~43KB total usage
- Features:
- Geometric history lengths: 76, 44, 26, 15, 9, 5
- Tagged entries with partial tags
- Useful counters for entry allocation
- Compressed history for efficiency
NT NT NT
-----> -----> ----->
ST WT WN SN
<----- <----- <-----
T T T
- SN: Strongly Not Taken
- WN: Weakly Not Taken
- WT: Weakly Taken
- ST: Strongly Taken
The custom TAGE predictor demonstrates superior performance across all trace types:
| Trace | Tournament | Gshare | Custom |
|---|---|---|---|
| fp_1 | 0.994% | 0.825% | 0.805% |
| fp_2 | 3.410% | 1.678% | 0.361% |
| int_1 | 13.846% | 13.839% | 8.133% |
| int_2 | 0.472% | 0.420% | 0.256% |
| mm_1 | 3.277% | 6.696% | 0.565% |
| mm_2 | 9.145% | 10.138% | 6.833% |
The TAGE predictor achieves an average improvement of:
- 67% over Tournament predictor
- 72% over Gshare predictor