Skip to content

Commit 6a34548

Browse files
authored
Embench Integration & Workflow Enhancement [compiling workloads using QEMU and BBVs generation] (#273)
# Overview This pull request significantly enhances the `QEMU-BBVS-Flow` by integrating the **Embench IoT benchmark suite** and streamlining the entire analysis workflow. The primary goal is to provide a more powerful, efficient, and flexible tool for computer architecture research, addressing the critical challenge of long simulation times by automating SimPoint analysis for a wider range of standard benchmarks. By containerizing a pre-built RISC-V toolchain and pre-compiling the Embench suite, this update drastically reduces setup and execution times, allowing researchers to focus on analysis rather than environment configuration. ## Key Features & Enhancements ### 1. Full Embench IoT Suite Integration - **Pre-built Workloads**: The `Dockerfile` now clones and pre-builds all 19 Embench workloads for the `riscv32` architecture. This ensures that the benchmarks are ready for immediate analysis without any compilation overhead during runtime. - **Standalone Embench Runner**: A new `run_embench_simple.sh` script allows for fine-grained control, enabling users to: - List all available Embench workloads. - Run individual workloads with or without timing. - Generate Basic Block Vector (BBV) traces for specific benchmarks on demand. - **Integrated Analysis Pipeline**: The main `run_workload.sh` script now recognizes `embench` as a workload type, automating the end-to-end SimPoint analysis for the entire suite. ### 2. Improved Generic Workload Support - **Flexible Workload Naming**: The system now supports any custom workload name (minimum 3 characters), replacing the previously hardcoded `"custom"` type. - **Automatic Build System Detection**: The `setup_workload.sh` script intelligently builds the user-provided source code by looking for either a `Makefile` or a `build.sh` script within the source directory. ### 3. Massive Efficiency Gains - **Pre-built RISC-V Toolchain**: The Docker image is now based on `ribeirovsilva/riscv-toolchain:latest` (by @vinicius-r-silva ), which includes a pre-compiled RISC-V toolchain. This single change cuts the Docker build time from over an hour to just a few minutes. - **Optimized Analysis Scripts**: The `run_analysis.sh` script now filters binaries based on the selected workload type, ensuring that only relevant benchmarks are processed, which speeds up batch analysis. ### 4. Robust Orchestration and Testing - **Unified Scripts**: The `build_docker.sh`, `run_workload.sh`, and `setup_workload.sh` scripts work in harmony to provide a seamless user experience, from building the environment to generating final results. - **Comprehensive Demo**: A new `integration_demo.sh` script is included to showcase and verify all new features, including Embench integration, BBV generation, backward compatibility with Dhrystone, and the enhanced generic workload handling. ## How to Test ### 1. Clone the repository and make all scripts executable ```bash chmod +x *.sh ```` ### 2. Run the complete integration demo This script will build the image and test all key functionalities automatically. ```bash ./integration_demo.sh ``` ### 3. Manual Verification Steps #### Build the Docker image ```bash ./build_docker.sh ``` #### List available Embench workloads ```bash docker run --rm qemu-simpoint-unified /run_embench_simple.sh --list ``` #### Run a single Embench workload and generate its BBV trace ```bash # Create an output directory on the host mkdir -p simpoint_output docker run --rm -v "$(pwd)/simpoint_output:/output" qemu-simpoint-unified /run_embench_simple.sh crc32 --bbv docker run --rm -v "$(pwd)/simpoint_output:/output" qemu-simpoint-unified /run_embench_simple.sh [workload_name] --bbv # Verify that the BBV file was created ls -lh simpoint_output/crc32_bbv.0.bb ``` #### Test the enhanced generic workload handler (The `integration_demo.sh` script creates a temporary `test_workload` directory to test this, or you can use your own.) ```bash # Assuming you have a project in ./my-riscv-project with a Makefile ./run_workload.sh my-riscv-project "$(pwd)/my-riscv-project" "-static" "riscv64" ``` --------- Signed-off-by: Aditi Mehta <[email protected]>
1 parent b873570 commit 6a34548

File tree

10 files changed

+775
-113
lines changed

10 files changed

+775
-113
lines changed

traces/qemu-bbvs-flow/Dockerfile

Lines changed: 33 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
1-
FROM ubuntu:22.04
1+
FROM ribeirovsilva/riscv-toolchain:latest
22

33
# Avoid interactive prompts during installation
44
ENV DEBIAN_FRONTEND=noninteractive
55
ENV TZ=Etc/UTC
66

7-
# Update package lists
8-
RUN apt update && apt upgrade -y
9-
10-
# Install all dependencies for QEMU compilation and workloads
11-
RUN apt install -y \
7+
# Update package lists and install additional dependencies
8+
RUN apt-get update && apt-get install -y \
129
git-email \
1310
libaio-dev \
1411
libbluetooth-dev \
@@ -67,12 +64,14 @@ RUN apt install -y \
6764
libexpat-dev \
6865
cmake \
6966
libglib2.0-dev \
70-
gcc-riscv64-linux-gnu \
7167
libslirp-dev \
7268
pkg-config \
7369
libpixman-1-dev \
7470
python3-dev \
75-
python3-venv
71+
python3-venv \
72+
qemu-user \
73+
qemu-user-static \
74+
&& rm -rf /var/lib/apt/lists/*
7675

7776
# Clone repositories
7877
RUN git clone https://gitlab.com/qemu-project/qemu.git
@@ -93,14 +92,33 @@ RUN make -j$(nproc)
9392
ENV PATH="$PATH:/SimPoint/bin"
9493

9594
# Create workload directory and output directory
96-
RUN mkdir -p /workloads /output
95+
RUN mkdir -p /workloads /output /workspace
9796

98-
# Copy workload setup script
99-
COPY setup_workload.sh /setup_workload.sh
100-
RUN chmod +x /setup_workload.sh
97+
# Clone and prepare Embench repository
98+
WORKDIR /workspace
99+
RUN git clone --recursive https://github.com/embench/embench-iot.git
100+
RUN sed -i '36s/^typedef uint8_t bool;/\/\/ &/' /workspace/embench-iot/src/wikisort/libwikisort.c
101+
102+
# Pre-build Embench workloads to avoid build time during analysis
103+
WORKDIR /workspace/embench-iot
104+
RUN python3 ./build_all.py \
105+
--arch riscv32 \
106+
--chip generic \
107+
--board ri5cyverilator \
108+
--cc riscv64-unknown-elf-gcc \
109+
--cflags="-c -O2 -ffunction-sections -march=rv32imfdc -mabi=ilp32d" \
110+
--ldflags="-Wl,-gc-sections -march=rv32imfdc -mabi=ilp32d" \
111+
--user-libs="-lm"
101112

102-
# Copy analysis script
113+
# Copy setup and analysis scripts
114+
COPY setup_workload.sh /setup_workload.sh
103115
COPY run_analysis.sh /run_analysis.sh
104-
RUN chmod +x /run_analysis.sh
116+
COPY run_embench_simple.sh /run_embench_simple.sh
117+
RUN chmod +x /setup_workload.sh /run_analysis.sh /run_embench_simple.sh
118+
119+
# Verify QEMU works with a test workload
120+
RUN echo "Testing QEMU with pre-built embench workload..." && \
121+
qemu-riscv32 /workspace/embench-iot/bd/src/crc32/crc32 && \
122+
echo "QEMU execution test successful"
105123

106-
WORKDIR /
124+
WORKDIR /

traces/qemu-bbvs-flow/README.md

Lines changed: 34 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# QEMU BBVs Flow
1+
# QEMU SimPoint Unified Analysis
22

33
A unified, containerized workflow for running various workloads on QEMU with SimPoint analysis for program phase detection and basic block vector generation.
44

@@ -27,24 +27,40 @@ This project provides a unified Docker-based environment for:
2727

2828
### 1. Clone Repository
2929
```bash
30-
git clone https://github.com/riscv-software-src/riscv-perf-model.git
31-
cd traces/qemu-bbvs-flow
30+
git clone https://github.com/yourusername/qemu-bbvs-flow.git
31+
cd qemu-bbvs-flow
3232
```
3333

3434
### 2. Run Dhrystone Analysis
3535
```bash
36-
./build_and_run.sh dhrystone
36+
./build_and_run.sh dhrystone
37+
# OR
38+
39+
./build_docker.sh
40+
./run_workload.sh dhrystone
3741
```
3842

3943
### 3. Run Embench Analysis
4044
```bash
41-
./build_and_run.sh embench
45+
#Embench gets compiled during the build itself
46+
./build_docker.sh
47+
48+
# Run specific Embench workload with BBV
49+
docker run --rm -v $(pwd)/simpoint_output:/output qemu-simpoint-unified /run_embench_simple.sh [workload_name] --bbv
50+
#[For example] –
51+
docker run --rm -v $(pwd)/simpoint_output:/output qemu-simpoint-unified /run_embench_simple.sh crc32 --bbv
52+
4253
```
4354

4455
### 4. Run Custom Workload
4556
```bash
4657
./build_and_run.sh custom /path/to/your/source "-O2 -static" riscv64
4758
```
59+
### 5. Individual Component Execution
60+
```bash
61+
./build_docker.sh
62+
./run_workload.sh [workload_type] [parameters]
63+
```
4864

4965
## Prerequisites
5066

@@ -75,8 +91,8 @@ cd traces/qemu-bbvs-flow
7591

7692
3. **Open WSL 2 Terminal** and clone repository:
7793
```bash
78-
git clone https://github.com/riscv-software-src/riscv-perf-model.git
79-
cd traces/qemu-bbvs-flow
94+
git clone https://github.com/yourusername/qemu-bbvs-flow.git
95+
cd qemu-bbvs-flow
8096
chmod +x *.sh
8197
```
8298

@@ -95,9 +111,8 @@ cd traces/qemu-bbvs-flow
95111

96112
2. **Clone and Setup**:
97113
```bash
98-
git clone https://github.com/riscv-software-src/riscv-perf-model.git
99-
cd traces/qemu-bbvs-flow
100-
114+
git clone https://github.com/yourusername/qemu-bbvs-flow.git
115+
cd qemu-bbvs-flow
101116
chmod +x *.sh
102117
```
103118

@@ -129,7 +144,8 @@ cd traces/qemu-bbvs-flow
129144

130145
#### Embench with Custom Settings
131146
```bash
132-
./build_and_run.sh embench "" "-march=rv32i -mabi=ilp32 -static" riscv32 50 20
147+
#Embench gets compiled during the build itself
148+
./build_docker.sh
133149
```
134150

135151
#### Custom Workload
@@ -392,17 +408,18 @@ ls -lh simpoint_output/*.bb
392408

393409
```
394410
qemu-bbvs-flow/
395-
├── README.md # This file
396411
├── Dockerfile # Unified Docker image
397412
├── setup_workload.sh # Workload setup script
398413
├── run_analysis.sh # Analysis execution script
399-
├── build_docker.sh # Docker build automation
414+
├── run_embench_simple.sh # embench compilation script
415+
├── build_docker.sh # Docker image build script
400416
├── run_workload.sh # Workload execution script
401417
├── build_and_run.sh # Complete workflow script
402-
├── workload_config.json # Configuration file
418+
├── workload_config.json # Workload configuration
419+
├── README.md # User documentation
403420
├── documentation/
404-
│ └── technical_details.md # Technical documentation
405-
└── simpoint_output/ # Results directory (created after execution)
421+
│ └── technical_details.md # This file
422+
└── simpoint_output/ # Generated results (after execution)
406423
```
407424

408425
## Contributing
@@ -452,4 +469,4 @@ For support and questions:
452469
- Support for Dhrystone, Embench, and custom workloads
453470
- Configurable compiler flags and QEMU architectures
454471
- Automated build and run scripts
455-
- Comprehensive documentation
472+
- Comprehensive documentation

traces/qemu-bbvs-flow/documentation/Technical_Documentation

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ qemu-bbvs-flow/
2727
├── Dockerfile # Unified Docker image
2828
├── setup_workload.sh # Workload setup script
2929
├── run_analysis.sh # Analysis execution script
30+
├── run_embench_simple.sh # embench compilation script
3031
├── build_docker.sh # Docker image build script
3132
├── run_workload.sh # Workload execution script
3233
├── build_and_run.sh # Complete workflow script
@@ -184,22 +185,3 @@ simpoint -loadFVFile input.bb -maxK 30 -saveSimpoints output.simpoints -saveSimp
184185
3. **Memory Issues**: Increase Docker memory limits
185186
4. **Network Issues**: Verify internet connectivity for source downloads
186187

187-
### Debug Mode
188-
Enable verbose output by setting environment variables:
189-
```bash
190-
export VERBOSE=1
191-
export DEBUG=1
192-
```
193-
194-
## Future Enhancements
195-
196-
### Planned Features
197-
1. Support for additional architectures (ARM, x86)
198-
2. Integration with performance monitoring tools
199-
3. Automated result visualization
200-
4. Distributed analysis support
201-
202-
### Configuration Extensions
203-
1. YAML-based configuration
204-
2. Template-based workload definitions
205-
3. Profile-based execution modes

0 commit comments

Comments
 (0)