Skip to content

Conversation

Jatin-exe
Copy link
Collaborator

  • 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.

@vinicius-r-silva
Copy link
Collaborator

vinicius-r-silva commented Aug 23, 2025

The amount of files in the docker_stf_trace_gen folder is making a litte confusing to identify the purpose of each script, I would suggest creating a sub folder for the files that needs to be used only once (Dockerfile, build-docker.sh, get-tools and the environment), and another folder for the test/example scripts (spike_vs_qemu.py, ...)

@Jatin-exe
Copy link
Collaborator Author

Jatin-exe commented Aug 25, 2025

@vinicius-r-silva Thanks for your review! I've made some improvements to the code, but there's still more to be done (e.g., better documentation and removing redundant lines/functions, PEP8 compliance ...). It's a work in progress. I've implemented the changes you suggested, as I had the same thoughts. I'd appreciate any additional feedback you have!

@jaksa-mips jaksa-mips self-requested a review September 4, 2025 16:03
@arupc arupc self-requested a review September 4, 2025 16:04
Copy link
Collaborator

@jaksa-mips jaksa-mips left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

per discussion in the meeting - approving

@jaksa-mips jaksa-mips merged commit 03e494a into riscv-software-src:master Sep 4, 2025
4 checks passed
Jatin-exe pushed a commit that referenced this pull request Sep 16, 2025
This PR introduces the Trace Generator Tool along with improvements in
the documentation at traces/stf_trace_archive/README.md and
traces/docker_stf_trace_gen/README.md. The main goal of this tool is to
create STF trace and it's metadata file for workload using docker.

The trace generator tool comes with three different modes
- **Macro** → uses `START_TRACE` and `STOP_TRACE` macros embedded in the
workload
- **Instruction Count (`insn_count`)** → traces a fixed number of
instructions after skipping some
- **Program Counter (`pc_count`)** → traces after a specific program
counter (PC) is reached

Other options included in the tool are:
* **`--isa ISA`**. Instruction set architecture (e.g., `rv64imafdc`).
* **`--dump`**. Create a trace file dump.
* **`--pk`**. Run Spike with **pk (proxy kernel)**.


This PR files follows this structure:
```text
README.md                  # Main documentation file
README.md                  # Trace generator documentation file
src/
├── data/                  # Core data models and classes
├── converters/                  # Converter classes
├── factories/              # Factory classes
├── utils/                 # Utility functions and helpers
└── generate_trace.py       # Main CLI entry point
```

### Quickstart

1. **Macro mode  (SPIKE only)**  
Trace using `START_TRACE` / `STOP_TRACE` markers inside the workload:
    ```bash
   python generate_trace.py --emulator spike macro workload.elf
    ```

2. **Instruction Count mode**
   Skip 1000 instructions, then trace 5000 instructions:

   ```bash
   python generate_trace.py --emulator qemu insn_count \
       --num-instructions 5000 --start-instruction 1000 workload.elf
   ```

3. **Program Counter mode (QEMU only)**
Start tracing after PC `0x80000000` is hit 5 times, trace 2000
instructions:

   ```bash
   python generate_trace.py --emulator qemu pc_count \
--num-instructions 2000 --start-pc 0x80000000 --pc-threshold 5
workload.elf
   ```

### Next Steps:
* Integrate `utils/docker_orchestrator.py` with all docker related
function created on PR #275
* Add a simpoint option, passing a simpoint file as input and generating
traces from it
* Validate and compare trace results generated by both Spike and QEMU
* Look at including a Macro mode for the qemu plugin
* Create test classes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants