Skip to content
This repository has been archived by the owner on Jun 11, 2024. It is now read-only.

Quick_Start

Andrea Mambretti edited this page Jan 8, 2020 · 1 revision

Dependencies

Speculator depends on the json-c and the pfmlib libraries (ninja is optional). To post-process speculator output is necessary to have sqlalchemy installed as well. Please make sure to have them installed on your system.

sudo apt-get install libjson-c-dev
sudo apt-get install libpfm4-dev
sudo apt-get install ninja-build
sudo apt-get install python-sqlalchemy
sudo apt-get install cmake
sudo apt-get install nasm

Other two hard requirements for speculator to work properly are:

  1. The system should be booted without Secure Boot

  2. The msr kernel module should be loaded:

sudo modprobe msr

Build

First of all, create speculator-build and speculator-install folders. Then update the environment variable in speculator.env and source the file.

mkdir speculator-build
mkdir speculator-install

# Update the file accordingly
vim speculator.env

source speculator.env

Now run cmake to configure in the following way.

cmake $SPEC_H -B$SPEC_B -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=$SPEC_I -G "Ninja"
ninja -C $SPEC_B install

Run

# Run speculator on mytest

ln -s $SPEC_H/templates/x86/template.asm $SPEC_H/tests/mytest.asm
cmake $SPEC_H -B$SPEC_B -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=$SPEC_I -G "Ninja"
ninja -C $SPEC_B install

sudo $SPEC_I/speculator_mon -v $SPEC_I/tests/mytest/mytest -c $SPEC_I/speculator.json -o $SPEC_I/results/myoutput

# Repeat experiment 100 times in quite mode with output written to my_output_file
sudo $SPEC_I/speculator_mon -v $SPEC_I/tests/mytest/mytest -o $SPEC_I/results/myoutput -r 100 -q

# Run all the snippet under tests for 1000 each, the results will be saved in $SPEC_I/results/
sudo $SPEC_I/scripts/run_test.py -r 1000 -c $SPEC_I/

# Aggregate results together
$SPEC_I/scripts/post-processing.py -l $SPEC_I/results

New test

# Manually creating a snippet
cp $SPEC_H/templates/x86/template.asm $SPEC_H/tests/mytest.asm

# Automatically creating a snippet based ona template and a sequence of instructions
$SPEC_H/scripts/cr_inc_snip.py -o $SPEC_H/tests/myfolder $SPEC_H/tests/inst_list.json $SPEC_H/tests/templates/template.asm

# Re-run cmake as above if not automatically detected by ninja
cmake $SPEC_H -B$SPEC_B -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=$SPEC_I -G "Ninja"
ninja -C $SPEC_B install
Clone this wiki locally