llbp

Branch predictor simulation framework for the Last-Level Branch Predictor

https://github.com/dhschall/llbp

Science Score: 67.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 6 DOI reference(s) in README
  • Academic publication links
    Links to: zenodo.org
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (16.4%) to scientific vocabulary
Last synced: 8 months ago · JSON representation ·

Repository

Branch predictor simulation framework for the Last-Level Branch Predictor

Basic Info
  • Host: GitHub
  • Owner: dhschall
  • License: mit
  • Language: C++
  • Default Branch: main
  • Homepage:
  • Size: 318 KB
Statistics
  • Stars: 27
  • Watchers: 1
  • Forks: 6
  • Open Issues: 1
  • Releases: 2
Created over 1 year ago · Last pushed over 1 year ago
Metadata Files
Readme License Citation

README.md

The Last-Level Branch Predictor Simulator

GitHub GitHub release Trace DOI Build and test

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 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 is presented at MICRO 2024.

This repository contains the source code of the branch predictor model used to evaluate LLBP's prediction accuracy. The code is based on the CBP5 framework, but was heavily modified and extended with various statistics to evaluate the performance of LLBP and the baseline TAGE predictor.

The aim of this framework is to provide a fast way to evaluate different branch predictor configurations and explore the design space of LLBP. It does not model the full CPU pipeline but only the branch predictor. The framework supports a timing approximation by clocking the predictor for every taken branch and/or more than 8 executed instructions between branches. While we found that this approximation is reasonable accurate to get understand the impact of late prefetches, it is only a rough estimation. For the exact timing the predictor needs to be integrated with a full CPU simulator like ChampSim or gem5.

We are currently working on integrating LLBP with gem5 and will release the code once it is ready.

Prerequisites

The infrastructure and 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 Dependencies

```bash

Install cmake

sudo apt install -y cmake libboost-all-dev build-essential pip parallel

Python dependencies for plotting.

pip install -r analysis/requirements.txt

```

Build the project

```bash mkdir build cd build cmake -DCMAKEBUILDTYPE=Debug .. cd ..

cmake --build ./build -j 8

```

Server traces

The 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 utils folder will download all traces from Zenodo and stores them into the traces directory.:

bash ./utils/download_traces.sh

Run the simulator

The 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 or llbp-timing.

The definition of the branch predictor models can be found in the bpmodels/base_predictor.cc file.

bash ./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 (./eval_benchmarks.sh <predictor>). The results in 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.

Plot results

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 (./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:

bash ./eval_all.sh Once the runs complete open they Jupyter notebook and hit run all cells.

Code Walkthrough

Misc: * The main.cc file contains the main entry point of the simulator. It reads the trace file, initializes the branch predictor model, and runs the simulation. * The bpmodel directory contains the implementation of the TAGE-SC-L and LLBP branch predictor models.

TAGE: * TAGE-SC-L is split into TAGE and SC-L components. The code is taken from the CBP5 framework and modified to include additional statistics to evaluate the branch predictor. * The only difference of the 512KiB TAGE-SC-L are 8x more entries in the TAGE predictor.

LLBP: * LLBP derives from the TAGE-SC-L base class and overrides several of the methods to implement the LLBP functionality. * There are two versions of LLBP: llbp and llbp-timing. Both are functionally the same but the later models prefetching of pattern sets and can be used to study the impact of late prefetches. * The high-capacity LLBP is called LLBPStorage and stores all pattern sets. The PatternBuffer is the small, fast structure that stores the patterns for the upcoming contexts. * The RCR class implements all the functionality to compute program context.

Citation

If you use our work, please cite paper: @inproceedings{schall2024llbp, title={The Last-Level Branch Predictor}, author={Schall, David and Sandberg, Andreas and Grot, Boris}, booktitle={Proceedings of the 57th Annual IEEE/ACM International Symposium on Microarchitecture}, year={2024} }

License

Distributed under the MIT License. See LICENSE for more information.

Contact

David Schall - GitHub, Website, Mail

Acknowledgements

We thank all the anonymous reviewers of MICRO and the artifact evaluation team for their valuable feedback. Furthermore the members of the EASE-lab team at the University of Edinburgh as well as Arm Ltd. for their support and feedback.

Owner

  • Name: David Schall
  • Login: dhschall
  • Kind: user
  • Location: Edinburgh
  • Company: University of Edinburgh

Citation (CITATION.cff)

# This CITATION.cff file was generated with cffinit.
# Visit https://bit.ly/cffinit to generate yours today!

cff-version: 1.2.0
message: "If you use this software, please cite it as below."
authors:
- given-names: David
  family-names: Schall
  email: david.schall@tum.de
  orcid: 'https://orcid.org/0000-0002-3587-3253'
  affiliation: University of Edinburgh
- given-names: Andreas
  family-names: Sandberg
  email: andreas.sandberg@arm.com
  affiliation: Arm Ltd.
  orcid: 'https://orcid.org/0000-0001-9349-5791'
- given-names: Boris
  family-names: Grot
  email: boris.grot@ed.ac.uk
  affiliation: University of Edinburgh
  orcid: 'https://orcid.org/0000-0001-6525-0762'
title: "The Last-Level Branch Predictor"
# version: 2.0.4
# doi: 10.5281/zenodo.1234
# date-released: 2017-12-18
# url: "https://github.com/github-linguist/linguist"
preferred-citation:
  type: article
  authors:
  - given-names: David
    family-names: Schall
    email: david.schall@tum.de
    orcid: 'https://orcid.org/0000-0002-3587-3253'
    affiliation: University of Edinburgh
  - given-names: Andreas
    family-names: Sandberg
    email: andreas.sandberg@arm.com
    affiliation: Arm Ltd.
    orcid: 'https://orcid.org/0000-0001-9349-5791'
  - given-names: Boris
    family-names: Grot
    email: boris.grot@ed.ac.uk
    affiliation: University of Edinburgh
    orcid: 'https://orcid.org/0000-0001-6525-0762'
  # doi: "10.0000/00000"
  title: "The Last-Level Branch Predictor"
  year: 2024

GitHub Events

Total
  • Issues event: 1
  • Watch event: 19
  • Issue comment event: 3
  • Fork event: 7
Last Year
  • Issues event: 1
  • Watch event: 19
  • Issue comment event: 3
  • Fork event: 7

Issues and Pull Requests

Last synced: 8 months ago

All Time
  • Total issues: 1
  • Total pull requests: 11
  • Average time to close issues: N/A
  • Average time to close pull requests: 1 day
  • Total issue authors: 1
  • Total pull request authors: 2
  • Average comments per issue: 6.0
  • Average comments per pull request: 0.09
  • Merged pull requests: 10
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 1
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 1
  • Pull request authors: 0
  • Average comments per issue: 6.0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • nmd1411 (1)
Pull Request Authors
  • dhschall (7)
  • Ria (4)
Top Labels
Issue Labels
Pull Request Labels

Dependencies

.github/workflows/build-and-run.yml actions
  • actions/cache v4 composite
  • actions/cache/restore v4 composite
  • actions/checkout v4 composite
.github/workflows/linters.yml actions
  • actions/checkout v4 composite
  • gaurav-nelson/github-action-markdown-link-check v1 composite
  • rojopolis/spellcheck-github-actions 0.40.0 composite
analysis/requirements.txt pypi
  • ipykernel *
  • matplotlib *
  • numpy *
  • pandas *