Skip to content

Commit b1a5e8f

Browse files
docker stf trace gen
1 parent 55d79ec commit b1a5e8f

File tree

5 files changed

+122
-0
lines changed

5 files changed

+122
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
FROM ubuntu:22.04
2+
3+
RUN apt-get update
4+
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
5+
6+
RUN mkdir riscv
7+
ENV RISCV=/riscv
8+
ENV PATH=$RISCV/bin:$PATH
9+
10+
RUN git clone https://github.com/jeffnye-gh/riscv-isa-sim.git
11+
RUN git clone https://github.com/riscv-software-src/riscv-pk.git
12+
RUN git clone https://github.com/riscv-collab/riscv-gnu-toolchain.git
13+
14+
WORKDIR /riscv-gnu-toolchain
15+
RUN ./configure --prefix=/opt/riscv
16+
ENV PATH=/opt/riscv/bin:$PATH
17+
RUN make -j$(nproc)
18+
19+
WORKDIR /riscv-pk/build
20+
RUN ../configure --prefix=$RISCV --host=riscv64-unknown-elf
21+
RUN make -j$(nproc)
22+
RUN make install
23+
24+
WORKDIR /riscv-isa-sim/build
25+
RUN git checkout spike_stf
26+
RUN git submodule update --init --recursive
27+
RUN ../configure --prefix=$RISCV
28+
RUN make -j$(nproc)
29+
RUN make install

traces/docker_stf_trace_gen/README.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Spike-STF trace generation
2+
3+
> 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
4+
5+
## Table of Contents
6+
7+
1. [Introduction](#introduction)
8+
1. [Dependencies](#dependencies)
9+
1. [Project Structure](#project-structure)
10+
1. [Usage](#usage)
11+
1. [Build the Docker Image](#build-the-docker-image)
12+
1. [Run STF Trace Generation](#run-stf-trace-generation)
13+
14+
## Introduction
15+
16+
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.
17+
18+
## Dependencies
19+
20+
- **Docker** – See the [official installation guide](https://docs.docker.com/engine/install).
21+
This workflow was tested with Docker version 28.3.0, build 38b7060, but it should also work with the latest available version.
22+
23+
## Project Structure
24+
25+
```bash
26+
qemu-simpoint-dhrystone/
27+
├── Dockerfile # Creates a Docker image with the RISC-V GNU toolchain, pk, and Spike-STF
28+
├── run_in_docker.sh # Runs an STF trace generation example inside the container
29+
├── build_docker.sh # Builds the Docker image
30+
├── build_and_run.sh # Executes both build_docker and run_in_docker scripts
31+
```
32+
33+
## Usage
34+
35+
This workflow can be split into two sequential tasks:
36+
37+
- Build the Docker image
38+
- Generate STF traces using the Docker container
39+
40+
Alternatively, you may run the [`build_and_run.sh`](./build_and_run.sh) script to see an example of the trace generation process.
41+
42+
### Build the Docker Image
43+
44+
```bash
45+
docker build -t spike-stf .
46+
```
47+
48+
### Run STF Trace Generation
49+
50+
```bash
51+
mkdir -p trace_output
52+
53+
docker run --rm \
54+
-v ./trace_output:/output \
55+
spike-stf \
56+
bash -c "
57+
echo '<REPLACE THIS ECHO COMMAND WITH SPIKE STF TRACE GENERATION COMMAND>' >> /output/EXAMPLE.zstf
58+
"
59+
```
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
# === Configuration ===
6+
BUILD_SCRIPT="./build_docker.sh"
7+
RUN_SCRIPT="./run_in_docker.sh"
8+
9+
echo "[STEP 1] Building Docker image..."
10+
bash "$BUILD_SCRIPT"
11+
12+
echo "[STEP 2] Running trace generation..."
13+
bash "$RUN_SCRIPT"
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
IMAGE_NAME="spike-stf"
6+
docker build -t "$IMAGE_NAME" .
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
IMAGE_NAME="spike-stf"
6+
OUTPUT_DIR="$(pwd)/trace_output"
7+
8+
mkdir -p "$OUTPUT_DIR"
9+
10+
docker run --rm \
11+
-v "$OUTPUT_DIR":/output \
12+
"$IMAGE_NAME" \
13+
bash -c "
14+
echo '<REPLACE THIS ECHO COMMAND WITH SPIKE STF TRACE GENERATION COMMAND>' >> /output/EXAMPLE.zstf
15+
"

0 commit comments

Comments
 (0)