[!INFO] This repository based on the original LLBP repository and contains an extended version: LLBP-X.
The Last-Level Branch Predictor (LLBP) is a microarchitectural approach that improves branch prediction accuracy through additional high-capacity storage backing the baseline TAGE predictor. The key insight is that LLBP breaks the branch predictor state into multiple program contexts, which can be thought of as a call chain. Each context comprises only a small number of patterns and can be prefetched ahead of time. This enables LLBP to store a large number of patterns in a high-capacity structure and prefetch only the patterns for the upcoming contexts into a small, fast structure to overcome the long access latency of the high-capacity structure (LLBP). LLBP was presented at MICRO 2024.
LLBP-X is an enhancement of the original LLBP design by introducing dynamic context depth adaptation, which yields a significantly better distribution of patterns for hard-to-predict branches, thereby reducing both pattern set contention and pattern duplication. LLBP-X is presented at HPCA 2026.
This repository contains the source code of the branch predictor models and infrastructure to evaluate LLBP-X's prediction accuracy.
The artifact consists of two main parts:
- The branch predictor simulator based on the CBP framework to evaluate the prediction accuracy of LLBP-X and other branch predictor models on server traces. The aim of this framework is to provide a fast and easy way to evaluate different branch predictor configurations. It does not model the full CPU pipeline, only the branch predictor.
- A gem5 implementation of LLBP-X to enable full-system simulations with gem5. (jump to gem5 Simulation for details)
The infrastructure and the following commands have been tested with the following system configuration:
- Ubuntu 22.04.2 LTS
- gcc 11.4.0
- cmake 3.22.1
See the CI pipeline for other tested system configurations.
# Install cmake
sudo apt install -y cmake libboost-all-dev build-essential pip parallel wget
# Python dependencies for plotting.
pip install -r analysis/requirements.txt
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Debug ..
cd ..
# Build the simulator
cmake --build ./build -j 8The traces use to evaluate LLBP collected by running the server applications on gem5 in full-system mode. The OS of the disk image is Ubuntu 20.04 and the kernel version is 5.4.84. The traces are in the ChampSim format and contains both user and kernel space instructions. The traces are available on Zenodo at 10.5281/zenodo.13133242.
The download_traces.sh script in the scripts folder will download all traces from Zenodo and store them in the traces directory.:
./scripts/download_traces.shThe simulator can be run with the following command and takes as inputs the trace file, the branch predictor model, the number of warmup instructions, and the number of simulation instructions.
The branch predictor model can be either tage64kscl, tage512kscl, llbp, llbp-timing, llbpx, or llbpx-timing.
The definition of the branch predictor models can be found in the
bpmodels/base_predictor.ccfile.
./build/predictor --model <predictor> -w <warmup instructions> -n <simulation instructions> <trace>For convenience, the simulator contains a script to run the experiments on all evaluated benchmarks for a given branch predictor model (./scripts/eval_benchmarks.sh <predictor>).
The results in the form of a stats file are stored in the results directory. Note, the simulator will print out some intermediate results after every 5M instructions, which is useful to monitor the progress of the simulation.
The Jupyter notebook (./analysis/mpki.ipynb) can be used to parse the statistics file and plot the branch MPKI for different branch predictor models.
To reproduce a similar graph as in the paper (Figure 9), we provide a separate script (./scripts/eval_all.sh) that runs the experiments for all evaluated branch predictor models and benchmarks.
Note: As we integrated the LLBP with ChampSim for the paper, the results might slightly differ from the presented numbers in the paper.
The script can be run as follows:
./scripts/eval_all.shOnce the runs are complete, open the Jupyter notebook and hit 'Run all cells'.
For simulating LLBP-X in gem5, we provide an implementation of LLBP-X based on CBP model described above. For implementing LLBP-X in gem5, we tried to reuse as much of the existing TAGE-SC-L implementation as possible to reduce code redundancy and enable easy integration into gem5. However, due to differences in the code structure of gem5 and CBP, there may be slight differences in the prediction accuracy of the models.
To simulate LLBP-X in gem5, you need to have gem5 cloned with all its prerequisites installed. The LLBP-X implementation has been tested with gem5 version v25.1.0.0. For further details on how to install gem5, please refer to the official gem5 documentation.
To integrate LLBP-X into gem5, copy the contents of the gem5models folder into the src/cpu/pred directory of your gem5 installation. Furthermore, apply the patch ./scripts/llbpx.patch which updates the SCons scripts and the TAGE-SC-L models to enable the integration. Then rebuild gem5.
Note that you can use the provided
./scripts/setup_gem5.shscript, which will clone gem5, check out a compatible commit, copy the LLBP-X files, and build gem5 for you. The model is compatible with gem5 version v25.1.0.0 and later.
cd <path-to-gem5>/
# Copy LLBP-X files
cp -r <path/to/LLBP-X>/gem5models/* src/cpu/pred/
# Apply patch
git apply <path/to/LLBP-X>/scripts/llbpx.patch
# Build gem5
scons build/ARM/gem5.opt -j`nproc`The scripts folder contains a simple configuration script (se-llbp.py) to run a hello world program in gem5's syscall emulation mode. You can run the simulation as follows:
./build/ARM/gem5.opt ./../scripts/se-llbp.py --bp=LLBPXThis will run the Hello World program with LLBP-X as the branch predictor. Can change the --bp argument to LLBPX, LLBP, or TSL64k to simulate the other branch predictor models.
To quickly run all models and collect the branch mispredictions run:
./scripts/run_all_gem5.shIt will simulate all three models and print the branch mispredictions at the end.
If you use our work, please cite the paper:
@inproceedings{schall2026llbpx,
title={The Last-Level Branch Predictor Revisited},
author={Schall, David and Ďuračková, Mária and Grot, Boris},
booktitle={Proceedings of the 32nd IEEE International Symposium on High-Performance Computer Architecture (HPCA-32)},
year={2026}
}
Distributed under the MIT License. See LICENSE for more information.
David Schall - GitHub, Website, Mail
The authors thank the anonymous reviewers as well as the members of the Systems Research Group at the Technical University of Munich and the EASE Lab team at the University of Edinburgh for their valuable feedback on this work. We are grateful to Caeden Whitaker, Mike Jennrich, and Matt Sinclair from the University of Wisconsin-Madison for their assistance with the initial gem5 implementation of LLBP, as well as to Phillip Assmann from the Technical University of Munich for his significant efforts in improving the model's correctness during his thesis work.