Skip to content

Docker workflow for STF trace generation #264

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions traces/docker_stf_trace_gen/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
FROM ubuntu:22.04

RUN apt-get update
RUN apt-get install -y device-tree-compiler libboost-regex-dev libboost-system-dev git binutils build-essential cmake gcc-riscv64-linux-gnu zstd libzstd-dev autoconf automake autotools-dev curl python3 python3-pip python3-tomli libmpc-dev libmpfr-dev libgmp-dev gawk build-essential bison flex texinfo gperf libtool patchutils bc zlib1g-dev libexpat-dev ninja-build git cmake libglib2.0-dev libslirp-dev

RUN mkdir riscv
ENV RISCV=/riscv
ENV PATH=$RISCV/bin:$PATH

RUN git clone https://github.com/jeffnye-gh/riscv-isa-sim.git
RUN git clone https://github.com/riscv-software-src/riscv-pk.git
RUN git clone https://github.com/riscv-collab/riscv-gnu-toolchain.git

WORKDIR /riscv-gnu-toolchain
RUN ./configure --prefix=/opt/riscv
ENV PATH=/opt/riscv/bin:$PATH
RUN make -j$(nproc)

WORKDIR /riscv-pk/build
RUN ../configure --prefix=$RISCV --host=riscv64-unknown-elf
RUN make -j$(nproc)
RUN make install

WORKDIR /riscv-isa-sim/build
RUN git checkout spike_stf
RUN git submodule update --init --recursive
RUN ../configure --prefix=$RISCV
RUN make -j$(nproc)
RUN make install
59 changes: 59 additions & 0 deletions traces/docker_stf_trace_gen/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Spike-STF trace generation

> This workflow is still under development. For the most up-to-date instructions, refer to the [Generating Input for Olympia](https://github.com/riscv-software-src/riscv-perf-model/blob/master/traces/README.md) README

## Table of Contents

1. [Introduction](#introduction)
1. [Dependencies](#dependencies)
1. [Project Structure](#project-structure)
1. [Usage](#usage)
1. [Build the Docker Image](#build-the-docker-image)
1. [Run STF Trace Generation](#run-stf-trace-generation)

## Introduction

This setup provides a containerized workflow to generate STF traces using Spike-STF. It sets up a complete environment with the RISC-V GNU toolchain, pk (proxy kernel), and Spike-STF.

## Dependencies

- **Docker** – See the [official installation guide](https://docs.docker.com/engine/install).
This workflow was tested with Docker version 28.3.0, build 38b7060, but it should also work with the latest available version.

## Project Structure

```bash
qemu-simpoint-dhrystone/
├── Dockerfile # Creates a Docker image with the RISC-V GNU toolchain, pk, and Spike-STF
├── run_in_docker.sh # Runs an STF trace generation example inside the container
├── build_docker.sh # Builds the Docker image
├── build_and_run.sh # Executes both build_docker and run_in_docker scripts
```

## Usage

This workflow can be split into two sequential tasks:

- Build the Docker image
- Generate STF traces using the Docker container

Alternatively, you may run the [`build_and_run.sh`](./build_and_run.sh) script to see an example of the trace generation process.

### Build the Docker Image

```bash
docker build -t spike-stf .
```

### Run STF Trace Generation

```bash
mkdir -p trace_output

docker run --rm \
-v ./trace_output:/output \
spike-stf \
bash -c "
echo '<REPLACE THIS ECHO COMMAND WITH SPIKE STF TRACE GENERATION COMMAND>' >> /output/EXAMPLE.zstf
"
```
13 changes: 13 additions & 0 deletions traces/docker_stf_trace_gen/build_and_run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

set -e

# === Configuration ===
BUILD_SCRIPT="./build_docker.sh"
RUN_SCRIPT="./run_in_docker.sh"

echo "[STEP 1] Building Docker image..."
bash "$BUILD_SCRIPT"

echo "[STEP 2] Running trace generation..."
bash "$RUN_SCRIPT"
6 changes: 6 additions & 0 deletions traces/docker_stf_trace_gen/build_docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

set -e

IMAGE_NAME="spike-stf"
docker build -t "$IMAGE_NAME" .
15 changes: 15 additions & 0 deletions traces/docker_stf_trace_gen/run_in_docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

set -e

IMAGE_NAME="spike-stf"
OUTPUT_DIR="$(pwd)/trace_output"

mkdir -p "$OUTPUT_DIR"

docker run --rm \
-v "$OUTPUT_DIR":/output \
"$IMAGE_NAME" \
bash -c "
echo '<REPLACE THIS ECHO COMMAND WITH SPIKE STF TRACE GENERATION COMMAND>' >> /output/EXAMPLE.zstf
"