Skip to content

Commit 03e494a

Browse files
authored
Initial Flow Script for riscv-perf-model (#275)
- Integrates `riscv-gnu-toolchain` (`get-tool.sh`) for baremetal, Linux, 32-bit, and 64-bit support, including newlib for diverse workloads. - Compiles Embench on baremetal for BBV generation, trace generation, and SimPoint analysis using Spike or QEMU. - Stores SimPoint results in `/outputs/`. - Introduces a modular baremetal environment with stubs for simplified workload porting, enabling direct jumps to `main()` or `benchmark()`. Includes emulator-specific stubs, entry points, linker script, and UART stdout support. - Enhances code modularity by organizing into separate files. Future improvement: leverage `.cfg` for easier `_building_x_benchmark` definitions and support workload-specific `crt0.S` and `link.ld` overrides. - Adds initial documentation in `doc/`. - Replaces old QEMU BBV flow with a unified flow. - Includes `doc/emulator-comparison.md` for detailed QEMU vs. Spike STF generation analysis. Alogn with a reproducible script. - Provides `full_flow.py` script for an interactive Docker-based workflow. - Adds `board.cfg` in environment for streamlined workload-specific flag and configuration declarations. **Next Steps**: - Test riscv-tests on QEMU (baremetal) and other workloads. - Use SimPoint results to reduce workload traces. - Integrate with `trace_archive.py` for metadata storage and trace upload. - Run traces on Olympia (local generation or archive fetch). - Add comprehensive workloads like CoreMark.
1 parent 6a34548 commit 03e494a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+4808
-1556
lines changed
Lines changed: 107 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,97 +1,135 @@
11
FROM ubuntu:24.04
22

3-
# Combine apt-get commands and clean up to reduce image size
3+
# Set environment variables early
4+
ENV RISCV=/riscv \
5+
QEMU_PLUGINS=/qemu/build/contrib/plugins \
6+
PATH=$RISCV/bin:/opt/riscv/riscv32-elf/bin:/opt/riscv/riscv64-elf/bin:/opt/riscv/riscv32-glibc/bin:/SimPoint/bin:/qemu/build:$PATH \
7+
DEBIAN_FRONTEND=noninteractive \
8+
WORKDIR=/workspace \
9+
WORKLOADS=/workloads \
10+
OUTPUT=/output
11+
12+
# Install dependencies and clean up in one layer
413
RUN apt-get update && apt-get install -y \
14+
autoconf \
15+
automake \
16+
autotools-dev \
17+
bc \
18+
binutils \
19+
bison \
20+
build-essential \
21+
cmake \
22+
curl \
23+
cython3 \
524
device-tree-compiler \
25+
flex \
26+
gawk \
27+
gcc-riscv64-linux-gnu \
28+
gperf \
29+
git \
30+
jq \
31+
libboost-json-dev \
32+
libboost-program-options-dev \
633
libboost-regex-dev \
734
libboost-system-dev \
8-
libboost-program-options-dev \
9-
libboost-json-dev \
10-
rapidjson-dev \
35+
libbz2-dev \
36+
libexpat-dev \
37+
libglib2.0-dev \
38+
libgmp-dev \
1139
libhdf5-dev \
1240
liblzma-dev \
13-
libbz2-dev \
14-
cython3 \
15-
git \
16-
binutils \
17-
build-essential \
18-
cmake \
19-
gcc-riscv64-linux-gnu \
20-
zstd \
41+
libmpc-dev \
42+
libmpfr-dev \
43+
libslirp-dev \
44+
libtool \
2145
libzstd-dev \
22-
autoconf \
23-
automake \
24-
autotools-dev \
25-
curl \
46+
ninja-build \
47+
patchutils \
2648
python3 \
2749
python3-pip \
2850
python3-tomli \
29-
libmpc-dev \
30-
libmpfr-dev \
31-
libgmp-dev \
32-
gawk \
33-
bison \
34-
flex \
51+
rapidjson-dev \
3552
texinfo \
36-
gperf \
37-
libtool \
38-
patchutils \
39-
bc \
40-
zlib1g-dev \
41-
libexpat-dev \
42-
ninja-build \
43-
libglib2.0-dev \
44-
libslirp-dev \
4553
wget \
46-
&& rm -rf /var/lib/apt/lists/*
47-
48-
# Set up RISCV environment
49-
ENV RISCV=/riscv
50-
ENV PATH=$RISCV/bin:/opt/riscv/bin:$PATH
51-
RUN mkdir -p $RISCV
52-
53-
# Using HTTP instead of SSH to avoid setting git credentials
54-
RUN git config --global url."https://github.com/".insteadOf "[email protected]:"
54+
zlib1g-dev \
55+
zstd \
56+
&& rm -rf /var/lib/apt/lists/* \
57+
&& apt-get clean
5558

56-
# Generic config details required during the cloning (git am, apply,patch done during the toolchain build process)
57-
RUN git config --global user.email "[email protected]" && \
59+
# Configure git for building
60+
RUN git config --global url."https://github.com/".insteadOf "[email protected]:" && \
61+
git config --global user.email "[email protected]" && \
5862
git config --global user.name "Docker Builder"
5963

64+
# Create directory structure
65+
RUN mkdir -p /workloads /output /workspace $RISCV
6066

61-
# Clone repositories
67+
# Clone repositories in RISCV directory
6268
WORKDIR $RISCV
63-
RUN git clone https://github.com/condorcomputing/condor.riscv-isa-sim.git --recurse-submodules || exit 1
64-
RUN git clone https://github.com/sparcians/stf_tools || exit 1
65-
RUN git clone https://github.com/riscv-software-src/riscv-pk.git || exit 1
66-
RUN git clone https://github.com/riscv-collab/riscv-gnu-toolchain.git || exit 1
69+
RUN git clone https://github.com/condorcomputing/condor.riscv-isa-sim.git --recurse-submodules && \
70+
git clone https://github.com/sparcians/stf_tools && \
71+
git clone https://github.com/riscv-software-src/riscv-pk.git
6772

68-
# Build riscv-gnu-toolchain
69-
WORKDIR $RISCV/riscv-gnu-toolchain
70-
RUN ./configure --prefix=/opt/riscv && make -j$(nproc) && make install
73+
# Clone QEMU and SimPoint
74+
WORKDIR /
75+
RUN git clone https://gitlab.com/qemu-project/qemu.git && \
76+
git clone https://github.com/hanhwi/SimPoint.git
7177

72-
# Build riscv-pk
73-
WORKDIR $RISCV/riscv-pk/build
74-
RUN ../configure --prefix=$RISCV --host=riscv64-unknown-elf && make -j$(nproc) && make install
78+
# Clone workloads with Embench PR
79+
WORKDIR /workloads
80+
RUN git clone https://github.com/riscv-software-src/riscv-tests.git && \
81+
git clone -b spike-as-board https://github.com/widlarizer/embench-iot.git
82+
83+
# Copy and execute toolchain setup script
84+
COPY utils/get-tool.sh $RISCV/get-tool.sh
85+
RUN chmod +x $RISCV/get-tool.sh && \
86+
$RISCV/get-tool.sh && \
87+
echo "Toolchain version:" && \
88+
riscv64-unknown-linux-gnu-gcc --version 2>/dev/null || echo "Toolchain setup pending"
89+
90+
RUN mkdir -p /qemu/build
91+
# Build QEMU with plugins support
92+
WORKDIR /qemu/build
93+
RUN ../configure \
94+
--target-list=riscv32-linux-user,riscv64-linux-user,riscv32-softmmu,riscv64-softmmu \
95+
--enable-plugins \
96+
--disable-docs \
97+
--disable-gtk \
98+
--disable-sdl
99+
RUN make -j$(nproc)
100+
RUN make install
101+
102+
# Build SimPoint
103+
WORKDIR /SimPoint
104+
RUN make -j$(nproc)
75105

76106
# Build stf_tools
77107
WORKDIR $RISCV/stf_tools
78-
RUN git submodule update --init --recursive || exit 1
108+
RUN git submodule update --init --recursive
79109
WORKDIR $RISCV/stf_tools/release
80110
RUN cmake .. -DCMAKE_BUILD_TYPE=Release && make -j$(nproc)
81111

82-
# Build condor.riscv-isa-sim
83-
WORKDIR $RISCV/condor.riscv-isa-sim
84-
RUN bash scripts/download-bm-compiler.sh && \
85-
COMPILER_DIR=$(find . -maxdepth 1 -type d -name "riscv-embecosm-*" | head -n 1) && \
86-
[ -n "$COMPILER_DIR" ] || (echo "Error: riscv-embecosm-* directory not found!" && exit 1) && \
87-
export PATH=$(pwd)/$COMPILER_DIR/bin:$PATH && \
88-
echo "export PATH=/riscv/condor.riscv-isa-sim/$COMPILER_DIR/bin:\$PATH" >> /root/.bashrc
89-
90-
RUN mkdir -p build && cd build && \
91-
../configure --prefix=$RISCV/condor.riscv-isa-sim/install && \
92-
make -j$(nproc) && \
93-
make regress && \
94-
make install
95-
96-
# shell
112+
# Build condor.riscv-isa-sim (Spike)
113+
# make the builddir ?
114+
WORKDIR $RISCV/condor.riscv-isa-sim/build
115+
RUN ../configure --prefix=$RISCV/condor.riscv-isa-sim/install
116+
RUN make -j$(nproc)
117+
RUN make regress
118+
RUN make install
119+
120+
# Create mount points for runtime mounting
121+
# Environment and flow scripts will be mounted at runtime
122+
RUN mkdir -p /workloads/environment /flow /outputs
123+
124+
# Note: The following are mounted at runtime:
125+
# - Host flow scripts -> /flow
126+
# - Host environment -> /workloads/environment
127+
# - Host outputs -> /outputs
128+
129+
RUN cp $RISCV/condor.riscv-isa-sim/install/bin/spike /usr/bin/
130+
WORKDIR /workspace
131+
132+
97133
CMD ["/bin/bash"]
134+
135+
# need to mount Volumes and show it in the documenation when runnignthis

0 commit comments

Comments
 (0)