Skip to content

Commit 6f3cb95

Browse files
committed
Proofread and fix documentation errors
1 parent 4830758 commit 6f3cb95

File tree

7 files changed

+59
-51
lines changed

7 files changed

+59
-51
lines changed

README.md

Lines changed: 50 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,12 @@ tool and starting point for customization. It is primarily written in C99, utili
2323
C11 atomics for memory management, with a focus on efficiency and readability.
2424

2525
Features:
26-
* Fast interpreter for executing the RV32 ISA
2726
* Fast interpreter that faithfully executes the complete RV32 instruction set
2827
* Full coverage of RV32I / RV32E plus the M (integer multiply–divide), A (atomics), F (single-precision floating-point), C (compressed), and Zba/Zbb/Zbc/Zbs bit-manipulation extensions
2928
* Built-in ELF loader for user-mode emulation
3029
* Newlib-compatible system-call layer for standalone programs
3130
* Minimal system emulation capable of booting an RV32 Linux kernel and running user-space binaries
32-
* Experimental SDL-based display/event/audio system calls for running video games
31+
* SDL-based display/event/audio system calls for running video games
3332
* WebAssembly build for user-mode and system emulation with SDL graphics and audio in modern browsers
3433
* Remote debugging through the GDB Remote Serial Protocol
3534
* Tiered JIT compilation for performance boost while maintaining a small footprint
@@ -54,13 +53,13 @@ $ make config # Configure build options interactively
5453
$ make
5554
```
5655

57-
### Experimental JIT compilation
56+
### Tiered JIT Compilation
5857
The tier-2 JIT compiler in `rv32emu` leverages LLVM for powerful optimization.
59-
Therefore, the target system must have [`LLVM`](https://llvm.org/) installed, with version 18 recommended.
58+
Therefore, the target system must have [`LLVM`](https://llvm.org/) installed, with versions 18 through 21 supported.
6059
If `LLVM` is not installed, only the tier-1 JIT compiler will be used for performance enhancement.
6160

62-
* macOS: `brew install llvm@18`
63-
* Ubuntu Linux / Debian: `sudo apt-get install llvm-18`
61+
* macOS: `brew install llvm@18` (or llvm@19, llvm@20, llvm@21)
62+
* Ubuntu Linux / Debian: `sudo apt-get install llvm-18` (or llvm-19, llvm-20, llvm-21)
6463

6564
Build the emulator with JIT compiler using the predefined configuration:
6665
```shell
@@ -96,6 +95,12 @@ If `ENABLE_ARCH_TEST=1` was previously set, run `make distclean` before proceedi
9695
$ make ENABLE_SYSTEM=1 system
9796
```
9897

98+
For improved performance, JIT compilation can be enabled in system emulation mode:
99+
```shell
100+
$ make system_jit_defconfig
101+
$ make system
102+
```
103+
99104
Build and run using specified images (`readonly` option makes the virtual block device read-only):
100105
```shell
101106
$ make ENABLE_SYSTEM=1
@@ -223,11 +228,12 @@ There are three ways to customize the build:
223228
#### 1. Predefined Configurations
224229
Use predefined configurations for common use cases:
225230
```shell
226-
$ make defconfig # Default: SDL enabled, all extensions
227-
$ make mini_defconfig # Minimal: no SDL, basic extensions only
228-
$ make jit_defconfig # JIT: enables tiered JIT compilation
229-
$ make system_defconfig # System: enables Linux system emulation
230-
$ make wasm_defconfig # WebAssembly: build for browser deployment
231+
$ make defconfig # Default: SDL enabled, all extensions
232+
$ make mini_defconfig # Minimal: no SDL, basic extensions only
233+
$ make jit_defconfig # JIT: enables tiered JIT compilation
234+
$ make system_defconfig # System: enables Linux system emulation
235+
$ make system_jit_defconfig # System+JIT: enables Linux system emulation with JIT
236+
$ make wasm_defconfig # WebAssembly: build for browser deployment
231237
```
232238
233239
#### 2. Interactive Configuration
@@ -256,12 +262,13 @@ Available configuration options:
256262
* `ENABLE_Zicsr`: Control and Status Register (CSR)
257263
* `ENABLE_Zifencei`: Instruction-Fetch Fence
258264
* `ENABLE_GDBSTUB`: GDB remote debugging support
259-
* `ENABLE_SDL`: Experimental Display and Event System Calls
260-
* `ENABLE_JIT`: Experimental JIT compiler
261-
* `ENABLE_SYSTEM`: Experimental system emulation, allowing booting Linux kernel
265+
* `ENABLE_SDL`: Display and Event System Calls for running video games
266+
* `ENABLE_JIT`: Tiered JIT compiler for performance optimization
267+
* `ENABLE_SYSTEM`: System emulation for booting Linux kernel
262268
* `ENABLE_GOLDFISH_RTC`: Enable Goldfish RTC peripheral when running the Linux kernel
263269
* `ENABLE_MOP_FUSION`: Macro-operation fusion
264270
* `ENABLE_BLOCK_CHAINING`: Block chaining of translated blocks
271+
* `T2C_OPT_LEVEL`: LLVM optimization level for tier-2 JIT (0-3, default varies by config)
265272
266273
### RISCOF
267274
[RISCOF](https://github.com/riscv-software-src/riscof) (RISC-V Compatibility Framework) is
@@ -330,31 +337,33 @@ Detail in riscv-arch-test:
330337
* [RISC-V Architecture Test Format Specification](https://github.com/riscv-non-isa/riscv-arch-test/blob/master/spec/TestFormatSpec.adoc)
331338
332339
## Benchmarks
333-
The benchmarks are classified into three categories based on their characteristics:
334-
| Category | Benchmark | Description |
335-
| -------------------------| ---------- | ----------- |
336-
| Computing intensive | puzzle | A sliding puzzle where numbered square tiles are arranged randomly with one tile missing, designed for solving the N-puzzle problem. |
337-
| | Pi | Calculates the millionth digit of π. |
338-
| | miniz | Compresses and decompresses 8 MiB of data. |
339-
| | primes | Finds the largest prime number below 33333333. |
340-
| | sha512 | Computes the SHA-512 hash of 64 MiB of data. |
341-
| I/O intensive | Richards | An OS task scheduler simulation benchmark for comparing system implementations. |
342-
| | Dhrystone | Evaluates string operations, involves frequent memory I/O, and generates the performance metric. |
343-
| Computing and I/O Hybrid | Mandelbrot | A benchmark based on the Mandelbrot set, which uses fixed-point arithmetic and involves numerous integer operations. |
344-
| | AES | Includes 23 encryption and decryption algorithms adhering to the Advanced Encryption Standard. |
345-
| | Nqueens | A puzzle benchmark where n queens are placed on an n × n chessboard without attacking each other, using deep recursion for execution. |
346-
| | qsort | Sorts an array with 50 million items. |
347-
348-
These benchmarks performed by rv32emu (interpreter-only mode) and [Spike](https://github.com/riscv-software-src/riscv-isa-sim) v1.1.0. Ran on Intel Core i7-11700 CPU running at 2.5 GHz and an Ampere [eMAG](https://en.wikichip.org/wiki/ampere_computing/emag) 8180
349-
microprocessor equipped with 32 Arm64 cores, capable of speeds up to 3.3 GHz. Both systems ran Ubuntu Linux 22.04.1 LTS. We utilized gcc version 12.3, configured as riscv32-unknown-elf-gcc.
350-
351-
The figures below illustrate the normalized execution time of rv32emu and Spike, where **the shorter indicates better performance**.
352-
353-
_x86-64_
354-
![](docs/interp-bench-x64.png)
355-
356-
_Arm64_
357-
![](docs/interp-bench-arm64.png)
340+
The benchmarks are classified based on their characteristics and cover various aspects of system performance. Most are derived from the industry-standard BYTEmark (nbench) suite, supplemented by cryptographic and system benchmarks:
341+
342+
| Benchmark | Description |
343+
| ------------- | ----------- |
344+
| numeric sort | Focuses on sorting integer arrays using various algorithms |
345+
| string sort | Evaluates string sorting capabilities |
346+
| bitfield | Tests bitwise operations and integer arithmetic on data words |
347+
| emfloat | Focuses on emulating floating-point calculations using integer arithmetic |
348+
| assignment | Tests solving resource allocation problems (e.g., assignment algorithm) |
349+
| idea | Assesses encryption and decryption using the International Data Encryption Algorithm (IDEA) |
350+
| huffman | Measures performance in data compression using Huffman coding |
351+
| dhrystone | Assesses general integer performance with a mix of string processing and control operations |
352+
| primes | Measures efficiency in computing prime numbers using algorithms like the Sieve of Eratosthenes |
353+
| sha512 | Tests cryptographic hash computations |
354+
355+
These benchmarks were performed by rv32emu (with tiered JIT enabled) and QEMU v9.0.0 on an Intel Core i7-11700 CPU running at 2.5 GHz with Ubuntu Linux 22.04.1 LTS. The toolchain used was GCC v14.2.0 with RV32IM extensions.
356+
357+
The figure below illustrates the speedup (normalized reciprocal of average elapsed time over 200 iterations) of rv32emu with tiered JIT compilation compared to QEMU. Higher values indicate better performance.
358+
359+
![](docs/jit-bench.png)
360+
361+
**Performance Summary:**
362+
- rv32emu with tiered JIT compilation outperforms QEMU v9.0.0 across all benchmarks
363+
- Significant performance gains in compute-intensive workloads (primes, sha512, emfloat)
364+
- Strong performance in optimization and cryptography benchmarks (assignment, idea, huffman)
365+
- Consistent advantages in sorting operations (numeric sort, string sort)
366+
- The tiered JIT approach effectively balances compilation overhead with code optimization quality
358367
359368
### Continuous Benchmarking
360369
Continuous benchmarking is integrated into GitHub Actions,
@@ -373,9 +382,8 @@ There are several files that have the potential to significantly impact the perf
373382
As a result, any modifications made to these files will trigger the benchmark CI.
374383
375384
## GDB Remote Debugging
376-
`rv32emu` is permitted to operate as gdbstub in an experimental manner since it supports
377-
a limited number of [GDB Remote Serial Protocol](https://sourceware.org/gdb/onlinedocs/gdb/Remote-Protocol.html) (GDBRSP).
378-
To enable this feature, you need to build the emulator and set `ENABLE_GDBSTUB=1` when running the `make` command.
385+
`rv32emu` supports a subset of the [GDB Remote Serial Protocol](https://sourceware.org/gdb/onlinedocs/gdb/Remote-Protocol.html) (GDBRSP).
386+
To enable this feature, use the configuration system (e.g., `make config` and enable `ENABLE_GDBSTUB`) or use the predefined configuration with GDB support.
379387
After that, you might execute it using the command below.
380388
```shell
381389
$ build/rv32emu -g <binary>

docs/base-image.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
The goal is to support both `x86-64` and `aarch64` docker images for development and testing.
44

5-
The base images contain `gcc` and `sail` images. We compile from the toolchain from source and use a specific version of the toolchains.
5+
The base images include `gcc` and `sail` toolchains. We compile the toolchains from source and use specific versions.
66

77
The build process should be used when an update on the toolchain is required. When a new build is made by running `build.sh`, build and push to Docker Hub are automated.
88

@@ -12,4 +12,4 @@ For `gcc`, we are using the compiler version `tags/2023.10.06`, as using the bin
1212

1313
For `sail`, we set up the toolchain to use `sail-0.16`, as the latest version `0.17.x` series will cause compilation errors.
1414

15-
We are using the commit `9547a30bf84572c458476591b569a95f5232c1c7` from `sail-riscv` for the reference simulator, as this is the commit cloest to the time when the [x86-64 reference sail emulator](https://github.com/sysprog21/rv32emu/commit/01b00b6f175f57ef39ffd1f4fa6a611891e36df3#diff-3b436c5e32c40ecca4095bdacc1fb69c0759096f86e029238ce34bbe73c6e68f) was added to the `rv32emu` Github repo.
15+
We are using the commit `9547a30bf84572c458476591b569a95f5232c1c7` from `sail-riscv` for the reference simulator, as this is the commit closest to the time when the [x86-64 reference sail emulator](https://github.com/sysprog21/rv32emu/commit/01b00b6f175f57ef39ffd1f4fa6a611891e36df3#diff-3b436c5e32c40ecca4095bdacc1fb69c0759096f86e029238ce34bbe73c6e68f) was added to the `rv32emu` Github repo.

docs/demo.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
## Doom
44
**source**: [doom\_riscv](https://github.com/sysprog21/doom_riscv)
55

6-
**commmad**: `make doom`
6+
**command**: `make doom`
77

88
[Doom](https://en.wikipedia.org/wiki/Doom_(franchise)), a pioneering first-person shooter game developed by [id Software](https://en.wikipedia.org/wiki/Id_Software) in 1993, is known for its open-source code and vibrant community.
99
It debuted innovations like genuine 3D graphics, networked multiplayer gameplay and the ability for players to create custom expansions.
@@ -19,17 +19,17 @@ It debuted innovations like genuine 3D graphics, networked multiplayer gameplay
1919
* 1: Fist
2020
* 3: Shotgun
2121

22-
### Music and sound effect
22+
### Music and Sound Effects
2323
The music and sound effects are supported.
2424

2525
## Quake
2626
**source**: [quake-embedded](https://github.com/sysprog21/quake-embedded/)
2727

2828
**command**: `make quake`
2929

30-
[Quake](https://en.wikipedia.org/wiki/Quake_(series)) was created in 1996 as a successor of the highly successful first-person shooter game Doom.
31-
It is built on the Doom game engine and offers 3D graphics compatibility.
32-
Moreover, it enhances fast-paced gameplay and supports online multiplayer over the Internet.
30+
[Quake](https://en.wikipedia.org/wiki/Quake_(series)) was created in 1996 as a successor to the highly successful first-person shooter game Doom.
31+
It features a fully 3D engine developed by id Software, offering true 3D graphics and gameplay.
32+
It emphasizes fast-paced gameplay and supports online multiplayer over the Internet.
3333

3434
![Quake Gameplay](https://imgur.com/gXKb7D0.gif)
3535

@@ -44,7 +44,7 @@ Moreover, it enhances fast-paced gameplay and supports online multiplayer over t
4444

4545
You may use the mouse to adjust the pitch and yaw angle.
4646

47-
### Music and sound effect
47+
### Music and Sound Effects
4848
Sound effects are supported, but music is currently unavailable in Quake because it requires a CD-ROM.
4949
The extracted pak file lacks any music or background music files.
5050

docs/interp-bench-arm64.png

-24.5 KB
Binary file not shown.

docs/interp-bench-x64.png

-24.5 KB
Binary file not shown.

docs/jit-bench.png

89.5 KB
Loading

docs/syscall.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ This mechanism allows code executed on a RISC-V target to interact with and util
112112

113113
Any other system calls will fail with an "unknown syscall" error.
114114

115-
## Experimental Display, Event, and Sound System Calls
115+
## Display, Event, and Sound System Calls
116116

117117
These system calls are solely for the convenience of accessing the [SDL library](https://www.libsdl.org/) and [SDL2_Mixer](https://wiki.libsdl.org/SDL2_mixer) and are only intended for the presentation of RISC-V graphics applications. They are not present in the ABI interface of POSIX or Linux.
118118

0 commit comments

Comments
 (0)