This repository has been archived on 2024-12-04. You can view files and clone it, but cannot push or open issues or pull requests.
Go to file
Nils Hölscher 4aa0080cb2 made poolhelper executable 2022-04-21 20:44:38 +02:00
.vscode Better Linting and README 2022-04-20 14:03:44 +02:00
CacheAnalysisPass removed some warnings. 2022-04-21 13:25:37 +02:00
include formatting 2022-04-20 13:36:41 +02:00
test first commit 2022-04-19 10:56:42 +02:00
.clang-format Gitignore, debugscript, and some linting. 2022-04-19 11:09:17 +02:00
.clang-tidy Better Linting and README 2022-04-20 14:03:44 +02:00
.gitignore Added Pool PC Setup. 2022-04-21 20:40:39 +02:00
CMakeLists.txt fixed Error for Pool PC Setup. 2022-04-21 20:42:09 +02:00
Dockerfile more minimalistic Dokcer Image. 2022-04-20 13:37:26 +02:00
LICENSE first commit 2022-04-19 10:56:42 +02:00
README.md Added Pool PC Setup. 2022-04-21 20:40:39 +02:00
helper.sh Added Pool PC Setup. 2022-04-21 20:40:39 +02:00
poolhelper.sh made poolhelper executable 2022-04-21 20:44:38 +02:00

README.md

RTSA-lab01-CacheAnalysis

In this lab session you will learn how to implement a LRU cache in abstract representation. The Goal is to implement an LRU must Join in include/AbstractState.h. The Project can be build, tested and Evaluated with the "helper" script.

Disclaimer

This is the first time we offer this exercise. Should you encounter something you think is a Bug, please let me (Nils) know, during lab sessions.

Keep track of the Repository as I may add more features to the script.

Also I do not support the usage of Windows, Linux is free of charge so get a copy. I am more than happy helping you install Linux on your machine.

Setup

I recommend using docker and VS Code for setup. Also check out the recommended extensions in the Docker section. If you prefer to work from Linux or Mac OS X, check the Dockerfile for dependencies.

Also make sure to have a LLVM13 install. And export your LLVM13 install to the $LLVM_DIR variable, with:

export LLVM_DIR=path/to/LLVM13

Setup on a Pool PC

You will have to use the poolhelber.sh script instead of the normal helper script.

Get and build llvm from source !!This will take a while!!

./poolhelper.sh llvm

In case you can not finish building llvm in one Sessionn just abort it and later on run this:

./poolhelper.sh continuellvm

Now you have a llvm13 source build.

Remember to use the poolhelper.sh instead of the helper.sh.

VS Code Setup

1.) Install VS Code on your Distribution or get it from Microsoft.

https://code.visualstudio.com/

2.) I recommend you install the following extensions in vs code

clangd, Clang-Format, CodeLLDB, Docker and Remote Development

For a general C/C++ setup of VS Code (I consider good) see: https://ahemery.dev/2020/08/24/c-cpp-vscode/

Most parts can be skipped, as they are already integrated in this Repo.

Installing LLVM 13 on Mac OS X

On Darwin you can install LLVM 13 with Homebrew:

brew install llvm@13

If you already have an older version of LLVM installed, you can upgrade it to LLVM 13 like this:

brew upgrade llvm

Once the installation (or upgrade) is complete, all the required header files, libraries and tools will be located in /usr/local/opt/llvm/.

Installing LLVM 13 on Ubuntu

On Ubuntu Bionic, you can install modern LLVM from the official repository:

wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
sudo apt-add-repository "deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-13 main"
sudo apt-get update
sudo apt-get install -y llvm-13 llvm-13-dev llvm-13-tools clang-13

This will install all the required header files, libraries and tools in /usr/lib/llvm-13/.

Building LLVM 13 From Sources

Building from sources can be slow and tricky to debug. It is not necessary, but might be your preferred way of obtaining LLVM 13. The following steps will work on Linux and Mac OS X:

git clone https://github.com/llvm/llvm-project.git
cd llvm-project
git checkout release/13.x
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release -DLLVM_TARGETS_TO_BUILD=host -DLLVM_ENABLE_PROJECTS=clang <llvm-project/root/dir>/llvm/
cmake --build .

For more details read the official documentation.

This will install all the required header files, libraries and tools in your/llvm/build/path.

Setting up Docker

1.) install docker and VS Code on your Distribution.

https://docs.docker.com/get-docker/

https://code.visualstudio.com/

For this setup you cannot use the OSS version of VS code or the version from Snap, as the remote development extensions will not work.

2.) I recommend you install the following extensions in vs code

clangd, Clang-Format, CodeLLDB, Docker and Remote Development

For a general C/C++ setup of VS Code (I consider good) see: https://ahemery.dev/2020/08/24/c-cpp-vscode/

Most of the setup can be skipped

3.) Use the helper script to build and run a Container

./helper.sh docker

This will build a docker image and run a Docker container with the current directory mounted.

The Docker container can later be started from the Docker VS Code extension.

4.) Attach VS Code to the container, in the Docker Tab, and start developing

Debugging

When you are using VS Code you can simply use the Debugging Tab, I prepared a debug script for you. You can also set the following variables in the CacheAnalysisPass/CacheAnalysisPass.cpp file, for more output:

  // Development Options
  bool PrintAddresses = false;
  bool PrintEdges = false;
  bool PrintEdgesPost = false;
  bool DumpToDot = false;
  bool DumpNodes = false;

Use the Helper script

Initial Setup

./helper.sh all

To get a list of what the helper script can do simply type

./helper.sh 

Run

Run the pass on a single test. fft1 is recommended during development.

./helper.sh run fft1

Eval

Runs the Pass on a set of tests and also prints the expected results. This will be used to measure correctness of you implementation.

./helper.sh eval

Use the Terminal (Obsolete if script is used)

This section is not needed, fi you are using the script but for the sake of completeness it is provided anyways.

Initial Setup:

mkdir build
cd build
cmake -DLT_LLVM_INSTALL_DIR=$LLVM_DIR ../CacheAnalysisPass/
make
cd ..

Run:

opt -load-pass-plugin build/libCacheAnalysisPass.so \
-passes=lru-misses test/crc.ll