Skip to content

Add ACT4 user-mode test coverage#731

Draft
cyrilmhansen wants to merge 4 commits into
sysprog21:masterfrom
cyrilmhansen:codex/act4-rv32imafc-user-tests
Draft

Add ACT4 user-mode test coverage#731
cyrilmhansen wants to merge 4 commits into
sysprog21:masterfrom
cyrilmhansen:codex/act4-rv32imafc-user-tests

Conversation

@cyrilmhansen

@cyrilmhansen cyrilmhansen commented May 15, 2026

Copy link
Copy Markdown

Summary

This PR brings up ACT4 user-mode architectural testing for rv32emu's RV32IMAF(C) configuration and fixes the main emulator issues exposed by those tests.

Related issue: #730

Changes include:

  • Add the rv32emu Sail configuration needed by ACT4.
  • Expand the default ACT user-mode batch to the currently passing extension set: I,M,F,Zicsr,Zicntr,Zifencei,Zca,Zcf,Misalign,MisalignZca,Zaamo.
  • Filter the ACT runner by ACT_EXTENSIONS, so targeted runs such as ACT_EXTENSIONS=F do not execute stale ELFs from earlier batches.
  • Prefer the ACT Sail 0.11 tool directory during ACT ELF generation so sail_riscv_sim --version does not pick the older arch-test prebuilt.
  • Fix x0 handling in interpreter execution and constant propagation.
  • Fix RV32F CSR handling for fflags, frm, and fcsr.
  • Merge the latest upstream master activity through 7b4e872 / PR Refine WebAssembly user/system mode demos #732.
  • Disable block chaining and MOP fusion in the architecture-test CI config to keep the ACT user-mode path deterministic while optimizer-specific issues are handled separately.

Notes

Zalrsc is intentionally not included in the default ACT batch yet. Zalrsc-sc.w still reaches the ACT fail halt path even when the dumped signature matches Sail's generated .results, so it needs separate LR/SC/tohost investigation before being enabled as a default passing batch.

The x0 repair is deliberately conservative and may warrant upstream review for hot-path performance. The FP CSR fix is architectural correctness and should not be gated behind an optimization flag.

Interpreter loop-fusion optimization work has been split out of this ACT PR and now lives on codex/interpreter-loop-fusions (71a6666).

Licensing

The ACT4 checkout is kept as a submodule. The local ACT tree documents code licensing as BSD-3-Clause or Apache-2.0, with documentation under CC-BY-4.0, and includes the corresponding license texts.

Testing

  • PKG_CONFIG=/usr/bin/pkg-config make -j4 with JIT+T2C
  • PKG_CONFIG=/usr/bin/pkg-config make ci_defconfig && PKG_CONFIG=/usr/bin/pkg-config make -j4
  • GEM_HOME=$PWD/build/act-tools/gems/ruby/3.4.0 GEM_PATH=$PWD/build/act-tools/gems/ruby/3.4.0:/home/john/.local/share/gem/ruby/3.4.0 BUNDLE_PATH=$PWD/build/act-tools/gems PATH=$PWD/build/act-tools/gems/ruby/3.4.0/bin:/home/john/.local/share/gem/ruby/3.4.0/bin:/home/john/projects/github/rv32emu/.venv/bin:$PATH PKG_CONFIG=/usr/bin/pkg-config make act-user-run ACT_EXTENSIONS=I -> ACT runner: 39/39 passed

Earlier broad generated ACT batches were also checked with the direct runner:

  • tools/run-act-elfs.sh build/rv32emu-user build/act/rv32emu-rv32imafc/elfs I,M,F,Zicsr,Zicntr,Zifencei,Zca,Zcf,Misalign,MisalignZca,Zaamo -> ACT runner: 182/182 passed
  • tools/run-act-elfs.sh build/rv32emu-user build/act/rv32emu-rv32imafc/elfs F -> ACT runner: 78/78 passed

Summary by cubic

Adds ACT4 user-mode tests for rv32emu RV32IMAF(C), fixes FCSR/x0 correctness, and speeds up the interpreter with new loop fusions. CI runs stay deterministic, and ACT runs are filterable via ACT_EXTENSIONS.

  • New Features

    • ACT4 integration: tests/riscv-act submodule, rv32emu config (Sail JSON, linker, YAML), and tools/run-act-elfs.sh; new act-user-elfs/act-user-run with ACT_EXTENSIONS; prefers Sail 0.11 via ACT_SAIL_BIN_DIR.
    • Interpreter-only fusions: ADDI+ADDI+BNE and ADDI+conditional-branch loops; ~1.22x speedup on an RV32IM microbench; JIT/T2C builds unaffected via stubs.
    • Build/test flow: RISCOF accepts dut_exe; separate rv32emu-user and rv32emu-system; env detection supports LLVM 18–21 (HAVE_LLVM), uses tools/detect-env.py for SDL checks, and respects PKG_CONFIG; toolchain detection adds riscv32-elf-/riscv64-elf-.
  • Bug Fixes

    • Enforced x0=0 in the interpreter loop and constant propagation; corrected RV32F CSR reads/writes for fflags, frm, and fcsr.
    • CI/build stability: disabled block chaining and MOP fusion for deterministic ACT runs; guarded user-mode demos/tests in system builds; minor fixes in riscv.c, SDL_mixer vars, and DTB dependency.

Written for commit 67b9f80. Summary will update on new commits. Review in cubic

@jserv jserv left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Benchmarks

Details
Benchmark suite Current: 67b9f80 Previous: 1456c8a Ratio
Dhrystone 1563.333 DMIPS 1569.333 DMIPS 1.00
CoreMark 1088.292 iterations/sec 1121.207 iterations/sec 1.03

This comment was automatically generated by workflow using github-action-benchmark.

Cyril M. Hansen added 4 commits May 15, 2026 21:41
Put the ACT Sail tool directory first in PATH while generating ACT ELFs so sail_riscv_sim --version does not resolve to the older arch-test prebuilt.
@cyrilmhansen cyrilmhansen force-pushed the codex/act4-rv32imafc-user-tests branch from 1456c8a to 67b9f80 Compare May 15, 2026 19:43
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.

2 participants