diff --git a/traces/README.md b/traces/README.md index 031e27b6..844dc6f6 100644 --- a/traces/README.md +++ b/traces/README.md @@ -34,7 +34,7 @@ Olympia. STFs are typically created by a RISC-V functional model that has been instrumented to generate one. Two functional models which generate STFs are documented. -[Spike-STF](https://github.com/jeffnye-gh/cpm.riscv-isa-sim) +[Spike-STF](https://github.com/condorcomputing/condor.riscv-isa-sim) is the latest model, [Dromajo](https://github.com/chipsalliance/dromajo) also generates STFs. @@ -123,7 +123,7 @@ cd build ## STF Inputs -Using the [stf_lib]() in the [Sparcians](https://github.com/sparcians) +Using the [stf_lib](https://github.com/sparcians/stf_lib) in the [Sparcians](https://github.com/sparcians) repo, Olympia is capable of reading a RISC-V STF trace generated from a functional simulator. Included in Olympia (in this directory) are several trace files @@ -185,7 +185,7 @@ the macro tracing mode. ### Build Spike-STF The first step to generating an STF with Spike-STF is to clone and build -the Spike-STF [repo](https://github.com/jeffnye-gh/cpm.riscv-isa-sim.git). +the Spike-STF [repo](https://github.com/condorcomputing/condor.riscv-isa-sim). This example uses the `riscv-perf-model/traces` directory as a working directory. @@ -198,11 +198,12 @@ your path. ```bash cd riscv-perf-model/traces -git clone https://github.com/jeffnye-gh/cpm.riscv-isa-sim.git --recursive +git clone https://github.com/condorcomputing/condor.riscv-isa-sim.git --recurse-submodules -cd cpm.riscv-isa-sim +cd condor.riscv-isa-sim bash scripts/download-bm-compiler.sh export PATH=`pwd`/riscv-embecosm-embedded-ubuntu2204-20250309/bin:$PATH +which riscv64-unknown-elf-gcc #verify compiler is in your path ``` Exit the conda environment, if enabled, before compiling Spike-STF. ``` @@ -221,14 +222,14 @@ The regress target executes the [riscv-tests](https://github.com/riscv-software- The compiler is a prebuilt RISC-V cross compiler from [Embecosm](https://embecosm.com/). There is detailed information in the Spike-STF repo, -[README_FORK.mk](https://github.com/jeffnye-gh/cpm.riscv-isa-sim/blob/spike_stf/README_FORK.md) and [USAGE.md](https://github.com/jeffnye-gh/cpm.riscv-isa-sim/blob/spike_stf/USAGE.md). +[README_FORK.mk](https://github.com/condorcomputing/condor.riscv-isa-sim/blob/spike_stf/README_FORK.md) and [USAGE.md](https://github.com/condorcomputing/condor.riscv-isa-sim/blob/spike_stf/USAGE.md). ### Generating the Baremetal Dhrystone Traces When Spike-STF is initially configured the dhrystone ELFs are created. If they need to be re-created: ```bash -cd riscv-perf-model/traces/cpm.riscv-isa-sim +cd riscv-perf-model/traces/condor.riscv-isa-sim make -C dhrystone ``` @@ -237,12 +238,12 @@ optimization running 1000 iterations. The source code has been modified to add the trace macros and to allow simplified execution under baremetal with limited syscall support. -A discussion of the 3 optimization levels is available in [USAGE.md](https://github.com/jeffnye-gh/cpm.riscv-isa-sim/blob/spike_stf/USAGE.md#dhrystone-optimization-discussion). +A discussion of the 3 optimization levels is available in [USAGE.md](https://github.com/condorcomputing/condor.riscv-isa-sim/blob/spike_stf/USAGE.md#dhrystone-optimization-discussion). Once the ELFs are built, traces are generated by: ``` -cd riscv-perf-model/traces/cpm.riscv-isa-sim +cd riscv-perf-model/traces/condor.riscv-isa-sim bash scripts/run-spike-stf.sh dhrystone/bin/dhrystone_opt1.1000.gcc.bare.riscv \ dhrystone_opt1.zstf @@ -257,9 +258,9 @@ The compressed trace outputs can then be run on olympia by ``` -./olympia ../traces/cpm.riscv-isa-sim/trace_out/dhrystone_opt1.zstf -./olympia ../traces/cpm.riscv-isa-sim/trace_out/dhrystone_opt2.zstf -./olympia ../traces/cpm.riscv-isa-sim/trace_out/dhrystone_opt3.zstf +./olympia ../traces/condor.riscv-isa-sim/trace_out/dhrystone_opt1.zstf +./olympia ../traces/condor.riscv-isa-sim/trace_out/dhrystone_opt2.zstf +./olympia ../traces/condor.riscv-isa-sim/trace_out/dhrystone_opt3.zstf ``` ## Generating Linux Traces @@ -268,14 +269,14 @@ The compressed trace outputs can then be run on olympia by In order to compile applications for linux, you must have riscv64-unknown-linux-gnu-gcc in your path. ``` -cd riscv-perf-model/traces/cpm.riscv-isa-sim +cd riscv-perf-model/traces/condor.riscv-isa-sim bash scripts/download-lnx-compiler.sh export PATH=`pwd`/riscv64-embecosm-linux-gcc-ubuntu2204-20240407/bin:$PATH ``` To build the linux version of the Dhrystone benchmarks: ``` -cd riscv-perf-model/traces/cpm.riscv-isa-sim +cd riscv-perf-model/traces/condor.riscv-isa-sim make -C dhrystone bin-linux ``` @@ -297,11 +298,11 @@ The process to clone and build these components is contained in a script. This is a lengthy process. ```bash -cd riscv-perf-model/traces/cpm.riscv-isa-sim +cd riscv-perf-model/traces/condor.riscv-isa-sim bash scripts/build-linux-collateral.sh ``` -Once complete, the directory `riscv-perf-model/traces/cpm.riscv-isa-sim/riscv-linux` will contain the files necessary to boot linux. +Once complete, the directory `riscv-perf-model/traces/condor.riscv-isa-sim/riscv-linux` will contain the files necessary to boot linux. ``` fw_jump.elf rootfs.cpio @@ -311,7 +312,7 @@ Image ### Booting Linux on Spike-STF With the linux components built, boot linux using the helper script: ``` -cd riscv-perf-model/traces/cpm.riscv-isa-sim +cd riscv-perf-model/traces/condor.riscv-isa-sim bash scripts/boot-linux.sh ``` The credentials are root/root. @@ -331,7 +332,7 @@ the buildroot source tree, rebuilds rootfs, and copies the image to riscv-linux for use in the next section. ``` -cd riscv-perf-model/traces/cpm.riscv-isa-sim +cd riscv-perf-model/traces/condor.riscv-isa-sim bash scripts/build-trace-rootfs.sh ``` @@ -353,7 +354,7 @@ arguments. The first specifes the new rootfs and the second specifies the path for the STF trace output. ``` -cd riscv-perf-model/traces/cpm.riscv-isa-sim +cd riscv-perf-model/traces/condor.riscv-isa-sim bash scripts/boot-linux.sh --rootfs ./riscv-linux/trace_rootfs.cpio \ --trace ./trace_out/linux_trace.zstf ``` @@ -405,7 +406,7 @@ This is useful in cases. For other use cases, check the USAGE.md file in the Spike-STF repo for instructions on how to use initd to automate linux based trace generation. -See [Automating Linux Tracing with INIT.d](https://github.com/jeffnye-gh/cpm.riscv-isa-sim/blob/spike_stf/USAGE.md#Automating-linux-tracing-with-initd) +See [Automating Linux Tracing with INIT.d](https://github.com/condorcomputing/condor.riscv-isa-sim/blob/spike_stf/USAGE.md#automating-linux-tracing-with-initd) ----------------------------------------------------- @@ -557,3 +558,4 @@ Running... olympia: STF file input detected ... ``` + diff --git a/traces/docker_stf_trace_gen/Dockerfile b/traces/docker_stf_trace_gen/Dockerfile index e89fc309..d33261da 100644 --- a/traces/docker_stf_trace_gen/Dockerfile +++ b/traces/docker_stf_trace_gen/Dockerfile @@ -1,29 +1,97 @@ -FROM ubuntu:22.04 +FROM ubuntu:24.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 +# Combine apt-get commands and clean up to reduce image size +RUN apt-get update && apt-get install -y \ + device-tree-compiler \ + libboost-regex-dev \ + libboost-system-dev \ + libboost-program-options-dev \ + libboost-json-dev \ + rapidjson-dev \ + libhdf5-dev \ + liblzma-dev \ + libbz2-dev \ + cython3 \ + 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 \ + bison \ + flex \ + texinfo \ + gperf \ + libtool \ + patchutils \ + bc \ + zlib1g-dev \ + libexpat-dev \ + ninja-build \ + libglib2.0-dev \ + libslirp-dev \ + wget \ + && rm -rf /var/lib/apt/lists/* -RUN mkdir riscv +# Set up RISCV environment 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 +ENV PATH=$RISCV/bin:/opt/riscv/bin:$PATH +RUN mkdir -p $RISCV + +# Using HTTP instead of SSH to avoid setting git credentials +RUN git config --global url."https://github.com/".insteadOf "git@github.com:" + +# Generic config details required during the cloning (git am, apply,patch done during the toolchain build process) +RUN git config --global user.email "builder@example.com" && \ + git config --global user.name "Docker Builder" + + +# Clone repositories +WORKDIR $RISCV +RUN git clone https://github.com/condorcomputing/condor.riscv-isa-sim.git --recurse-submodules || exit 1 +RUN git clone https://github.com/sparcians/stf_tools || exit 1 +RUN git clone https://github.com/riscv-software-src/riscv-pk.git || exit 1 +RUN git clone https://github.com/riscv-collab/riscv-gnu-toolchain.git || exit 1 + +# Build riscv-gnu-toolchain +WORKDIR $RISCV/riscv-gnu-toolchain +RUN ./configure --prefix=/opt/riscv && make -j$(nproc) && make install + +# Build riscv-pk +WORKDIR $RISCV/riscv-pk/build +RUN ../configure --prefix=$RISCV --host=riscv64-unknown-elf && make -j$(nproc) && make install + +# Build stf_tools +WORKDIR $RISCV/stf_tools +RUN git submodule update --init --recursive || exit 1 +WORKDIR $RISCV/stf_tools/release +RUN cmake .. -DCMAKE_BUILD_TYPE=Release && make -j$(nproc) + +# Build condor.riscv-isa-sim +WORKDIR $RISCV/condor.riscv-isa-sim +RUN bash scripts/download-bm-compiler.sh && \ + COMPILER_DIR=$(find . -maxdepth 1 -type d -name "riscv-embecosm-*" | head -n 1) && \ + [ -n "$COMPILER_DIR" ] || (echo "Error: riscv-embecosm-* directory not found!" && exit 1) && \ + export PATH=$(pwd)/$COMPILER_DIR/bin:$PATH && \ + echo "export PATH=/riscv/condor.riscv-isa-sim/$COMPILER_DIR/bin:\$PATH" >> /root/.bashrc + +RUN mkdir -p build && cd build && \ + ../configure --prefix=$RISCV/condor.riscv-isa-sim/install && \ + make -j$(nproc) && \ + make regress && \ + make install + +# shell +CMD ["/bin/bash"] diff --git a/traces/docker_stf_trace_gen/README.md b/traces/docker_stf_trace_gen/README.md index 1b676fb9..dc20e8ee 100644 --- a/traces/docker_stf_trace_gen/README.md +++ b/traces/docker_stf_trace_gen/README.md @@ -24,7 +24,7 @@ This setup provides a containerized workflow to generate STF traces using Spike- ```bash qemu-simpoint-dhrystone/ -├── Dockerfile # Creates a Docker image with the RISC-V GNU toolchain, pk, and Spike-STF +├── Dockerfile # Creates a Docker image with the RISC-V GNU toolchain, pk, stf_tools 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 @@ -50,10 +50,10 @@ docker build -t spike-stf . ```bash mkdir -p trace_output -docker run --rm \ - -v ./trace_output:/output \ +docker run --rm \ + -v :/riscv/condor.riscv-isa-sim/trace_out \ spike-stf \ bash -c " - echo '' >> /output/EXAMPLE.zstf + bash scripts/run-spike-stf.sh " ``` diff --git a/traces/docker_stf_trace_gen/run_in_docker.sh b/traces/docker_stf_trace_gen/run_in_docker.sh index 02e70049..18a5d744 100755 --- a/traces/docker_stf_trace_gen/run_in_docker.sh +++ b/traces/docker_stf_trace_gen/run_in_docker.sh @@ -5,11 +5,15 @@ set -e IMAGE_NAME="spike-stf" OUTPUT_DIR="$(pwd)/trace_output" +# The binary to run on spike (bare-metal) +BINARY_NAME="dhrystone/bin/dhrystone_opt1.1000.gcc.bare.riscv" +TRACEOUT_NAME="trace_output.zstf" + mkdir -p "$OUTPUT_DIR" docker run --rm \ - -v "$OUTPUT_DIR":/output \ + -v "$OUTPUT_DIR":/riscv/condor.riscv-isa-sim/trace_out \ "$IMAGE_NAME" \ bash -c " - echo '' >> /output/EXAMPLE.zstf - " \ No newline at end of file + bash scripts/run-spike-stf.sh $BINARY_NAME $TRACEOUT_NAME + "